Skip to content

Commit 000a621

Browse files
committed
Fixed bug in getting named wildcards
1 parent f99ffb2 commit 000a621

File tree

3 files changed

+3
-47
lines changed

3 files changed

+3
-47
lines changed

Utilities.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,47 +2558,6 @@ const char * Convert_PCRE_Runtime_Error (const int iError)
25582558
}
25592559
} // end of Convert_PCRE_Runtime_Error
25602560

2561-
2562-
/*************************************************
2563-
* Find first set of multiple named strings *
2564-
*************************************************/
2565-
2566-
// taken from pcre_get.c - with minor modifications
2567-
2568-
/* This function allows for duplicate names in the table of named substrings.
2569-
It returns the number of the first one that was set in a pattern match.
2570-
2571-
Arguments:
2572-
code the compiled regex
2573-
stringname the name of the capturing substring
2574-
ovector the vector of matched substrings
2575-
2576-
Returns: the number of the first that is set,
2577-
or the number of the last one if none are set,
2578-
or a negative number on error
2579-
*/
2580-
2581-
typedef unsigned char uschar;
2582-
2583-
int
2584-
njg_get_first_set(const pcre *code, const char *stringname, const int *ovector)
2585-
{
2586-
const real_pcre *re = (const real_pcre *)code;
2587-
int entrysize;
2588-
char *first, *last;
2589-
uschar *entry;
2590-
if ((re->options & (PCRE_DUPNAMES | PCRE_JCHANGED)) == 0)
2591-
return pcre_get_stringnumber(code, stringname);
2592-
entrysize = pcre_get_stringtable_entries(code, stringname, &first, &last);
2593-
if (entrysize <= 0) return entrysize;
2594-
for (entry = (uschar *)first; entry <= (uschar *)last; entry += entrysize)
2595-
{
2596-
int n = (entry[0] << 8) + entry[1];
2597-
if (ovector[n*2] >= 0) return n;
2598-
}
2599-
return (first[0] << 8) + first[1];
2600-
}
2601-
26022561
// i18n (Internationalization) stuff
26032562

26042563
// translate message (eg. "File cannot be opened") into locale-specific language

regexp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,21 @@ string t_regexp::GetWildcard (const string& sName) const
171171

172172
if (namecount > 0)
173173
{
174-
unsigned char *name_table;
175174
int name_entry_size;
176175
unsigned char *tabptr;
177176
int ncapt;
178177
int jchanged;
179178
pcre_fullinfo(m_program, m_extra, PCRE_INFO_CAPTURECOUNT, &ncapt);
180-
pcre_fullinfo(m_program, m_extra, PCRE_INFO_NAMETABLE, &name_table);
179+
pcre_fullinfo(m_program, m_extra, PCRE_INFO_NAMETABLE, &tabptr);
181180
pcre_fullinfo(m_program, m_extra, PCRE_INFO_NAMEENTRYSIZE, &name_entry_size);
182181
pcre_fullinfo(m_program, m_extra, PCRE_INFO_JCHANGED, &jchanged);
183-
tabptr = name_table;
184182
set<string> found_strings;
185183
for (int i = 0; i < namecount; i++, tabptr += name_entry_size)
186184
{
187185
int n = (tabptr[0] << 8) | tabptr[1];
188186
const unsigned char * name = tabptr + 2;
187+
if (strcmp (sName.c_str (), (LPCTSTR) name) != 0) // skip if wrong name
188+
continue;
189189
// if duplicates were possible then ...
190190
if (jchanged)
191191
{

regexp.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020

2121
#include "pcre\pcre.h"
2222

23-
// for duplicate named wildcards
24-
int njg_get_first_set(const pcre *code, const char *stringname, const int *ovector);
25-
2623
// compiled regular expression type
2724

2825
class t_regexp

0 commit comments

Comments
 (0)