Update of /cvsroot/digraphanalysis/digraphanalysis/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26763
Modified Files:
Tag: JBREKER
list.c main.c
Log Message:
fix 2 bugs
-print_list segfaults on empty lists: fixed by LIST_INIT during list_new()
-segfault on LIST_REMOVE: apparently you can't use this to remove the first element. (elm)->field.le_prev is null thus *(elm)->field.le_prev segfaults.
Index: main.c
===================================================================
RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v
retrieving revision 1.2.2.11
retrieving revision 1.2.2.12
diff -C2 -d -r1.2.2.11 -r1.2.2.12
*** main.c 10 Apr 2005 03:59:48 -0000 1.2.2.11
--- main.c 11 Apr 2005 04:32:39 -0000 1.2.2.12
***************
*** 20,23 ****
--- 20,24 ----
#include <ctype.h>
+ #include <err.h>
#include <libgen.h>
#include <stdio.h>
***************
*** 86,91 ****
/* Iterate through the list of keys, analyzing the key and outputting its file */
! iter1 = LIST_FIRST(keys1);
! while(iter1 != NULL)
{
nnlist = list_new();
--- 87,91 ----
/* Iterate through the list of keys, analyzing the key and outputting its file */
! LIST_FOREACH(iter1, keys1, entries)
{
nnlist = list_new();
***************
*** 99,103 ****
list_free(snlist);
list_free(sslist);
- iter1 = LIST_NEXT(iter1, entries);
}
iter1 = NULL;
--- 99,102 ----
***************
*** 221,225 ****
size = size * 10;
size = size + c - '0';
- printf("%u", size);
}
if(c == EOF)
--- 220,223 ----
***************
*** 343,359 ****
{
if(((c = getchar()) != ':') && (c != EOF))
! errx(EX_DATAERR, "001 Invalid character, %c (ASCII: %d), encountered!\n", c, c);
if(c == EOF)
break;
if((field1 = get_field()) == NULL)
! errx(EX_OSERR, "001 Cannot allocate memory!\n");
if(*field1 == EOF)
break;
if(((c = getchar()) != ':') && (c != EOF))
! errx(EX_DATAERR, "002 Invalid character, %c (ASCII: %d), encountered!\n", c, c);
if(c == EOF)
break;
if((field2 = get_field()) == NULL)
! errx(EX_OSERR, "002 Cannot allocate memory!\n");
if(*field2 == EOF)
break;
--- 341,357 ----
{
if(((c = getchar()) != ':') && (c != EOF))
! errx(EX_DATAERR, "Invalid character, %c (ASCII: %d), encountered!\n", c, c);
if(c == EOF)
break;
if((field1 = get_field()) == NULL)
! errx(EX_OSERR, "Cannot allocate memory!\n");
if(*field1 == EOF)
break;
if(((c = getchar()) != ':') && (c != EOF))
! errx(EX_DATAERR, "Invalid character, %c (ASCII: %d), encountered!\n", c, c);
if(c == EOF)
break;
if((field2 = get_field()) == NULL)
! errx(EX_OSERR, "Cannot allocate memory!\n");
if(*field2 == EOF)
break;
***************
*** 368,372 ****
{
free(tmpkey);
! if(key1->name == NULL)
{
key1->name = field2;
--- 366,370 ----
{
free(tmpkey);
! if(*(key1->name) == '\0')
{
key1->name = field2;
***************
*** 374,378 ****
}
}
- printf(key1->keyid);
}
else
--- 372,375 ----
***************
*** 387,391 ****
free(tmpkey);
list_add_object(key2->signatures, key1, &pgpkey_compare);
-
}
--- 384,387 ----
***************
*** 405,411 ****
struct node_t *node;
! LIST_FOREACH(node, list, entries)
! fprintf(filep, " %s %s\n", ((pgpkey_t *) node->object)->keyid + 8, ((pgpkey_t *) node->object)->name);
return;
--- 401,414 ----
struct node_t *node;
! pgpkey_t *key;
! char *keyid, *name;
+ LIST_FOREACH(node, list, entries)
+ {
+ key = (pgpkey_t *) node->object;
+ keyid = key->keyid + 8;
+ name = key->name;
+ fprintf(filep, " %s %s\n", keyid, name);
+ }
return;
Index: list.c
===================================================================
RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** list.c 10 Apr 2005 03:59:48 -0000 1.1.2.4
--- list.c 11 Apr 2005 04:32:39 -0000 1.1.2.5
***************
*** 130,134 ****
struct node_t *iter;
! for(iter = LIST_FIRST(list2); iter != NULL; iter = LIST_NEXT(iter, entries))
list_add_object(list1, iter->object, compare);
--- 130,134 ----
struct node_t *iter;
! LIST_FOREACH(iter, list2, entries)
list_add_object(list1, iter->object, compare);
***************
*** 145,148 ****
--- 145,150 ----
return NULL;
+ LIST_INIT(list);
+
return list;
}
***************
*** 173,177 ****
if((i = compare(iter->object, object)) == 0)
{
! LIST_REMOVE(iter, entries);
free(iter);
break;
--- 175,182 ----
if((i = compare(iter->object, object)) == 0)
{
! if(iter == LIST_FIRST(list))
! LIST_FIRST(list) = LIST_NEXT(iter, entries);
! else
! LIST_REMOVE(iter, entries);
free(iter);
break;
***************
*** 223,231 ****
struct list_t *list;
! if((list = list_new()) == NULL)
return NULL;
! if(list_merge_list(list, list1, compare) == NULL)
! return NULL;
! return list_merge_list(list, list2, compare);
}
--- 228,236 ----
struct list_t *list;
! if(((list = list_new()) == NULL) ||
! (list_merge_list(list, list1, compare) == NULL) ||
! (list_merge_list(list, list2, compare) == NULL))
return NULL;
! return list;
}
|