diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-11-12 16:53:25 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-11-12 16:53:25 +0000 |
commit | 68565d28dbbdfa6d073328347815306dd96b37a6 (patch) | |
tree | 47ec4db1f1fdd0e9eebc99e80e964421556d7991 /pcrecpp.cc | |
parent | 9c74abda0f1247b4d108930b1a396161cf7a9cb6 (diff) | |
download | pcre-68565d28dbbdfa6d073328347815306dd96b37a6.tar.gz |
Apply Craig's patch, which makes it possible to "ignore" values in parens
when parsing an RE using the c++ wrapper.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@263 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcrecpp.cc')
-rw-r--r-- | pcrecpp.cc | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -618,23 +618,27 @@ bool Arg::parse_null(const char* str, int n, void* dest) { } bool Arg::parse_string(const char* str, int n, void* dest) { + if (dest == NULL) return true; reinterpret_cast<string*>(dest)->assign(str, n); return true; } bool Arg::parse_stringpiece(const char* str, int n, void* dest) { + if (dest == NULL) return true; reinterpret_cast<StringPiece*>(dest)->set(str, n); return true; } bool Arg::parse_char(const char* str, int n, void* dest) { if (n != 1) return false; + if (dest == NULL) return true; *(reinterpret_cast<char*>(dest)) = str[0]; return true; } bool Arg::parse_uchar(const char* str, int n, void* dest) { if (n != 1) return false; + if (dest == NULL) return true; *(reinterpret_cast<unsigned char*>(dest)) = str[0]; return true; } @@ -683,6 +687,7 @@ bool Arg::parse_long_radix(const char* str, long r = strtol(str, &end, radix); if (end != str + n) return false; // Leftover junk if (errno) return false; + if (dest == NULL) return true; *(reinterpret_cast<long*>(dest)) = r; return true; } @@ -700,6 +705,7 @@ bool Arg::parse_ulong_radix(const char* str, unsigned long r = strtoul(str, &end, radix); if (end != str + n) return false; // Leftover junk if (errno) return false; + if (dest == NULL) return true; *(reinterpret_cast<unsigned long*>(dest)) = r; return true; } @@ -711,6 +717,7 @@ bool Arg::parse_short_radix(const char* str, long r; if (!parse_long_radix(str, n, &r, radix)) return false; // Could not parse if (r < SHRT_MIN || r > SHRT_MAX) return false; // Out of range + if (dest == NULL) return true; *(reinterpret_cast<short*>(dest)) = static_cast<short>(r); return true; } @@ -722,6 +729,7 @@ bool Arg::parse_ushort_radix(const char* str, unsigned long r; if (!parse_ulong_radix(str, n, &r, radix)) return false; // Could not parse if (r > USHRT_MAX) return false; // Out of range + if (dest == NULL) return true; *(reinterpret_cast<unsigned short*>(dest)) = static_cast<unsigned short>(r); return true; } @@ -733,6 +741,7 @@ bool Arg::parse_int_radix(const char* str, long r; if (!parse_long_radix(str, n, &r, radix)) return false; // Could not parse if (r < INT_MIN || r > INT_MAX) return false; // Out of range + if (dest == NULL) return true; *(reinterpret_cast<int*>(dest)) = r; return true; } @@ -744,6 +753,7 @@ bool Arg::parse_uint_radix(const char* str, unsigned long r; if (!parse_ulong_radix(str, n, &r, radix)) return false; // Could not parse if (r > UINT_MAX) return false; // Out of range + if (dest == NULL) return true; *(reinterpret_cast<unsigned int*>(dest)) = r; return true; } @@ -771,6 +781,7 @@ bool Arg::parse_longlong_radix(const char* str, #endif if (end != str + n) return false; // Leftover junk if (errno) return false; + if (dest == NULL) return true; *(reinterpret_cast<long long*>(dest)) = r; return true; #endif /* HAVE_LONG_LONG */ @@ -800,6 +811,7 @@ bool Arg::parse_ulonglong_radix(const char* str, #endif if (end != str + n) return false; // Leftover junk if (errno) return false; + if (dest == NULL) return true; *(reinterpret_cast<unsigned long long*>(dest)) = r; return true; #endif /* HAVE_UNSIGNED_LONG_LONG */ @@ -817,6 +829,7 @@ bool Arg::parse_double(const char* str, int n, void* dest) { double r = strtod(buf, &end); if (end != buf + n) return false; // Leftover junk if (errno) return false; + if (dest == NULL) return true; *(reinterpret_cast<double*>(dest)) = r; return true; } @@ -824,6 +837,7 @@ bool Arg::parse_double(const char* str, int n, void* dest) { bool Arg::parse_float(const char* str, int n, void* dest) { double r; if (!parse_double(str, n, &r)) return false; + if (dest == NULL) return true; *(reinterpret_cast<float*>(dest)) = static_cast<float>(r); return true; } |