[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Changes to m4/src/freeze.c,v
From: |
Gary V. Vaughan |
Subject: |
Changes to m4/src/freeze.c,v |
Date: |
Thu, 13 Jul 2006 23:35:18 +0000 |
CVSROOT: /sources/m4
Module name: m4
Changes by: Gary V. Vaughan <gary> 06/07/13 23:35:16
Index: src/freeze.c
===================================================================
RCS file: /sources/m4/m4/src/freeze.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- src/freeze.c 19 Jun 2006 15:43:35 -0000 1.43
+++ src/freeze.c 13 Jul 2006 23:35:16 -0000 1.44
@@ -24,20 +24,19 @@
#include "m4.h"
#include "m4private.h"
-static int decode_char (FILE *in);
-static void issue_expect_message (int expected);
-static int produce_char_dump (char *buf, int ch);
-static void produce_syntax_dump (FILE *file, m4_syntax_table *syntax,
- char ch);
-static void produce_module_dump (FILE *file, lt_dlhandle handle);
-static void produce_symbol_dump (m4 *context, FILE *file,
- m4_symbol_table *symtab);
-static void *dump_symbol_CB (m4_symbol_table *symtab,
- const char *symbol_name, m4_symbol *symbol,
- void *userdata);
+static int decode_char (FILE *);
+static void issue_expect_message (int);
+static int produce_char_dump (char *, int);
+static void produce_resyntax_dump (m4 *, FILE *);
+static void produce_syntax_dump (FILE *, m4_syntax_table *, char);
+static void produce_module_dump (FILE *, lt_dlhandle);
+static void produce_symbol_dump (m4 *, FILE *, m4_symbol_table *);
+static void *dump_symbol_CB (m4_symbol_table *, const char *,
+ m4_symbol *, void *);
/* Produce a frozen state to the given file NAME. */
+
static int
produce_char_dump (char *buf, int ch)
{
@@ -77,6 +76,32 @@
return strlen (buf);
}
+
+/* Produce the 'R14\nPOSIX_EXTENDED\n' frozen file dump of the current
+ default regular expression syntax. Note that it would be a little
+ faster to use the encoded syntax in this format as used by re_compile(),
+ but the representation of RE_SYNTAX_POSIX_EXTENDED may change in
+ future (or alternative) implementations of re_compile, so we use an
+ unencoded representation here. */
+
+static void
+produce_resyntax_dump (m4 *context, FILE *file)
+{
+ int code = m4_get_regexp_syntax_opt (context);
+
+ /* Don't dump default syntax code (`0' for GNU_EMACS). */
+ if (code)
+ {
+ const char *resyntax = m4_regexp_syntax_decode (code);
+
+ if (!resyntax)
+ M4ERROR ((EXIT_FAILURE, 0,
+ _("Invalid regexp syntax code `%d'"), code));
+
+ fprintf (file, "R%d\n%s\n", strlen(resyntax), resyntax);
+ }
+}
+
#define MAX_CHAR_LENGTH 4 /* '\377' -> 4 characters */
static void
@@ -238,6 +263,10 @@
fputc ('\n', file);
}
+ /* Dump regular expression syntax. */
+
+ produce_resyntax_dump (context, file);
+
/* Dump syntax table. */
produce_syntax_dump (file, M4SYNTAX, 'I');
@@ -515,6 +544,30 @@
break;
+ case 'R':
+
+ if (version < 2)
+ {
+ /* 'R' operator is not supported in format version 1. */
+ M4ERROR ((EXIT_FAILURE, 0, _("Ill-formed frozen file")));
+ }
+
+ GET_CHARACTER;
+ GET_NUMBER (number[0]);
+ VALIDATE ('\n');
+ GET_STRING (file, string[0], allocated[0], number[0]);
+ VALIDATE ('\n');
+
+ m4_set_regexp_syntax_opt (context,
+ m4_regexp_syntax_encode (string[0]));
+ if (m4_get_regexp_syntax_opt (context) < 0)
+ {
+ M4ERROR ((EXIT_FAILURE, 0,
+ _("Unknown regexp syntax code %s"), string[0]));
+ }
+
+ break;
+
case 'S':
if (version < 2)
- Changes to m4/src/freeze.c,v,
Gary V. Vaughan <=