[Aide-commits] aide branch, master, updated. ec4e284f0d3278aa26037f25c91ca778a0aebd6b
Brought to you by:
hvhaugwitz,
rvdb
From: Hannes v. H. <hvh...@us...> - 2010-07-24 18:06:49
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "aide". The branch, master has been updated via ec4e284f0d3278aa26037f25c91ca778a0aebd6b (commit) from 3184dd061f81c3c953df98708d29352fee76200a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ec4e284f0d3278aa26037f25c91ca778a0aebd6b Author: Hannes von Haugwitz <ha...@vo...> Date: Sat Jul 24 17:52:08 2010 +0200 Sort files in report by filename diff --git a/ChangeLog b/ChangeLog index f9961da..c285323 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2010-07-24 Hannes von Haugwitz <ha...@vo...> + * Sort files in report by filename, see feature request 1337718 + 2010-07-23 Hannes von Haugwitz <ha...@vo...> * Fixed indent of XAttrs output * Fixed report_attributes for XAttrs diff --git a/NEWS b/NEWS index 75cc4a6..c0f92be 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ ========================================================= Version UNRELEASED + * Sort files in report by filename * Added support for e2fsattrs attribute * Added support for ftype attribute * Bug fixes diff --git a/include/list.h b/include/list.h index 5ae64b1..f28f8b7 100644 --- a/include/list.h +++ b/include/list.h @@ -42,6 +42,7 @@ typedef struct list_header{ }list_header; +list* list_sorted_insert(list* listp, void* data, int (*compare) (const void*, const void*)); list* list_append(list* listp,void*data); diff --git a/src/gen_list.c b/src/gen_list.c index 461f07e..0a2b85b 100644 --- a/src/gen_list.c +++ b/src/gen_list.c @@ -58,6 +58,13 @@ void fs2db_line(struct AIDE_STAT_TYPE* fs,db_line* line); void calc_md(struct AIDE_STAT_TYPE* old_fs,db_line* line); void no_hash(db_line* line); +int compare_node_by_path(const void *n1, const void *n2) +{ + const seltree *x1 = n1; + const seltree *x2 = n2; + return strcmp(x1->path, x2->path); +} + char* strrxtok(char* rx) { char*p=NULL; @@ -275,7 +282,7 @@ seltree* new_seltree_node( } } free(tmprxtok); - parent->childs=list_append(parent->childs,(void*)node); + parent->childs=list_sorted_insert(parent->childs,(void*)node, compare_node_by_path); node->parent=parent; }else { node->parent=NULL; diff --git a/src/list.c b/src/list.c index b7b75d8..47e9c75 100644 --- a/src/list.c +++ b/src/list.c @@ -37,6 +37,71 @@ */ + +/* list_sorted_insert() + * Adds an item in a sorted list: + * - The first argument is the head of the list + * - The second argument is the data to be added + * - The third argument is the function pointer to the compare function to use + * - Returns the head of the list + */ +list* list_sorted_insert(list* listp, void* data, int (*compare) (const void*, const void*)) { + list* newitem=NULL; + list* curitem=NULL; + newitem=(list*)malloc(sizeof(list)); + if (newitem==NULL) { + error(0,"Not enough memory to add a new item to list.\n"); + exit(EXIT_FAILURE); + } + if (listp==NULL){ + list_header* header=(list_header*)malloc(sizeof(list_header)); + if (header==NULL){ + error(0,"Not enough memory for list header allocation\n"); + exit(EXIT_FAILURE); + } + newitem->data=data; + newitem->header=header; + newitem->next=NULL; + newitem->prev=NULL; + header->head=newitem; + header->tail=newitem; + return newitem; + } else { + /* add element in sorted, non-empty list (use insertion sort) */ + curitem = listp->header->head; + newitem->header=listp->header; + newitem->data=data; + if (compare(newitem->data,curitem->data) < 0) { + /* new element is the new head */ + listp->header->head=newitem; + curitem->prev=newitem; + newitem->next=curitem; + newitem->prev=NULL; + return newitem; + } else { + /* find position for new element */ + while(curitem->next != NULL) { + curitem=curitem->next; + if (compare(newitem->data, curitem->data) < 0) break; + } + if (curitem->next == NULL) { + /* new element is the new tail */ + listp->header->tail=newitem; + curitem->next=newitem; + newitem->prev=curitem; + newitem->next=NULL; + } else { + /* new element is an inner element */ + curitem->prev->next=newitem; + newitem->prev=curitem->prev; + curitem->prev=newitem; + newitem->next=curitem; + } + } + return listp; + } +} + /* list_append() * append an item to list * returns the head ----------------------------------------------------------------------- Summary of changes: ChangeLog | 3 ++ NEWS | 1 + include/list.h | 1 + src/gen_list.c | 9 +++++++- src/list.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 1 deletions(-) hooks/post-receive -- aide |