]> code.delx.au - gnu-emacs/blobdiff - lib-src/sorted-doc.c
Fix warnings produced by compiling with -Wwrite_strings (i.e. use const char *).
[gnu-emacs] / lib-src / sorted-doc.c
index ef25a645145159f72d4b775ba2f58f6a9fa0c3ff..db3f3029532aa5974f34d106c15fecf24ec03da6 100644 (file)
@@ -2,7 +2,7 @@
    standard output a file of texinfo input containing the doc strings.
 
 Copyright (C) 1989, 1992, 1994, 1996, 1999, 2000, 2001, 2002, 2003,
-              2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+              2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -65,8 +65,7 @@ struct docstr                 /* Allocated thing for an entry. */
 /* Print error message.  `s1' is printf control string, `s2' is arg for it. */
 
 void
-error (s1, s2)
-     char *s1, *s2;
+error (const char *s1, const char *s2)
 {
   fprintf (stderr, "sorted-doc: ");
   fprintf (stderr, s1, s2);
@@ -76,8 +75,7 @@ error (s1, s2)
 /* Print error message and exit.  */
 
 void
-fatal (s1, s2)
-     char *s1, *s2;
+fatal (const char *s1, const char *s2)
 {
   error (s1, s2);
   exit (EXIT_FAILURE);
@@ -86,8 +84,7 @@ fatal (s1, s2)
 /* Like malloc but get fatal error if memory is exhausted.  */
 
 char *
-xmalloc (size)
-     int size;
+xmalloc (int size)
 {
   char *result = malloc ((unsigned)size);
   if (result == NULL)
@@ -96,8 +93,7 @@ xmalloc (size)
 }
 
 char *
-xstrdup (str)
-     char * str;
+xstrdup (char *str)
 {
   char *buf = xmalloc (strlen (str) + 1);
   (void) strcpy (buf, str);
@@ -107,28 +103,27 @@ xstrdup (str)
 /* Comparison function for qsort to call.  */
 
 int
-cmpdoc (a, b)
-     DOCSTR **a;
-     DOCSTR **b;
+cmpdoc (const void *va, const void *vb)
 {
+  DOCSTR *const *a = va;
+  DOCSTR *const *b = vb;
   register int val = strcmp ((*a)->name, (*b)->name);
   if (val) return val;
   return (*a)->type - (*b)->type;
 }
 
-
 enum state
 {
   WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET
 };
 
-char *states[] =
+const char *states[] =
 {
   "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET"
 };
 
 int
-main ()
+main (void)
 {
   register DOCSTR *dp = NULL;  /* allocated DOCSTR */
   register LINE *lp = NULL;    /* allocated line */