ANSI fixes, use strdup instead of rolling your own
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 27 Feb 1991 05:42:22 +0000 (21:42 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 27 Feb 1991 05:42:22 +0000 (21:42 -0800)
SCCS-vsn: usr.bin/ctags/C.c 5.5
SCCS-vsn: usr.bin/ctags/ctags.c 5.8
SCCS-vsn: usr.bin/ctags/ctags.h 5.4
SCCS-vsn: usr.bin/ctags/fortran.c 5.5
SCCS-vsn: usr.bin/ctags/lisp.c 5.5
SCCS-vsn: usr.bin/ctags/print.c 5.4
SCCS-vsn: usr.bin/ctags/tree.c 5.5
SCCS-vsn: usr.bin/ctags/yacc.c 5.6

usr/src/usr.bin/ctags/C.c
usr/src/usr.bin/ctags/ctags.c
usr/src/usr.bin/ctags/ctags.h
usr/src/usr.bin/ctags/fortran.c
usr/src/usr.bin/ctags/lisp.c
usr/src/usr.bin/ctags/print.c
usr/src/usr.bin/ctags/tree.c
usr/src/usr.bin/ctags/yacc.c

index c076628..2af1ce8 100644 (file)
@@ -6,11 +6,15 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)C.c        5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)C.c        5.5 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <stdio.h>
 #endif /* not lint */
 
 #include <stdio.h>
-#include <ctags.h>
+#include <string.h>
+#include "ctags.h"
+
+static int func_entry(), str_entry();
+static void hash_entry();
 
 /*
  * c_entries --
 
 /*
  * c_entries --
@@ -233,7 +237,7 @@ func_entry()
  * hash_entry --
  *     handle a line starting with a '#'
  */
  * hash_entry --
  *     handle a line starting with a '#'
  */
-static
+static void
 hash_entry()
 {
        extern int      dflag;          /* -d: non-macro defines */
 hash_entry()
 {
        extern int      dflag;          /* -d: non-macro defines */
index 3befa94..ef1e3af 100644 (file)
@@ -12,11 +12,13 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)ctags.c    5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)ctags.c    5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include <ctags.h>
+#include <stdio.h>
 #include <string.h>
 #include <string.h>
+#include <stdlib.h>
+#include "ctags.h"
 
 /*
  * ctags: create a tags file
 
 /*
  * ctags: create a tags file
index adda5d4..7220a76 100644 (file)
@@ -4,12 +4,9 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ctags.h     5.3 (Berkeley) %G%
+ *     @(#)ctags.h     5.4 (Berkeley) %G%
  */
 
  */
 
-#include <stdio.h>
-#include <ctype.h>
-
 #define        bool    char
 
 #define        YES             1
 #define        bool    char
 
 #define        YES             1
index edb699f..f635e40 100644 (file)
@@ -6,13 +6,16 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)fortran.c  5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)fortran.c  5.5 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include <ctags.h>
+#include <stdio.h>
 #include <string.h>
 #include <string.h>
+#include "ctags.h"
 
 
-char   *lbp;                           /* line buffer pointer */
+static void takeprec();
+
+char *lbp;                             /* line buffer pointer */
 
 PF_funcs()
 {
 
 PF_funcs()
 {
@@ -112,7 +115,7 @@ cicmp(cp)
        return(NO);
 }
 
        return(NO);
 }
 
-static
+static void
 takeprec()
 {
        for (;isspace(*lbp);++lbp);
 takeprec()
 {
        for (;isspace(*lbp);++lbp);
index 02d1e11..4765e99 100644 (file)
@@ -6,11 +6,12 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)lisp.c     5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)lisp.c     5.5 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include <ctags.h>
+#include <stdio.h>
 #include <string.h>
 #include <string.h>
+#include "ctags.h"
 
 extern char    *lbp;                   /* pointer shared with fortran */
 
 
 extern char    *lbp;                   /* pointer shared with fortran */
 
index 2c57e36..fe8b870 100644 (file)
@@ -6,12 +6,14 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)print.c    5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)print.c    5.4 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include <sys/types.h>
-#include <sys/file.h>
-#include <ctags.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "ctags.h"
 
 extern char    searchar;               /* ex search character */
 
 
 extern char    searchar;               /* ex search character */
 
@@ -84,25 +86,3 @@ put_entries(node)
        if (node->right)
                put_entries(node->right);
 }
        if (node->right)
                put_entries(node->right);
 }
-
-char *
-savestr(str)
-       char    *str;
-{
-       register u_int  len;
-       register char   *space;
-       char    *malloc();
-
-       len = strlen(str) + 1;
-       if (!(space = malloc((u_int)len))) {
-               /*
-                * should probably free up the tree, here,
-                * we're just as likely to fail here as we
-                * are when getting the NODE structure
-                */
-               fputs("ctags: no more space.\n",stderr);
-               exit(1);
-       }
-       bcopy(str,space,len);
-       return(space);
-}
index c2cc8e1..9ad2624 100644 (file)
@@ -6,11 +6,14 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)tree.c     5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)tree.c     5.5 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include <ctags.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <string.h>
+#include "ctags.h"
 
 /*
  * pfnote --
 
 /*
  * pfnote --
@@ -24,8 +27,7 @@ pfnote(name,ln)
        extern char     *curfile;       /* current input file name */
        register NODE   *np;
        register char   *fp;
        extern char     *curfile;       /* current input file name */
        register NODE   *np;
        register char   *fp;
-       char    nbuf[MAXTOKEN],
-               *malloc(), *savestr();
+       char    nbuf[MAXTOKEN];
 
        /*NOSTRICT*/
        if (!(np = (NODE *)malloc(sizeof(NODE)))) {
 
        /*NOSTRICT*/
        if (!(np = (NODE *)malloc(sizeof(NODE)))) {
@@ -49,11 +51,17 @@ pfnote(name,ln)
                        *fp = EOS;
                name = nbuf;
        }
                        *fp = EOS;
                name = nbuf;
        }
-       np->entry = savestr(name);
+       if (!(np->entry = strdup(name))) {
+               (void)fprintf(stderr, "ctags: %s\n", strerror(errno));
+               exit(1);
+       }
        np->file = curfile;
        np->lno = ln;
        np->left = np->right = 0;
        np->file = curfile;
        np->lno = ln;
        np->left = np->right = 0;
-       np->pat = savestr(lbuf);
+       if (!(np->pat = strdup(lbuf))) {
+               (void)fprintf(stderr, "ctags: %s\n", strerror(errno));
+               exit(1);
+       }
        if (!head)
                head = np;
        else
        if (!head)
                head = np;
        else
index 5329aa7..e5ead9d 100644 (file)
@@ -6,11 +6,12 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)yacc.c     5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)yacc.c     5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include <ctags.h>
+#include <stdio.h>
 #include <string.h>
 #include <string.h>
+#include "ctags.h"
 
 /*
  * y_entries:
 
 /*
  * y_entries: