summaryrefslogtreecommitdiff
path: root/src/system.h
diff options
context:
space:
mode:
authorAkim Demaille <akim@lrde.epita.fr>2012-07-26 11:19:18 +0200
committerAkim Demaille <akim@lrde.epita.fr>2012-07-26 12:30:02 +0200
commit13b712d7d492da45303f20502adcf6a8c5a7afa2 (patch)
treefe37780deccdd736f66f0f2da8df3ad1de4e0cd1 /src/system.h
parentdba9149595b908562a3eead383c064ff5e9b2c02 (diff)
downloadbison-13b712d7d492da45303f20502adcf6a8c5a7afa2.tar.gz
obstack_escape: escape M4 characters
* src/muscle-tab.h (MUSCLE_OBSTACK_SGROW): This is not related to muscles, so move to, and rename as... * src/system.h (obstack_escape): this. Adjust dependencies.
Diffstat (limited to 'src/system.h')
-rw-r--r--src/system.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/system.h b/src/system.h
index 944907ec..06224596 100644
--- a/src/system.h
+++ b/src/system.h
@@ -192,6 +192,27 @@ typedef size_t uintptr_t;
} while (0)
+/* Output Str escaped for our postprocessing (i.e., escape M4 special
+ characters).
+
+ For instance "[foo]" -> "@{foo@}", "$$" -> "$][$][". */
+
+# define obstack_escape(Obs, Str) \
+ do { \
+ char const *p; \
+ for (p = Str; *p; p++) \
+ switch (*p) \
+ { \
+ case '$': obstack_sgrow (Obs, "$]["); break; \
+ case '@': obstack_sgrow (Obs, "@@" ); break; \
+ case '[': obstack_sgrow (Obs, "@{" ); break; \
+ case ']': obstack_sgrow (Obs, "@}" ); break; \
+ default: obstack_1grow (Obs, *p ); break; \
+ } \
+ } while (0)
+
+
+
/*-----------------------------------------.
| Extensions to use for the output files. |