summaryrefslogtreecommitdiff
path: root/regexp.c
diff options
context:
space:
mode:
authorMark Whitley <markw@lineo.com>2000-06-28 21:59:31 +0000
committerMark Whitley <markw@lineo.com>2000-06-28 21:59:31 +0000
commit268b8c4f387b9019bbb3591fb07403925d55d0c5 (patch)
tree865886ff91af78d6425ff766efd3941e96526b85 /regexp.c
parent0c96eba3de7e81e310f30e66bb595980ea13f979 (diff)
downloadbusybox-w32-268b8c4f387b9019bbb3591fb07403925d55d0c5.tar.gz
busybox-w32-268b8c4f387b9019bbb3591fb07403925d55d0c5.tar.bz2
busybox-w32-268b8c4f387b9019bbb3591fb07403925d55d0c5.zip
Moved some function decls, a struct, and a #define from regexp.h into here.
Also static-ified said functions so they do not have namespace conflicts with the libc regex functions.
Diffstat (limited to '')
-rw-r--r--regexp.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/regexp.c b/regexp.c
index c271412cb..6fedb01ba 100644
--- a/regexp.c
+++ b/regexp.c
@@ -8,6 +8,21 @@
8#include <ctype.h> 8#include <ctype.h>
9 9
10 10
11#define NSUBEXP 10
12typedef struct regexp {
13 char *startp[NSUBEXP];
14 char *endp[NSUBEXP];
15 int minlen; /* length of shortest possible match */
16 char first; /* first character, if known; else \0 */
17 char bol; /* boolean: must start at beginning of line? */
18 char program[1]; /* Unwarranted chumminess with compiler. */
19} regexp;
20
21
22static regexp *regcomp(char* text);
23static int regexec(struct regexp* re, char* str, int bol, int ignoreCase);
24static void regsub(struct regexp* re, char* src, char* dst);
25
11#if ( defined BB_GREP || defined BB_SED) 26#if ( defined BB_GREP || defined BB_SED)
12 27
13/* This also tries to find a needle in a haystack, but uses 28/* This also tries to find a needle in a haystack, but uses
@@ -467,7 +482,7 @@ static int match(regexp * re, char *str, char *prog, char *here,
467 482
468 483
469/* This function compiles a regexp. */ 484/* This function compiles a regexp. */
470extern regexp *regcomp(char *text) 485static regexp *regcomp(char *text)
471{ 486{
472 int needfirst; 487 int needfirst;
473 unsigned size; 488 unsigned size;
@@ -595,7 +610,7 @@ extern regexp *regcomp(char *text)
595/* str -- the string to search through */ 610/* str -- the string to search through */
596/* bol -- does str start at the beginning of a line? (boolean) */ 611/* bol -- does str start at the beginning of a line? (boolean) */
597/* ignoreCase -- ignoreCase or not */ 612/* ignoreCase -- ignoreCase or not */
598extern int regexec(struct regexp *re, char *str, int bol, int ignoreCase) 613static int regexec(struct regexp *re, char *str, int bol, int ignoreCase)
599{ 614{
600 char *prog; /* the entry point of re->program */ 615 char *prog; /* the entry point of re->program */
601 int len; /* length of the string */ 616 int len; /* length of the string */
@@ -644,7 +659,7 @@ extern int regexec(struct regexp *re, char *str, int bol, int ignoreCase)
644 659
645#if defined BB_SED 660#if defined BB_SED
646/* This performs substitutions after a regexp match has been found. */ 661/* This performs substitutions after a regexp match has been found. */
647extern void regsub(regexp * re, char *src, char *dst) 662static void regsub(regexp * re, char *src, char *dst)
648{ 663{
649 char *cpy; 664 char *cpy;
650 char *end; 665 char *end;