=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ctags/ctags.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- src/usr.bin/ctags/ctags.c 1999/07/02 18:37:11 1.4 +++ src/usr.bin/ctags/ctags.c 2000/07/25 19:28:30 1.5 @@ -1,4 +1,4 @@ -/* $OpenBSD: ctags.c,v 1.4 1999/07/02 18:37:11 deraadt Exp $ */ +/* $OpenBSD: ctags.c,v 1.5 2000/07/25 19:28:30 deraadt Exp $ */ /* $NetBSD: ctags.c,v 1.4 1995/09/02 05:57:23 jtc Exp $ */ /* @@ -44,7 +44,7 @@ #if 0 static char sccsid[] = "@(#)ctags.c 8.4 (Berkeley) 2/7/95"; #endif -static char rcsid[] = "$OpenBSD: ctags.c,v 1.4 1999/07/02 18:37:11 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: ctags.c,v 1.5 2000/07/25 19:28:30 deraadt Exp $"; #endif /* not lint */ #include @@ -95,7 +95,7 @@ int exit_val; /* exit value */ int step; /* step through args */ int ch; /* getopts char */ - char cmd[100]; /* too ugly to explain */ + char *cmd; aflag = uflag = NO; while ((ch = getopt(argc, argv, "BFadf:tuwvx")) != -1) @@ -160,11 +160,14 @@ else { if (uflag) { for (step = 0; step < argc; step++) { - (void)sprintf(cmd, - "mv %s OTAGS; fgrep -v '\t%s\t' OTAGS >%s; rm OTAGS", - outfile, argv[step], - outfile); + (void)asprintf(&cmd, + "mv %s OTAGS; fgrep -v '\t%s\t' OTAGS >%s; rm OTAGS", + outfile, argv[step], outfile); + if (cmd == NULL) + err(1, "out of space"); system(cmd); + free(cmd); + cmd = NULL; } ++aflag; } @@ -173,9 +176,13 @@ put_entries(head); (void)fclose(outf); if (uflag) { - (void)sprintf(cmd, "sort -o %s %s", - outfile, outfile); + (void)asprintf(&cmd, "sort -o %s %s", + outfile, outfile); + if (cmd == NULL) + err(1, "out of space"); system(cmd); + free(cmd); + cmd = NULL; } } } @@ -231,7 +238,7 @@ char *cp; lineno = 0; /* should be 1 ?? KB */ - if (cp = strrchr(file, '.')) { + if ((cp = strrchr(file, '.'))) { if (cp[1] == 'l' && !cp[2]) { int c;