diff options
author | Greg McGary <greg@mcgary.org> | 1997-04-18 06:34:23 +0000 |
---|---|---|
committer | Greg McGary <greg@mcgary.org> | 1997-04-18 06:34:23 +0000 |
commit | ab66bea0c326c2e18866ad37134dc91bf99c514a (patch) | |
tree | 54cc06ba3cd8ca1b5e8f72284438c5a2172ec5b6 | |
parent | 809b665811bde40439d829d6193b278b26ae00ed (diff) | |
download | idutils-ab66bea0c326c2e18866ad37134dc91bf99c514a.tar.gz idutils-ab66bea0c326c2e18866ad37134dc91bf99c514a.tar.bz2 idutils-ab66bea0c326c2e18866ad37134dc91bf99c514a.zip |
imported from mkid-3.0.1r3_0_1
-rw-r--r-- | Makefile.in | 7 | ||||
-rw-r--r-- | acconfig.h | 3 | ||||
-rw-r--r-- | aclocal.m4 | 3 | ||||
-rw-r--r-- | alloc.h | 12 | ||||
-rw-r--r-- | config.h.in | 6 | ||||
-rwxr-xr-x | configure | 13 | ||||
-rw-r--r-- | configure.in | 12 | ||||
-rw-r--r-- | depend.out | 20 | ||||
-rw-r--r-- | fid.c | 6 | ||||
-rw-r--r-- | filenames.c | 10 | ||||
-rw-r--r-- | filenames.h | 2 | ||||
-rw-r--r-- | idfile.c | 23 | ||||
-rw-r--r-- | idfile.h | 14 | ||||
-rw-r--r-- | iid.c | 115 | ||||
-rw-r--r-- | iid.y | 49 | ||||
-rw-r--r-- | lid.c | 41 | ||||
-rw-r--r-- | misc.c | 15 | ||||
-rw-r--r-- | misc.h | 1 | ||||
-rw-r--r-- | mkid.c | 137 | ||||
-rw-r--r-- | mkid.info | 69 | ||||
-rw-r--r-- | mkid.texinfo | 6 | ||||
-rw-r--r-- | scanners.c | 4 | ||||
-rw-r--r-- | strcasecmp.c | 5 | ||||
-rw-r--r-- | strxtra.h | 20 |
24 files changed, 311 insertions, 282 deletions
diff --git a/Makefile.in b/Makefile.in index b256166..db37dae 100644 --- a/Makefile.in +++ b/Makefile.in @@ -262,3 +262,10 @@ $(srcdir)/config.h.in: stamp-h.in $(srcdir)/stamp-h.in: configure.in aclocal.m4 acconfig.h cd $(srcdir) && autoheader date >$(srcdir)/stamp-h.in + +depend $(DEPEND): $(ALL_CFILES) + (cd $(srcdir) && $(CC) $(CC_FLAGS) -MM $(ALL_CFILES);) >$(DEPEND) + +############################################################################## + +@DEPEND_FILE@ @@ -23,5 +23,8 @@ /* Define to the minor.minor.patch_level # of the distribution. */ #undef FULL_VERSION +/* Define to the patch level of the distribution. */ +#undef PATCH_LEVEL + /* Define to filename of iid help text. */ #undef IID_HELP_FILE @@ -28,8 +28,9 @@ ac_save_CFLAGS="$CFLAGS" # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX -Aa -D_HPUX_SOURCE +# CX/UX -Xa (-Xc is strict ANSI) # SVR4 -Xc -for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -Xc +for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -Xa -Xc do CFLAGS="$ac_save_CFLAGS $ac_arg" AC_TRY_COMPILE( @@ -19,10 +19,16 @@ #ifndef _alloc_h_ #define _alloc_h_ +#if HAVE_STDLIB_H +#include <stdlib.h> +#else /* not HAVE_STDLIB_H */ +#if HAVE_MALLOC_H #include <malloc.h> +#endif /* HAVE_MALLOC_H */ +#endif /* not HAVE_STDLIB_H */ -#define CALLOC(type, n) ((type *)calloc(sizeof(type), (n))) -#define MALLOC(type, n) ((type *)malloc(sizeof(type) * (n))) -#define REALLOC(old, type, n) ((type *)realloc((old), sizeof(type) * (n))) +#define CALLOC(type, n) ((type *) calloc (sizeof (type), (n))) +#define MALLOC(type, n) ((type *) malloc (sizeof (type) * (n))) +#define REALLOC(old, type, n) ((type *) realloc ((old), sizeof (type) * (n))) #endif /* not _alloc_h_ */ diff --git a/config.h.in b/config.h.in index ae5350f..1f1c41e 100644 --- a/config.h.in +++ b/config.h.in @@ -49,6 +49,9 @@ /* Define to the version of the distribution. */ #undef VERSION +/* Define to the patch level of the distribution. */ +#undef PATCH_LEVEL + /* Define to filename of iid help text. */ #undef IID_HELP_FILE @@ -85,6 +88,9 @@ /* Define if you have the strdup function. */ #undef HAVE_STRDUP +/* Define if you have the strerror function. */ +#undef HAVE_STRERROR + /* Define if you have the strrchr function. */ #undef HAVE_STRRCHR @@ -1709,12 +1709,14 @@ EOF fi -if test "$ac_cv_func_re_comp" = no; then REGEXP=rx.o; fi +if test "$ac_cv_func_re_comp" = no; then REGEXP="regex.o"; fi if test "$ac_cv_func_getopt_long" = no; then GETOPT="getopt.o getopt1.o"; fi if test "$ac_cv_func_strcasecmp" = no; then STRCASECMP="strcasecmp.o"; fi +if test "$ac_cv_func_strerror" = no; then STRERROR="strerror.o"; fi + if test "x$prefix" != xNONE; then libdir=$prefix/lib @@ -1729,6 +1731,11 @@ cat >> confdefs.h <<EOF EOF +DEPEND=${srcdir:-.}/depend.out +DEPEND_FILE=$DEPEND + + + trap '' 1 2 15 if test -w $cache_file; then echo "updating cache $cache_file" @@ -1844,8 +1851,12 @@ s%@ALLOCA@%$ALLOCA%g s%@REGEXP@%$REGEXP%g s%@GETOPT@%$GETOPT%g s%@STRCASECMP@%$STRCASECMP%g +s%@STRERROR@%$STRERROR%g s%@libdir@%$libdir%g s%@IID_HELP_FILE@%$IID_HELP_FILE%g +s%@DEPEND@%$DEPEND%g +/@DEPEND_FILE@/r $DEPEND_FILE +s%@DEPEND_FILE@%%g CEOF EOF diff --git a/configure.in b/configure.in index 830f227..bf54cc4 100644 --- a/configure.in +++ b/configure.in @@ -53,16 +53,19 @@ AC_SUBST(LDFLAGS) dnl Checks for library functions. AC_PROG_GCC_TRADITIONAL -AC_CHECK_FUNCS(getwd getcwd getopt_long re_comp strdup strchr strrchr strcasecmp) +AC_CHECK_FUNCS(getwd getcwd getopt_long re_comp) +AC_CHECK_FUNCS(strdup strchr strrchr strcasecmp strerror) AC_CHECK_FUNCS(memcpy bcopy memset bzero) AC_FUNC_ALLOCA AC_SUBST(ALLOCA) -if test "$ac_cv_func_re_comp" = no; then REGEXP=rx.o; fi +if test "$ac_cv_func_re_comp" = no; then REGEXP="regex.o"; fi AC_SUBST(REGEXP) if test "$ac_cv_func_getopt_long" = no; then GETOPT="getopt.o getopt1.o"; fi AC_SUBST(GETOPT) if test "$ac_cv_func_strcasecmp" = no; then STRCASECMP="strcasecmp.o"; fi AC_SUBST(STRCASECMP) +if test "$ac_cv_func_strerror" = no; then STRERROR="strerror.o"; fi +AC_SUBST(STRERROR) if test "x$prefix" != xNONE; then libdir=$prefix/lib @@ -74,4 +77,9 @@ AC_SUBST(libdir) AC_SUBST(IID_HELP_FILE) AC_DEFINE_UNQUOTED(IID_HELP_FILE, "$libdir/iid.help") +DEPEND=${srcdir:-.}/depend.out +DEPEND_FILE=$DEPEND +AC_SUBST(DEPEND) +AC_SUBST_FILE(DEPEND_FILE) + AC_OUTPUT(Makefile) @@ -17,24 +17,4 @@ getopt.o: getopt.c getopt1.o: getopt1.c getopt.h strcasecmp.o: strcasecmp.c strerror.o: strerror.c -iid.o: iid.c config.h strxtra.h -mkid.o: mkid.c config.h strxtra.h alloc.h idfile.h idarg.h token.h bitops.h misc.h \ - filenames.h scanners.h -lid.o: lid.c config.h alloc.h idfile.h idarg.h token.h bitops.h strxtra.h misc.h \ - filenames.h -fid.o: fid.c config.h idfile.h idarg.h bitops.h filenames.h misc.h strxtra.h \ - alloc.h token.h -idx.o: idx.c config.h misc.h filenames.h scanners.h -misc.o: misc.c config.h strxtra.h misc.h -scanners.o: scanners.c config.h strxtra.h token.h alloc.h scanners.h -idfile.o: idfile.c config.h alloc.h idfile.h idarg.h strxtra.h -filenames.o: filenames.c config.h strxtra.h filenames.h misc.h -bitops.o: bitops.c config.h bitops.h -token.o: token.c config.h token.h -regex.o: regex.c regex.h -alloca.o: alloca.c -getopt.o: getopt.c -getopt1.o: getopt1.c getopt.h -strcasecmp.o: strcasecmp.c -strerror.o: strerror.c iid.o: iid.c ./config.h ./strxtra.h @@ -57,18 +57,18 @@ main (int argc, char **argv) int index_1 = -1; int index_2 = -1; - program_name = basename (GETARG (argc, argv)); + program_name = basename ((argc--, *argv++)); while (argc) { - char const *arg = GETARG (argc, argv); + char const *arg = (argc--, *argv++); switch (op = *arg++) { case '-': case '+': break; default: - UNGETARG (argc, argv); + (argc++, --argv); goto argsdone; } while (*arg) diff --git a/filenames.c b/filenames.c index 9ccd4ad..9a766ac 100644 --- a/filenames.c +++ b/filenames.c @@ -565,21 +565,11 @@ unsymlink (char *n) return n; } -long input_chars = 0; - FILE * open_source_FILE (char *file_name, char const *filter) { - struct stat stat_buf; FILE *source_FILE; - if (stat (file_name, &stat_buf) < 0) - { - filerr ("open", file_name); - return NULL; - } - input_chars += stat_buf.st_size; - if (filter) { char command[1024]; diff --git a/filenames.h b/filenames.h index d2b7a39..938f04a 100644 --- a/filenames.h +++ b/filenames.h @@ -33,6 +33,4 @@ void close_source_FILE (FILE *fp, char const *filter); char const *get_sccs (char const *dir, char const *base, char const *sccs_dir); char const *co_rcs (char const *dir, char const *base, char const *rcs_dir); -extern long input_chars; - #endif /* not _filenames_h_ */ @@ -24,10 +24,10 @@ #include "idarg.h" #include "strxtra.h" -static int io_idhead (FILE *fp, int (*io) (FILE *, void *, int, int), struct idhead *idh); -static int io_write (FILE *output_FILE, void *addr, int size, int is_int); -static int io_read (FILE *input_FILE, void *addr, int size, int is_int); -static int io_size (FILE *, void *, int size, int); +static int io_idhead (FILE *fp, int (*io) (FILE *, void *, unsigned int, int), struct idhead *idh); +static int io_write (FILE *output_FILE, void *addr, unsigned int size, int is_int); +static int io_read (FILE *input_FILE, void *addr, unsigned int size, int is_int); +static int io_size (FILE *, void *, unsigned int size, int); extern char *program_name; @@ -39,7 +39,7 @@ FILE * init_idfile (char const *id_file, struct idhead *idh, struct idarg **id_args) { FILE *id_FILE; - int i; + unsigned int i; char *strings; struct idarg *ida; @@ -99,13 +99,13 @@ sizeof_idhead () } static int -io_size (FILE *ignore_FILE, void *ignore_addr, int size, int ignore_int) +io_size (FILE *ignore_FILE, void *ignore_addr, unsigned int size, int ignore_int) { return size; } static int -io_read (FILE *input_FILE, void *addr, int size, int is_int) +io_read (FILE *input_FILE, void *addr, unsigned int size, int is_int) { if (is_int) { @@ -134,7 +134,7 @@ io_read (FILE *input_FILE, void *addr, int size, int is_int) } static int -io_write (FILE *output_FILE, void *addr, int size, int is_int) +io_write (FILE *output_FILE, void *addr, unsigned int size, int is_int) { if (is_int) { @@ -163,10 +163,11 @@ io_write (FILE *output_FILE, void *addr, int size, int is_int) } static int -io_idhead (FILE *fp, int (*io) (FILE *, void *, int, int), struct idhead *idh) +io_idhead (FILE *fp, int (*io) (FILE *, void *, unsigned int, int), struct idhead *idh) { - int size = 0; - fseek (fp, 0L, 0); + unsigned int size = 0; + if (fp) + fseek (fp, 0L, 0); size += io (fp, idh->idh_magic, sizeof (idh->idh_magic), 0); size += io (fp, &idh->idh_pad_1, sizeof (idh->idh_pad_1), 0); size += io (fp, &idh->idh_version, sizeof (idh->idh_version), 0); @@ -33,20 +33,18 @@ struct idhead #define IDH_VERSION 3 unsigned short idh_flags; #define IDH_COUNTS 0x0001 /* occurrence counts are included with each token */ - long idh_args; /* total # of args for mkid update */ - long idh_paths; /* total # of file names for mkid update */ - long idh_tokens; /* total # of tokens */ - long idh_buf_size; /* # of bytes in longest entry (bufsiz for lid) */ - long idh_vec_size; /* # of hits in longest entry (max vector size for lid) */ + unsigned long idh_args; /* total # of args for mkid update */ + unsigned long idh_paths; /* total # of file names for mkid update */ + unsigned long idh_tokens; /* total # of tokens */ + unsigned long idh_buf_size; /* # of bytes in longest entry (bufsiz for lid) */ + unsigned long idh_vec_size; /* # of hits in longest entry (max vector size for lid) */ off_t idh_args_offset; /* file offset of args */ off_t idh_tokens_offset; /* file offset of tokens section */ off_t idh_end_offset; /* file offset beyond tokens section */ }; -#define GETARG(argc, argv) ((argc)--, *(argv)++) -#define UNGETARG(argc, argv) ((argc)++, --(argv)) - struct idarg; + FILE *init_idfile (char const *id_file, struct idhead *idhp, struct idarg **id_args); int read_idhead (FILE *input_FILE, struct idhead *idh); int write_idhead (FILE *input_FILE, struct idhead *idh); @@ -49,16 +49,17 @@ #include <stdlib.h> #include <unistd.h> #include <getopt.h> +#include "strxtra.h" -#ifdef HAVE_ALLOCA -#ifdef HAVE_ALLOCA_H +#if HAVE_ALLOCA + +#if HAVE_ALLOCA_H #include <alloca.h> #endif - #define TEMP_ALLOC(s) alloca(s) #define TEMP_FREE(s) -#else /* not HAVE_ALLOCA +#else /* not HAVE_ALLOCA */ #define TEMP_ALLOC(s) malloc(s) #define TEMP_FREE(s) free(s) @@ -250,7 +251,7 @@ set_type * SetInverse( set_type * sp ) ; void RunShell( char * pp , id_list_type * idlp ) ; -#line 229 "iid.y" +#line 230 "iid.y" typedef union { set_type * setdef ; id_type * strdef ; @@ -342,9 +343,9 @@ static const short yyrhs[] = { 9, #if YYDEBUG != 0 static const short yyrline[] = { 0, - 255, 263, 264, 270, 276, 282, 288, 292, 299, 308, - 317, 326, 333, 342, 351, 362, 369, 378, 387, 395, - 403, 412, 421, 430, 438, 445, 451, 459, 467 + 256, 264, 265, 271, 277, 283, 289, 293, 300, 309, + 318, 327, 334, 343, 352, 363, 370, 379, 388, 396, + 404, 413, 422, 431, 439, 446, 452, 460, 468 }; static const char * const yytname[] = { "$","error","$illegal.","SET","ID", @@ -967,7 +968,7 @@ yyreduce: switch (yyn) { case 1: -#line 257 "iid.y" +#line 258 "iid.y" { /* cd to the directory specified as argument, flush sets */ @@ -976,7 +977,7 @@ case 1: ; break;} case 3: -#line 265 "iid.y" +#line 266 "iid.y" { /* print the list of files resulting from Query */ @@ -984,7 +985,7 @@ case 3: ; break;} case 4: -#line 271 "iid.y" +#line 272 "iid.y" { /* run PAGER on the list of files in SET */ @@ -992,7 +993,7 @@ case 4: ; break;} case 5: -#line 277 "iid.y" +#line 278 "iid.y" { /* describe sets created so far */ @@ -1000,7 +1001,7 @@ case 5: ; break;} case 6: -#line 283 "iid.y" +#line 284 "iid.y" { /* run PAGER on the help file */ @@ -1008,13 +1009,13 @@ case 6: ; break;} case 7: -#line 289 "iid.y" +#line 290 "iid.y" { exit(0) ; ; break;} case 8: -#line 293 "iid.y" +#line 294 "iid.y" { /* run the shell command and eat the results as a file set */ @@ -1023,7 +1024,7 @@ case 8: ; break;} case 9: -#line 300 "iid.y" +#line 301 "iid.y" { /* run the shell command */ @@ -1032,7 +1033,7 @@ case 9: ; break;} case 10: -#line 310 "iid.y" +#line 311 "iid.y" { /* Turn on verbose query flag */ @@ -1040,7 +1041,7 @@ case 10: ; break;} case 11: -#line 319 "iid.y" +#line 320 "iid.y" { /* Turn off verbose query flag */ @@ -1048,7 +1049,7 @@ case 11: ; break;} case 12: -#line 328 "iid.y" +#line 329 "iid.y" { /* value of query is set associated with primitive */ @@ -1056,7 +1057,7 @@ case 12: ; break;} case 13: -#line 334 "iid.y" +#line 335 "iid.y" { /* value of query is intersection of the two query sets */ @@ -1067,7 +1068,7 @@ case 13: ; break;} case 14: -#line 343 "iid.y" +#line 344 "iid.y" { /* value of query is union of the two query sets */ @@ -1078,7 +1079,7 @@ case 14: ; break;} case 15: -#line 352 "iid.y" +#line 353 "iid.y" { /* value of query is inverse of other query */ @@ -1089,7 +1090,7 @@ case 15: ; break;} case 16: -#line 364 "iid.y" +#line 365 "iid.y" { /* Value of primitive is value of recorded set */ @@ -1097,7 +1098,7 @@ case 16: ; break;} case 17: -#line 370 "iid.y" +#line 371 "iid.y" { /* Value of primitive is obtained by running an lid query */ @@ -1108,7 +1109,7 @@ case 17: ; break;} case 18: -#line 379 "iid.y" +#line 380 "iid.y" { /* Value of primitive is obtained by running an aid query */ @@ -1119,7 +1120,7 @@ case 18: ; break;} case 19: -#line 388 "iid.y" +#line 389 "iid.y" { /* Match names from database against pattern */ yyval. setdef = RunProg("pid -kmn", yyvsp[0]. listdef ) ; @@ -1129,7 +1130,7 @@ case 19: ; break;} case 20: -#line 396 "iid.y" +#line 397 "iid.y" { /* value of primitive is value of query */ @@ -1137,7 +1138,7 @@ case 20: ; break;} case 21: -#line 405 "iid.y" +#line 406 "iid.y" { /* make arg list holding single ID */ @@ -1147,7 +1148,7 @@ case 21: ; break;} case 22: -#line 413 "iid.y" +#line 414 "iid.y" { /* arg list is Id_list */ @@ -1156,7 +1157,7 @@ case 22: ; break;} case 23: -#line 423 "iid.y" +#line 424 "iid.y" { /* arg list is Id_list */ @@ -1164,7 +1165,7 @@ case 23: ; break;} case 24: -#line 432 "iid.y" +#line 433 "iid.y" { /* make arg list holding single ID */ @@ -1173,7 +1174,7 @@ case 24: ; break;} case 25: -#line 439 "iid.y" +#line 440 "iid.y" { /* make arg list holding names from set */ @@ -1182,7 +1183,7 @@ case 25: ; break;} case 26: -#line 446 "iid.y" +#line 447 "iid.y" { /* extend arg list with additional ID */ @@ -1190,7 +1191,7 @@ case 26: ; break;} case 27: -#line 452 "iid.y" +#line 453 "iid.y" { /* extend arg list with additional file names */ @@ -1198,7 +1199,7 @@ case 27: ; break;} case 28: -#line 461 "iid.y" +#line 462 "iid.y" { /* make arg list holding single ID */ @@ -1207,7 +1208,7 @@ case 28: ; break;} case 29: -#line 468 "iid.y" +#line 469 "iid.y" { /* extend arg list with additional ID */ @@ -1438,7 +1439,7 @@ yyerrhandle: yystate = yyn; goto yynewstate; } -#line 475 "iid.y" +#line 476 "iid.y" /* ScanLine - a global variable holding a pointer to the current @@ -1523,20 +1524,20 @@ yylex( void ) /* first token on line, check for command names */ - if (strcasecmp(yytext, "SS")) return(SS) ; - if (strcasecmp(yytext, "FILES")) return(FILES) ; - if (strcasecmp(yytext, "F")) return(FILES) ; - if (strcasecmp(yytext, "HELP")) return(HELP) ; - if (strcasecmp(yytext, "H")) return(HELP) ; - if (strcasecmp(yytext, "?")) return(HELP) ; - if (strcasecmp(yytext, "BEGIN")) return(BEGIN) ; - if (strcasecmp(yytext, "B")) return(BEGIN) ; - if (strcasecmp(yytext, "SETS")) return(SETS) ; - if (strcasecmp(yytext, "SHOW")) return(SHOW) ; - if (strcasecmp(yytext, "P")) return(SHOW) ; - if (strcasecmp(yytext, "OFF")) return(OFF) ; - if (strcasecmp(yytext, "Q")) return(OFF) ; - if (strcasecmp(yytext, "QUIT")) return(OFF) ; + if (strcaseequ(yytext, "SS")) return(SS) ; + if (strcaseequ(yytext, "FILES")) return(FILES) ; + if (strcaseequ(yytext, "F")) return(FILES) ; + if (strcaseequ(yytext, "HELP")) return(HELP) ; + if (strcaseequ(yytext, "H")) return(HELP) ; + if (strcaseequ(yytext, "?")) return(HELP) ; + if (strcaseequ(yytext, "BEGIN")) return(BEGIN) ; + if (strcaseequ(yytext, "B")) return(BEGIN) ; + if (strcaseequ(yytext, "SETS")) return(SETS) ; + if (strcaseequ(yytext, "SHOW")) return(SHOW) ; + if (strcaseequ(yytext, "P")) return(SHOW) ; + if (strcaseequ(yytext, "OFF")) return(OFF) ; + if (strcaseequ(yytext, "Q")) return(OFF) ; + if (strcaseequ(yytext, "QUIT")) return(OFF) ; if (yytext[0] == '!') { code = SHELL_COMMAND ; } else { @@ -1546,12 +1547,12 @@ yylex( void ) /* not first token, check for operator names */ - if (strcasecmp(yytext, "LID")) return(LID) ; - if (strcasecmp(yytext, "AID")) return(AID) ; - if (strcasecmp(yytext, "AND")) return(AND) ; - if (strcasecmp(yytext, "OR")) return(OR) ; - if (strcasecmp(yytext, "NOT")) return(NOT) ; - if (strcasecmp(yytext, "MATCH")) return(MATCH) ; + if (strcaseequ(yytext, "LID")) return(LID) ; + if (strcaseequ(yytext, "AID")) return(AID) ; + if (strcaseequ(yytext, "AND")) return(AND) ; + if (strcaseequ(yytext, "OR")) return(OR) ; + if (strcaseequ(yytext, "NOT")) return(NOT) ; + if (strcaseequ(yytext, "MATCH")) return(MATCH) ; if ((yytext[0] == 's' || yytext[0] == 'S') && isdigit(yytext[1])) { /* this might be a set specification */ @@ -24,16 +24,17 @@ #include <stdlib.h> #include <unistd.h> #include <getopt.h> +#include "strxtra.h" -#ifdef HAVE_ALLOCA -#ifdef HAVE_ALLOCA_H +#if HAVE_ALLOCA + +#if HAVE_ALLOCA_H #include <alloca.h> #endif - #define TEMP_ALLOC(s) alloca(s) #define TEMP_FREE(s) -#else /* not HAVE_ALLOCA +#else /* not HAVE_ALLOCA */ #define TEMP_ALLOC(s) malloc(s) #define TEMP_FREE(s) free(s) @@ -556,20 +557,20 @@ yylex( void ) /* first token on line, check for command names */ - if (strcasecmp(yytext, "SS")) return(SS) ; - if (strcasecmp(yytext, "FILES")) return(FILES) ; - if (strcasecmp(yytext, "F")) return(FILES) ; - if (strcasecmp(yytext, "HELP")) return(HELP) ; - if (strcasecmp(yytext, "H")) return(HELP) ; - if (strcasecmp(yytext, "?")) return(HELP) ; - if (strcasecmp(yytext, "BEGIN")) return(BEGIN) ; - if (strcasecmp(yytext, "B")) return(BEGIN) ; - if (strcasecmp(yytext, "SETS")) return(SETS) ; - if (strcasecmp(yytext, "SHOW")) return(SHOW) ; - if (strcasecmp(yytext, "P")) return(SHOW) ; - if (strcasecmp(yytext, "OFF")) return(OFF) ; - if (strcasecmp(yytext, "Q")) return(OFF) ; - if (strcasecmp(yytext, "QUIT")) return(OFF) ; + if (strcaseequ(yytext, "SS")) return(SS) ; + if (strcaseequ(yytext, "FILES")) return(FILES) ; + if (strcaseequ(yytext, "F")) return(FILES) ; + if (strcaseequ(yytext, "HELP")) return(HELP) ; + if (strcaseequ(yytext, "H")) return(HELP) ; + if (strcaseequ(yytext, "?")) return(HELP) ; + if (strcaseequ(yytext, "BEGIN")) return(BEGIN) ; + if (strcaseequ(yytext, "B")) return(BEGIN) ; + if (strcaseequ(yytext, "SETS")) return(SETS) ; + if (strcaseequ(yytext, "SHOW")) return(SHOW) ; + if (strcaseequ(yytext, "P")) return(SHOW) ; + if (strcaseequ(yytext, "OFF")) return(OFF) ; + if (strcaseequ(yytext, "Q")) return(OFF) ; + if (strcaseequ(yytext, "QUIT")) return(OFF) ; if (yytext[0] == '!') { code = SHELL_COMMAND ; } else { @@ -579,12 +580,12 @@ yylex( void ) /* not first token, check for operator names */ - if (strcasecmp(yytext, "LID")) return(LID) ; - if (strcasecmp(yytext, "AID")) return(AID) ; - if (strcasecmp(yytext, "AND")) return(AND) ; - if (strcasecmp(yytext, "OR")) return(OR) ; - if (strcasecmp(yytext, "NOT")) return(NOT) ; - if (strcasecmp(yytext, "MATCH")) return(MATCH) ; + if (strcaseequ(yytext, "LID")) return(LID) ; + if (strcaseequ(yytext, "AID")) return(AID) ; + if (strcaseequ(yytext, "AND")) return(AND) ; + if (strcaseequ(yytext, "OR")) return(OR) ; + if (strcaseequ(yytext, "NOT")) return(NOT) ; + if (strcaseequ(yytext, "MATCH")) return(MATCH) ; if ((yytext[0] == 's' || yytext[0] == 'S') && isdigit(yytext[1])) { /* this might be a set specification */ @@ -26,9 +26,9 @@ #include <errno.h> #include <sys/types.h> #include <sys/wait.h> -#include <rx.h> #include <assert.h> #include <limits.h> +#include <regex.h> #include "alloc.h" #include "idfile.h" #include "idarg.h" @@ -134,11 +134,11 @@ main (int argc, char **argv) char const *REL_file_name = NULL; int (*forced_find_func) (char const *arg, doit_t doit) = NULL; - program_name = basename (GETARG (argc, argv)); + program_name = basename ((argc--, *argv++)); while (argc) { - char const *arg = GETARG (argc, argv); + char const *arg = (argc--, *argv++); int op = *arg++; switch (op) { @@ -146,7 +146,7 @@ main (int argc, char **argv) case '+': break; default: - UNGETARG (argc, argv); + (argc++, --argv); goto argsdone; } while (*arg) @@ -279,14 +279,14 @@ argsdone: if (argc == 0) { - UNGETARG (argc, argv); + (argc++, --argv); *(char const **)argv = "."; } while (argc) { long val = -1; - char *arg = GETARG (argc, argv); + char *arg = (argc--, *argv++); if (forced_find_func) find_func = forced_find_func; @@ -430,20 +430,11 @@ edit_id (char const *name, char **argv) static char const *eid_left_del; if (editor == NULL) - editor = getenv ("EDITOR"); - if (editor == NULL) { - char const *ucb_vi = "/usr/ucb/vi"; - char const *bin_vi = "/usr/bin/vi"; - - if (access (ucb_vi, 01) == 0) - editor = ucb_vi; - else if (access (bin_vi, 01) == 0) - editor = bin_vi; - else - editor = "/bin/ed"; /* YUCK! */ - if (editor == ucb_vi || editor == bin_vi) + editor = getenv ("EDITOR"); + if (editor == NULL) { + editor = "vi"; eid_arg = "+1;/%s/"; eid_left_del = "\\<"; eid_right_del = "\\>"; @@ -533,7 +524,7 @@ editit: switch (fork ()) { case -1: - fprintf (stderr, "%s: Cannot fork (%s)\n", program_name, uerror ()); + fprintf (stderr, "%s: Cannot fork (%s)\n", program_name, strerror (errno)); exit (1); case 0: argv--; @@ -544,7 +535,7 @@ editit: argv[1] = ed_arg_buffer; } *(char const **) argv = editor; - execv (editor, argv); + execvp (editor, argv); filerr ("exec", editor); default: { @@ -1290,16 +1281,20 @@ tree8_to_argv (unsigned char const *hits_tree8) #endif #if HAVE_TERMIOS_H || HAVE_TERMIO_H + #if HAVE_TERMIOS_H #include <termios.h> -#endif +struct termios linemode; +struct termios charmode; +struct termios savemode; +#else /* not HAVE_TERMIOS_H */ #if HAVE_TERMIO_H #include <termio.h> -#endif - struct termio linemode; struct termio charmode; struct termio savemode; +#endif /* HAVE_TERMIO_H */ +#endif /* not HAVE_TERMIOS_H */ void savetty (void) @@ -67,23 +67,10 @@ fgets0 (char *buf0, int size, FILE * in_FILE) extern char const *program_name; -char const * -uerror (void) -{ - static char errbuf[10]; - - if (errno == 0 || errno >= sys_nerr) - { - sprintf (errbuf, "error %d", errno); - return errbuf; - } - return sys_errlist[errno]; -} - void filerr (char const *syscall, char const *file_name) { - fprintf (stderr, "%s: Cannot %s `%s' (%s)\n", program_name, syscall, file_name, uerror ()); + fprintf (stderr, "%s: Cannot %s `%s' (%s)\n", program_name, syscall, file_name, strerror (errno)); } int @@ -22,7 +22,6 @@ char const *basename (char const *path); char const *dirname (char const *path); int fgets0 (char *buf0, int size, FILE *in_FILE); -char const *uerror (void); void filerr (char const *syscall, char const *file_name); int tree8_count_levels (int cardinality); int gets_past_00 (char *tok, FILE *input_FILE); @@ -24,7 +24,6 @@ #include <limits.h> #include <assert.h> #include <stdio.h> -#define fileno(FP) ((FP)->_fileno) #include <string.h> #include "strxtra.h" #include <ctype.h> @@ -43,9 +42,14 @@ struct summary struct token **sum_tokens; unsigned char const *sum_hits; struct summary *sum_parent; - struct summary *sum_kids[8]; - long sum_tokens_size; - long sum_hits_count; + union { + struct summary *u_kids[8]; /* when sum_level > 0 */ + struct idarg *u_files[8]; /* when sum_level == 0 */ + } sum_u; +#define sum_kids sum_u.u_kids +#define sum_files sum_u.u_files + unsigned long sum_tokens_size; + unsigned long sum_hits_count; int sum_free_index; int sum_level; }; @@ -68,7 +72,7 @@ char *bitsand (char *s1, char const *s2, int n); char *bitsxor (char *s1, char const *s2, int n); int bitstst (char const *s1, char const *s2, int n); int bitsany (char const *s, int n); -int round2(int rough); +int round2 (int rough); struct token *make_token (char const *name, int); void scan_1_file (char const *(*get_token) (FILE*, int*), FILE *source_FILE); struct idarg *parse_idargs (int argc, char **argv); @@ -85,7 +89,7 @@ void rehash (void); void write_idfile (char const *id_file, struct idarg *idargs); void bump_current_hits_signature (void); -void init_hits_signature (int index); +void init_hits_signature (int i); int bit_to_index (int bit); int compare_tokens (void const *x, void const *y); void free_summary_tokens (void); @@ -101,6 +105,7 @@ int count_buf_size (struct summary *summary, unsigned char const *tail_hits); void usage (void); /* Miscellaneous statistics */ +long input_chars; long name_tokens; long number_tokens; long string_tokens; @@ -113,12 +118,12 @@ long tokens_length = 0; long output_length = 0; /* Hash table maintenance */ -long hash_size; /* # of slots */ -long hash_capacity; /* # of usable slots */ -long hash_fill; /* # of keys inserted in table */ -long hash_probes = 0; -long hash_lookups = 0; -int hash_rehashes = 0; +unsigned long hash_size; /* # of slots */ +unsigned long hash_capacity; /* # of usable slots */ +unsigned long hash_fill; /* # of keys inserted in table */ +unsigned long hash_probes = 0; +unsigned long hash_lookups = 0; +unsigned int hash_rehashes = 0; int verbose_flag = 0; int statistics_flag = 1; @@ -135,7 +140,7 @@ struct summary *summary_leaf; char PWD_name[BUFSIZ]; /* The current working directory */ char absolute_idfile_name[BUFSIZ]; /* The absolute name of the database */ -char const *id_file = IDFILE; +char const *id_file_name = IDFILE; char const *program_name; @@ -165,7 +170,7 @@ main (int argc, char **argv) struct idarg *idarg_0; char const *sbrk0; - program_name = basename (GETARG (argc, argv)); + program_name = basename ((argc--, *argv++)); if (kshgetwd (PWD_name) == NULL) { fprintf (stderr, "%s: cannot get current working directory name.\n", program_name); @@ -173,6 +178,8 @@ main (int argc, char **argv) } strcat (PWD_name, "/"); + init_scanners (); + idarg_0 = parse_idargs (argc, argv); if (idarg_0 == NULL) { @@ -183,17 +190,16 @@ main (int argc, char **argv) sbrk0 = (char const *)sbrk (0); init_hash (scan_count * 64); - strcpy (absolute_idfile_name, span_file_name (PWD_name, id_file)); - if (access (id_file, 06) < 0 - && (errno != ENOENT || access (dirname (id_file), 06) < 0)) + strcpy (absolute_idfile_name, span_file_name (PWD_name, id_file_name)); + if (access (id_file_name, 06) < 0 + && (errno != ENOENT || access (dirname (id_file_name), 06) < 0)) { - filerr ("modify", id_file); + filerr ("modify", id_file_name); return 1; } init_hits_signature (0); init_summary (); - init_scanners (); scan_files (idarg_0); @@ -203,8 +209,8 @@ main (int argc, char **argv) free_summary_tokens (); free (hash_table); - write_idfile (id_file, idarg_0); - heap_size = (char const *)sbrk (0) - sbrk0; + write_idfile (id_file_name, idarg_0); + heap_size = (char const *) sbrk (0) - sbrk0; if (statistics_flag) report_statistics (); @@ -278,16 +284,12 @@ scan_files (struct idarg *idarg) goto skip; if (verbose_flag) { - if (filter) - { - printf ("%s: ", lang_name); - printf (filter, arg); - putchar ('\n'); - } - else - printf ("%s: %s\n", lang_name, arg); + printf ("%s: ", lang_name); + printf (filter ? filter : "%s", arg); } scan_1_file (scanner, source_FILE); + if (verbose_flag) + putchar ('\n'); close_source_FILE (source_FILE, filter); skip: if (!keep_lang) @@ -341,13 +343,13 @@ parse_idargs (int argc, char **argv) AF_QUERY = 0x8 }; /* no file args necessary: usage query */ - idarg = idarg_0 = CALLOC(struct idarg, 1); + idarg = idarg_0 = CALLOC (struct idarg, 1); /* Process some arguments, and snarf-up some others for processing later. */ while (argc) { - arg = GETARG (argc, argv); + arg = (argc--, *argv++); if (*arg != '-' && *arg != '+') { /* arguments are from command line (not pipe) */ @@ -356,7 +358,7 @@ parse_idargs (int argc, char **argv) idarg->ida_flags = IDA_SCAN_ME; idarg->ida_index = file_name_count++; scan_count++; - idarg = (idarg->ida_next = CALLOC(struct idarg, 1)); + idarg = (idarg->ida_next = CALLOC (struct idarg, 1)); continue; } @@ -366,7 +368,7 @@ parse_idargs (int argc, char **argv) case 'u': #if 0 args_from |= AF_IDFILE; - old_idarg (id_file, &idarg); + old_idarg (id_file_name, &idarg); break; #endif case '\0': @@ -384,7 +386,7 @@ parse_idargs (int argc, char **argv) } break; case 'f': - id_file = arg; + id_file_name = arg; break; case 'v': verbose_flag = 1; @@ -401,7 +403,7 @@ parse_idargs (int argc, char **argv) case 'r': idarg->ida_arg = &arg[-2]; idarg->ida_index = -1; - idarg = (idarg->ida_next = CALLOC(struct idarg, 1)); + idarg = (idarg->ida_next = CALLOC (struct idarg, 1)); args_count++; break; @@ -466,28 +468,51 @@ parse_idargs_from_FILE (FILE *arg_FILE, struct idarg *idarg) void scan_1_file (char const *(*get_token) (FILE*, int*), FILE *source_FILE) { + struct stat stat_buf; struct token **slot; char const *key; + int bytes = 0; + int total_tokens = 0; + int new_tokens = 0; + int distinct_tokens = 0; int flags; + if (fstat (fileno (source_FILE), &stat_buf) == 0) + { + bytes = stat_buf.st_size; + input_chars += bytes; + } + while ((key = (*get_token) (source_FILE, &flags)) != NULL) { struct token *token = *(slot = hash_lookup (key)); + total_tokens++; if (token) { token->tok_flags |= flags; if (token->tok_count < USHRT_MAX) token->tok_count++; if (!(token->tok_hits[0] & current_hits_signature[0])) - sign_token (token); + { + sign_token (token); + distinct_tokens++; + } } else { *slot = token = make_token (key, flags); sign_token (token); + distinct_tokens++; + new_tokens++; if (hash_fill++ >= hash_capacity) rehash (); } } + if (verbose_flag) + printf (" uniq=%d/%d=%.2f, new=%d/%d=%.2f", + distinct_tokens, total_tokens, + (double) distinct_tokens / (double) total_tokens, + new_tokens, distinct_tokens, + (double) new_tokens / (double) distinct_tokens); } /* As the database is written, may need to adjust the file names. If @@ -498,7 +523,7 @@ scan_1_file (char const *(*get_token) (FILE*, int*), FILE *source_FILE) directory which you have no write access to, so you cannot create the ID file.) */ void -write_idfile (char const *id_file, struct idarg *idarg) +write_idfile (char const *file_name, struct idarg *idarg) { struct token **tokens; int i; @@ -514,7 +539,7 @@ write_idfile (char const *id_file, struct idarg *idarg) int max_vec_size = 0; if (verbose_flag) - printf ("Writing `%s'...\n", id_file); + printf ("Writing `%s'...\n", file_name); lsl = strrchr (relative_file_name (PWD_name, absolute_idfile_name), '/'); if (lsl == NULL) { @@ -529,10 +554,10 @@ write_idfile (char const *id_file, struct idarg *idarg) fixup_names = 1; *(lsl + 1) = '\0'; } - id_FILE = fopen (id_file, "w+b"); + id_FILE = fopen (file_name, "w+b"); if (id_FILE == NULL) { - filerr ("create", id_file); + filerr ("create", file_name); exit (1); } strncpy (idh.idh_magic, IDH_MAGIC, sizeof (idh.idh_magic)); @@ -565,7 +590,7 @@ write_idfile (char const *id_file, struct idarg *idarg) putc ('\0', id_FILE); putc ('\0', id_FILE); - idh.idh_tokens_offset = ftell(id_FILE); + idh.idh_tokens_offset = ftell (id_FILE); assert (summary_root->sum_hits_count == hash_fill); tokens = REALLOC (summary_root->sum_tokens, struct token *, hash_fill); @@ -699,7 +724,7 @@ string_hash_2 (char const *key) void rehash (void) { - long old_hash_size = hash_size; + unsigned long old_hash_size = hash_size; struct token **old_hash_table = hash_table; struct token **htp; struct token **slot; @@ -775,14 +800,14 @@ bump_current_hits_signature (void) } void -init_hits_signature (int index) +init_hits_signature (int i) { unsigned char *hits = current_hits_signature; unsigned char const *end = ¤t_hits_signature[MAX_LEVELS]; while (hits < end) { - *hits = 1 << (index & 7); - index >>= 3; + *hits = 1 << (i & 7); + i >>= 3; hits++; } } @@ -799,8 +824,8 @@ bit_to_index (int bit) int compare_tokens (void const *x, void const *y) { - return strcmp ((*(struct token const *const *)x)->tok_name, - (*(struct token const *const *)y)->tok_name); + return strcmp ((*(struct token const *const *) x)->tok_name, + (*(struct token const *const *) y)->tok_name); } void @@ -822,11 +847,11 @@ summarize (void) do { - long count = summary->sum_hits_count; + unsigned long count = summary->sum_hits_count; unsigned char *hits = MALLOC (unsigned char, count + 1); - int level = summary->sum_level; + unsigned int level = summary->sum_level; struct token **tokens = summary->sum_tokens; - long init_size = INIT_TOKENS_SIZE (summary->sum_level); + unsigned long init_size = INIT_TOKENS_SIZE (summary->sum_level); if (verbose_flag) { @@ -867,7 +892,7 @@ summarize (void) void init_summary (void) { - long size = INIT_TOKENS_SIZE (0); + unsigned long size = INIT_TOKENS_SIZE (0); summary_root = summary_leaf = CALLOC (struct summary, 1); summary_root->sum_tokens_size = size; summary_root->sum_tokens = MALLOC (struct token *, size); @@ -877,7 +902,7 @@ struct summary * make_sibling_summary (struct summary *summary) { struct summary *parent = summary->sum_parent; - long size; + unsigned long size; if (parent == NULL) { @@ -955,10 +980,12 @@ assert_hits (struct summary* summary) struct summary **kids = summary->sum_kids; struct summary **end = &kids[8]; + /* Some systems have broken assert() macros that expand into exposed + if-statements, so we need braces around them when used with if/else. */ if (summary == summary_root) - assert (summary->sum_hits == 0); + { assert (summary->sum_hits == 0); } else - assert (summary->sum_hits && *summary->sum_hits == 0); + { assert (summary->sum_hits && *summary->sum_hits == 0); } if (end[-1] == 0) while (*--end == 0) @@ -1019,7 +1046,7 @@ sign_token (struct token *token) void add_token_to_summary (struct summary *summary, struct token *token) { - long size = summary->sum_tokens_size; + unsigned long size = summary->sum_tokens_size; if (summary->sum_hits_count >= size) { @@ -26,6 +26,9 @@ translation. File: mkid.info, Node: Top, Next: Overview, Prev: (dir), Up: (dir) +GNU `mkid' +********** + * Menu: * Overview:: What is an ID database and what tools manipulate it? @@ -1057,38 +1060,38 @@ Command Index Tag Table: Node: Top913 -Node: Overview1298 -Node: History2862 -Node: Mkid5027 -Node: Mkid Command Line Options6363 -Node: Scanner Arguments8124 -Node: Builtin Scanners10479 -Node: C11144 -Node: Plain Text12039 -Node: Assembler13107 -Node: Adding Your Own Scanner14295 -Node: Mkid Examples16272 -Node: Database Query Tools18249 -Node: Common Options19190 -Node: Patterns22906 -Node: Lid24148 -Node: Aid24570 -Node: Gid25101 -Node: Eid25721 -Node: Pid26845 -Node: Iid27735 -Node: Ss and Files commands29605 -Node: Sets33068 -Node: Show33308 -Node: Begin33636 -Node: Help34123 -Node: Off34404 -Node: Shell Commands as Queries34634 -Node: Shell Escape35160 -Node: Other Tools35502 -Node: GNU Emacs Interface35879 -Node: Fid36685 -Node: Idx37237 -Node: Command Index37912 +Node: Overview1321 +Node: History2885 +Node: Mkid5050 +Node: Mkid Command Line Options6386 +Node: Scanner Arguments8147 +Node: Builtin Scanners10502 +Node: C11167 +Node: Plain Text12062 +Node: Assembler13130 +Node: Adding Your Own Scanner14318 +Node: Mkid Examples16295 +Node: Database Query Tools18272 +Node: Common Options19213 +Node: Patterns22929 +Node: Lid24171 +Node: Aid24593 +Node: Gid25124 +Node: Eid25744 +Node: Pid26868 +Node: Iid27758 +Node: Ss and Files commands29628 +Node: Sets33091 +Node: Show33331 +Node: Begin33659 +Node: Help34146 +Node: Off34427 +Node: Shell Commands as Queries34657 +Node: Shell Escape35183 +Node: Other Tools35525 +Node: GNU Emacs Interface35902 +Node: Fid36708 +Node: Idx37260 +Node: Command Index37935 End Tag Table diff --git a/mkid.texinfo b/mkid.texinfo index e1fcc3f..076b313 100644 --- a/mkid.texinfo +++ b/mkid.texinfo @@ -1,4 +1,4 @@ -\input texinfo @c -*-texinfo-*- +\input texinfo @comment %**start of header (This is for running Texinfo on a region.) @setfilename mkid.info @settitle The ID Database @@ -65,7 +65,9 @@ into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation. @end titlepage +@ifinfo @node Top, Overview, (dir), (dir) +@top GNU @code{mkid} @menu * Overview:: What is an ID database and what tools manipulate it? @@ -76,6 +78,8 @@ except that this permission notice may be stated in a translation. * Command Index:: Command Index @end menu +@end ifinfo + @node Overview, Mkid, Top, Top @chapter Overview @cindex Reference to First Chapter @@ -134,9 +134,9 @@ void init_scanners (void) { struct language *lang; - struct language *lang_N = &languages[(sizeof(languages)/sizeof(languages[0])) - 1]; + struct language *lang_N = &languages[(sizeof (languages) / sizeof (languages[0])) - 1]; struct suffix *suff; - struct suffix *suff_N = &suffixes[(sizeof(suffixes)/sizeof(suffixes[0])) - 1]; + struct suffix *suff_N = &suffixes[(sizeof (suffixes) / sizeof (suffixes[0])) - 1]; for (lang = languages; lang <= lang_N; ++lang) lang->lang_next = lang + 1; diff --git a/strcasecmp.c b/strcasecmp.c index 8a93ef2..cd038e3 100644 --- a/strcasecmp.c +++ b/strcasecmp.c @@ -58,10 +58,9 @@ static unsigned char charmap[] = { }; int -strcasecmp(s1, s2) - char *s1, *s2; +strcasecmp(char const *s1, char const *s2) { - register unsigned char u1, u2; + unsigned char u1, u2; for (;;) { u1 = (unsigned char) *s1++; @@ -19,17 +19,21 @@ #ifndef _strxtra_h_ #define _strxtra_h_ -#ifdef HAVE_MALLOC_H +#if HAVE_STDLIB_H +#include <stdlib.h> +#else /* not HAVE_STDLIB_H */ +#if HAVE_MALLOC_H #include <malloc.h> -#endif +#endif /* HAVE_MALLOC_H */ +#endif /* not HAVE_STDLIB_H */ -#define strequ(s1, s2) (strcmp((s1), (s2)) == 0) -#define strnequ(s1, s2, n) (strncmp((s1), (s2), (n)) == 0) -#define strcaseequ(s1, s2) (strcasecmp((s1), (s2)) == 0) -#define strncaseequ(s1, s2, n) (strncasecmp((s1), (s2), (n)) == 0) +#define strequ(s1, s2) (strcmp ((s1), (s2)) == 0) +#define strnequ(s1, s2, n) (strncmp ((s1), (s2), (n)) == 0) +#define strcaseequ(s1, s2) (strcasecmp ((s1), (s2)) == 0) +#define strncaseequ(s1, s2, n) (strncasecmp ((s1), (s2), (n)) == 0) #ifndef HAVE_STRDUP -#define strdup(s) (strcpy(calloc(1, strlen(s)+1), (s))) +#define strdup(s) (strcpy (calloc (1, strlen (s) + 1), (s))) #endif -#define strndup(s, n) (strncpy(calloc(1, (n)+1), (s), (n))) +#define strndup(s, n) (strncpy (calloc (1, (n)+1), (s), (n))) #endif /* not _strxtra_h_ */ |