diff --git a/Utilities.cpp b/Utilities.cpp index fef82af0..bf5034b4 100644 --- a/Utilities.cpp +++ b/Utilities.cpp @@ -2558,47 +2558,6 @@ const char * Convert_PCRE_Runtime_Error (const int iError) } } // end of Convert_PCRE_Runtime_Error - -/************************************************* -* Find first set of multiple named strings * -*************************************************/ - -// taken from pcre_get.c - with minor modifications - -/* This function allows for duplicate names in the table of named substrings. -It returns the number of the first one that was set in a pattern match. - -Arguments: - code the compiled regex - stringname the name of the capturing substring - ovector the vector of matched substrings - -Returns: the number of the first that is set, - or the number of the last one if none are set, - or a negative number on error -*/ - -typedef unsigned char uschar; - -int -njg_get_first_set(const pcre *code, const char *stringname, const int *ovector) -{ -const real_pcre *re = (const real_pcre *)code; -int entrysize; -char *first, *last; -uschar *entry; -if ((re->options & (PCRE_DUPNAMES | PCRE_JCHANGED)) == 0) - return pcre_get_stringnumber(code, stringname); -entrysize = pcre_get_stringtable_entries(code, stringname, &first, &last); -if (entrysize <= 0) return entrysize; -for (entry = (uschar *)first; entry <= (uschar *)last; entry += entrysize) - { - int n = (entry[0] << 8) + entry[1]; - if (ovector[n*2] >= 0) return n; - } -return (first[0] << 8) + first[1]; -} - // i18n (Internationalization) stuff // translate message (eg. "File cannot be opened") into locale-specific language diff --git a/regexp.cpp b/regexp.cpp index 3f228a71..1bb59c1f 100644 --- a/regexp.cpp +++ b/regexp.cpp @@ -171,21 +171,21 @@ string t_regexp::GetWildcard (const string& sName) const if (namecount > 0) { - unsigned char *name_table; int name_entry_size; unsigned char *tabptr; int ncapt; int jchanged; pcre_fullinfo(m_program, m_extra, PCRE_INFO_CAPTURECOUNT, &ncapt); - pcre_fullinfo(m_program, m_extra, PCRE_INFO_NAMETABLE, &name_table); + pcre_fullinfo(m_program, m_extra, PCRE_INFO_NAMETABLE, &tabptr); pcre_fullinfo(m_program, m_extra, PCRE_INFO_NAMEENTRYSIZE, &name_entry_size); pcre_fullinfo(m_program, m_extra, PCRE_INFO_JCHANGED, &jchanged); - tabptr = name_table; set found_strings; for (int i = 0; i < namecount; i++, tabptr += name_entry_size) { int n = (tabptr[0] << 8) | tabptr[1]; const unsigned char * name = tabptr + 2; + if (strcmp (sName.c_str (), (LPCTSTR) name) != 0) // skip if wrong name + continue; // if duplicates were possible then ... if (jchanged) { diff --git a/regexp.h b/regexp.h index a1f73bce..ac8838a2 100644 --- a/regexp.h +++ b/regexp.h @@ -20,9 +20,6 @@ #include "pcre\pcre.h" -// for duplicate named wildcards -int njg_get_first_set(const pcre *code, const char *stringname, const int *ovector); - // compiled regular expression type class t_regexp