bug-indent
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-indent] indent-2.2.7 patch: I/O fixes and compile fixes


From: Peter Moulder
Subject: [Bug-indent] indent-2.2.7 patch: I/O fixes and compile fixes
Date: Fri, 01 Feb 2002 20:03:00 +1100

One thing I haven't fixed is src/indent.c (indent) where type_code is
used uninitialized.

pjm.


diff -durp indent-2.2.7/ChangeLog indent-2.2.7-pjm/ChangeLog
--- indent-2.2.7/ChangeLog      Wed Dec  5 07:07:36 2001
+++ indent-2.2.7-pjm/ChangeLog  Fri Feb  1 19:47:33 2002
@@ -1,3 +1,25 @@
+2002-02-01  Peter Moulder  <address@hidden>
+
+       * src/indent.c (need_chars), configure.ac, src/sys.h: Use
+       autoconf-provided inline instead of custom INDENT macro.
+
+       * src/indent.c (indent), src/lexi.c (lexi): Use %.1s instead of %c
+       when calling WARNING, to reduce the casting gymnastics.  All po
+       files updated.
+
+       * src/globs.c (xmalloc, xrealloc), src/globs.h: Use size_t instead
+       of unsigned for size.
+       * configure.ac: Ensure that size_t is defined.
+
+       * src/indent.h: Fix compile bug when building with separate build
+       directory: get rid of `intl/' from #include <libgettext.h>, as per
+       gettext manual.
+
+       * src/io.c: Rename vms_read to greedy_read, and use for all platforms.
+       Check for read errors.
+
+       * src/wildexp.c: Fix fparms,chkparms prototypes (static).
+
 2001-12-04 John Bridges <address@hidden>
        * indent.dsp, wildcard.c : improvements for vc++.
        
diff -durp indent-2.2.7/configure.ac indent-2.2.7-pjm/configure.ac
--- indent-2.2.7/configure.ac   Tue Dec 18 07:05:31 2001
+++ indent-2.2.7-pjm/configure.ac       Fri Feb  1 17:46:38 2002
@@ -25,6 +25,8 @@ AC_OBJEXT
 dnl Checks for typedefs, structures, and compiler characteristics.
 dnl AM_C_PROTOTYPES
 AC_C_CONST
+AC_C_INLINE
+AC_TYPE_SIZE_T
 
 dnl Check for tools needed for formatting the documentation.
 ac_aux_dir_abs=`cd $ac_aux_dir && pwd`
diff -durp indent-2.2.7/miscel/README.VMS indent-2.2.7-pjm/miscel/README.VMS
--- indent-2.2.7/miscel/README.VMS      Wed Dec 19 09:47:32 2001
+++ indent-2.2.7-pjm/miscel/README.VMS  Fri Feb  1 17:47:33 2002
@@ -12,6 +12,10 @@ DECC is the default compiler for VMS the
 [...]
 VMSers should be able to just rename config.h.vms to config.h and
 run @make-decc.
+[2002 update: At the time of writing, config.h.vms is out of date; compare with
+ config.h.in and add the missing things like an appropriate definition of
+ `inline', `size_t'. Then send the resulting config.h.vc++ changes to the GNU
+ indent maintainer, so that it can be included in future indent distributions.]
 
 ----
 Date: long long ago
@@ -34,6 +38,8 @@ POSSIBLE PROBLEMS
 The function for reading, `read', is defined by the macro SYS_READ.
 By default under VMS, this is defined to be the functions `vms_read'
 defined in io.c.
+[2002 update: vms_read has been renamed as greedy_read, and is now used
+ by all platforms.]
 
 People have sent me various versions of this function, with differring
 semantics.  I have no way of testing these, so I have done my best to
