*
* This code draws many ideas from the regular expression packages by
* Henry Spencer of the University of Toronto and Richard Stallman of
- * the Free Software Foundation.
*
* Emacs-specific code and syntax table code is almost directly borrowed
* from GNU regexp.
* Eric Bollengier April 2007
*/
/*
- Bacula® - The Network Backup Solution
-
- Copyright (C) 2006-2010 Free Software Foundation Europe e.V.
-
- The main author of Bacula is Kern Sibbald, with contributions from
- many others, a complete list can be found in the file AUTHORS.
- This program is Free Software; you can redistribute it and/or
- modify it under the terms of version two of the GNU General Public
- License as published by the Free Software Foundation and included
- in the file LICENSE.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
- Bacula® is a registered trademark of Kern Sibbald.
- The licensor of Bacula is the Free Software Foundation Europe
- (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
- Switzerland, email:ftf@fsfeurope.org.
+ Bacula(R) - The Network Backup Solution
+
+ Copyright (C) 2000-2016 Kern Sibbald
+
+ The original author of Bacula is Kern Sibbald, with contributions
+ from many others, a complete list can be found in the file AUTHORS.
+
+ You may use this file and others of this release according to the
+ license defined in the LICENSE file, which includes the Affero General
+ Public License, v3.0 ("AGPLv3") and some additional permissions and
+ terms pursuant to its AGPLv3 Section 7.
+
+ This notice must be preserved when any source code is
+ conveyed and/or propagated.
+
+ Bacula(R) is a registered trademark of Kern Sibbald.
*/
} cntr;
} item_t;
-#define STACK_PAGE_SIZE 256
+#define B_STACK_PAGE_SIZE 256
#define NUM_REGISTERS 256
/* A 'page' of stack items. */
typedef struct item_page_t {
- item_t items[STACK_PAGE_SIZE];
+ item_t items[B_STACK_PAGE_SIZE];
struct item_page_t *prev;
struct item_page_t *next;
} item_page_t;
struct {
/* index into the current page. If index == 0 and you need
* to pop an item, move to the previous page and set index
- * = STACK_PAGE_SIZE - 1. Otherwise decrement index to
- * push a page. If index == STACK_PAGE_SIZE and you need
+ * = B_STACK_PAGE_SIZE - 1. Otherwise decrement index to
+ * push a page. If index == B_STACK_PAGE_SIZE and you need
* to push a page move to the next page and set index =
* 0. If there is no new next page, allocate a new page
* and link it in. Otherwise, increment index to push a
if (stack.current->prev == NULL) \
on_error; \
stack.current = stack.current->prev; \
- stack.index += STACK_PAGE_SIZE; \
+ stack.index += B_STACK_PAGE_SIZE; \
}
/* Store a pointer to the previous item on the stack. Used to pop an
if (stack.current->prev == NULL) \
on_error; \
stack.current = stack.current->prev; \
- stack.index = STACK_PAGE_SIZE - 1; \
+ stack.index = B_STACK_PAGE_SIZE - 1; \
} \
else \
{ \
* on to the stack. */
#define STACK_NEXT(stack, top, on_error) \
-if (stack.index == STACK_PAGE_SIZE) \
+if (stack.index == B_STACK_PAGE_SIZE) \
{ \
if (stack.current->next == NULL) \
{ \
if (current->prev == NULL) \
on_error; \
current = current->prev; \
- index += STACK_PAGE_SIZE; \
+ index += B_STACK_PAGE_SIZE; \
} \
top = &(current->items[index]); \
}
{ \
if (stack.current->prev == NULL) \
on_error; \
- top = &(stack.current->prev->items[STACK_PAGE_SIZE - 1]); \
+ top = &(stack.current->prev->items[B_STACK_PAGE_SIZE - 1]); \
} \
else \
{ \
bufp->fastmap_accurate = 1;
}
-/*
+/*
* star is coded as:
* 1: failure_jump 2
* ... code for operand of star
char *p, *lcase = bstrdup(regex);
for( p = lcase; *p ; p++) {
*p = tolower(*p);
- }
+ }
re_compile_pattern(bufp, (unsigned char *)lcase);
bfree(lcase);
} else {
return 0;
}
-void re_registers_to_regmatch(regexp_registers_t old_regs,
- regmatch_t pmatch[],
+void re_registers_to_regmatch(regexp_registers_t old_regs,
+ regmatch_t pmatch[],
size_t nmatch)
{
size_t i=0;
-
+
/* We have to set the last entry to -1 */
nmatch = nmatch - 1;
for (i=0; (i < nmatch) && (old_regs->start[i] > -1) ; i++) {
}
pmatch[i].rm_eo = pmatch[i].rm_so = -1;
-}
+}
int regexec(regex_t * preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags)
int len = strlen(string);
struct re_registers regs;
stat = re_search(preg, (unsigned char *)string, len, 0, len, ®s);
- if (stat >= 0) {
+ if (stat >= 0 && nmatch > 0) {
re_registers_to_regmatch(®s, pmatch, nmatch);
}
- /* stat is the start position in the string base 0 where
+ /* stat is the start position in the string base 0 where
* the pattern was found or negative if not found.
*/
return stat < 0 ? -1 : 0;