[libmarpa-r2-perl] 02/14: Add more version checking: t+

Jonas Smedegaard dr at jones.dk
Sat May 17 21:24:08 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag Marpa-R2-2.085_003
in repository libmarpa-r2-perl.

commit 77630d985d5cd73b6a409aa7d7c3284c4b74f223
Author: Jeffrey Kegler <JKEGL at cpan.org>
Date:   Wed Apr 16 18:37:41 2014 -0700

    Add more version checking: t+
---
 cpan/libmarpa/dev/api.texi       | 29 ++++++++++++++++++++---------
 cpan/libmarpa/dev/marpa.w        | 24 +++++++++++++++++++++---
 cpan/libmarpa/public/texi2err.pl |  1 +
 3 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/cpan/libmarpa/dev/api.texi b/cpan/libmarpa/dev/api.texi
index 6150086..e6a3eb1 100644
--- a/cpan/libmarpa/dev/api.texi
+++ b/cpan/libmarpa/dev/api.texi
@@ -4435,15 +4435,6 @@ Numeric value: 16.
 Suggested message: "No event at that index".
 @end deftypevr
 
- at deftypevr Macro int MARPA_ERR_I_AM_NOT_OK
-The Libmarpa base grammar is in a "not ok"
-state.
-Currently, the only way this can happen
-is if Libmarpa memory is being overwritten.
-Numeric value: 29.
-Suggested message: "Marpa is in a not OK state".
- at end deftypevr
-
 @deftypevr Macro int MARPA_ERR_GRAMMAR_HAS_CYCLE
 The grammar has a cycle --- one or more loop
 rules.
@@ -4455,6 +4446,26 @@ Numeric value: 17.
 Suggested message: "Grammar has cycle".
 @end deftypevr
 
+ at deftypevr Macro int MARPA_ERR_HEADERS_DO_NOT_MATCH
+This is an internal error, and indicates that
+Libmarpa was wrongly built.
+Libmarpa was compiled with headers which do not
+match the rest of the code.
+The solution is to find a correctly built
+Libmarpa.
+Numeric value: 98.
+Suggested message: "Internal error: Libmarpa was built incorrectly"
+ at end deftypevr
+
+ at deftypevr Macro int MARPA_ERR_I_AM_NOT_OK
+The Libmarpa base grammar is in a "not ok"
+state.
+Currently, the only way this can happen
+is if Libmarpa memory is being overwritten.
+Numeric value: 29.
+Suggested message: "Marpa is in a not OK state".
+ at end deftypevr
+
 @deftypevr Macro int MARPA_ERR_INACCESSIBLE_TOKEN
 This error code indicates that
 the token symbol is an inaccessible symbol --- one which
diff --git a/cpan/libmarpa/dev/marpa.w b/cpan/libmarpa/dev/marpa.w
index 23f6a3a..53f4b42 100644
--- a/cpan/libmarpa/dev/marpa.w
+++ b/cpan/libmarpa/dev/marpa.w
@@ -586,8 +586,18 @@ prototypes, look at
 
 @** The public header file.
 @*0 Version constants.
-@ I should do something about making sure the |MARPA_H_MAJOR_VERSION|, etc.
-match these.  Static assertions?
+@ This macro checks that the header version numbers
+and the library version numbers are identical.
+It is all compile-time constants,
+so it is expected that
+it will be optimized out completely at compile time.
+ at d HEADER_VERSION_MISMATCH (
+   MARPA_MAJOR_VERSION != MARPA_H_MAJOR_VERSION
+   || MARPA_MINOR_VERSION != MARPA_H_MINOR_VERSION
+   || MARPA_MICRO_VERSION != MARPA_H_MICRO_VERSION
+)
+@ Set globals to the library version numbers,
+so that they can be found at runtime.
 @<Global constant variables@> =
 const int marpa_major_version = MARPA_MAJOR_VERSION;
 const int marpa_minor_version = MARPA_MINOR_VERSION;
@@ -14251,7 +14261,15 @@ if (_MARPA_UNLIKELY(!R_is_Consistent(r))) {
     @<Fail if fatal error@>@;
     @<Fail if recognizer not started@>@;
 
-@ @<Fail if fatal error@> =
+@ It is expected the first test, for
+mismatched headers, will be optimized
+completely out if the versions
+numbers are consistent.
+@<Fail if fatal error@> =
+if (HEADER_VERSION_MISMATCH) {
+    MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH);
+    return failure_indicator;
+}
 if (_MARPA_UNLIKELY(!IS_G_OK(g))) {
     MARPA_ERROR(g->t_error);
     return failure_indicator;
diff --git a/cpan/libmarpa/public/texi2err.pl b/cpan/libmarpa/public/texi2err.pl
index 3adb91d..a915f8c 100644
--- a/cpan/libmarpa/public/texi2err.pl
+++ b/cpan/libmarpa/public/texi2err.pl
@@ -139,6 +139,7 @@ MARPA_ERR_SYMBOL_IS_NOT_PREDICTION_EVENT
 MARPA_ERR_RECCE_IS_INCONSISTENT
 MARPA_ERR_INVALID_ASSERTION_ID
 MARPA_ERR_NO_SUCH_ASSERTION_ID
+MARPA_ERR_HEADERS_DO_NOT_MATCH
 );
 
 my %error_number = map { $error_codes[$_], $_ } (0 .. $#error_codes);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmarpa-r2-perl.git



More information about the Pkg-perl-cvs-commits mailing list