From 8ec8e9d5dd37eac5266f8cd94ce946f23f436ef9 Mon Sep 17 00:00:00 2001 From: louie Date: Sat, 11 Jul 2020 08:57:14 -0700 Subject: Fixed bug when compmode is on and an entry is forced --- draw.c | 4 +++- entry.c | 12 ++++++++++-- entry.h | 4 +++- entry.o | Bin 3336 -> 3672 bytes read_cfg.c | 18 +++++++++--------- read_cfg.o | Bin 10072 -> 10136 bytes 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/draw.c b/draw.c index 2e24a03..96b4525 100644 --- a/draw.c +++ b/draw.c @@ -359,6 +359,7 @@ char *get_launch(){ char *program = get_gprog(g[g_hover]); char *flags = get_gflags(g[g_hover]); char *path = get_epath(e[e_hover]); + bool force = get_eforce(e[e_hover]); int mode = get_compmode(); char *full_command = malloc(sizeof(char) * BUF_LEN); bool quote_flag_p = (program[0] == '"' ? false : true); @@ -376,7 +377,8 @@ char *get_launch(){ } else{ - if(mode != 0) path = compat_convert(path, mode); + //if the entry is not forced and compatability mode is on, run it through the converter function + if(mode != 0 && !force) path = compat_convert(path, mode); if(quote_flag_p) strcat(full_command, "\""); strcat(full_command, program); if(quote_flag_p) strcat(full_command, "\""); diff --git a/entry.c b/entry.c index c47b5d7..7431b64 100644 --- a/entry.c +++ b/entry.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -11,22 +12,24 @@ typedef struct entry{ char name[BUF_LEN]; char path[BUF_LEN]; + bool path_force; struct entry *next; } ENTRY; -ENTRY *create_entry(char *new_name, char *new_path); +ENTRY *create_entry(char *new_name, char *new_path, bool force); ENTRY *entry_add_last(ENTRY *tail, ENTRY *add); ENTRY **get_entries(ENTRY *head, int count); char *get_ename(ENTRY *e); char *get_epath(ENTRY *e); -ENTRY *create_entry(char *new_name, char *new_path){ +ENTRY *create_entry(char *new_name, char *new_path, bool force){ ENTRY *new; new = malloc(sizeof(ENTRY)); strcpy(new->name, new_name); strcpy(new->path, new_path); + new->path_force = force; new->next = NULL; return new; @@ -66,6 +69,11 @@ char *get_epath(ENTRY *e){ return e->path; } +bool get_eforce(ENTRY *e){ + assert(e != NULL); + return e->path_force; +} + void entry_debug(ENTRY *trav){ while(trav != NULL){ diff --git a/entry.h b/entry.h index b76919c..b70462c 100644 --- a/entry.h +++ b/entry.h @@ -3,7 +3,7 @@ typedef struct entry ENTRY; -ENTRY *create_entry(char *new_name, char *new_path); +ENTRY *create_entry(char *new_name, char *new_path, bool force); ENTRY *entry_add_last(ENTRY *tail, ENTRY *add); @@ -13,6 +13,8 @@ char *get_ename(ENTRY *e); char *get_epath(ENTRY *e); +bool get_eforce(ENTRY *e); + void entry_debug(ENTRY *trav); #endif diff --git a/entry.o b/entry.o index 1fd4495..ad68585 100644 Binary files a/entry.o and b/entry.o differ diff --git a/read_cfg.c b/read_cfg.c index de75f64..52eb26c 100644 --- a/read_cfg.c +++ b/read_cfg.c @@ -202,12 +202,12 @@ void handle_fname(char *path, char *group, bool recurs, bool force, char *name){ //don't check that the path arg is valid if(force){ - if(name != NULL) new = create_entry(name, full_path_cpy); + if(name != NULL) new = create_entry(name, full_path_cpy, force); else if(hr){ strcpy(auto_name, autoAlias(full_path_cpy)); - new = create_entry(auto_name, full_path_cpy); + new = create_entry(auto_name, full_path_cpy, force); } - else new = create_entry(full_path_cpy, full_path_cpy); + else new = create_entry(full_path_cpy, full_path_cpy, force); if(new != NULL) group_add(group, new); } @@ -237,13 +237,13 @@ void handle_fname(char *path, char *group, bool recurs, bool force, char *name){ if(fname->d_type == DT_REG && !(wild_cmp(&arg_cpy[i+1], fname->d_name))){ //check if a name was given as argument - if(name != NULL) new = create_entry(name, relative_path_cpy); + if(name != NULL) new = create_entry(name, relative_path_cpy, force); //check if autoAlias is on. If it is, go to the autoAlias function else if(hr){ strcpy(auto_name, autoAlias(relative_path_cpy)); - new = create_entry(auto_name, relative_path_cpy); + new = create_entry(auto_name, relative_path_cpy, force); } - else new = create_entry(relative_path_cpy, relative_path_cpy); + else new = create_entry(relative_path_cpy, relative_path_cpy, force); if(new != NULL) group_add(group, new); } } @@ -262,12 +262,12 @@ void handle_fname(char *path, char *group, bool recurs, bool force, char *name){ //file name is okay //FIXME does not take into account whether the argument is a file (could be a directory, symlink, etc.) else{ - if(name != NULL) new = create_entry(name, full_path_cpy); + if(name != NULL) new = create_entry(name, full_path_cpy, force); else if(hr){ strcpy(auto_name, autoAlias(full_path_cpy)); - new = create_entry(auto_name, full_path_cpy); + new = create_entry(auto_name, full_path_cpy, force); } - else new = create_entry(full_path_cpy, full_path_cpy); + else new = create_entry(full_path_cpy, full_path_cpy, force); if(new != NULL){ group_add(group, new); } diff --git a/read_cfg.o b/read_cfg.o index 18e631c..540a909 100644 Binary files a/read_cfg.o and b/read_cfg.o differ -- cgit