diff options
-rw-r--r-- | entry.c | 21 | ||||
-rw-r--r-- | entry.h | 4 | ||||
-rw-r--r-- | entry.o | bin | 4976 -> 4672 bytes | |||
-rw-r--r-- | group.c | 36 | ||||
-rw-r--r-- | group.o | bin | 8248 -> 7864 bytes | |||
-rw-r--r-- | read_cfg.c | 4 | ||||
-rw-r--r-- | read_cfg.o | bin | 12896 -> 12896 bytes |
7 files changed, 21 insertions, 44 deletions
@@ -7,6 +7,7 @@ #include <unistd.h> #include "entry.h" #include "group.h" +#include "read_cfg.h" #define BUF_LEN 1024 typedef struct entry{ @@ -19,8 +20,7 @@ typedef struct entry{ ENTRY *create_entry(char *new_name, char *new_path, bool force); void entry_rm(ENTRY *e, ENTRY *prev); void clear_entries(ENTRY *head); -ENTRY *entry_add_last(ENTRY *tail, ENTRY *add); -int entry_add_sorted(ENTRY *head, ENTRY *tail, ENTRY *add); +int entry_add(ENTRY *head, ENTRY *tail, ENTRY *add); ENTRY **get_entries(ENTRY *head, int count); char *get_ename(ENTRY *e); char *get_epath(ENTRY *e); @@ -58,22 +58,9 @@ void clear_entries(ENTRY *head){ return; } -//TODO consider joining entry_add_last and entry_add_sorted -ENTRY *entry_add_last(ENTRY *tail, ENTRY *add){ - assert(add != NULL); - - if(tail == NULL) tail = add; - else{ - tail->next = add; - tail = add; - } - - return tail; -} - //returns 0 if in the middle, 1 if new head, 2 if new tail, or 3 if both new head and tail //TODO this is kind of a stupid way of handling things -int entry_add_sorted(ENTRY *head, ENTRY *tail, ENTRY *add){ +int entry_add(ENTRY *head, ENTRY *tail, ENTRY *add){ assert(add != NULL); ENTRY *ahead; @@ -81,7 +68,7 @@ int entry_add_sorted(ENTRY *head, ENTRY *tail, ENTRY *add){ if(head == NULL) return 3; //add is the new tail - if(strcmp(tail->name, add->name) <= 0){ + if(!get_sort() || strcmp(tail->name, add->name) <= 0){ tail->next = add; return 2; } @@ -9,9 +9,7 @@ void entry_rm(ENTRY *e, ENTRY *prev); void clear_entries(ENTRY *head); -ENTRY *entry_add_last(ENTRY *tail, ENTRY *add); - -int entry_add_sorted(ENTRY *head, ENTRY *tail, ENTRY *add); +int entry_add(ENTRY *head, ENTRY *tail, ENTRY *add); ENTRY **get_entries(ENTRY *head, int count); @@ -6,7 +6,6 @@ #include <unistd.h> #include "entry.h" #include "group.h" -#include "read_cfg.h" #define BUF_LEN 1024 typedef struct group{ @@ -104,29 +103,22 @@ void group_add(char *gname, ENTRY *addme){ //add the entry to the list of entries in the group if(addme != NULL){ - if(get_sort()){ - i = entry_add_sorted(gp->head, gp->tail, addme); - switch(i){ - case 1: - gp->head = addme; - break; - - case 2: - gp->tail = addme; - break; - - case 3: - gp->head = addme; - gp->tail = addme; - break; + i = entry_add(gp->head, gp->tail, addme); + switch(i){ + case 1: + gp->head = addme; + break; - } - } + case 2: + gp->tail = addme; + break; - else{ - gp->tail = entry_add_last(gp->tail, addme); - if(gp->head == NULL) gp->head = gp->tail; //first element of the new list - } + case 3: + gp->head = addme; + gp->tail = addme; + break; + + } gp->entry_count++; total_count++; Binary files differ@@ -34,8 +34,8 @@ int compmode = 0; //1 -> WSL //maybe more later? -//turn on or off sorting (A-Z) -bool sort = 0; +//turn on or off sorting (A-Z); On by default +bool sort = 1; //set to true to automatically try to create a human readable name for an entry bool hr = false; Binary files differ |