]> code.delx.au - gnu-emacs/blobdiff - lib-src/ebrowse.c
Update copyright year to 2015
[gnu-emacs] / lib-src / ebrowse.c
index 2828591ed3f3e0b1d67fd562663ff10bf4427fda..d16c9ae54af12f44cd994df05e3ae81ddc6491ea 100644 (file)
@@ -1,6 +1,6 @@
 /* ebrowse.c --- parsing files for the ebrowse C++ browser
 
-Copyright (C) 1992-2013 Free Software Foundation, Inc.
+Copyright (C) 1992-2015 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -514,7 +514,7 @@ static char *
 xstrdup (char *s)
 {
   if (s)
-    s = strcpy (xmalloc (strlen (s) + 1), s);
+    return strcpy (xmalloc (strlen (s) + 1), s);
   return s;
 }
 
@@ -1096,7 +1096,7 @@ leave_namespace (void)
 /* Write string S to the output file FP in a Lisp-readable form.
    If S is null, write out `()'.  */
 
-static inline void
+static void
 putstr (const char *s, FILE *fp)
 {
   if (!s)
@@ -1150,19 +1150,19 @@ sym_scope_1 (struct sym *p)
   if (*scope_buffer)
     {
       ensure_scope_buffer_room (3);
-      strcat (scope_buffer, "::");
+      strcpy (scope_buffer + scope_buffer_len, "::");
       scope_buffer_len += 2;
     }
 
   len = strlen (p->name);
   ensure_scope_buffer_room (len + 1);
-  strcat (scope_buffer, p->name);
+  strcpy (scope_buffer + scope_buffer_len, p->name);
   scope_buffer_len += len;
 
   if (HAS_FLAG (p->flags, F_TEMPLATE))
     {
       ensure_scope_buffer_room (3);
-      strcat (scope_buffer, "<>");
+      strcpy (scope_buffer + scope_buffer_len, "<>");
       scope_buffer_len += 2;
     }
 
@@ -2797,24 +2797,25 @@ operator_name (int *sc)
       s = token_string (LA1);
       MATCH ();
 
-      len = strlen (s) + 10;
+      ptrdiff_t slen = strlen (s);
+      len = slen + 10;
       if (len > id_size)
        {
          size_t new_size = max (len, 2 * id_size);
          id = (char *) xrealloc (id, new_size);
          id_size = new_size;
        }
-      strcpy (id, s);
+      char *z = stpcpy (id, s);
 
       /* Vector new or delete?  */
       if (LOOKING_AT ('['))
        {
-         strcat (id, "[");
+         z = stpcpy (z, "[");
          MATCH ();
 
          if (LOOKING_AT (']'))
            {
-             strcat (id, "]");
+             strcpy (z, "]");
              MATCH ();
            }
        }
@@ -2830,7 +2831,7 @@ operator_name (int *sc)
          id = (char *) xrealloc (id, new_size);
          id_size = new_size;
        }
-      strcpy (id, "operator");
+      char *z = stpcpy (id, "operator");
 
       /* Beware access declarations of the form "X::f;" Beware of
         `operator () ()'.  Yet another difficulty is found in
@@ -2842,14 +2843,16 @@ operator_name (int *sc)
          len += strlen (s) + 2;
          if (len > id_size)
            {
+             ptrdiff_t idlen = z - id;
              size_t new_size = max (len, 2 * id_size);
              id = (char *) xrealloc (id, new_size);
              id_size = new_size;
+             z = id + idlen;
            }
 
          if (*s != ')' && *s != ']')
-           strcat (id, " ");
-          strcat (id, s);
+           *z++ = ' ';
+          z = stpcpy (z, s);
           MATCH ();
 
          /* If this is a simple operator like `+', stop now.  */
@@ -3462,9 +3465,9 @@ open_file (char *file)
          buffer = (char *) xrealloc (buffer, buffer_size);
        }
 
-      strcpy (buffer, path->path);
-      strcat (buffer, "/");
-      strcat (buffer, file);
+      char *z = stpcpy (buffer, path->path);
+      *z++ = '/';
+      strcpy (z, file);
       fp = fopen (buffer, "r");
     }
 
@@ -3481,7 +3484,9 @@ open_file (char *file)
 
 /* Display usage information and exit program.  */
 
-#define USAGE "\
+static char const *const usage_message[] =
+  {
+    "\
 Usage: ebrowse [options] {files}\n\
 \n\
   -a, --append                  append output to existing file\n\
@@ -3489,6 +3494,8 @@ Usage: ebrowse [options] {files}\n\
   -I, --search-path=LIST        set search path for input files\n\
   -m, --min-regexp-length=N     set minimum regexp length to N\n\
   -M, --max-regexp-length=N     set maximum regexp length to N\n\
+",
+    "\
   -n, --no-nested-classes       exclude nested classes\n\
   -o, --output-file=FILE        set output file name to FILE\n\
   -p, --position-info           print info about position in file\n\
@@ -3498,12 +3505,16 @@ Usage: ebrowse [options] {files}\n\
   -x, --no-regexps             don't record regular expressions\n\
       --help                    display this help\n\
       --version                        display version info\n\
+\n\
 "
+  };
 
 static _Noreturn void
 usage (int error)
 {
-  puts (USAGE);
+  int i;
+  for (i = 0; i < sizeof usage_message / sizeof *usage_message; i++)
+    fputs (usage_message[i], stdout);
   exit (error ? EXIT_FAILURE : EXIT_SUCCESS);
 }