diff -durp indent-2.2.7/miscel/README.vc++ indent-2.2.7-pjm/miscel/README.vc++
--- indent-2.2.7/miscel/README.vc++     Wed Dec  5 06:10:57 2001
+++ indent-2.2.7-pjm/miscel/README.vc++ Fri Feb  1 17:48:16 2002
@@ -8,7 +8,8 @@ There are a couple of methods of compili
 Preparation steps
 -----------------
 
-1. As Win32 has no equivalent of the 'configure' shell script, it is necessary 
to manually create the config.h file yourself. This can be done by renaming 
'config.vc++' to 'config.h'. These options are sufficient for VC++ 6. If you 
are having problems compiling on an earlier releases, this file may be the 
place to look and modify the #defines.
+1. As Win32 has no equivalent of the 'configure' shell script, it is necessary 
to manually create the config.h file yourself. This can be done by renaming 
'config.h.vc++' to 'config.h'. These options are sufficient for VC++ 6. If you 
are having problems compiling on an earlier releases, this file may be the 
place to look and modify the #defines.
+At the time of writing, config.h.vc++ is out of date; compare with config.h.in 
and add the missing things like an appropriate definition of `inline' if the 
compiler chokes.  Then send the resulting config.h.vc++ changes to the GNU 
indent maintainer, so that it can be included in future indent distributions.
 
 Compilation procedure
 ---------------------
diff -durp indent-2.2.7/po/zh_TW.Big5.po indent-2.2.7-pjm/po/zh_TW.Big5.po
--- indent-2.2.7/po/zh_TW.Big5.po       Wed Dec 19 09:47:35 2001
+++ indent-2.2.7-pjm/po/zh_TW.Big5.po   Fri Feb  1 15:11:33 2002
@@ -145,8 +145,8 @@ msgstr "address@hidden"
 
 #: src/indent.c:949 src/indent.c:1533
 #, c-format
-msgid "Extra %c"
-msgstr "¦hªº¦r¤¸ %c"
+msgid "Extra %.1s"
+msgstr "¦hªº¦r¤¸ %.1s"
 
 #: src/indent.c:2253
 msgid "Unmatched #else"
@@ -258,9 +258,9 @@ msgstr "address@hidden"
 #. * code).
 #: src/lexi.c:1000
 #, c-format
-msgid "old style assignment ambiguity in \"=%c\".  Assuming \"= %c\"\n"
+msgid "old style assignment ambiguity in \"=%.1s\".  Assuming \"= %.1s\"\n"
 msgstr ""
-"¦³ºÃ¸qªº«ü©w±Ô­z \"=%c\"¡A¥i¯à¬°Â¦¡ªº¼gªk¡Cindent ±N°²³]¥¦¬° \"= %c\"\n"
+"¦³ºÃ¸qªº«ü©w±Ô­z \"=%.1s\"¡A¥i¯à¬°Â¦¡ªº¼gªk¡Cindent ±N°²³]¥¦¬° \"= %.1s\"\n"
 
 #: src/parse.c:359
 msgid "Unmatched 'else'"
diff -durp indent-2.2.7/src/args.c indent-2.2.7-pjm/src/args.c
--- indent-2.2.7/src/args.c     Wed Oct 17 04:23:48 2001
+++ indent-2.2.7-pjm/src/args.c Fri Feb  1 19:01:18 2002
@@ -186,7 +186,7 @@ int use_tabs;
    last default value is the one actually assigned. */
 struct pro
 {
-  char *p_name;                        /* option name, e.g. "bl", "cli" */
+  char const *p_name;          /* option name, e.g. "bl", "cli" */
   enum profile p_type;         /* profile type */
   int p_default;               /* the default value (if PRO_BOOL or PRO_INT) */
 
@@ -450,8 +450,8 @@ struct pro pro[] = {
 
 struct long_option_conversion
 {
-  char *long_name;
-  char *short_name;
+  char const *long_name;
+  char const *short_name;
 };
 
 struct long_option_conversion option_conversions[] = {
@@ -570,7 +570,7 @@ struct long_option_conversion option_con
 
 static int
 eqin (
-      char *s1,
+      char const *s1,
       char *s2,
       char **start_param)
 {
@@ -613,7 +613,7 @@ set_defaults_after (void)
 }
 
 /* Stings which can prefix an option, longest first. */
-static char *option_prefixes[] = {
+static char const *option_prefixes[] = {
   "--",
   "-",
   "+",
@@ -624,8 +624,8 @@ static int
 option_prefix (
                char *arg)
 {
-  char **prefixes = option_prefixes;
-  char *this_prefix, *argp;
+  char const **prefixes = option_prefixes;
+  char const *this_prefix, *argp;
 
   do
     {
@@ -961,7 +961,7 @@ set_profile (void)
 
   if ((f = fopen (INDENT_PROFILE, "r")) != NULL)
     {
-      int len = strlen (INDENT_PROFILE) + 3;
+      size_t len = strlen (INDENT_PROFILE) + 3;
 
       scan_profile (f);
       (void) fclose (f);
diff -durp indent-2.2.7/src/backup.c indent-2.2.7-pjm/src/backup.c
--- indent-2.2.7/src/backup.c   Wed Oct 17 04:23:48 2001
+++ indent-2.2.7-pjm/src/backup.c       Fri Feb  1 19:10:31 2002
@@ -126,7 +126,7 @@ RCSTAG_CC ("$Id: backup.c,v 1.17 2001/10
 #endif
 
 /* Default backup file suffix to use */
-static char *simple_backup_suffix = BACKUP_SUFFIX_STR;
+static char const *simple_backup_suffix = BACKUP_SUFFIX_STR;
 
 /* What kinds of backup files to make -- see
    table `version_control_values' below. */
