diff options
author | louie <lshprung@yahoo.com> | 2020-07-07 17:23:16 -0700 |
---|---|---|
committer | louie <lshprung@yahoo.com> | 2020-07-07 17:23:16 -0700 |
commit | 697ba798ab9ac09ba84dbf2285bcb0fb44ea0b36 (patch) | |
tree | 44f5596f37311cbb7968e1f077bf98526c533ea0 /read_cfg.c | |
parent | 5ee2e091adf1aca46eb5e93c7733fff9c8ce6500 (diff) |
Improved autoAlias
Diffstat (limited to 'read_cfg.c')
-rw-r--r-- | read_cfg.c | 29 |
1 files changed, 25 insertions, 4 deletions
@@ -175,7 +175,7 @@ void handle_fname(char *path, char *group){ } //file is not recognized, perhaps it has a wildcard? - //TODO finish rewriting a more robust wildcard thingy, still doesn't work using regex + //TODO finish rewriting a more robust wildcard thingy if(access(path, F_OK) == -1){ i = search_ch(path, '*'); if(i > -1){ @@ -238,6 +238,7 @@ char *autoAlias(char *path){ char *hr_name = malloc(sizeof(char) * BUF_LEN); char *p = hr_name; char *rpath; //necessary so as not to touch the actual path + bool stop = false; //stop when you don't want to add a series of chars to the output //get to the relative path name if(compmode) rpath = strrchr(path, '\\'); @@ -246,16 +247,36 @@ char *autoAlias(char *path){ while(*rpath != '\0'){ switch(*rpath){ + case '(': + stop = true; + break; + + case ')': + stop = false; + break; + case '-': case '_': - *p = ' '; + if(*(p-1) != ' ' && !stop){ + *p = ' '; + *p++; + } + break; + + case ' ': + if(*(p-1) != ' ' && !stop){ + *p = *rpath; + *p++; + } break; default: - *p = *rpath; + if(!stop){ + *p = *rpath; + *p++; + } } *rpath++; - *p++; } //close the name |