[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Inform m4 whether a tag is a valid id.
From: |
Akim Demaille |
Subject: |
[PATCH] Inform m4 whether a tag is a valid id. |
Date: |
Tue, 11 Nov 2008 14:16:59 -0000 |
* src/output.c (is_identifier): New.
(symbol_definitions_output): Use it to define tag_is_id.
But maybe this should be done at m4 level?
---
ChangeLog | 7 +++++++
src/output.c | 25 +++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4d59ee0..2aa7ec7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2008-11-11 Akim Demaille <address@hidden>
+ Inform m4 whether a tag is a valid id.
+ * src/output.c (is_identifier): New.
+ (symbol_definitions_output): Use it to define tag_is_id.
+ But maybe this should be done at m4 level?
+
+2008-11-11 Akim Demaille <address@hidden>
+
Test 214 was failing: it greps with a pattern containing [ ]*
which obviously meant to catch spaces and tabs, but contained only
spaces. Tabulations in sources are a nuisance, so to simplify the
diff --git a/src/output.c b/src/output.c
index a7003ed..afcec94 100644
--- a/src/output.c
+++ b/src/output.c
@@ -396,6 +396,26 @@ merger_output (FILE *out)
}
+/*----------------------------------.
+| Whether S is a valid identifier. |
+`----------------------------------*/
+
+static bool
+is_identifier (uniqstr s)
+{
+ static char const alphanum[26 + 26 + 1 + 10] =
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "_"
+ "0123456789";
+ if (!s || ! memchr (alphanum, *s, sizeof alphanum - 10))
+ return false;
+ for (++s; *s; ++s)
+ if (! memchr (alphanum, *s, sizeof alphanum))
+ return false;
+ return true;
+}
+
/*---------------------------------------.
| Output the symbol definitions to OUT. |
`---------------------------------------*/
@@ -414,6 +434,11 @@ symbol_definitions_output (FILE *out)
obstack_1grow (&format_obstack, 0); \
key = obstack_finish (&format_obstack);
+ // Whether the tag is a valid identifier.
+ SET_KEY("tag_is_id");
+ MUSCLE_INSERT_INT (key, is_identifier(sym->tag));
+
+ // The inner tag.
SET_KEY("tag");
MUSCLE_INSERT_STRING (key, sym->tag);
--
1.6.0.2.588.g3102
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Inform m4 whether a tag is a valid id.,
Akim Demaille <=