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