@@ -153,12 +153,12 @@ simple_backup_name (
 
 static int
 version_number (
-                char *base,
-                char *direntry,
-                int base_length)
+                char const *base,
+                char const *direntry,
+                size_t base_length)
 {
   int version;
-  char *p;
+  char const *p;
 
   version = 0;
   if (!strncmp (base, direntry, base_length) && ISDIGIT (direntry[base_length 
+ 2]))
@@ -183,14 +183,14 @@ version_number (
 
 static int
 highest_version (
-     char *filename,
-     char *dirname)
+     char const *filename,
+     char const *dirname)
 {
   DIR *dirp;
   struct dirent *dp;
   int highest_version;
   int this_version;
-  int file_name_length;
+  size_t file_name_length;
 
   dirp = opendir (dirname);
   if (!dirp)
@@ -230,10 +230,9 @@ max_version (
 {
   char *p;
   char *filename;
-  int pathlen = strlen (pathname);
   int version;
 
-  p = pathname + pathlen - 1;
+  p = pathname + strlen (pathname) - 1;
   while (p > pathname && *p != '/')
   {
       p--;
@@ -241,7 +240,7 @@ max_version (
 
   if (*p == '/')
     {
-      int dirlen = p - pathname;
+      size_t dirlen = p - pathname;
       char *dirname;
 
       filename = p + 1;
diff -durp indent-2.2.7/src/backup.h indent-2.2.7-pjm/src/backup.h
--- indent-2.2.7/src/backup.h   Tue Dec  4 07:25:00 2001
+++ indent-2.2.7-pjm/src/backup.h       Fri Feb  1 19:11:18 2002
@@ -42,7 +42,7 @@ enum backup_mode
 struct version_control_values
 {
   enum backup_mode value;
-  char *name;
+  char const *name;
 };
 
 /* Determine the value of `version_control' by looking in the environment
diff -durp indent-2.2.7/src/comments.c indent-2.2.7-pjm/src/comments.c
--- indent-2.2.7/src/comments.c Wed Oct 17 04:23:48 2001
+++ indent-2.2.7-pjm/src/comments.c     Fri Feb  1 17:11:52 2002
@@ -28,7 +28,7 @@ RCSTAG_CC ("$Id: comments.c,v 1.28 2001/
 #define CHECK_COM_SIZE \
        if (e_com >= l_com) \
           { \
-           int nsize = l_com-s_com+400; \
+           size_t nsize = l_com-s_com+400; \
            combuf = (char *) xrealloc (combuf, nsize); \
            e_com = combuf + (e_com-s_com) + 1; \
            l_com = combuf + nsize - 5; \
diff -durp indent-2.2.7/src/globs.c indent-2.2.7-pjm/src/globs.c
--- indent-2.2.7/src/globs.c    Wed Oct 17 04:23:48 2001
+++ indent-2.2.7-pjm/src/globs.c        Fri Feb  1 17:13:25 2002
@@ -27,13 +27,10 @@
 
 RCSTAG_CC ("$Id: globs.c,v 1.11 2001/10/16 18:23:48 david Exp $");
 
-/* Like malloc but get error if no storage available.  size really should be
- * size_t, but not all systems have size_t, so I hope "unsigned" will work.
- * It works for GNU style machines, where it is 32 bits, and works on
- * MS-DOS.  */
+/* Like malloc but get error if no storage available. */
 
 char *
-xmalloc (unsigned size)
+xmalloc (size_t size)
 {
     char *val = (char *) malloc (size);
 
@@ -56,7 +53,7 @@ xmalloc (unsigned size)
 
 char *xrealloc (
                 char *ptr,
-                unsigned size)
+                size_t size)
 {
     char *val = (char *) realloc (ptr, size);
 
@@ -71,30 +68,30 @@ char *xrealloc (
 
 void
 message (
-         char     * kind,
-         char     * string,
-         unsigned * a0,
-         unsigned * a1)
+         char const * kind,
+         char const * format_string,
+         char const * a0,
+         char const * a1)
 {
     if (kind)
     {
         fprintf (stderr, _("indent: %s:%d: %s:"), in_name, line_no, kind);
     }
 
-    fprintf (stderr, string, a0, a1);
-    fprintf (stderr, "\n");
+    fprintf (stderr, format_string, a0, a1);
+    putc ('\n', stderr);
 }
 
 /* Print a fatal error message and exit, or, if compiled with
    "DEBUG" defined, abort (). */
 
 void fatal (
-            char *string,
-            char *a0)
+            char const *format_string,
+            char const *a0)
 {
     fprintf (stderr, _("indent: Fatal Error: "));
-    fprintf (stderr, string, a0);
-    fprintf (stderr, "\n");
+    fprintf (stderr, format_string, a0);
+    putc ('\n', stderr);
 
 #ifdef DEBUG
     abort ();
diff -durp indent-2.2.7/src/globs.h indent-2.2.7-pjm/src/globs.h
--- indent-2.2.7/src/globs.h    Tue Dec  4 07:25:00 2001
+++ indent-2.2.7-pjm/src/globs.h        Fri Feb  1 15:18:04 2002
@@ -21,16 +21,20 @@
 RCSTAG_H (globs, "$Id: globs.h,v 1.7 2001/12/03 20:25:00 david Exp $");
 
 /* Warning messages:  indent continues */
-#define WARNING(s,a,b) \
-    message (_("Warning"), s, (unsigned int *)(a), (unsigned int *)(b))
+#define WARNING(_s, _a, _b) \
+    message (_("Warning"), _s, (_a), (_b))
 
 /* Error messages: indent stops processing the current file. */
-#define ERROR(s,a,b) \
-    message (_("Error"), s, (unsigned int *)(a), (unsigned int *)(b))
+/* FIXME: Presumably ERROR is meant to call fatal, according to the
+ * above comment; or at least set an error flag.  (At the time of
+ * writing (2.2.7), indent will happily exit(0) even if it encounters
+ * an error.) */
+#define ERROR(_s, _a, _b) \
+    message (_("Error"), _s, (_a), (_b))
 
-extern char *xmalloc (unsigned int size);
-extern char *xrealloc (char *ptr, unsigned int size);
-extern void fatal (char *string, char *a0);
-extern void message (char *kind, char *string, unsigned int *a0, unsigned int 
*a1);
+extern char *xmalloc (size_t size);
+extern char *xrealloc (char *ptr, size_t size);
+extern void fatal (char const *format_string, char const *a0);
+extern void message (char const *kind, char const *format_string, char const 
*a0, char const *a1);
 
 #endif /* INDENT_GLOBS_H */
diff -durp indent-2.2.7/src/indent.c indent-2.2.7-pjm/src/indent.c
--- indent-2.2.7/src/indent.c   Thu Jan 31 22:39:02 2002
+++ indent-2.2.7-pjm/src/indent.c       Fri Feb  1 18:02:24 2002
@@ -84,16 +84,17 @@ int code_lines;
 int line_no;
 int break_comma;
 
-/* Round up P to be a multiple of SIZE. */
+/* Round up P to be a multiple of SIZE.
+   (Assumes that SIZE is a power of 2.) */
 
 #ifndef ROUND_UP
-#define ROUND_UP(p,size) (((unsigned long) (p) + (size) - 1) & ~((size) - 1))
+#define ROUND_UP(p,size) (((p) + ((size) - 1)) & ~((size) - 1))
 #endif
 
-static INLINE void
-need_chars (struct buf *bp, int needed)
+static inline void
+need_chars (struct buf *bp, size_t needed)
 {
-  int current_size = (bp->end - bp->ptr);
+  size_t current_size = (bp->end - bp->ptr);
 
   if ((current_size + needed) >= bp->size)
     {
@@ -129,7 +130,7 @@ int squest;
 
 #define CHECK_CODE_SIZE \
        if (e_code >= l_code) { \
-         int nsize = l_code-s_code+400; \
+         size_t nsize = l_code-s_code+400; \
          codebuf = (char *) xrealloc (codebuf, nsize); \
          e_code = codebuf + (e_code-s_code) + 1; \
          l_code = codebuf + nsize - 5; \
@@ -138,7 +139,7 @@ int squest;
 
 #define CHECK_LAB_SIZE \
        if (e_lab >= l_lab) { \
-         int nsize = l_lab-s_lab+400; \
+         size_t nsize = l_lab-s_lab+400; \
          labbuf = (char *) xrealloc (labbuf, nsize); \
          e_lab = labbuf + (e_lab-s_lab) + 1; \
          l_lab = labbuf + nsize - 5; \
@@ -946,8 +947,7 @@ indent (struct file_buffer *this_file)
                 if (--parser_state_tos->p_l_follow < 0)
                 {
                     parser_state_tos->p_l_follow = 0;
-                    WARNING (_("Extra %c"),
-                             (unsigned long) *((unsigned char *) token), 0);
+                    WARNING (_("Extra %.1s"), token, 0);
                 }
 
                 /* if the paren starts the line, then indent it */
@@ -1530,8 +1530,7 @@ indent (struct file_buffer *this_file)
                     if (--parser_state_tos->p_l_follow < 0)
                     {
                         parser_state_tos->p_l_follow = 0;
-                        WARNING (_("Extra %c"),
-                                 (unsigned long) *((unsigned char *) token), 
0);
+                        WARNING (_("Extra %.1s"), token, 0);
                     }
                 }
                 else if (parser_state_tos->dec_nest > 0)
@@ -2675,7 +2674,6 @@ main (
       int argc,
       char **argv)
 {
-  int i;
   char *profile_pathname = 0;
   int using_stdin = false;
   enum exit_values exit_status;
diff -durp indent-2.2.7/src/indent.h indent-2.2.7-pjm/src/indent.h
--- indent-2.2.7/src/indent.h   Tue Dec  4 07:25:00 2001
+++ indent-2.2.7-pjm/src/indent.h       Fri Feb  1 19:15:00 2002
@@ -24,7 +24,7 @@
 
 RCSTAG_H (indent, "$Id: indent.h,v 1.27 2001/12/03 20:25:00 david Exp $");
 
-#include <intl/libgettext.h>
+#include <libgettext.h>
 #define _(X) gettext(X)
 
 #include "lexi.h"
@@ -130,7 +130,7 @@ struct buf
   char *end;                   /* points to the character beyond the last
                                   one (e.g. is equal to ptr if the buffer is
                                   empty).  */
-  int size;                    /* how many chars are currently allocated.  */
+  size_t size;                 /* how many chars are currently allocated.  */
   int len;                     /* how many chars we're actually using. */
   int start_column;            /* corresponding column of first character
                                   in the buffer. */
@@ -435,10 +435,10 @@ struct parser_state
   int sizeof_keyword;
   int dumped_decl_indent;
   int in_parameter_declaration;
-  char *procname;              /* The name of the current procedure */
-  char *procname_end;          /* One char past the last one in procname */
-  char *classname;             /* The name of the current C++ class */
-  char *classname_end;         /* One char past the last one in classname */
+  char const *procname;                /* The name of the current procedure */
+  char const *procname_end;            /* One char past the last one in 
procname */
+  char const *classname;               /* The name of the current C++ class */
+  char const *classname_end;           /* One char past the last one in 
classname */
   int just_saw_decl;
   int matching_brace_on_same_line;     /* Set to a value >= 0 if the the
                                           current '}' has a matching '{'
diff -durp indent-2.2.7/src/io.c indent-2.2.7-pjm/src/io.c
--- indent-2.2.7/src/io.c       Wed Oct 17 04:23:49 2001
+++ indent-2.2.7-pjm/src/io.c   Fri Feb  1 19:26:42 2002
@@ -617,43 +617,55 @@ static void set_next_buf_break (
     }
 }
 
-#ifdef VMS
+
 /* Folks say VMS requires its own read routine.  Then again, some folks
  * say it doesn't.  Different folks have also sent me conflicting versions
  * of this function.  Who's right?
  *
  * Anyway, this version was sent by address@hidden and modified
- * slightly by me. */
+ * slightly by me.  pjm added error propogation, and used size_t as
+ * required for arg 3 of read. */
 
-int
-vms_read (int file_desc,
-          char *buffer,
-          int nbytes)
+
+/* [pjm]: read is allowed to return less data than was requested even without
+ * reaching end of file.  However, read_file wants to slurp in all the data,
+ * so greedy_read just loops around until either nbytes have been read or
+ * end of file reached. */
+
+static size_t
+greedy_read (int file_desc,
+             char *buffer,
+             size_t nbytes)
 {
     char *bufp;
-    int nread, nleft;
+    size_t nread, nleft;
 
     bufp = buffer;
-    nread = 0;
     nleft = nbytes;
 
-    nread = read (file_desc, bufp, nleft);
-    
-    while (nread > 0)
+    while ((nread = read (file_desc, bufp, nleft))
+           != 0)
     {
-        bufp += nread;
-        nleft -= nread;
-        if (nleft < 0)
+        if (nread == (size_t) -1)
+            return nread;
+        if (nleft < nread)
         {
             fatal (_("Internal buffering error"), 0);
+            /* [pjm]: I advocate removing this test.  It can't happen
+               according to the specs for `read'.  It isn't practical
+               to attempt to check all library functions for correct
+               behaviour: too much source code clutter to justify the
+               small probability of misbehaviour, coupled with the
+               relatively large probability that if read is
+               ill-behaved then other things are also ill-behaved,
+               leaving one screwed whether or not one checks read. */
         }
-        
-        nread = read (file_desc, bufp, nleft);
+        bufp += nread;
+        nleft -= nread;
     }
 
     return nbytes - nleft;
 }
-#endif /* VMS */
 
 /* Return the column we are at in the input line. */
 
@@ -1311,11 +1323,6 @@ compute_label_target (void)
     }
 }
 
-/* VMS defines it's own read routine, `vms_read' */
-#ifndef INDENT_SYS_READ
-#define INDENT_SYS_READ read
-#endif
-
 /* Read file FILENAME into a `fileptr' structure, and return a pointer to
    that structure. */
 
@@ -1330,9 +1337,9 @@ struct file_buffer *read_file (
     /* Required for MSDOS, in order to read files larger than 32767
      * bytes in a 16-bit world... */
   
-    unsigned int size;
+    size_t size;
 
-    int namelen = strlen (filename);
+    size_t namelen = strlen (filename);
 
     fd = open (filename, O_RDONLY, 0777);
   
@@ -1372,16 +1379,16 @@ struct file_buffer *read_file (
     
     if (fileptr.data != 0)
     {
-        fileptr.data = (char *) xrealloc (fileptr.data, (unsigned) 
file_stats->st_size + 1);
+        fileptr.data = (char *) xrealloc (fileptr.data, (size_t) 
file_stats->st_size + 1);
     }
     else
     {
-        fileptr.data = (char *) xmalloc ((unsigned) file_stats->st_size + 1);
+        fileptr.data = (char *) xmalloc ((size_t) file_stats->st_size + 1);
     }
 
-    size = INDENT_SYS_READ (fd, fileptr.data, fileptr.size);
+    size = greedy_read (fd, fileptr.data, fileptr.size);
     
-    if (size == (unsigned int) -1)
+    if (size == (size_t) -1)
     {
         fatal (_("Error reading input file %s"), filename);
     }
@@ -1402,7 +1409,7 @@ struct file_buffer *read_file (
 
     if (fileptr.name != 0)
     {
-        fileptr.name = (char *) xrealloc (fileptr.name, (unsigned) namelen + 
1);
+        fileptr.name = (char *) xrealloc (fileptr.name, namelen + 1);
     }
     else
     {
@@ -1429,7 +1436,7 @@ struct file_buffer stdinptr;
 
 struct file_buffer * read_stdin (void)
 {
-    unsigned int size = 15 * BUFSIZ;
+    size_t size = 15 * BUFSIZ;
     int ch;
     char *p;
 
@@ -1438,7 +1445,7 @@ struct file_buffer * read_stdin (void)
         free (stdinptr.data);
     }
 
-    stdinptr.data = (char *) xmalloc (size + 1);
+    stdinptr.data = (char *) xmalloc (size);
     stdinptr.size = 0;
     p = stdinptr.data;
     do
@@ -1459,7 +1466,7 @@ struct file_buffer * read_stdin (void)
         if (ch != EOF)
        {
             size += (2 * BUFSIZ);
-            stdinptr.data = xrealloc (stdinptr.data, (unsigned) size);
+            stdinptr.data = xrealloc (stdinptr.data, size);
             p = stdinptr.data + stdinptr.size;
        }
     } while (ch != EOF);
diff -durp indent-2.2.7/src/lexi.c indent-2.2.7-pjm/src/lexi.c
--- indent-2.2.7/src/lexi.c     Tue Nov 27 08:50:49 2001
+++ indent-2.2.7-pjm/src/lexi.c Fri Feb  1 16:31:29 2002
@@ -997,8 +997,8 @@ enum codes lexi (void)
                  * they don't want indent to silently change the meaning of 
their
                  * code).  */
                 
-                WARNING (_("old style assignment ambiguity in \"=%c\".  
Assuming \"= %c\"\n"),
-                         (unsigned long) *((unsigned char *) buf_ptr), 
(unsigned long) *((unsigned char *) buf_ptr));
+                WARNING (_("old style assignment ambiguity in \"=%.1s\".  
Assuming \"= %.1s\"\n"),
+                         buf_ptr, buf_ptr);
             }
 
             code = binary_op;
diff -durp indent-2.2.7/src/parse.c indent-2.2.7-pjm/src/parse.c
--- indent-2.2.7/src/parse.c    Wed Oct 17 04:23:49 2001
+++ indent-2.2.7-pjm/src/parse.c        Fri Feb  1 18:54:56 2002
@@ -155,14 +155,12 @@ inc_pstack (void)
 }
 
 #ifdef DEBUG
-static char **debug_symbol_strings;
+static char const **debug_symbol_strings;
 
 void
 debug_init (void)
 {
-  int size = ((int) number_of_codes) * sizeof (char *);
-
-  debug_symbol_strings = (char **) xmalloc (size);
+  debug_symbol_strings = (char const **) xmalloc (number_of_codes * sizeof 
(char const *));
 
   debug_symbol_strings[code_eof] = "code_eof";
   debug_symbol_strings[newline] = "newline";
diff -durp indent-2.2.7/src/parse.h indent-2.2.7-pjm/src/parse.h
--- indent-2.2.7/src/parse.h    Tue Dec  4 07:25:00 2001
+++ indent-2.2.7-pjm/src/parse.h        Thu Jan 31 23:06:41 2002
@@ -29,4 +29,8 @@ extern void init_parser (void);
 extern void reset_parser (void);
 extern void reduce (void);
 
+#ifdef DEBUG
+extern void debug_init (void);
+#endif
+
 #endif /* INDENT_PARSE_H */
diff -durp indent-2.2.7/src/sys.h indent-2.2.7-pjm/src/sys.h
--- indent-2.2.7/src/sys.h      Tue Dec  4 07:25:00 2001
+++ indent-2.2.7-pjm/src/sys.h  Fri Feb  1 01:11:25 2002
@@ -45,19 +45,12 @@ char *strchr (), *strrchr ();
 extern int debug;
 #endif
 
-#ifdef __GNUC__
-#define INLINE __inline__
-#else
-#define INLINE
-#endif
-
 #ifdef VMS
 # define ONE_DOT_PER_FILENAME 1
 # define PROFILE_FORMAT "%s%s"
 # define BACKUP_SUFFIX_STR    "_"
 # define BACKUP_SUFFIX_CHAR   '_'
 # define BACKUP_SUFFIX_FORMAT "%s._%d_"
-# define INDENT_SYS_READ vms_read      /* Defined in io.c */
 # if defined(VAXC) || defined(__DECC)
 #  include <unixio.h>
 # endif
diff -durp indent-2.2.7/src/wildexp.c indent-2.2.7-pjm/src/wildexp.c
--- indent-2.2.7/src/wildexp.c  Wed Dec  5 05:53:03 2001
+++ indent-2.2.7-pjm/src/wildexp.c      Fri Feb  1 19:37:51 2002
@@ -46,21 +46,20 @@ myabort (char *str)
   exit (1);
 }
 
-void fparms (struct arginfo *arg, char *fname);
-void chkparm (struct arginfo *arg, char *str);
+static void fparms (struct arginfo *arg, char *fname);
+static void chkparm (struct arginfo *arg, char *str);
 
 static void
 addarg (struct arginfo *arg, char *str)
 {
-  int cnt;
-
   if (*str == '@')
     {
       fparms (arg, str + 1);
     }
   else
     {
-      cnt = strlen (str) + 1;
+      size_t cnt = strlen (str) + 1;
+
       if (arg->argpos + cnt >= arg->bufsize)
        {
          arg->bufsize += 8192;
@@ -174,13 +173,13 @@ removearg (struct arginfo *arg, char *st
 {
   char *cp;
   int i;
-  int cnt;
 
   i = arg->nargc;
   cp = arg->argbuf;
   while (i-- > 0)
     {
-      cnt = strlen (cp) + 1;
+      size_t cnt = strlen (cp) + 1;
+
       if (wildmatch (str, cp))
        {
          arg->argpos -= cnt;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]