]> granicus.if.org Git - flex/commitdiff
Added function buf_m4_undefine.
authorJohn Millaway <john43@users.sourceforge.net>
Thu, 13 Mar 2003 08:18:50 +0000 (08:18 +0000)
committerJohn Millaway <john43@users.sourceforge.net>
Thu, 13 Mar 2003 08:18:50 +0000 (08:18 +0000)
buf.c
flexdef.h
scan.l

diff --git a/buf.c b/buf.c
index 427d711fedb2305abba26a2afce804f8494a4fac..49c87f2dfc8b618e9c81ecac4cfd244b62cf4a16 100644 (file)
--- a/buf.c
+++ b/buf.c
@@ -113,7 +113,6 @@ struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val)
 {
     const char * fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n";
     char * str;
-    int len;
 
     val = val?val:"";
     str = (char*)flex_alloc(strlen(fmt) + strlen(def) + strlen(val) + 2);
@@ -122,6 +121,22 @@ struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val)
     buf_append(buf, &str, 1);
 }
 
+/** Pushes "m4_undefine([[def]])m4_dnl" to end of buffer.
+ * @param buf A buffer as a list of strings.
+ * @param def The m4 symbol to undefine.
+ * @return buf
+ */
+struct Buf *buf_m4_undefine (struct Buf *buf, const char* def)
+{
+    const char * fmt = "m4_undefine( [[%s]])m4_dnl\n";
+    char * str;
+
+    str = (char*)flex_alloc(strlen(fmt) + strlen(def) + 2);
+
+    sprintf(str, fmt, def);
+    buf_append(buf, &str, 1);
+}
+
 /* create buf with 0 elements, each of size elem_size. */
 void buf_init (buf, elem_size)
      struct Buf *buf;
index d283c4a15fa742ac35c92283f39f0a78c12ba8cf..4cbcdf86d2fd6bb6bd8d78e4af390ae2507cc2da 100644 (file)
--- a/flexdef.h
+++ b/flexdef.h
@@ -1086,6 +1086,7 @@ extern struct Buf *buf_strdefine
 PROTO ((struct Buf * buf, const char *str, const char *def));
 extern struct Buf *buf_prints PROTO((struct Buf *buf, const char *fmt, const char* s));
 extern struct Buf *buf_m4_define PROTO((struct Buf *buf, const char* def, const char* val));
+extern struct Buf *buf_m4_undefine PROTO((struct Buf *buf, const char* def));
 extern struct Buf *buf_print_strings PROTO((struct Buf * buf, FILE* out));
 
 /* a string buffer for #define's generated by user-options on cmd line. */
diff --git a/scan.l b/scan.l
index 82d6210d3629bbf6b89129489584f8b2370b8832..a0b68db6668d221a8a8a0ddbf56a59ed660addb8 100644 (file)
--- a/scan.l
+++ b/scan.l
@@ -47,6 +47,8 @@ extern bool tablesverify, tablesext;
     do{ \
         if ( should_define ) \
             buf_m4_define( &m4defs_buf, def, NULL);\
+        else \
+            buf_m4_undefine( &m4defs_buf, def);\
     } while(0)
 
 #define MARK_END_OF_PROLOG mark_prolog();