m4-commit
[Top][All Lists]
Advanced

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

[SCM] GNU M4 source repository branch, branch-1_4, updated. branch-cvs-r


From: Eric Blake
Subject: [SCM] GNU M4 source repository branch, branch-1_4, updated. branch-cvs-readonly-63-g9d400bc
Date: Sat, 23 Feb 2008 17:01:52 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU M4 source repository".

http://git.sv.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=9d400bc11d96c313d041e73b8f7b9a2d069d1ae5

The branch, branch-1_4 has been updated
       via  9d400bc11d96c313d041e73b8f7b9a2d069d1ae5 (commit)
       via  c91769acf89e163c06e86be0f17022572f33bbab (commit)
       via  0b1129f73235ba35fa46f1afcef5bd5c0cdbf73c (commit)
      from  58ffaf13f5206f8bac8ec4ebad8147e99157263d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9d400bc11d96c313d041e73b8f7b9a2d069d1ae5
Author: Eric Blake <address@hidden>
Date:   Sat Feb 23 09:58:03 2008 -0700

    Use size_t consistently for string length truncation.
    
    * src/m4.h (max_debug_argument_length): Change type to size_t.
    (shipout_string_trunc, arg_print): Change parameter type.
    * src/debug.c (trace_format, trace_pre): Adjust all callers.
    * src/input.c (input_print): Likewise.
    * src/m4.c (max_debug_argument_length, main): Likewise.
    * src/macro.c (arg_print): Likewise.
    * src/output.c (shipout_string_trunc): Likewise.
    Reported by Ralf Wildenhues.
    
    Signed-off-by: Eric Blake <address@hidden>

commit c91769acf89e163c06e86be0f17022572f33bbab
Author: Eric Blake <address@hidden>
Date:   Sat Feb 23 09:42:02 2008 -0700

    s/obstack_print/shipout_string_trunc/.
    
    * src/m4.h (obstack_print): Rename...
    (shipout_string_trunc): ...to this, to leave obstack_ prefix for
    actual obstack API.
    * src/debug.c (trace_format): Adjust caller.
    (obstack_print): Move...
    * src/output.c (shipout_string_trunc): ...here, including rename.
    * src/input.c (input_print): Adjust caller.
    * src/macro.c (arg_print): Likewise.
    Reported by Ralf Wildenhues.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 0b1129f73235ba35fa46f1afcef5bd5c0cdbf73c
Author: Eric Blake <address@hidden>
Date:   Sat Feb 23 09:30:43 2008 -0700

    s/shipout_text/divert_text/.
    
    * src/m4.h (shipout_text): Rename...
    (divert_text): ...to this, so that shipout_ prefix can be used for
    functions that do not do #line tracking.
    * src/output.c (divert_text): Rename.
    * src/macro.c (expand_token): Adjust all callers.
    
    Signed-off-by: Eric Blake <address@hidden>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog    |   28 ++++++++++++++++++++++++++++
 src/debug.c  |   36 ++++--------------------------------
 src/input.c  |    8 ++++----
 src/m4.c     |    9 +++++----
 src/m4.h     |    8 ++++----
 src/macro.c  |   35 ++++++++++++++++++++---------------
 src/output.c |   31 ++++++++++++++++++++++++++++++-
 7 files changed, 95 insertions(+), 60 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1269290..f867f1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,33 @@
 2008-02-23  Eric Blake  <address@hidden>
 
+       Use size_t consistently for string length truncation.
+       * src/m4.h (max_debug_argument_length): Change type to size_t.
+       (shipout_string_trunc, arg_print): Change parameter type.
+       * src/debug.c (trace_format, trace_pre): Adjust all callers.
+       * src/input.c (input_print): Likewise.
+       * src/m4.c (max_debug_argument_length, main): Likewise.
+       * src/macro.c (arg_print): Likewise.
+       * src/output.c (shipout_string_trunc): Likewise.
+       Reported by Ralf Wildenhues.
+
+       s/obstack_print/shipout_string_trunc/.
+       * src/m4.h (obstack_print): Rename...
+       (shipout_string_trunc): ...to this, to leave obstack_ prefix for
+       actual obstack API.
+       * src/debug.c (trace_format): Adjust caller.
+       (obstack_print): Move...
+       * src/output.c (shipout_string_trunc): ...here, including rename.
+       * src/input.c (input_print): Adjust caller.
+       * src/macro.c (arg_print): Likewise.
+       Reported by Ralf Wildenhues.
+
+       s/shipout_text/divert_text/.
+       * src/m4.h (shipout_text): Rename...
+       (divert_text): ...to this, so that shipout_ prefix can be used for
+       functions that do not do #line tracking.
+       * src/output.c (divert_text): Rename.
+       * src/macro.c (expand_token): Adjust all callers.
+
        Stage 18: try harder to reuse argv in recursion.
        When pushing arguments that contain an existing $@ ref, reuse the
        ref rather than creating another layer of wrappers.
