m4-commit
[Top][All Lists]
Advanced

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

Changes to m4/m4/symtab.c,v


From: Eric Blake
Subject: Changes to m4/m4/symtab.c,v
Date: Tue, 26 Sep 2006 21:21:51 +0000

CVSROOT:        /sources/m4
Module name:    m4
Changes by:     Eric Blake <ericb>      06/09/26 21:21:50

Index: m4/symtab.c
===================================================================
RCS file: /sources/m4/m4/m4/symtab.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- m4/symtab.c 18 Sep 2006 13:16:44 -0000      1.60
+++ m4/symtab.c 26 Sep 2006 21:21:50 -0000      1.61
@@ -57,7 +57,8 @@
                                         void *arg, void *ignored);
 static void *    arg_copy_CB           (m4_hash *src, const void *name,
                                         void *arg, m4_hash *dest);
-
+static void      symbol_value_print    (m4_symbol_value *, m4_obstack *, bool,
+                                        const char *, const char *);
 
 
 /* -- SYMBOL TABLE MANAGEMENT --
@@ -461,6 +462,76 @@
   return result;
 }
 
+/* Grow OBS with a text representation of VALUE.  If QUOTE, then
+   surround a text definition by LQUOTE and RQUOTE.  */
+static void
+symbol_value_print (m4_symbol_value *value, m4_obstack *obs, bool quote,
+                   const char *lquote, const char *rquote)
+{
+  if (m4_is_symbol_value_text (value))
+    {
+      if (quote)
+       {
+         obstack_grow (obs, lquote, strlen (lquote));
+         obstack_grow (obs, m4_get_symbol_value_text (value),
+                       strlen (m4_get_symbol_value_text (value)));
+         obstack_grow (obs, rquote, strlen (rquote));
+       }
+      else
+       obstack_grow (obs, m4_get_symbol_value_text (value),
+                     strlen (m4_get_symbol_value_text (value)));
+    }
+  else if (m4_is_symbol_value_func (value))
+    {
+      const m4_builtin *bp;
+      bp = m4_builtin_find_by_func (NULL, m4_get_symbol_value_func (value));
+      assert (bp);
+      obstack_1grow (obs, '<');
+      obstack_grow (obs, bp->name, strlen (bp->name));
+      obstack_1grow (obs, '>');
+    }
+  else if (m4_is_symbol_value_placeholder (value))
+    {
+      /* FIXME - is it worth translating "placeholder for "?  */
+      obstack_grow (obs, "<placeholder for ", strlen ("<placeholder for "));
+      obstack_grow (obs, m4_get_symbol_value_placeholder (value),
+                   strlen (m4_get_symbol_value_placeholder (value)));
+      obstack_1grow (obs, '>');
+    }
+  else
+    {
+      assert (!"invalid token in symbol_value_print");
+      abort ();
+    }
+}
+
+/* Grow OBS with a text representation of SYMBOL.  If QUOTE, then
+   surround each definition by LQUOTE and RQUOTE.  If STACK, then
+   append all pushdef'd values, rather than just the top.  */
+void
+m4_symbol_print (m4_symbol *symbol, m4_obstack *obs, bool quote,
+                const char *lquote, const char *rquote, bool stack)
+{
+  m4_symbol_value *value;
+
+  assert (symbol);
+  assert (obs);
+
+  value = m4_get_symbol_value (symbol);
+  symbol_value_print (value, obs, quote, lquote, rquote);
+  if (stack)
+    {
+      value = VALUE_NEXT (value);
+      while (value)
+       {
+         obstack_1grow (obs, ',');
+         obstack_1grow (obs, ' ');
+         symbol_value_print (value, obs, quote, lquote, rquote);
+         value = VALUE_NEXT (value);
+       }
+    }
+}
+
 
 /* Define these functions at the end, so that calls in the file use the
    faster macro version from m4module.h.  */




reply via email to

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