[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
proposal for version mismatch
From: |
Eric Blake |
Subject: |
proposal for version mismatch |
Date: |
Tue, 18 Jul 2006 15:32:46 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Would this patch be okay to apply to branch-1_4? It will help people playing
with m4 2.0 to more easily recognize when 1.4.6 can't parse a frozen file
generated by 2.0.
2006-07-18 Eric Blake <address@hidden>
* src/m4.h (EXIT_MISMATCH): Define.
* src/freeze.c (reload_frozen_state): Detect version mismatch, by
exiting with status 63.
* src/m4.c (usage): Document this.
* doc/m4.texinfo (Invoking m4, Using frozen files): Likewise.
* NEWS: Likewise.
Index: NEWS
===================================================================
RCS file: /sources/m4/m4/NEWS,v
retrieving revision 1.1.1.1.2.41
diff -u -r1.1.1.1.2.41 NEWS
--- NEWS 17 Jul 2006 17:09:53 -0000 1.1.1.1.2.41
+++ NEWS 18 Jul 2006 15:21:35 -0000
@@ -7,6 +7,8 @@
* Fix buffer overrun in regexp and patsubst macros when handed a trailing
backslash in the replacement text.
* The format macro now understands %F, %g, and %G.
+* When loading frozen files, m4 now exits with status 63 if version
+ mismatch is detected.
Version 1.4.5 - 15 July 2006, by Eric Blake (CVS version 1.4.4c)
Index: doc/m4.texinfo
===================================================================
RCS file: /sources/m4/m4/doc/m4.texinfo,v
retrieving revision 1.1.1.1.2.48
diff -u -r1.1.1.1.2.48 m4.texinfo
--- doc/m4.texinfo 17 Jul 2006 17:09:53 -0000 1.1.1.1.2.48
+++ doc/m4.texinfo 18 Jul 2006 15:21:36 -0000
@@ -593,7 +593,9 @@
argument collection or a quoted string.
If none of the input files invoked @code{m4exit} (@pxref{M4exit}), the
-exit status of @code{m4} will be 0 for success, and 1 for failure.
+exit status of @code{m4} will be 0 for success, 1 for general failure
+(such as problems with reading an input file), and 63 for version
+mismatch (@pxref{Using frozen files}).
If you need to read a file whose name starts with a @file{-}, you can
specify it as @samp{./-file}, or use @option{--} to mark the end of
@@ -4016,6 +4018,11 @@
It is looked up the same way as an @code{include} file (@pxref{Search
Path}).
+If the frozen file was generated with a newer version of @code{m4} and
+contains directives that an older @code{m4} cannot parse, attempting to
+load the frozen file with option @option{-R} will cause @code{m4} to
+exit with status 63 to indicate version mismatch.
+
@node Frozen file format
@section Frozen file format
@cindex frozen file format
Index: src/freeze.c
===================================================================
RCS file: /sources/m4/m4/src/freeze.c,v
retrieving revision 1.1.1.1.2.9
diff -u -r1.1.1.1.2.9 freeze.c
--- src/freeze.c 7 Jul 2006 03:37:26 -0000 1.1.1.1.2.9
+++ src/freeze.c 18 Jul 2006 15:21:36 -0000
@@ -234,8 +234,14 @@
GET_DIRECTIVE;
VALIDATE ('V');
GET_CHARACTER;
- VALIDATE ('1');
- GET_CHARACTER;
+ GET_NUMBER (number[0]);
+ if (number[0] > 1)
+ M4ERROR ((EXIT_MISMATCH, 0,
+ "frozen file version %d greater than max supported of 1",
+ number[0]));
+ else if (number[0] < 1)
+ M4ERROR ((EXIT_FAILURE, 0,
+ "ill-formed frozen file, version directive expected"));
VALIDATE ('\n');
GET_DIRECTIVE;
Index: src/m4.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/m4.c,v
retrieving revision 1.1.1.1.2.18
diff -u -r1.1.1.1.2.18 m4.c
--- src/m4.c 15 Jul 2006 22:08:58 -0000 1.1.1.1.2.18
+++ src/m4.c 18 Jul 2006 15:21:36 -0000
@@ -217,8 +217,8 @@
", stdout);
fputs ("\
\n\
-Exit status is 0 for success, 1 for failure, or whatever value was passed\n\
-to the m4exit macro.\n\
+Exit status is 0 for success, 1 for failure, 63 for frozen file version\n\
+mismatch, or whatever value was passed to the m4exit macro.\n\
", stdout);
}
exit (status);
Index: src/m4.h
===================================================================
RCS file: /sources/m4/m4/src/m4.h,v
retrieving revision 1.1.1.1.2.16
diff -u -r1.1.1.1.2.16 m4.h
--- src/m4.h 11 Jul 2006 12:17:11 -0000 1.1.1.1.2.16
+++ src/m4.h 18 Jul 2006 15:21:36 -0000
@@ -73,6 +73,9 @@
#if ! HAVE_MKSTEMP
int mkstemp (char *);
#endif
+
+/* Used for version mismatch, when -R detects a frozen file it can't parse. */
+#define EXIT_MISMATCH 63
/* Various declarations. */
- proposal for version mismatch,
Eric Blake <=