diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-12-12 06:18:14 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-12-12 06:18:14 -0500 |
commit | ed98742c5f7df1cbb79f7b287328596a3b596f9b (patch) | |
tree | 2062695ce29a940f4c8053c925f5b773b91e7a1a | |
parent | ebbf4fb2f167d9a31f63f5c2ba899b5411ab59bf (diff) | |
download | deheader-ed98742c5f7df1cbb79f7b287328596a3b596f9b.tar.gz deheader-ed98742c5f7df1cbb79f7b287328596a3b596f9b.tar.bz2 deheader-ed98742c5f7df1cbb79f7b287328596a3b596f9b.tar.xz deheader-ed98742c5f7df1cbb79f7b287328596a3b596f9b.zip |
Test for bsort(3); fix test for bsd_signal(3).
-rwxr-xr-x | deheader | 2 | ||||
-rw-r--r-- | test/bsd_signal.c | 2 | ||||
-rw-r--r-- | test/bsort.c | 52 | ||||
-rw-r--r-- | test/regress.chk | 14 |
4 files changed, 66 insertions, 4 deletions
@@ -54,6 +54,8 @@ requirements = map(lambda (r, h): (re.compile(r), h), ( (r"\Wbasename\s*\(", ["<libgen.h>"]), (r"\Wbcmp\s*\(", ["<string.h>"]), (r"\Wbrk\s*\(", ["<unistd.h>"]), + (r"\Wbsd_signal\s*\(",["<signal.h>"]), + (r"\Wbsort\s*\(", ["<stdlib.h>"]), (r"\Wumask\s*\(", ["<sys/stat.h>", "<sys/types.h>"]), # Dependencies observed on systems other than the Linux this was # developed under. diff --git a/test/bsd_signal.c b/test/bsd_signal.c index b7f0c9e..8be2f94 100644 --- a/test/bsd_signal.c +++ b/test/bsd_signal.c @@ -4,7 +4,7 @@ * Items: bsd_signal( * Requires: <signal.h> * Standardized-By: SuS - * Detected-by: gcc-4.4.3 + Linux + * Not-Detected-by: gcc-4.4.3 + Linux */ #include <signal.h> diff --git a/test/bsort.c b/test/bsort.c new file mode 100644 index 0000000..89d7ddb --- /dev/null +++ b/test/bsort.c @@ -0,0 +1,52 @@ +/* bsort() requires <stdlib.h> */ + +/* example taken pretty much directly from SuS */ + +/* + * Items: bsort( + * Requires: <stdlib.h> + * Standardized-By: SuS + * Not-Detected-by: gcc-4.4.3 + Linux + */ + +#ifndef __DEHEADER__ +#include <stdio.h> +#endif +#include <stdlib.h> +#include <string.h> + +#define TABSIZE 1000 + +struct node { /* these are stored in the table */ + char *string; + int length; +}; +struct node table[TABSIZE]; /* table to be searched */ + +int +node_compare(const void *node1, const void *node2) +{ + return strcoll(((const struct node *)node1)->string, + ((const struct node *)node2)->string); +} + +main(int argc, char **argv) +{ + struct node *node_ptr, node; + char str_space[20]; /* space to read string into */ + + node.string = str_space; + while (scanf("%s", node.string) != EOF) { + node_ptr = (struct node *)bsearch((void *)(&node), + (void *)table, TABSIZE, + sizeof(struct node), node_compare); + if (node_ptr != NULL) { + (void)printf("string = %20s, length = %d\n", + node_ptr->string, node_ptr->length); + } else { + (void)printf("not found: %s\n", node.string); + } + } +} + + diff --git a/test/regress.chk b/test/regress.chk index 494b808..0dfece4 100644 --- a/test/regress.chk +++ b/test/regress.chk @@ -17,6 +17,7 @@ deheader: ./bcmp.c includes <string.h> deheader: ./bcopy.c includes <string.h> deheader: ./atexit.c includes <stdlib.h> deheader: ./abs.c includes <stdlib.h> +deheader: ./bsd_signal.c has requires <signal.h> from \Wbsd_signal\s*\( deheader: ./bsd_signal.c includes <signal.h> deheader: ./access.c has requires <unistd.h> from \Waccess\s*\( deheader: ./access.c includes <unistd.h> @@ -38,6 +39,11 @@ deheader: ./atan.c includes <math.h> deheader: ./basename.c has requires <libgen.h> from \Wbasename\s*\( deheader: ./basename.c includes <libgen.h> deheader: ./asin.c includes <math.h> +deheader: ./bsort.c has requires <stdlib.h> from \Wbsort\s*\( +deheader: ./bsort.c includes <stdio.h> +deheader: ignoring <stdio.h> (conditional inclusion) +deheader: ./bsort.c includes <stdlib.h> +deheader: ./bsort.c includes <string.h> deheader: ./advance.c has requires <regexp.h> from \Wadvance\s*\( deheader: ./advance.c includes <regexp.h> deheader: ./atan2.c has requires <math.h> from \Watan2\s*\( @@ -49,8 +55,7 @@ deheader: in ./acos.c, retaining required '#include <math.h>\n' deheader: in ./brk.c, retaining required '#include <unistd.h>\n' deheader: ./string.c without <string.h> succeeded. deheader: remove <string.h> from ./string.c -deheader: ./bsd_signal.c without <signal.h> succeeded. -deheader: remove <signal.h> from ./bsd_signal.c +deheader: in ./bsd_signal.c, retaining required '#include <signal.h>\n' deheader: ./abs.c without <stdlib.h> succeeded. deheader: remove <stdlib.h> from ./abs.c deheader: in ./basename.c, retaining required '#include <libgen.h>\n' @@ -70,6 +75,9 @@ deheader: ./alarm.c without <unistd.h> succeeded. deheader: remove <unistd.h> from ./alarm.c deheader: ./sbrk.c without <unistd.h> succeeded. deheader: remove <unistd.h> from ./sbrk.c +deheader: ./bsort.c without <string.h> succeeded. +deheader: in ./bsort.c, retaining required '#include <stdlib.h>\n' +deheader: remove <string.h> from ./bsort.c deheader: in ./umask.c, retaining required '#include <sys/types.h>\n' deheader: in ./umask.c, retaining required '#include <sys/stat.h>\n' deheader: ./abort.c without <stdlib.h> succeeded. @@ -80,4 +88,4 @@ deheader: in ./acosh.c, retaining required '#include <math.h>\n' deheader: in ./bcmp.c, retaining required '#include <string.h>\n' deheader: in ./a64l.c, retaining required '#include <stdlib.h>\n' deheader: in ./advance.c, retaining required '#include <regexp.h>\n' -deheader: saw 27 files, 28 includes, 10 removed +deheader: saw 28 files, 30 includes, 10 removed |