bug-enscript
[Top][All Lists]
Advanced

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

[bug-enscript] [PATCH 8/8] Simply avoid warnings of modern gcc


From: Werner Fink
Subject: [bug-enscript] [PATCH 8/8] Simply avoid warnings of modern gcc
Date: Tue, 23 Jan 2018 15:26:50 +0100

Signed-off-by: Werner Fink <address@hidden>
---
 afmlib/afmparse.c |  2 +-
 compat/regex.c    | 12 ++++++------
 compat/xalloc.c   |  6 +++---
 src/gsint.h       |  2 +-
 src/main.c        |  3 ++-
 src/psgen.c       | 30 ++++++++++++++----------------
 src/util.c        | 10 ++++++----
 states/main.c     |  2 +-
 states/utils.c    |  2 +-
 9 files changed, 35 insertions(+), 34 deletions(-)

diff --git afmlib/afmparse.c afmlib/afmparse.c
index 7b29620..9bebc70 100644
--- afmlib/afmparse.c
+++ afmlib/afmparse.c
@@ -620,7 +620,7 @@ static void
 get_key (AFMHandle handle, ParseCtx *ctx, AFMKey *key_return)
 {
   int key;
-  char msg[256];
+  char msg[1024+16];
 
   while (1)
     {
diff --git compat/regex.c compat/regex.c
index c6907f3..c059b4b 100644
--- compat/regex.c
+++ compat/regex.c
@@ -2400,11 +2400,12 @@ regex_compile (pattern, size, syntax, bufp)
             case ')':
               if (syntax & RE_NO_BK_PARENS) goto normal_backslash;
 
-              if (COMPILE_STACK_EMPTY)
+              if (COMPILE_STACK_EMPTY) {
                 if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
                   goto normal_backslash;
                 else
                   FREE_STACK_RETURN (REG_ERPAREN);
+             }
 
             handle_close:
               if (fixup_alt_jump)
@@ -2420,11 +2421,12 @@ regex_compile (pattern, size, syntax, bufp)
                 }
 
               /* See similar code for backslashed left paren above.  */
-              if (COMPILE_STACK_EMPTY)
+              if (COMPILE_STACK_EMPTY) {
                 if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
                   goto normal_char;
                 else
                   FREE_STACK_RETURN (REG_ERPAREN);
+             }
 
               /* Since we just checked for an empty stack above, this
                  ``can't happen''.  */
@@ -3106,8 +3108,6 @@ re_compile_fastmap (bufp)
   char *destination;
 #endif
   /* We don't push any register information onto the failure stack.  */
-  unsigned num_regs = 0;
-
   register char *fastmap = bufp->fastmap;
   unsigned char *pattern = bufp->buffer;
   unsigned char *p = pattern;
@@ -4801,8 +4801,8 @@ re_match_2_internal (bufp, string1, size1, string2, 
size2, pos, regs, stop)
                register from the stack, since lowest will == highest in
                `pop_failure_point'.  */
             active_reg_t dummy_low_reg, dummy_high_reg;
-            unsigned char *pdummy;
-            const char *sdummy;
+            unsigned char *pdummy __attribute__ ((__unused__));
+            const char *sdummy __attribute__ ((__unused__));
 
             DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n");
             POP_FAILURE_POINT (sdummy, pdummy,
diff --git compat/xalloc.c compat/xalloc.c
index c1ff51f..4194855 100644
--- compat/xalloc.c
+++ compat/xalloc.c
@@ -67,7 +67,7 @@ xmalloc (size)
   ptr = malloc (size);
   if (ptr == NULL)
     {
-      fprintf (stderr, _("xmalloc(): couldn't allocate %d bytes\n"), size);
+      fprintf (stderr, _("xmalloc(): couldn't allocate %zd bytes\n"), size);
       exit (1);
     }
 
@@ -85,7 +85,7 @@ xcalloc (num, size)
   ptr = calloc (num, size);
   if (ptr == NULL)
     {
-      fprintf (stderr, _("xcalloc(): couldn't allocate %d bytes\n"), size);
+      fprintf (stderr, _("xcalloc(): couldn't allocate %zd bytes\n"), size);
       exit (1);
     }
 
@@ -106,7 +106,7 @@ xrealloc (ptr, size)
   nptr = realloc (ptr, size);
   if (nptr == NULL)
     {
-      fprintf (stderr, _("xrealloc(): couldn't reallocate %d bytes\n"), size);
+      fprintf (stderr, _("xrealloc(): couldn't reallocate %zd bytes\n"), size);
       exit (1);
     }
 
diff --git src/gsint.h src/gsint.h
index 81c3257..c59c92c 100644
--- src/gsint.h
+++ src/gsint.h
@@ -131,7 +131,7 @@ extern double atan2 ___P ((double, double));
   (('0' <= (ch) && (ch) <= '9') || (ch) == '.' || (ch) == '-' || (ch) == '+')
 
 /* Return the width of the character <ch> */
-#define CHAR_WIDTH(ch) (font_widths[(unsigned char) (ch)])
+#define FNT_CHAR_WIDTH(ch) (font_widths[(unsigned char) (ch)])
 
 /* Current point y movement from line to line. */
 #define LINESKIP (Fpt.h + baselineskip)
diff --git src/main.c src/main.c
index c9f4951..b68699b 100644
--- src/main.c
+++ src/main.c
@@ -1470,7 +1470,8 @@ name             width\theight\tllx\tlly\turx\tury\n\
       buffer_append (&buffer, enscript_library);
       buffer_append (&buffer, "/hl/*.st");
 
-      system (buffer_ptr (&buffer));
+      if (system (buffer_ptr (&buffer)) < 0)
+       perror("system");
       exit (0);
     }
 
diff --git src/psgen.c src/psgen.c
index 21e4c75..3990659 100644
--- src/psgen.c
+++ src/psgen.c
@@ -585,8 +585,8 @@ process_file (char *fname_arg, InputStream *is, int is_toc)
    * Count possible line number spaces.  This should be enought for 99999
    * lines
    */
-  linenumber_space = CHAR_WIDTH ('0') * 5 + 1.0;
-  linenumber_margin = CHAR_WIDTH (':') + CHAR_WIDTH ('m');
+  linenumber_space = FNT_CHAR_WIDTH ('0') * 5 + 1.0;
+  linenumber_margin = FNT_CHAR_WIDTH (':') + FNT_CHAR_WIDTH ('m');
 
   /* We got a new input file. */
   input_filenum++;
@@ -1137,7 +1137,7 @@ large for page\n"),
 /* Help macros. */
 
 /* Check if character <ch> fits to current line. */
-#define FITS_ON_LINE(ch) ((linepos + CHAR_WIDTH (ch) < linew) || col == 0)
+#define FITS_ON_LINE(ch) ((linepos + FNT_CHAR_WIDTH (ch) < linew) || col == 0)
 
 /* Is line buffer empty? */
 #define BUFFER_EMPTY() (bufpos == 0)
@@ -1160,13 +1160,13 @@ large for page\n"),
 #define EMIT(ch)               \
   do {                         \
     APPEND_CHAR (ch);          \
-    linepos += CHAR_WIDTH (ch);        \
+    linepos += FNT_CHAR_WIDTH (ch);    \
     col++;                     \
   } while (0)
 
 #define UNEMIT(ch)             \
   do {                         \
-    linepos -= CHAR_WIDTH (ch); \
+    linepos -= FNT_CHAR_WIDTH (ch); \
     col--;                     \
   } while (0)
 
@@ -1690,7 +1690,7 @@ get_next_token (InputStream *is, double linestart, double 
linepos,
            {
              /* Proportional font. */
 
-             double grid = tabsize * CHAR_WIDTH (' ');
+             double grid = tabsize * FNT_CHAR_WIDTH (' ');
              col++;
 
              /* Move linepos to the next multiple of <grid>. */
@@ -1748,9 +1748,9 @@ get_next_token (InputStream *is, double linestart, double 
linepos,
          if (ch == bs)
            {
              if (BUFFER_EMPTY () || !EXISTS (buffer[bufpos - 1]))
-               linepos -= CHAR_WIDTH ('m');
+               linepos -= FNT_CHAR_WIDTH ('m');
              else
-               linepos -= CHAR_WIDTH (buffer[bufpos - 1]);
+               linepos -= FNT_CHAR_WIDTH (buffer[bufpos - 1]);
 
              done = DONE_DONE;
              break;
@@ -1775,7 +1775,7 @@ get_next_token (InputStream *is, double linestart, double 
linepos,
                        APPEND_CHAR (buf[i]);
 
                      /* Update current point counters manually. */
-                     linepos += CHAR_WIDTH (ch);
+                     linepos += FNT_CHAR_WIDTH (ch);
                      col++;
                    }
                  else if (ch == '(' || ch == ')' || ch == '\\')
@@ -1848,7 +1848,7 @@ get_next_token (InputStream *is, double linestart, double 
linepos,
 
              /* Count length. */
              for (i = 0; buf[i]; i++)
-               len += CHAR_WIDTH (buf[i]);
+               len += FNT_CHAR_WIDTH (buf[i]);
 
              if (linepos + len < linew || col == 0)
                {
@@ -2472,7 +2472,7 @@ recognize_eps_file (Token *token)
                  /* No, this BoundingBox comment is corrupted. */
                  MESSAGE (0, (stderr, _("EPS file \"%s\" contains malformed \
 %%%%BoundingBox row:\n\"%.*s\"\n"),
-                              token->u.epsf.filename, strlen (buf) - 1, buf));
+                              token->u.epsf.filename, (int)(strlen (buf) - 1), 
buf));
                  break;
                }
            }
@@ -2599,7 +2599,7 @@ read_float (InputStream *is, int units, int horizontal)
 
        case 'l':               /* lines or characters */
          if (horizontal)
-           val *= CHAR_WIDTH ('m');
+           val *= FNT_CHAR_WIDTH ('m');
          else
            val *= LINESKIP;
          break;
@@ -2728,7 +2728,7 @@ print_line_number (double x, double y, double space, 
double margin,
   int i;
   char *saved_Fname = "";
   FontPoint saved_Fpt;
-  InputEncoding saved_Fencoding;
+  InputEncoding saved_Fencoding = 0;
 
   saved_Fpt.w = 0.0;
   saved_Fpt.h = 0.0;
@@ -2758,7 +2758,7 @@ print_line_number (double x, double y, double space, 
double margin,
   /* Count linenumber string length. */
   sprintf (buf, "%d", linenum);
   for (i = 0; buf[i]; i++)
-    len += CHAR_WIDTH (buf[i]);
+    len += FNT_CHAR_WIDTH (buf[i]);
 
   /* Print line numbers. */
   OUTPUT ((cofp, "%g %g M (%s:) s\n", x + space - len, y, buf));
@@ -2781,8 +2781,6 @@ print_line_number (double x, double y, double space, 
double margin,
  * The name of the divert file, shared between divert() and undivert()
  * functions.
  */
-static char divertfname[512];
-
 static void
 divert ()
 {
diff --git src/util.c src/util.c
index 5ec7396..25e5e32 100644
--- src/util.c
+++ src/util.c
@@ -647,7 +647,7 @@ paste_file (char *name, char *suffix)
 
          if (j >= sizeof (name) - 1)
            FATAL ((stderr, _("%s:%d: %%Format: too long name, maxlen=%d"),
-                   buffer_ptr (ctx.fullname), line, sizeof (name) - 1));
+                   buffer_ptr (ctx.fullname), line, (int)(sizeof (name) - 1)));
 
          /* Find the start of the format string. */
          for (; buf[i] && isspace (buf[i]); i++)
@@ -1388,7 +1388,8 @@ format_user_string (char *context_name, char *str)
                  break;
 
                case 'c':       /* `%c' trailing component of pwd. */
-                 getcwd (buf, sizeof (buf));
+                 if (!getcwd (buf, sizeof (buf)))
+                   perror("getcwd");
                  cp = strrchr (buf, '/');
                  if (cp)
                    cp++;
@@ -1404,7 +1405,8 @@ format_user_string (char *context_name, char *str)
                  break;
 
                case 'd':       /* `%d' current working directory */
-                 getcwd (buf, sizeof (buf));
+                 if (!getcwd (buf, sizeof (buf)))
+                   perror("getcwd");
                  APPEND_STR (buf);
                  break;
 
@@ -1872,7 +1874,7 @@ parse_float (char *string, int units, int horizontal)
 
        case 'l':
          if (horizontal)
-           val *= CHAR_WIDTH ('m');
+           val *= FNT_CHAR_WIDTH ('m');
          else
            val *= LINESKIP;
          break;
diff --git states/main.c states/main.c
index 1c330dc..b0865f4 100644
--- states/main.c
+++ states/main.c
@@ -371,7 +371,7 @@ main (argc, argv)
       if (cp)
        {
          path = xmalloc (cp - defs_file + 3);
-         sprintf (path, ".%c%.*s", PATH_SEPARATOR, cp - defs_file, defs_file);
+         sprintf (path, ".%c%.*s", PATH_SEPARATOR, (int)(cp - defs_file), 
defs_file);
        }
       else
        path = ".";
diff --git states/utils.c states/utils.c
index d4ee9dd..8ce3355 100644
--- states/utils.c
+++ states/utils.c
@@ -833,7 +833,7 @@ eval_expr (expr, env)
        {
          Environment *nenv = NULL;
          ListItem *i, *e;
-         List *stmts;
+         List *stmts __attribute__ ((__unused__));
          List *lst;
          Cons *args_locals;
 
-- 
2.12.3




reply via email to

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