|
Packit |
ae235b |
/*************************************************
|
|
Packit |
ae235b |
* Perl-Compatible Regular Expressions *
|
|
Packit |
ae235b |
*************************************************/
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
/* PCRE is a library of functions to support regular expressions whose syntax
|
|
Packit |
ae235b |
and semantics are as close as possible to those of the Perl 5 language.
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
Written by Philip Hazel
|
|
Packit |
ae235b |
Copyright (c) 1997-2012 University of Cambridge
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
-----------------------------------------------------------------------------
|
|
Packit |
ae235b |
Redistribution and use in source and binary forms, with or without
|
|
Packit |
ae235b |
modification, are permitted provided that the following conditions are met:
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
* Redistributions of source code must retain the above copyright notice,
|
|
Packit |
ae235b |
this list of conditions and the following disclaimer.
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
* Redistributions in binary form must reproduce the above copyright
|
|
Packit |
ae235b |
notice, this list of conditions and the following disclaimer in the
|
|
Packit |
ae235b |
documentation and/or other materials provided with the distribution.
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
* Neither the name of the University of Cambridge nor the names of its
|
|
Packit |
ae235b |
contributors may be used to endorse or promote products derived from
|
|
Packit |
ae235b |
this software without specific prior written permission.
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
ae235b |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
ae235b |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
ae235b |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
Packit |
ae235b |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit |
ae235b |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit |
ae235b |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit |
ae235b |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit |
ae235b |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
ae235b |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
Packit |
ae235b |
POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
ae235b |
-----------------------------------------------------------------------------
|
|
Packit |
ae235b |
*/
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
/* This module contains the external function pcre_version(), which returns a
|
|
Packit |
ae235b |
string that identifies the PCRE version that is in use. */
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
#include "config.h"
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
#include "pcre_internal.h"
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
/*************************************************
|
|
Packit |
ae235b |
* Return version string *
|
|
Packit |
ae235b |
*************************************************/
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
/* These macros are the standard way of turning unquoted text into C strings.
|
|
Packit |
ae235b |
They allow macros like PCRE_MAJOR to be defined without quotes, which is
|
|
Packit |
ae235b |
convenient for user programs that want to test its value. */
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
#define STRING(a) # a
|
|
Packit |
ae235b |
#define XSTRING(s) STRING(s)
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
/* A problem turned up with PCRE_PRERELEASE, which is defined empty for
|
|
Packit |
ae235b |
production releases. Originally, it was used naively in this code:
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
return XSTRING(PCRE_MAJOR)
|
|
Packit |
ae235b |
"." XSTRING(PCRE_MINOR)
|
|
Packit |
ae235b |
XSTRING(PCRE_PRERELEASE)
|
|
Packit |
ae235b |
" " XSTRING(PCRE_DATE);
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
However, when PCRE_PRERELEASE is empty, this leads to an attempted expansion of
|
|
Packit |
ae235b |
STRING(). The C standard states: "If (before argument substitution) any
|
|
Packit |
ae235b |
argument consists of no preprocessing tokens, the behavior is undefined." It
|
|
Packit |
ae235b |
turns out the gcc treats this case as a single empty string - which is what we
|
|
Packit |
ae235b |
really want - but Visual C grumbles about the lack of an argument for the
|
|
Packit |
ae235b |
macro. Unfortunately, both are within their rights. To cope with both ways of
|
|
Packit |
ae235b |
handling this, I had resort to some messy hackery that does a test at run time.
|
|
Packit |
ae235b |
I could find no way of detecting that a macro is defined as an empty string at
|
|
Packit |
ae235b |
pre-processor time. This hack uses a standard trick for avoiding calling
|
|
Packit |
ae235b |
the STRING macro with an empty argument when doing the test. */
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
#ifdef COMPILE_PCRE8
|
|
Packit |
ae235b |
PCRE_EXP_DEFN const char * PCRE_CALL_CONVENTION
|
|
Packit |
ae235b |
pcre_version(void)
|
|
Packit |
ae235b |
#else
|
|
Packit |
ae235b |
PCRE_EXP_DEFN const char * PCRE_CALL_CONVENTION
|
|
Packit |
ae235b |
pcre16_version(void)
|
|
Packit |
ae235b |
#endif
|
|
Packit |
ae235b |
{
|
|
Packit |
ae235b |
return (XSTRING(Z PCRE_PRERELEASE)[1] == 0)?
|
|
Packit |
ae235b |
XSTRING(PCRE_MAJOR.PCRE_MINOR PCRE_DATE) :
|
|
Packit |
ae235b |
XSTRING(PCRE_MAJOR.PCRE_MINOR) XSTRING(PCRE_PRERELEASE PCRE_DATE);
|
|
Packit |
ae235b |
}
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
/* End of pcre_version.c */
|