diff options
author | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2013-09-24 13:29:52 +0000 |
---|---|---|
committer | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2013-09-24 13:29:52 +0000 |
commit | 9ee7ed799de3b09ef90511dd85a93ff687af1116 (patch) | |
tree | 944712cd51cdc1a6f789ee99b26ff8011ccd4371 /usr.bin | |
parent | 5d1a68f4ddee8b6577d93517cee6c7ed9941fc5a (diff) |
rename re_match to regex_match to prevent a namespace conflict on Linux as
reported by Han Boetes.
while here, rename re_buff accordingly for consistency.
ok florian@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mg/re_search.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/usr.bin/mg/re_search.c b/usr.bin/mg/re_search.c index 87f559e2725..cde1c2a2721 100644 --- a/usr.bin/mg/re_search.c +++ b/usr.bin/mg/re_search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: re_search.c,v 1.27 2013/05/31 18:03:45 lum Exp $ */ +/* $OpenBSD: re_search.c,v 1.28 2013/09/24 13:29:51 jasper Exp $ */ /* This file is in the public domain. */ @@ -120,8 +120,8 @@ re_searchagain(int f, int n) } /* Compiled regex goes here-- changed only when new pattern read */ -static regex_t re_buff; -static regmatch_t re_match[RE_NMATCH]; +static regex_t regex_buff; +static regmatch_t regex_match[RE_NMATCH]; /* * Re-Query Replace. @@ -152,14 +152,14 @@ retry: update(CMODE); switch (getkey(FALSE)) { case ' ': - plen = re_match[0].rm_eo - re_match[0].rm_so; + plen = regex_match[0].rm_eo - regex_match[0].rm_so; if (re_doreplace((RSIZE)plen, news) == FALSE) return (FALSE); rcnt++; break; case '.': - plen = re_match[0].rm_eo - re_match[0].rm_so; + plen = regex_match[0].rm_eo - regex_match[0].rm_so; if (re_doreplace((RSIZE)plen, news) == FALSE) return (FALSE); rcnt++; @@ -173,7 +173,7 @@ retry: goto stopsearch; case '!': do { - plen = re_match[0].rm_eo - re_match[0].rm_so; + plen = regex_match[0].rm_eo - regex_match[0].rm_so; if (re_doreplace((RSIZE)plen, news) == FALSE) return (FALSE); rcnt++; @@ -262,10 +262,10 @@ re_doreplace(RSIZE plen, char *st) } else { if (num >= RE_NMATCH) return (FALSE); - k = re_match[num].rm_eo - re_match[num].rm_so; + k = regex_match[num].rm_eo - regex_match[num].rm_so; if (j + k >= REPLEN) return (FALSE); - bcopy(&(clp->l_text[re_match[num].rm_so]), + bcopy(&(clp->l_text[regex_match[num].rm_so]), &repstr[j], k); j += k; if (*st == '\0') @@ -320,15 +320,15 @@ re_forwsrch(void) * always makes the last line empty so this is good. */ while (clp != (curbp->b_headp)) { - re_match[0].rm_so = tbo; - re_match[0].rm_eo = llength(clp); - error = regexec(&re_buff, ltext(clp), RE_NMATCH, re_match, + regex_match[0].rm_so = tbo; + regex_match[0].rm_eo = llength(clp); + error = regexec(®ex_buff, ltext(clp), RE_NMATCH, regex_match, REG_STARTEND); if (error != 0) { clp = lforw(clp); tbo = 0; } else { - curwp->w_doto = re_match[0].rm_eo; + curwp->w_doto = regex_match[0].rm_eo; curwp->w_dotp = clp; curwp->w_rflag |= WFMOVE; return (TRUE); @@ -366,27 +366,27 @@ re_backsrch(void) * always makes the last line empty so this is good. */ while (clp != (curbp->b_headp)) { - re_match[0].rm_so = 0; - re_match[0].rm_eo = llength(clp); + regex_match[0].rm_so = 0; + regex_match[0].rm_eo = llength(clp); lastmatch.rm_so = -1; /* * Keep searching until we don't match any longer. Assumes a - * non-match does not modify the re_match array. We have to + * non-match does not modify the regex_match array. We have to * do this character-by-character after the first match since * POSIX regexps don't give you a way to do reverse matches. */ - while (!regexec(&re_buff, ltext(clp), RE_NMATCH, re_match, - REG_STARTEND) && re_match[0].rm_so < tbo) { - memcpy(&lastmatch, &re_match[0], sizeof(regmatch_t)); - re_match[0].rm_so++; - re_match[0].rm_eo = llength(clp); + while (!regexec(®ex_buff, ltext(clp), RE_NMATCH, regex_match, + REG_STARTEND) && regex_match[0].rm_so < tbo) { + memcpy(&lastmatch, ®ex_match[0], sizeof(regmatch_t)); + regex_match[0].rm_so++; + regex_match[0].rm_eo = llength(clp); } if (lastmatch.rm_so == -1) { clp = lback(clp); tbo = llength(clp); } else { - memcpy(&re_match[0], &lastmatch, sizeof(regmatch_t)); - curwp->w_doto = re_match[0].rm_so; + memcpy(®ex_match[0], &lastmatch, sizeof(regmatch_t)); + curwp->w_doto = regex_match[0].rm_so; curwp->w_dotp = clp; curwp->w_rflag |= WFMOVE; return (TRUE); @@ -425,11 +425,11 @@ re_readpattern(char *prompt) else flags = REG_EXTENDED; if (dofree) - regfree(&re_buff); - error = regcomp(&re_buff, re_pat, flags); + regfree(®ex_buff); + error = regcomp(®ex_buff, re_pat, flags); if (error != 0) { char message[256]; - regerror(error, &re_buff, message, sizeof(message)); + regerror(error, ®ex_buff, message, sizeof(message)); ewprintf("Regex Error: %s", message); re_pat[0] = '\0'; return (FALSE); @@ -519,9 +519,9 @@ killmatches(int cond) while (clp != (curbp->b_headp)) { /* see if line matches */ - re_match[0].rm_so = 0; - re_match[0].rm_eo = llength(clp); - error = regexec(&re_buff, ltext(clp), RE_NMATCH, re_match, + regex_match[0].rm_so = 0; + regex_match[0].rm_eo = llength(clp); + error = regexec(®ex_buff, ltext(clp), RE_NMATCH, regex_match, REG_STARTEND); /* Delete line when appropriate */ @@ -594,9 +594,9 @@ countmatches(int cond) while (clp != (curbp->b_headp)) { /* see if line matches */ - re_match[0].rm_so = 0; - re_match[0].rm_eo = llength(clp); - error = regexec(&re_buff, ltext(clp), RE_NMATCH, re_match, + regex_match[0].rm_so = 0; + regex_match[0].rm_eo = llength(clp); + error = regexec(®ex_buff, ltext(clp), RE_NMATCH, regex_match, REG_STARTEND); /* Count line when appropriate */ |