X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/1cc59d374be28e0f2a27720d003271216676c12e..6bf342e1eb87c656de34d668d7303a7d0138e89a:/src/src/pcre/pcre_version.c diff --git a/src/src/pcre/pcre_version.c b/src/src/pcre/pcre_version.c index 47f889f1d..1a30fe014 100644 --- a/src/src/pcre/pcre_version.c +++ b/src/src/pcre/pcre_version.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/pcre/pcre_version.c,v 1.3 2006/11/07 16:50:36 ph10 Exp $ */ +/* $Cambridge: exim/src/src/pcre/pcre_version.c,v 1.4 2007/01/23 15:08:45 ph10 Exp $ */ /************************************************* * Perl-Compatible Regular Expressions * @@ -51,16 +51,38 @@ string that identifies the PCRE version that is in use. */ * Return version string * *************************************************/ +/* These macros are the standard way of turning unquoted text into C strings. +They allow macros like PCRE_MAJOR to be defined without quotes, which is +convenient for user programs that want to test its value. */ + #define STRING(a) # a #define XSTRING(s) STRING(s) +/* A problem turned up with PCRE_PRERELEASE, which is defined empty for +production releases. Originally, it was used naively in this code: + + return XSTRING(PCRE_MAJOR) + "." XSTRING(PCRE_MINOR) + XSTRING(PCRE_PRERELEASE) + " " XSTRING(PCRE_DATE); + +However, when PCRE_PRERELEASE is empty, this leads to an attempted expansion of +STRING(). The C standard states: "If (before argument substitution) any +argument consists of no preprocessing tokens, the behavior is undefined." It +turns out the gcc treats this case as a single empty string - which is what we +really want - but Visual C grumbles about the lack of an argument for the +macro. Unfortunately, both are within their rights. To cope with both ways of +handling this, I had resort to some messy hackery that does a test at run time. +I could find no way of detecting that a macro is defined as an empty string at +pre-processor time. This hack uses a standard trick for avoiding calling +the STRING macro with an empty argument when doing the test. */ + PCRE_DATA_SCOPE const char * pcre_version(void) { -return XSTRING(PCRE_MAJOR) - "." XSTRING(PCRE_MINOR) - XSTRING(PCRE_PRERELEASE) - " " XSTRING(PCRE_DATE); +return (XSTRING(Z PCRE_PRERELEASE)[1] == 0)? + XSTRING(PCRE_MAJOR.PCRE_MINOR PCRE_DATE) : + XSTRING(PCRE_MAJOR.PCRE_MINOR) XSTRING(PCRE_PRERELEASE PCRE_DATE); } /* End of pcre_version.c */