diff --git a/src/debug.c b/src/debug.c
index 737ee52..46e1306 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -248,7 +248,7 @@ trace_format (const char *fmt, ...)
   char ch;
   int d;
   const char *s;
-  int maxlen;
+  size_t maxlen;
 
   va_start (args, fmt);
 
@@ -260,7 +260,7 @@ trace_format (const char *fmt, ...)
       if (ch == '\0')
        break;
 
-      maxlen = INT_MAX;
+      maxlen = SIZE_MAX;
       switch (*fmt++)
        {
        case 'B':
@@ -294,7 +294,7 @@ trace_format (const char *fmt, ...)
          break;
        }
 
-      if (obstack_print (&trace, s, SIZE_MAX, &maxlen))
+      if (shipout_string_trunc (&trace, s, SIZE_MAX, &maxlen))
        break;
     }
 
@@ -364,7 +364,7 @@ trace_pre (const char *name, int id, macro_arguments *argv)
 
   if (arg_argc (argv) > 1 && (debug_level & DEBUG_TRACE_ARGS))
     {
-      int len = max_debug_argument_length;
+      size_t len = max_debug_argument_length;
       trace_format ("(");
       arg_print (&trace, argv, 1,
                 (debug_level & DEBUG_TRACE_QUOTE) ? &curr_quote : NULL,
@@ -401,31 +401,3 @@ trace_post (const char *name, int id, macro_arguments 
*argv,
     trace_format (" -> %l%B%r", expanded);
   trace_flush ();
 }
-
-/* Dump the string STR of length LEN to the obstack OBS.  If LEN is
-   SIZE_MAX, use strlen (STR) instead.  If MAX_LEN is non-NULL,
-   truncate the dump at MAX_LEN bytes and return true if MAX_LEN was
-   reached; otherwise, return false and update MAX_LEN as
-   appropriate.  */
-bool
-obstack_print (struct obstack *obs, const char *str, size_t len, int *max_len)
-{
-  int max = max_len ? *max_len : INT_MAX;
-
-  if (len == SIZE_MAX)
-    len = strlen (str);
-  if (len < max)
-    {
-      obstack_grow (obs, str, len);
-      max -= len;
-    }
-  else
-    {
-      obstack_grow (obs, str, max);
-      obstack_grow (obs, "...", 3);
-      max = 0;
-    }
-  if (max_len)
-    *max_len = max;
-  return max == 0;
-}
diff --git a/src/input.c b/src/input.c
index e2bf0aa..9d8b8f3 100644
--- a/src/input.c
+++ b/src/input.c
@@ -680,14 +680,14 @@ pop_wrapup (void)
 void
 input_print (struct obstack *obs, const input_block *input)
 {
-  int maxlen = max_debug_argument_length;
+  size_t maxlen = max_debug_argument_length;
   token_chain *chain;
 
   assert (input);
   switch (input->type)
     {
     case INPUT_STRING:
-      obstack_print (obs, input->u.u_s.str, input->u.u_s.len, &maxlen);
+      shipout_string_trunc (obs, input->u.u_s.str, input->u.u_s.len, &maxlen);
       break;
     case INPUT_FILE:
       obstack_grow (obs, "<file: ", strlen ("<file: "));
@@ -704,8 +704,8 @@ input_print (struct obstack *obs, const input_block *input)
          switch (chain->type)
            {
            case CHAIN_STR:
-             if (obstack_print (obs, chain->u.u_s.str, chain->u.u_s.len,
-                                &maxlen))
+             if (shipout_string_trunc (obs, chain->u.u_s.str,
+                                       chain->u.u_s.len, &maxlen))
                return;
              break;
            case CHAIN_ARGV:
diff --git a/src/m4.c b/src/m4.c
index 0ace6dc..fe8c548 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -47,7 +47,7 @@ int no_gnu_extensions = 0;
 int prefix_all_builtins = 0;
 
 /* Max length of arguments in trace output (-lsize).  */
-int max_debug_argument_length = INT_MAX;
+size_t max_debug_argument_length = SIZE_MAX;
 
 /* Suppress warnings about missing arguments.  */
 int suppress_warnings = 0;
@@ -572,9 +572,10 @@ main (int argc, char *const *argv, char *const *envp)
        break;
 
       case 'l':
-       max_debug_argument_length = atoi (optarg);
-       if (max_debug_argument_length <= 0)
-         max_debug_argument_length = INT_MAX;
+       {
+         int tmp = atoi (optarg);
+         max_debug_argument_length = tmp <= 0 ? SIZE_MAX : (size_t) tmp;
+       }
        break;
 
       case 'o':
diff --git a/src/m4.h b/src/m4.h
index 54deb42..7e35acc 100644
--- a/src/m4.h
+++ b/src/m4.h
@@ -129,7 +129,7 @@ extern int debug_level;                     /* -d */
 extern size_t hash_table_size;         /* -H */
 extern int no_gnu_extensions;          /* -G */
 extern int prefix_all_builtins;                /* -P */
-extern int max_debug_argument_length;  /* -l */
+extern size_t max_debug_argument_length;/* -l */
 extern int suppress_warnings;          /* -Q */
 extern int warning_status;             /* -E */
 extern int nesting_limit;              /* -L */
@@ -249,7 +249,6 @@ void trace_pre (const char *, int, macro_arguments *);
 void trace_post (const char *, int, macro_arguments *,
                 const input_block *);
 
-bool obstack_print (struct obstack *, const char *, size_t, int *);
 
 /* File: input.c  --- lexical definitions.  */
 
@@ -424,7 +423,8 @@ extern int output_current_line;
 void output_init (void);
 void output_exit (void);
 void output_text (const char *, int);
-void shipout_text (struct obstack *, const char *, int, int);
+void divert_text (struct obstack *, const char *, int, int);
+bool shipout_string_trunc (struct obstack *, const char *, size_t, size_t *);
 void make_diversion (int);
 void insert_diversion (int);
 void insert_file (FILE *);
@@ -500,7 +500,7 @@ size_t arg_len (macro_arguments *, unsigned int);
 builtin_func *arg_func (macro_arguments *, unsigned int);
 struct obstack *arg_scratch (void);
 bool arg_print (struct obstack *, macro_arguments *, unsigned int,
-               const string_pair *, bool, const char *, int *, bool);
+               const string_pair *, bool, const char *, size_t *, bool);
 macro_arguments *make_argv_ref (macro_arguments *, const char *, size_t,
                                bool, bool);
 void push_arg (struct obstack *, macro_arguments *, unsigned int);
diff --git a/src/macro.c b/src/macro.c
index 32ff62d..0846f8d 100644
--- a/src/macro.c
+++ b/src/macro.c
@@ -305,10 +305,10 @@ expand_token (struct obstack *obs, token_type t, 
token_data *td, int line,
              && peek_token () != TOKEN_OPEN))
        {
 #ifdef ENABLE_CHANGEWORD
-         shipout_text (obs, TOKEN_DATA_ORIG_TEXT (td),
-                       TOKEN_DATA_LEN (td), line);
+         divert_text (obs, TOKEN_DATA_ORIG_TEXT (td),
+                      TOKEN_DATA_LEN (td), line);
 #else
-         shipout_text (obs, TOKEN_DATA_TEXT (td), TOKEN_DATA_LEN (td), line);
+         divert_text (obs, TOKEN_DATA_TEXT (td), TOKEN_DATA_LEN (td), line);
 #endif /* !ENABLE_CHANGEWORD */
          /* The word just appended is unquoted, but the heuristics of
             safe_quote are applicable.  */
@@ -324,7 +324,7 @@ expand_token (struct obstack *obs, token_type t, token_data 
*td, int line,
       assert (!"expand_token");
       abort ();
     }
-  shipout_text (obs, TOKEN_DATA_TEXT (td), TOKEN_DATA_LEN (td), line);
+  divert_text (obs, TOKEN_DATA_TEXT (td), TOKEN_DATA_LEN (td), line);
   return result;
 }
 
@@ -1194,9 +1194,9 @@ arg_scratch (void)
 bool
 arg_print (struct obstack *obs, macro_arguments *argv, unsigned int index,
           const string_pair *quotes, bool flatten, const char *sep,
-          int *max_len, bool quote_each)
+          size_t *max_len, bool quote_each)
 {
-  int len = max_len ? *max_len : INT_MAX;
+  size_t len = max_len ? *max_len : INT_MAX;
   unsigned int i;
   token_data *token;
   token_chain *chain;
@@ -1212,23 +1212,27 @@ arg_print (struct obstack *obs, macro_arguments *argv, 
unsigned int index,
     {
       if (quote_each && max_len)
        len = *max_len;
-      if (use_sep && obstack_print (obs, sep, sep_len, plen))
+      if (use_sep && shipout_string_trunc (obs, sep, sep_len, plen))
        return true;
       use_sep = true;
       token = arg_token (argv, i, NULL);
       switch (TOKEN_DATA_TYPE (token))
        {
        case TOKEN_TEXT:
-         if (quotes && obstack_print (obs, quotes->str1, quotes->len1, plen))
+         if (quotes && shipout_string_trunc (obs, quotes->str1, quotes->len1,
+                                             plen))
            return true;
-         if (obstack_print (obs, TOKEN_DATA_TEXT (token),
-                            TOKEN_DATA_LEN (token), &len) && !quote_each)
+         if (shipout_string_trunc (obs, TOKEN_DATA_TEXT (token),
+                                   TOKEN_DATA_LEN (token), &len)
+             && !quote_each)
            return true;
-         if (quotes && obstack_print (obs, quotes->str2, quotes->len2, plen))
+         if (quotes && shipout_string_trunc (obs, quotes->str2, quotes->len2,
+                                             plen))
            return true;
          break;
        case TOKEN_COMP:
-         if (quotes && obstack_print (obs, quotes->str1, quotes->len1, plen))
+         if (quotes && shipout_string_trunc (obs, quotes->str1, quotes->len1,
+                                             plen))
            return true;
          chain = token->u.u_c.chain;
          done = false;
@@ -1237,8 +1241,8 @@ arg_print (struct obstack *obs, macro_arguments *argv, 
unsigned int index,
              switch (chain->type)
                {
                case CHAIN_STR:
-                 if (obstack_print (obs, chain->u.u_s.str, chain->u.u_s.len,
-                                    &len))
+                 if (shipout_string_trunc (obs, chain->u.u_s.str,
+                                           chain->u.u_s.len, &len))
                    done = true;
                  break;
                case CHAIN_ARGV:
@@ -1256,7 +1260,8 @@ arg_print (struct obstack *obs, macro_arguments *argv, 
unsigned int index,
            }
          if (done && !quote_each)
            return true;
-         if (quotes && obstack_print (obs, quotes->str2, quotes->len2, plen))
+         if (quotes && shipout_string_trunc (obs, quotes->str2, quotes->len2,
+                                             plen))
            return true;
          break;
        case TOKEN_FUNC:
diff --git a/src/output.c b/src/output.c
index d252d74..7b2d6de 100644
--- a/src/output.c
+++ b/src/output.c
@@ -469,7 +469,7 @@ output_text (const char *text, int length)
 `--------------------------------------------------------------------*/
 
 void
-shipout_text (struct obstack *obs, const char *text, int length, int line)
+divert_text (struct obstack *obs, const char *text, int length, int line)
 {
   static bool start_of_output_line = true;
   const char *cursor;
@@ -571,6 +571,35 @@ shipout_text (struct obstack *obs, const char *text, int 
length, int line)
        }
     }
 }
+
+/* Dump the string STR of length LEN to the obstack OBS.  If LEN is
+   SIZE_MAX, use strlen (STR) instead.  If MAX_LEN is non-NULL,
+   truncate the dump at MAX_LEN bytes and return true if MAX_LEN was
+   reached; otherwise, return false and update MAX_LEN as
+   appropriate.  */
+bool
+shipout_string_trunc (struct obstack *obs, const char *str, size_t len,
+                     size_t *max_len)
+{
+  size_t max = max_len ? *max_len : INT_MAX;
+
+  if (len == SIZE_MAX)
+    len = strlen (str);
+  if (len < max)
+    {
+      obstack_grow (obs, str, len);
+      max -= len;
+    }
+  else
+    {
+      obstack_grow (obs, str, max);
+      obstack_grow (obs, "...", 3);
+      max = 0;
+    }
+  if (max_len)
+    *max_len = max;
+  return max == 0;
+}
 
 /* Functions for use by diversions.  */
 


hooks/post-receive
--
GNU M4 source repository




reply via email to

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