summaryrefslogtreecommitdiffstats
path: root/lib/libc/regex/regcomp.c
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2017-05-07 01:31:42 +0000
committerpfg <pfg@FreeBSD.org>2017-05-07 01:31:42 +0000
commit7a027d3bd08849589328b2a085d33dea2874465a (patch)
tree4057c07ffd45d6fea0e1912c8f19500125498605 /lib/libc/regex/regcomp.c
parentcca5af1b9cc197e4953c52bd73cf0d77e87c7484 (diff)
downloadFreeBSD-src-7a027d3bd08849589328b2a085d33dea2874465a.zip
FreeBSD-src-7a027d3bd08849589328b2a085d33dea2874465a.tar.gz
MFC r317346:
regex: unsign and constify some variables. Taking some hints from the regex variant in nvi(1) and higher-level compiler warnings, update some types in our regex(3) implementation. Joint work with: Kyle Evans
Diffstat (limited to 'lib/libc/regex/regcomp.c')
-rw-r--r--lib/libc/regex/regcomp.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index a3968cc..dfb02c6 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -66,8 +66,8 @@ __FBSDID("$FreeBSD$");
* other clumsinesses
*/
struct parse {
- char *next; /* next character in RE */
- char *end; /* end of string (-> NUL normally) */
+ const char *next; /* next character in RE */
+ const char *end; /* end of string (-> NUL normally) */
int error; /* has an error been seen? */
sop *strip; /* malloced strip */
sopno ssize; /* malloced strip size (allocated) */
@@ -207,7 +207,7 @@ regcomp(regex_t * __restrict preg,
return(REG_INVARG);
len = preg->re_endp - pattern;
} else
- len = strlen((char *)pattern);
+ len = strlen(pattern);
/* do the mallocs early so failure handling is easy */
g = (struct re_guts *)malloc(sizeof(struct re_guts));
@@ -239,7 +239,7 @@ regcomp(regex_t * __restrict preg,
/* set things up */
p->g = g;
- p->next = (char *)pattern; /* convenience; we do not modify it */
+ p->next = pattern; /* convenience; we do not modify it */
p->end = p->next + len;
p->error = 0;
p->ncsalloc = 0;
@@ -840,7 +840,7 @@ p_b_term(struct parse *p, cset *cs)
static void
p_b_cclass(struct parse *p, cset *cs)
{
- char *sp = p->next;
+ const char *sp = p->next;
size_t len;
wctype_t wct;
char clname[16];
@@ -903,12 +903,11 @@ static wint_t /* value of collating element */
p_b_coll_elem(struct parse *p,
wint_t endc) /* name ended by endc,']' */
{
- char *sp = p->next;
+ const char *sp = p->next;
struct cname *cp;
- int len;
mbstate_t mbs;
wchar_t wc;
- size_t clen;
+ size_t clen, len;
while (MORE() && !SEETWO(endc, ']'))
NEXT();
@@ -955,8 +954,8 @@ othercase(wint_t ch)
static void
bothcases(struct parse *p, wint_t ch)
{
- char *oldnext = p->next;
- char *oldend = p->end;
+ const char *oldnext = p->next;
+ const char *oldend = p->end;
char bracket[3 + MB_LEN_MAX];
size_t n;
mbstate_t mbs;
@@ -1009,8 +1008,8 @@ ordinary(struct parse *p, wint_t ch)
static void
nonnewline(struct parse *p)
{
- char *oldnext = p->next;
- char *oldend = p->end;
+ const char *oldnext = p->next;
+ const char *oldend = p->end;
char bracket[4];
p->next = bracket;
OpenPOWER on IntegriCloud