m4-patches
[Top][All Lists]
Advanced

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

FYI: build correctly with -DNDEBUG [m4--devo--1.0--patch-6]


From: Gary V. Vaughan
Subject: FYI: build correctly with -DNDEBUG [m4--devo--1.0--patch-6]
Date: Thu, 14 Oct 2004 10:49:08 +0100 (BST)
User-agent: mailnotify/0.4

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Applied to HEAD.

  * looking for address@hidden/m4--devo--1.0--patch-5 to compare with
  * comparing to address@hidden/m4--devo--1.0--patch-5
  M  ChangeLog
  M  m4/syntax.c
  M  m4/m4private.h
  M  m4/m4.c
  
  * modified files
  
  Index: Changelog
  from  Noah Misch  <address@hidden>,
        Gary V. Vaughan  <address@hidden>
  
        * m4/m4.c (m4_context_field_table, m4_context_opt_bit_table):
        Protect definitions from macro expansion under -DNDEBUG by
        parenthesising the expanded function names.
        * m4/syntax.c (m4_get_syntax_lquote, m4_get_syntax_rquote)
        (m4_get_syntax_bcomm, m4_get_syntax_ecomm)
        (m4_is_syntax_single_quotes, m4_is_syntax_single_comments)
        (m4_is_syntax_macro_escaped): Similarly protect function
        definitions from macro expansion under -DNDEBUG by #undefing the
        matching macro names before each definition.  Also, move all the
        function definitions to the end of the file so that any
        invocations in the rest of the file pick up the fast macro
        versions.
        * m4/m4private.h (m4_set_symbol_table, m4_set_syntax_table)
        (m4_set_debug_file, m4_set_trace_messages)
        (m4_set_warning_status_opt, m4_set_no_gnu_extensions_opt)
        (m4_set_nesting_limit_opt, m4_set_debug_level_opt)
        (m4_set_max_debug_arg_length_opt): New fast macro versions of the
        option setter functions.
  
  --- orig/m4/m4.c
  +++ mod/m4/m4.c
  @@ -1,5 +1,5 @@
   /* GNU m4 -- A simple macro processor
  -   Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2001
  +   Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2001, 2004
      Free Software Foundation, Inc.
   
      This program is free software; you can redistribute it and/or modify
  @@ -78,23 +78,11 @@
   
   
   /* Use the preprocessor to generate the repetitive bit twiddling functions
  -   for us.  */
  -#undef m4_get_symbol_table
  -#undef m4_get_syntax_table
  -#undef m4_get_warning_status_opt
  -#undef m4_get_no_gnu_extensions_opt
  -#undef m4_get_nesting_limit_opt
  -#undef m4_get_debug_level_opt
  -#undef m4_get_max_debug_arg_length_opt
  -#undef m4_get_prefix_builtins_opt
  -#undef m4_get_suppress_warnings_opt
  -#undef m4_get_discard_comments_opt
  -#undef m4_get_interactive_opt
  -#undef m4_get_sync_output_opt
  -#undef m4_get_posixly_correct_opt
  -
  +   for us.  Note the additional paretheses around the expanded function
  +   name to protect against macro expansion from the fast macros used to
  +   replace these functions when NDEBUG is defined.  */
   #define M4FIELD(type, base, field)                                   \
  -     type CONC(m4_get_, base) (m4 *context)                          \
  +     type (CONC(m4_get_, base)) (m4 *context)                        \
        {                                                               \
          assert (context);                                             \
          return context->field;                                        \
  @@ -103,7 +91,7 @@
   #undef M4FIELD
   
   #define M4FIELD(type, base, field)                                   \
  -     type CONC(m4_set_, base) (m4 *context, type value)              \
  +     type (CONC(m4_set_, base)) (m4 *context, type value)            \
        {                                                               \
          assert (context);                                             \
          return context->field = value;                                \
  @@ -112,7 +100,7 @@
   #undef M4FIELD
   
   #define M4OPT_BIT(bit, base)                                                 
\
  -     bool CONC(m4_get_, base) (m4 *context)                  \
  +     bool (CONC(m4_get_, base)) (m4 *context)                        \
        {                                                               \
          assert (context);                                             \
          return BIT_TEST (context->opt_flags, (bit));                  \
  @@ -121,7 +109,7 @@
   #undef M4OPT_BIT
   
   #define M4OPT_BIT(bit, base)                                                 
\
  -     bool CONC(m4_set_, base) (m4 *context, bool value)      \
  +     bool (CONC(m4_set_, base)) (m4 *context, bool value)            \
        {                                                               \
          assert (context);                                             \
          if (value)                                                    \
  
  
  --- orig/m4/m4private.h
  +++ mod/m4/m4private.h
  @@ -73,14 +73,23 @@
      that also have an identically named function exported in m4module.h.  */
   #ifdef NDEBUG
   #  define m4_get_symbol_table(C)             ((C)->symtab)
  +#  define m4_set_symbol_table(C, V)          ((C)->symtab = (V))
   #  define m4_get_syntax_table(C)             ((C)->syntax)
  +#  define m4_set_syntax_table(C, V)          ((C)->syntax = (V))
   #  define m4_get_debug_file(C)                       ((C)->debug_file)
  +#  define m4_set_debug_file(C, V)            ((C)->debug_file = (V))
   #  define m4_get_trace_messages(C)           ((C)->trace_messages)
  +#  define m4_set_trace_messages(C, V)                ((C)->trace_messages = 
(V))
   #  define m4_get_warning_status_opt(C)               ((C)->warning_status)
  +#  define m4_set_warning_status_opt(C, V)    ((C)->warning_status = (V))
   #  define m4_get_no_gnu_extensions_opt(C)    ((C)->no_gnu_extensions)
  +#  define m4_set_no_gnu_extensions_opt(C, V) ((C)->no_gnu_extensions = (V))
   #  define m4_get_nesting_limit_opt(C)                ((C)->nesting_limit)
  +#  define m4_set_nesting_limit_opt(C, V)     ((C)->nesting_limit = (V))
   #  define m4_get_debug_level_opt(C)          ((C)->debug_level)
  +#  define m4_set_debug_level_opt(C, V)               ((C)->debug_level = (V))
   #  define m4_get_max_debug_arg_length_opt(C) ((C)->max_debug_arg_length)
  +#  define m4_set_max_debug_arg_length_opt(C, V)      
((C)->max_debug_arg_length=(V))
   
   #  define m4_get_prefix_builtins_opt(C)                                      
\
                (BIT_TEST((C)->opt_flags, M4_OPT_PREFIX_BUILTINS_BIT))
  @@ -94,6 +103,9 @@
                (BIT_TEST((C)->opt_flags, M4_OPT_SYNC_OUTPUT_BIT))
   #  define m4_get_posixly_correct_opt(C)                                      
\
                (BIT_TEST((C)->opt_flags, M4_OPT_POSIXLY_CORRECT_BIT))
  +
  +/* No fast opt bit set macros, as they would need to evaluate their
  +   arguments more than once, which would subtly change their semantics.  */
   #endif
   
   /* Accessors for private fields of m4, which have no function version
  @@ -155,6 +167,8 @@
   #define SYMBOL_MIN_ARGS(S)   (VALUE_MIN_ARGS      ((S)->value))
   #define SYMBOL_MAX_ARGS(S)   (VALUE_MAX_ARGS      ((S)->value))
   
  +/* Fast macro versions of symbol table accessor functions,
  +   that also have an identically named function exported in m4module.h.  */
   #ifdef NDEBUG
   #  define m4_get_symbol_traced(S)    ((S)->traced)
   #  define m4_set_symbol_traced(S, V) ((S)->traced = (V))
  @@ -235,6 +249,8 @@
     bool is_macro_escaped;
   };
   
  +/* Fast macro versions of syntax table accessor functions,
  +   that also have an identically named function exported in m4module.h.  */
   #ifdef NDEBUG
   #  define m4_get_syntax_lquote(S)    ((S)->lquote.string)
   #  define m4_get_syntax_rquote(S)    ((S)->rquote.string)
  
  
  --- orig/m4/syntax.c
  +++ mod/m4/syntax.c
  @@ -1,5 +1,5 @@
   /* GNU m4 -- A simple macro processor
  -   Copyright (C) 1989, 90, 91, 92, 93, 94, 2002 Free Software Foundation, 
Inc.
  +   Copyright (C) 1989, 90, 91, 92, 93, 94, 2002, 2004 Free Software 
Foundation, Inc.
   
      This program is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
  @@ -192,6 +192,84 @@
   
   
   
  +/* Functions to manipulate the syntax table.  */
  +static int
  +add_syntax_attribute (m4_syntax_table *syntax, int ch, int code)
  +{
  +  if (code & M4_SYNTAX_MASKS)
  +    syntax->table[ch] |= code;
  +  else
  +    syntax->table[ch] = code;
  +
  +#ifdef DEBUG_SYNTAX
  +  fprintf(stderr, "Set syntax %o %c = %04X\n",
  +       ch, isprint(ch) ? ch : '-',
  +       syntax->table[ch]);
  +#endif
  +
  +  return syntax->table[ch];
  +}
  +
  +static int
  +remove_syntax_attribute (m4_syntax_table *syntax, int ch, int code)
  +{
  +  if (code & M4_SYNTAX_MASKS)
  +    syntax->table[ch] &= ~code;
  +
  +#ifdef DEBUG_SYNTAX
  +  fprintf(stderr, "Unset syntax %o %c = %04X\n",
  +       ch, isprint(ch) ? ch : '-',
  +       syntax->table[ch]);
  +#endif
  +
  +  return syntax->table[ch];
  +}
  +
  +int
  +m4_set_syntax (m4_syntax_table *syntax, char key, const unsigned char *chars)
  +{
  +  int ch, code;
  +
  +  assert (syntax);
  +
  +  code = m4_syntax_code (key);
  +
  +  if ((code < 0) && (key != '\0'))
  +    {
  +      return -1;
  +    }
  +
  +  if (*chars != '\0')
  +    while ((ch = *chars++))
  +      add_syntax_attribute (syntax, ch, code);
  +  else
  +    for (ch = 256; --ch > 0; )
  +      add_syntax_attribute (syntax, ch, code);
  +
  +  if (syntax->is_macro_escaped || code == M4_SYNTAX_ESCAPE)
  +    check_is_macro_escaped (syntax);
  +
  +  return code;
  +}
  +
  +static bool
  +check_is_macro_escaped (m4_syntax_table *syntax)
  +{
  +  int ch;
  +
  +  syntax->is_macro_escaped = false;
  +  for (ch = 256; --ch >= 0; )
  +    if (m4_has_syntax (syntax, ch, M4_SYNTAX_ESCAPE))
  +      {
  +     syntax->is_macro_escaped = true;
  +     break;
  +      }
  +
  +  return syntax->is_macro_escaped;
  +}
  +
  +
  +
   /* Functions for setting quotes and comment delimiters.  Used by
      m4_changecom () and m4_changequote ().  Both functions overrides the
      syntax table to maintain compatibility.  */
  @@ -227,20 +305,6 @@
       check_is_macro_escaped (syntax);
   }
   
  -const char *
  -m4_get_syntax_lquote (m4_syntax_table *syntax)
  -{
  -  assert (syntax);
  -  return syntax->lquote.string;
  -}
  -
  -const char *
  -m4_get_syntax_rquote (m4_syntax_table *syntax)
  -{
  -  assert (syntax);
  -  return syntax->rquote.string;
  -}
  -
   void
   m4_set_comment (m4_syntax_table *syntax, const char *bc, const char *ec)
   {
  @@ -273,20 +337,27 @@
       check_is_macro_escaped (syntax);
   }
   
  +
  +
  +/* Define these functions at the end, so that calls in the file use the
  +   faster macro version from m4module.h.  */
  +#undef m4_get_syntax_lquote
   const char *
  -m4_get_syntax_bcomm (m4_syntax_table *syntax)
  +m4_get_syntax_lquote (m4_syntax_table *syntax)
   {
     assert (syntax);
  -  return syntax->bcomm.string;
  +  return syntax->lquote.string;
   }
   
  +#undef m4_get_syntax_rquote
   const char *
  -m4_get_syntax_ecomm (m4_syntax_table *syntax)
  +m4_get_syntax_rquote (m4_syntax_table *syntax)
   {
     assert (syntax);
  -  return syntax->ecomm.string;
  +  return syntax->rquote.string;
   }
   
  +#undef m4_is_syntax_single_quotes
   bool
   m4_is_syntax_single_quotes (m4_syntax_table *syntax)
   {
  @@ -294,94 +365,34 @@
     return syntax->is_single_quotes;
   }
   
  -bool
  -m4_is_syntax_single_comments (m4_syntax_table *syntax)
  +#undef m4_get_syntax_bcomm
  +const char *
  +m4_get_syntax_bcomm (m4_syntax_table *syntax)
   {
     assert (syntax);
  -  return syntax->is_single_comments;
  +  return syntax->bcomm.string;
   }
   
  -bool
  -m4_is_syntax_macro_escaped (m4_syntax_table *syntax)
  +#undef m4_get_syntax_ecomm
  +const char *
  +m4_get_syntax_ecomm (m4_syntax_table *syntax)
   {
     assert (syntax);
  -  return syntax->is_macro_escaped;
  -}
  -
  -
  -
  -/* Functions to manipulate the syntax table.  */
  -static int
  -add_syntax_attribute (m4_syntax_table *syntax, int ch, int code)
  -{
  -  if (code & M4_SYNTAX_MASKS)
  -    syntax->table[ch] |= code;
  -  else
  -    syntax->table[ch] = code;
  -
  -#ifdef DEBUG_SYNTAX
  -  fprintf(stderr, "Set syntax %o %c = %04X\n",
  -       ch, isprint(ch) ? ch : '-',
  -       syntax->table[ch]);
  -#endif
  -
  -  return syntax->table[ch];
  -}
  -
  -static int
  -remove_syntax_attribute (m4_syntax_table *syntax, int ch, int code)
  -{
  -  if (code & M4_SYNTAX_MASKS)
  -    syntax->table[ch] &= ~code;
  -
  -#ifdef DEBUG_SYNTAX
  -  fprintf(stderr, "Unset syntax %o %c = %04X\n",
  -       ch, isprint(ch) ? ch : '-',
  -       syntax->table[ch]);
  -#endif
  -
  -  return syntax->table[ch];
  +  return syntax->ecomm.string;
   }
   
  -int
  -m4_set_syntax (m4_syntax_table *syntax, char key, const unsigned char *chars)
  +#undef m4_is_syntax_single_comments
  +bool
  +m4_is_syntax_single_comments (m4_syntax_table *syntax)
   {
  -  int ch, code;
  -
     assert (syntax);
  -
  -  code = m4_syntax_code (key);
  -
  -  if ((code < 0) && (key != '\0'))
  -    {
  -      return -1;
  -    }
  -
  -  if (*chars != '\0')
  -    while ((ch = *chars++))
  -      add_syntax_attribute (syntax, ch, code);
  -  else
  -    for (ch = 256; --ch > 0; )
  -      add_syntax_attribute (syntax, ch, code);
  -
  -  if (syntax->is_macro_escaped || code == M4_SYNTAX_ESCAPE)
  -    check_is_macro_escaped (syntax);
  -
  -  return code;
  +  return syntax->is_single_comments;
   }
   
  -static bool
  -check_is_macro_escaped (m4_syntax_table *syntax)
  +#undef m4_is_syntax_macro_escaped
  +bool
  +m4_is_syntax_macro_escaped (m4_syntax_table *syntax)
   {
  -  int ch;
  -
  -  syntax->is_macro_escaped = false;
  -  for (ch = 256; --ch >= 0; )
  -    if (m4_has_syntax (syntax, ch, M4_SYNTAX_ESCAPE))
  -      {
  -     syntax->is_macro_escaped = true;
  -     break;
  -      }
  -
  +  assert (syntax);
     return syntax->is_macro_escaped;
   }
  
  
  
- -- 
Gary V. Vaughan      ())_.  address@hidden,gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker           / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook
_________________________________________________________
This patch notification generated by tlaapply version 0.7
http://tkd.kicks-ass.net/arch/address@hidden/cvs-utils--tla--1.0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFBbkuTFRMICSmD1gYRAskAAKDL452rldYj7KbzJsuD3GyI+mBIFgCfX7be
PuWuuQyelBMVgjcR+b90AOY=
=ZanB
-----END PGP SIGNATURE-----




reply via email to

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