=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mg/re_search.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- src/usr.bin/mg/re_search.c 2013/05/31 18:03:45 1.27 +++ src/usr.bin/mg/re_search.c 2013/09/24 13:29:51 1.28 @@ -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 @@ } /* 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 @@ 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 @@ 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 @@ } 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 @@ * 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 @@ * 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 @@ 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 @@ 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 @@ 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 */