Mail Archives: djgpp-workers/1998/07/08/12:22:53
On Wed, 8 Jul 1998 18:09:29 +0300 (IDT), you wrote:
>> As you say, we could just get rid of the warnings with flags. My
>> patch does things at such a minor scope that it produces the same
>> effect -- I'm just not letting the compiler guess. Both paths are
>> open -- DJ?
>>
>> I like the warning flag option best. Or, rather, I find it's
>> advantages make it logically tolerable.
>
>My vote is also to leave the warning options on and fix the sources.
Oh, actually, I was meaning to vote to leave the source as it is. I
had reversed the logic in that sentence, too, hoping it would be
clearer. English needs an ANSI committee.
What I meant by logically tolerable is that the compiler does it fine
right now, doing similar things to what I do explicitly. Obviously,
it has always made the best choice. I suppose I'm neutral on the
subject, since there is little chance I've made a bad decision. Okay,
I'm for changing the sources. Don't want to portray a bad image.
- Burton Radons
*** src/libc/posix/regex~1/cclass.h Tue Jun 13 01:35:08 1995
--- src/libc/posix/regex/cclass.h Wed Jul 8 05:40:48 1998
***************
*** 1,32 ****
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
/* character-class table */
static struct cclass {
! char *name;
! char *chars;
! char *multis;
} cclasses[] = {
! "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
! 0123456789", "",
! "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
! "",
! "blank", " \t", "",
! "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
! \25\26\27\30\31\32\33\34\35\36\37\177", "",
! "digit", "0123456789", "",
! "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
! "",
! "lower", "abcdefghijklmnopqrstuvwxyz",
! "",
! "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
! "",
! "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
! "",
! "space", "\t\n\v\f\r ", "",
! "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
! "",
! "xdigit", "0123456789ABCDEFabcdef",
! "",
! NULL, 0, ""
};
--- 1,32 ----
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
/* character-class table */
static struct cclass {
! const char *name;
! const char *chars;
! const char *multis;
} cclasses[] = {
! { "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
! 0123456789", "" },
! { "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
! "" },
! { "blank", " \t", "" },
! { "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
! \25\26\27\30\31\32\33\34\35\36\37\177", "" },
! { "digit", "0123456789", "" },
! { "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
! "" },
! { "lower", "abcdefghijklmnopqrstuvwxyz",
! "" },
! { "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
! "" },
! { "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
! "" },
! { "space", "\t\n\v\f\r ", "" },
! { "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
! "" },
! { "xdigit", "0123456789ABCDEFabcdef",
! "" },
! { NULL, 0, "" }
};
*** src/libc/posix/regex~1/cname.h Tue Jun 13 01:35:08 1995
--- src/libc/posix/regex/cname.h Wed Jul 8 05:42:24 1998
***************
*** 1,103 ****
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
/* character-name table */
static struct cname {
! char *name;
! char code;
} cnames[] = {
! "NUL", '\0',
! "SOH", '\001',
! "STX", '\002',
! "ETX", '\003',
! "EOT", '\004',
! "ENQ", '\005',
! "ACK", '\006',
! "BEL", '\007',
! "alert", '\007',
! "BS", '\010',
! "backspace", '\b',
! "HT", '\011',
! "tab", '\t',
! "LF", '\012',
! "newline", '\n',
! "VT", '\013',
! "vertical-tab", '\v',
! "FF", '\014',
! "form-feed", '\f',
! "CR", '\015',
! "carriage-return", '\r',
! "SO", '\016',
! "SI", '\017',
! "DLE", '\020',
! "DC1", '\021',
! "DC2", '\022',
! "DC3", '\023',
! "DC4", '\024',
! "NAK", '\025',
! "SYN", '\026',
! "ETB", '\027',
! "CAN", '\030',
! "EM", '\031',
! "SUB", '\032',
! "ESC", '\033',
! "IS4", '\034',
! "FS", '\034',
! "IS3", '\035',
! "GS", '\035',
! "IS2", '\036',
! "RS", '\036',
! "IS1", '\037',
! "US", '\037',
! "space", ' ',
! "exclamation-mark", '!',
! "quotation-mark", '"',
! "number-sign", '#',
! "dollar-sign", '$',
! "percent-sign", '%',
! "ampersand", '&',
! "apostrophe", '\'',
! "left-parenthesis", '(',
! "right-parenthesis", ')',
! "asterisk", '*',
! "plus-sign", '+',
! "comma", ',',
! "hyphen", '-',
! "hyphen-minus", '-',
! "period", '.',
! "full-stop", '.',
! "slash", '/',
! "solidus", '/',
! "zero", '0',
! "one", '1',
! "two", '2',
! "three", '3',
! "four", '4',
! "five", '5',
! "six", '6',
! "seven", '7',
! "eight", '8',
! "nine", '9',
! "colon", ':',
! "semicolon", ';',
! "less-than-sign", '<',
! "equals-sign", '=',
! "greater-than-sign", '>',
! "question-mark", '?',
! "commercial-at", '@',
! "left-square-bracket", '[',
! "backslash", '\\',
! "reverse-solidus", '\\',
! "right-square-bracket", ']',
! "circumflex", '^',
! "circumflex-accent", '^',
! "underscore", '_',
! "low-line", '_',
! "grave-accent", '`',
! "left-brace", '{',
! "left-curly-bracket", '{',
! "vertical-line", '|',
! "right-brace", '}',
! "right-curly-bracket", '}',
! "tilde", '~',
! "DEL", '\177',
! NULL, 0,
};
--- 1,103 ----
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
/* character-name table */
static struct cname {
! const char *name;
! const char code;
} cnames[] = {
! { "NUL", '\0' },
! { "SOH", '\001' },
! { "STX", '\002' },
! { "ETX", '\003' },
! { "EOT", '\004' },
! { "ENQ", '\005' },
! { "ACK", '\006' },
! { "BEL", '\007' },
! { "alert", '\007' },
! { "BS", '\010' },
! { "backspace", '\b' },
! { "HT", '\011' },
! { "tab", '\t' },
! { "LF", '\012' },
! { "newline", '\n' },
! { "VT", '\013' },
! { "vertical-tab", '\v' },
! { "FF", '\014' },
! { "form-feed", '\f' },
! { "CR", '\015' },
! { "carriage-return", '\r' },
! { "SO", '\016' },
! { "SI", '\017' },
! { "DLE", '\020' },
! { "DC1", '\021' },
! { "DC2", '\022' },
! { "DC3", '\023' },
! { "DC4", '\024' },
! { "NAK", '\025' },
! { "SYN", '\026' },
! { "ETB", '\027' },
! { "CAN", '\030' },
! { "EM", '\031' },
! { "SUB", '\032' },
! { "ESC", '\033' },
! { "IS4", '\034' },
! { "FS", '\034' },
! { "IS3", '\035' },
! { "GS", '\035' },
! { "IS2", '\036' },
! { "RS", '\036' },
! { "IS1", '\037' },
! { "US", '\037' },
! { "space", ' ' },
! { "exclamation-mark", '!' },
! { "quotation-mark", '"' },
! { "number-sign", '#' },
! { "dollar-sign", '$' },
! { "percent-sign", '%' },
! { "ampersand", '&' },
! { "apostrophe", '\'' },
! { "left-parenthesis", '(' },
! { "right-parenthesis", ')' },
! { "asterisk", '*' },
! { "plus-sign", '+' },
! { "comma", ',' },
! { "hyphen", '-' },
! { "hyphen-minus", '-' },
! { "period", '.' },
! { "full-stop", '.' },
! { "slash", '/' },
! { "solidus", '/' },
! { "zero", '0' },
! { "one", '1' },
! { "two", '2' },
! { "three", '3' },
! { "four", '4' },
! { "five", '5' },
! { "six", '6' },
! { "seven", '7' },
! { "eight", '8' },
! { "nine", '9' },
! { "colon", ':' },
! { "semicolon", ';' },
! { "less-than-sign", '<' },
! { "equals-sign", '=' },
! { "greater-than-sign", '>' },
! { "question-mark", '?' },
! { "commercial-at", '@' },
! { "left-square-bracket", '[' },
! { "backslash", '\\' },
! { "reverse-solidus", '\\' },
! { "right-square-bracket", ']' },
! { "circumflex", '^' },
! { "circumflex-accent", '^' },
! { "underscore", '_' },
! { "low-line", '_' },
! { "grave-accent", '`' },
! { "left-brace", '{' },
! { "left-curly-bracket", '{' },
! { "vertical-line", '|' },
! { "right-brace", '}' },
! { "right-curly-bracket", '}' },
! { "tilde", '~' },
! { "DEL", '\177' },
! { NULL, 0 }
};
*** src/libc/posix/regex~1/debug.c Tue Jun 13 01:35:08 1995
--- src/libc/posix/regex/debug.c Wed Jul 8 05:31:44 1998
***************
*** 118,124 ****
fprintf(d, "missing initial OEND!\n");
for (s = &g->strip[1]; !done; s++) {
opnd = OPND(*s);
! switch (OP(*s)) {
case OEND:
fprintf(d, "\n");
done = 1;
--- 118,124 ----
fprintf(d, "missing initial OEND!\n");
for (s = &g->strip[1]; !done; s++) {
opnd = OPND(*s);
! switch ((int) OP(*s)) {
case OEND:
fprintf(d, "\n");
done = 1;
***************
*** 198,223 ****
break;
case OCH_:
fprintf(d, "<");
! if (OP(*(s+opnd)) != OOR2)
fprintf(d, "<%ld>", (long)opnd);
break;
case OOR1:
! if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_)
fprintf(d, "<%ld>", (long)opnd);
fprintf(d, "|");
break;
case OOR2:
fprintf(d, "|");
! if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH)
fprintf(d, "<%ld>", (long)opnd);
break;
case O_CH:
! if (OP(*(s-opnd)) != OOR1)
fprintf(d, "<%ld>", (long)opnd);
fprintf(d, ">");
break;
default:
! fprintf(d, "!%d(%d)!", OP(*s), opnd);
break;
}
if (!done)
--- 198,223 ----
break;
case OCH_:
fprintf(d, "<");
! if (OP(*(s+opnd)) != (unsigned) OOR2)
fprintf(d, "<%ld>", (long)opnd);
break;
case OOR1:
! if (OP(*(s-opnd)) != (unsigned) OOR1 && OP(*(s-opnd)) != (unsigned) OCH_)
fprintf(d, "<%ld>", (long)opnd);
fprintf(d, "|");
break;
case OOR2:
fprintf(d, "|");
! if (OP(*(s+opnd)) != (unsigned) OOR2 && OP(*(s+opnd)) != (unsigned) O_CH)
fprintf(d, "<%ld>", (long)opnd);
break;
case O_CH:
! if (OP(*(s-opnd)) != (unsigned) OOR1)
fprintf(d, "<%ld>", (long)opnd);
fprintf(d, ">");
break;
default:
! fprintf(d, "!%ld(%ld)!", OP(*s), opnd);
break;
}
if (!done)
*** src/libc/posix/regex~1/engine.c Tue Jun 13 01:35:08 1995
--- src/libc/posix/regex/engine.c Wed Jul 8 05:49:44 1998
***************
*** 66,72 ****
static int /* 0 success, REG_NOMATCH failure */
matcher(g, string, nmatch, pmatch, eflags)
register struct re_guts *g;
! char *string;
size_t nmatch;
regmatch_t pmatch[];
int eflags;
--- 66,72 ----
static int /* 0 success, REG_NOMATCH failure */
matcher(g, string, nmatch, pmatch, eflags)
register struct re_guts *g;
! const char *string;
size_t nmatch;
regmatch_t pmatch[];
int eflags;
***************
*** 76,83 ****
struct match mv;
register struct match *m = &mv;
register char *dp;
! const register sopno gf = g->firststate+1; /* +1 for OEND */
! const register sopno gl = g->laststate;
char *start;
char *stop;
--- 76,83 ----
struct match mv;
register struct match *m = &mv;
register char *dp;
! register const sopno gf = g->firststate+1; /* +1 for OEND */
! register const sopno gl = g->laststate;
char *start;
char *stop;
***************
*** 85,95 ****
if (g->cflags®_NOSUB)
nmatch = 0;
if (eflags®_STARTEND) {
! start = string + pmatch[0].rm_so;
! stop = string + pmatch[0].rm_eo;
} else {
! start = string;
! stop = start + strlen(start);
}
if (stop < start)
return(REG_INVARG);
--- 85,95 ----
if (g->cflags®_NOSUB)
nmatch = 0;
if (eflags®_STARTEND) {
! (const char *) start = string + pmatch[0].rm_so;
! (const char *) stop = string + pmatch[0].rm_eo;
} else {
! (const char *) start = string;
! (const char *) stop = start + strlen(start);
}
if (stop < start)
return(REG_INVARG);
***************
*** 109,115 ****
m->eflags = eflags;
m->pmatch = NULL;
m->lastpos = NULL;
! m->offp = string;
m->beginp = start;
m->endp = stop;
STATESETUP(m, 4);
--- 109,115 ----
m->eflags = eflags;
m->pmatch = NULL;
m->lastpos = NULL;
! (const char *) m->offp = string;
m->beginp = start;
m->endp = stop;
STATESETUP(m, 4);
***************
*** 150,156 ****
STATETEARDOWN(m);
return(REG_ESPACE);
}
! for (i = 1; i <= m->g->nsub; i++)
m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
if (!g->backrefs && !(m->eflags®_BACKR)) {
NOTE("dissecting");
--- 150,156 ----
STATETEARDOWN(m);
return(REG_ESPACE);
}
! for (i = 1; (unsigned) i <= m->g->nsub; i++)
m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
if (!g->backrefs && !(m->eflags®_BACKR)) {
NOTE("dissecting");
***************
*** 207,214 ****
}
if (nmatch > 1) {
assert(m->pmatch != NULL);
! for (i = 1; i < nmatch; i++)
! if (i <= m->g->nsub)
pmatch[i] = m->pmatch[i];
else {
pmatch[i].rm_so = -1;
--- 207,214 ----
}
if (nmatch > 1) {
assert(m->pmatch != NULL);
! for (i = 1; (unsigned) i < nmatch; i++)
! if ((unsigned) i <= m->g->nsub)
pmatch[i] = m->pmatch[i];
else {
pmatch[i].rm_so = -1;
***************
*** 256,275 ****
for (ss = startst; ss < stopst; ss = es) {
/* identify end of subRE */
es = ss;
! switch (OP(m->g->strip[es])) {
case OPLUS_:
case OQUEST_:
es += OPND(m->g->strip[es]);
break;
case OCH_:
! while (OP(m->g->strip[es]) != O_CH)
es += OPND(m->g->strip[es]);
break;
}
es++;
/* figure out what it matched */
! switch (OP(m->g->strip[ss])) {
case OEND:
assert(nope);
break;
--- 256,275 ----
for (ss = startst; ss < stopst; ss = es) {
/* identify end of subRE */
es = ss;
! switch ((int) OP(m->g->strip[es])) {
case OPLUS_:
case OQUEST_:
es += OPND(m->g->strip[es]);
break;
case OCH_:
! while (OP(m->g->strip[es]) != (unsigned) O_CH)
es += OPND(m->g->strip[es]);
break;
}
es++;
/* figure out what it matched */
! switch ((int) OP(m->g->strip[ss])) {
case OEND:
assert(nope);
break;
***************
*** 376,382 ****
assert(OP(m->g->strip[esub]) == OOR2);
ssub = esub + 1;
esub += OPND(m->g->strip[esub]);
! if (OP(m->g->strip[esub]) == OOR2)
esub--;
else
assert(OP(m->g->strip[esub]) == O_CH);
--- 376,382 ----
assert(OP(m->g->strip[esub]) == OOR2);
ssub = esub + 1;
esub += OPND(m->g->strip[esub]);
! if (OP(m->g->strip[esub]) == (unsigned) OOR2)
esub--;
else
assert(OP(m->g->strip[esub]) == O_CH);
***************
*** 445,451 ****
/* get as far as we can with easy stuff */
hard = 0;
for (ss = startst; !hard && ss < stopst; ss++)
! switch (OP(s = m->g->strip[ss])) {
case OCHAR:
if (sp == stop || *sp++ != (char)OPND(s))
return(NULL);
--- 445,451 ----
/* get as far as we can with easy stuff */
hard = 0;
for (ss = startst; !hard && ss < stopst; ss++)
! switch ((int) OP(s = m->g->strip[ss])) {
case OCHAR:
if (sp == stop || *sp++ != (char)OPND(s))
return(NULL);
***************
*** 505,511 ****
do {
assert(OP(s) == OOR2);
ss += OPND(s);
! } while (OP(s = m->g->strip[ss]) != O_CH);
/* note that the ss++ gets us past the O_CH */
break;
default: /* have to make a choice */
--- 505,511 ----
do {
assert(OP(s) == OOR2);
ss += OPND(s);
! } while (OP(s = m->g->strip[ss]) != (unsigned) O_CH);
/* note that the ss++ gets us past the O_CH */
break;
default: /* have to make a choice */
***************
*** 522,528 ****
/* the hard stuff */
AT("hard", sp, stop, ss, stopst);
s = m->g->strip[ss];
! switch (OP(s)) {
case OBACK_: /* the vilest depths */
i = OPND(s);
assert(0 < i && i <= m->g->nsub);
--- 522,528 ----
/* the hard stuff */
AT("hard", sp, stop, ss, stopst);
s = m->g->strip[ss];
! switch ((int) OP(s)) {
case OBACK_: /* the vilest depths */
i = OPND(s);
assert(0 < i && i <= m->g->nsub);
***************
*** 536,542 ****
ssp = m->offp + m->pmatch[i].rm_so;
if (memcmp(sp, ssp, len) != 0)
return(NULL);
! while (m->g->strip[ss] != SOP(O_BACK, i))
ss++;
return(backref(m, sp+len, stop, ss+1, stopst, lev));
break;
--- 536,542 ----
ssp = m->offp + m->pmatch[i].rm_so;
if (memcmp(sp, ssp, len) != 0)
return(NULL);
! while (m->g->strip[ss] != (unsigned) SOP(O_BACK, i))
ss++;
return(backref(m, sp+len, stop, ss+1, stopst, lev));
break;
***************
*** 572,584 ****
if (dp != NULL)
return(dp);
/* that one missed, try next one */
! if (OP(m->g->strip[esub]) == O_CH)
return(NULL); /* there is none */
esub++;
! assert(OP(m->g->strip[esub]) == OOR2);
ssub = esub + 1;
esub += OPND(m->g->strip[esub]);
! if (OP(m->g->strip[esub]) == OOR2)
esub--;
else
assert(OP(m->g->strip[esub]) == O_CH);
--- 572,584 ----
if (dp != NULL)
return(dp);
/* that one missed, try next one */
! if (OP(m->g->strip[esub]) == (unsigned) O_CH)
return(NULL); /* there is none */
esub++;
! assert(OP(m->g->strip[esub]) == (unsigned) OOR2);
ssub = esub + 1;
esub += OPND(m->g->strip[esub]);
! if (OP(m->g->strip[esub]) == (unsigned) OOR2)
esub--;
else
assert(OP(m->g->strip[esub]) == O_CH);
***************
*** 614,619 ****
--- 614,620 ----
/* "can't happen" */
assert(nope);
/* NOTREACHED */
+ return NULL; /* Djgpp do not care */
}
/*
***************
*** 826,832 ****
for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) {
s = g->strip[pc];
! switch (OP(s)) {
case OEND:
assert(pc == stop-1);
break;
--- 827,833 ----
for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) {
s = g->strip[pc];
! switch ((int) OP(s)) {
case OEND:
assert(pc == stop-1);
break;
***************
*** 897,903 ****
case OOR1: /* done a branch, find the O_CH */
if (ISSTATEIN(aft, here)) {
for (look = 1;
! OP(s = g->strip[pc+look]) != O_CH;
look += OPND(s))
assert(OP(s) == OOR2);
FWD(aft, aft, look);
--- 898,904 ----
case OOR1: /* done a branch, find the O_CH */
if (ISSTATEIN(aft, here)) {
for (look = 1;
! OP(s = g->strip[pc+look]) != (unsigned) O_CH;
look += OPND(s))
assert(OP(s) == OOR2);
FWD(aft, aft, look);
***************
*** 905,912 ****
break;
case OOR2: /* propagate OCH_'s marking */
FWD(aft, aft, 1);
! if (OP(g->strip[pc+OPND(s)]) != O_CH) {
! assert(OP(g->strip[pc+OPND(s)]) == OOR2);
FWD(aft, aft, OPND(s));
}
break;
--- 906,913 ----
break;
case OOR2: /* propagate OCH_'s marking */
FWD(aft, aft, 1);
! if (OP(g->strip[pc+OPND(s)]) != (unsigned) O_CH) {
! assert(OP(g->strip[pc+OPND(s)]) == (unsigned) OOR2);
FWD(aft, aft, OPND(s));
}
break;
*** src/libc/posix/regex~1/engine.ih Tue Jun 13 01:35:08 1995
--- src/libc/posix/regex/engine.ih Wed Jul 8 05:49:10 1998
***************
*** 4,10 ****
#endif
/* === engine.c === */
! static int matcher (register struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
static char *dissect (register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
static char *backref (register struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev);
static char *fast (register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
--- 4,10 ----
#endif
/* === engine.c === */
! static int matcher (register struct re_guts *g, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
static char *dissect (register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
static char *backref (register struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev);
static char *fast (register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
*** src/libc/posix/regex~1/main.c Tue Jun 13 01:35:08 1995
--- src/libc/posix/regex/main.c Wed Jul 8 05:39:46 1998
***************
*** 4,9 ****
--- 4,11 ----
#include <sys/types.h>
#include <regex.h>
#include <assert.h>
+ #include <unistd.h>
+ #include <stdlib.h>
#include "main.ih"
***************
*** 18,32 ****
regoff_t endoff = 0;
! extern int split();
! extern void regprint();
/*
- main - do the simple case, hand off to regress() for regression
*/
! main(argc, argv)
! int argc;
! char *argv[];
{
regex_t re;
# define NS 10
--- 20,32 ----
regoff_t endoff = 0;
! extern int split(char *string, char *fields[], int nfields, const char *sep);
! extern void regprint(regex_t *r, FILE *d);
/*
- main - do the simple case, hand off to regress() for regression
*/
! int main(int argc, char *argv[])
{
regex_t re;
# define NS 10
***************
*** 78,84 ****
err = regcomp(&re, argv[optind++], copts);
if (err) {
len = regerror(err, &re, erbuf, sizeof(erbuf));
! fprintf(stderr, "error %s, %d/%d `%s'\n",
eprint(err), len, sizeof(erbuf), erbuf);
exit(status);
}
--- 78,84 ----
err = regcomp(&re, argv[optind++], copts);
if (err) {
len = regerror(err, &re, erbuf, sizeof(erbuf));
! fprintf(stderr, "error %s, %ld/%ld `%s'\n",
eprint(err), len, sizeof(erbuf), erbuf);
exit(status);
}
***************
*** 96,102 ****
err = regexec(&re, argv[optind], (size_t)NS, subs, eopts);
if (err) {
len = regerror(err, &re, erbuf, sizeof(erbuf));
! fprintf(stderr, "error %s, %d/%d `%s'\n",
eprint(err), len, sizeof(erbuf), erbuf);
exit(status);
}
--- 96,102 ----
err = regexec(&re, argv[optind], (size_t)NS, subs, eopts);
if (err) {
len = regerror(err, &re, erbuf, sizeof(erbuf));
! fprintf(stderr, "error %s, %ld/%ld `%s'\n",
eprint(err), len, sizeof(erbuf), erbuf);
exit(status);
}
***************
*** 104,110 ****
len = (int)(subs[0].rm_eo - subs[0].rm_so);
if (subs[0].rm_so != -1) {
if (len != 0)
! printf("match `%.*s'\n", len,
argv[optind] + subs[0].rm_so);
else
printf("match `'@%.1s\n",
--- 104,110 ----
len = (int)(subs[0].rm_eo - subs[0].rm_so);
if (subs[0].rm_so != -1) {
if (len != 0)
! printf("match `%.*s'\n", (int) len,
argv[optind] + subs[0].rm_so);
else
printf("match `'@%.1s\n",
***************
*** 134,142 ****
int i;
char erbuf[100];
size_t ne;
! char *badpat = "invalid regular expression";
# define SHORT 10
! char *bpname = "REG_BADPAT";
regex_t re;
while (fgets(inbuf, sizeof(inbuf), in) != NULL) {
--- 134,142 ----
int i;
char erbuf[100];
size_t ne;
! const char *badpat = "invalid regular expression";
# define SHORT 10
! const char *bpname = "REG_BADPAT";
regex_t re;
while (fgets(inbuf, sizeof(inbuf), in) != NULL) {
***************
*** 153,159 ****
}
for (i = 0; i < nf; i++)
if (strcmp(f[i], "\"\"") == 0)
! f[i] = "";
if (nf <= 3)
f[3] = NULL;
if (nf <= 4)
--- 153,159 ----
}
for (i = 0; i < nf; i++)
if (strcmp(f[i], "\"\"") == 0)
! (const char *) f[i] = "";
if (nf <= 3)
f[3] = NULL;
if (nf <= 4)
***************
*** 218,224 ****
char erbuf[100];
int err;
int len;
! char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE";
register int i;
char *grump;
char f0copy[1000];
--- 218,224 ----
char erbuf[100];
int err;
int len;
! const char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE";
register int i;
char *grump;
char f0copy[1000];
***************
*** 231,237 ****
if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
/* unexpected error or wrong error */
len = regerror(err, &re, erbuf, sizeof(erbuf));
! fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n",
line, type, eprint(err), len,
sizeof(erbuf), erbuf);
status = 1;
--- 231,237 ----
if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
/* unexpected error or wrong error */
len = regerror(err, &re, erbuf, sizeof(erbuf));
! fprintf(stderr, "%d: %s error %s, %d/%ld `%s'\n",
line, type, eprint(err), len,
sizeof(erbuf), erbuf);
status = 1;
***************
*** 262,268 ****
if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
/* unexpected error or wrong error */
len = regerror(err, &re, erbuf, sizeof(erbuf));
! fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
line, type, eprint(err), len,
sizeof(erbuf), erbuf);
status = 1;
--- 262,268 ----
if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
/* unexpected error or wrong error */
len = regerror(err, &re, erbuf, sizeof(erbuf));
! fprintf(stderr, "%d: %s exec error %s, %d/%ld `%s'\n",
line, type, eprint(err), len,
sizeof(erbuf), erbuf);
status = 1;
***************
*** 292,298 ****
nshould = split(f4, should+1, NSHOULD-1, ",");
if (nshould == 0) {
nshould = 1;
! should[1] = "";
}
for (i = 1; i < NSUBS; i++) {
grump = check(f2, subs[i], should[i]);
--- 292,298 ----
nshould = split(f4, should+1, NSHOULD-1, ",");
if (nshould == 0) {
nshould = 1;
! (const char *) should[1] = "";
}
for (i = 1; i < NSUBS; i++) {
grump = check(f2, subs[i], should[i]);
***************
*** 318,324 ****
{
register char *p;
register int o = (type == 'c') ? copts : eopts;
! register char *legal = (type == 'c') ? "bisnmp" : "^$#tl";
for (p = s; *p != '\0'; p++)
if (strchr(legal, *p) != NULL)
--- 318,324 ----
{
register char *p;
register int o = (type == 'c') ? copts : eopts;
! register const char *legal = (type == 'c') ? "bisnmp" : "^$#tl";
for (p = s; *p != '\0'; p++)
if (strchr(legal, *p) != NULL)
***************
*** 413,424 ****
register char *p;
static char grump[500];
register char *at = NULL;
if (should != NULL && strcmp(should, "-") == 0)
should = NULL;
if (should != NULL && should[0] == '@') {
at = should + 1;
! should = "";
}
/* check rm_so and rm_eo for consistency */
--- 413,427 ----
register char *p;
static char grump[500];
register char *at = NULL;
+ char *nomatch;
+
+ (const char *) nomatch = "did not match";
if (should != NULL && strcmp(should, "-") == 0)
should = NULL;
if (should != NULL && should[0] == '@') {
at = should + 1;
! (const char *) should = "";
}
/* check rm_so and rm_eo for consistency */
***************
*** 435,444 ****
if (sub.rm_so == -1 && should == NULL)
return(NULL);
if (sub.rm_so == -1)
! return("did not match");
/* check for in range */
! if (sub.rm_eo > strlen(str)) {
sprintf(grump, "start %ld end %ld, past end of string",
(long)sub.rm_so, (long)sub.rm_eo);
return(grump);
--- 438,447 ----
if (sub.rm_so == -1 && should == NULL)
return(NULL);
if (sub.rm_so == -1)
! return(nomatch);
/* check for in range */
! if ((unsigned) sub.rm_eo > strlen(str)) {
sprintf(grump, "start %ld end %ld, past end of string",
(long)sub.rm_so, (long)sub.rm_eo);
return(grump);
*** src/libc/posix/regex~1/regcomp.c Tue Jun 13 01:35:08 1995
--- src/libc/posix/regex/regcomp.c Wed Jul 8 05:44:14 1998
***************
*** 109,115 ****
return(REG_INVARG);
len = preg->re_endp - pattern;
} else
! len = strlen((char *)pattern);
/* do the mallocs early so failure handling is easy */
g = (struct re_guts *)malloc(sizeof(struct re_guts) +
--- 109,115 ----
return(REG_INVARG);
len = preg->re_endp - pattern;
} else
! len = strlen((const char *)pattern);
/* do the mallocs early so failure handling is easy */
g = (struct re_guts *)malloc(sizeof(struct re_guts) +
***************
*** 126,132 ****
/* set things up */
p->g = g;
! p->next = (char *)pattern; /* convenience; we do not modify it */
p->end = p->next + len;
p->error = 0;
p->ncsalloc = 0;
--- 126,132 ----
/* set things up */
p->g = g;
! (const char *) p->next = (const char *)pattern; /* convenience; we do not modify it */
p->end = p->next + len;
p->error = 0;
p->ncsalloc = 0;
***************
*** 741,750 ****
return;
}
! u = cp->chars;
while ((c = *u++) != '\0')
CHadd(cs, c);
! for (u = cp->multis; *u != '\0'; u += strlen(u) + 1)
MCadd(p, cs, u);
}
--- 741,750 ----
return;
}
! (const char *) u = cp->chars;
while ((c = *u++) != '\0')
CHadd(cs, c);
! for ((const char *) u = cp->multis; *u != '\0'; u += strlen(u) + 1)
MCadd(p, cs, u);
}
***************
*** 1061,1067 ****
register cset *top = &p->g->sets[p->g->ncsets];
register size_t css = (size_t)p->g->csetsize;
! for (i = 0; i < css; i++)
CHsub(cs, i);
if (cs == top-1) /* recover only the easy case */
p->g->ncsets--;
--- 1061,1067 ----
register cset *top = &p->g->sets[p->g->ncsets];
register size_t css = (size_t)p->g->csetsize;
! for (i = 0; (unsigned) i < css; i++)
CHsub(cs, i);
if (cs == top-1) /* recover only the easy case */
p->g->ncsets--;
***************
*** 1092,1101 ****
for (cs2 = &p->g->sets[0]; cs2 < top; cs2++)
if (cs2->hash == h && cs2 != cs) {
/* maybe */
! for (i = 0; i < css; i++)
if (!!CHIN(cs2, i) != !!CHIN(cs, i))
break; /* no */
! if (i == css)
break; /* yes */
}
--- 1092,1101 ----
for (cs2 = &p->g->sets[0]; cs2 < top; cs2++)
if (cs2->hash == h && cs2 != cs) {
/* maybe */
! for (i = 0; (unsigned) i < css; i++)
if (!!CHIN(cs2, i) != !!CHIN(cs, i))
break; /* no */
! if ((unsigned) i == css)
break; /* yes */
}
***************
*** 1119,1125 ****
register int i;
register size_t css = (size_t)p->g->csetsize;
! for (i = 0; i < css; i++)
if (CHIN(cs, i))
return((char)i);
assert(never);
--- 1119,1125 ----
register int i;
register size_t css = (size_t)p->g->csetsize;
! for (i = 0; (unsigned) i < css; i++)
if (CHIN(cs, i))
return((char)i);
assert(never);
***************
*** 1139,1145 ****
register size_t css = (size_t)p->g->csetsize;
register int n = 0;
! for (i = 0; i < css; i++)
if (CHIN(cs, i))
n++;
return(n);
--- 1139,1145 ----
register size_t css = (size_t)p->g->csetsize;
register int n = 0;
! for (i = 0; (unsigned) i < css; i++)
if (CHIN(cs, i))
n++;
return(n);
***************
*** 1514,1520 ****
scan = g->strip + 1;
do {
s = *scan++;
! switch (OP(s)) {
case OCHAR: /* sequence member */
if (newlen == 0) /* new sequence */
newstart = scan - 1;
--- 1514,1520 ----
scan = g->strip + 1;
do {
s = *scan++;
! switch ((int) OP(s)) {
case OCHAR: /* sequence member */
if (newlen == 0) /* new sequence */
newstart = scan - 1;
***************
*** 1531,1542 ****
scan += OPND(s);
s = *scan;
/* assert() interferes w debug printouts */
! if (OP(s) != O_QUEST && OP(s) != O_CH &&
! OP(s) != OOR2) {
g->iflags |= BAD;
return;
}
! } while (OP(s) != O_QUEST && OP(s) != O_CH);
/* fallthrough */
default: /* things that break a sequence */
if (newlen > g->mlen) { /* ends one */
--- 1531,1542 ----
scan += OPND(s);
s = *scan;
/* assert() interferes w debug printouts */
! if (OP(s) != (unsigned) O_QUEST && OP(s) != (unsigned) O_CH &&
! OP(s) != (unsigned) OOR2) {
g->iflags |= BAD;
return;
}
! } while (OP(s) != (unsigned) O_QUEST && OP(s) != (unsigned) O_CH);
/* fallthrough */
default: /* things that break a sequence */
if (newlen > g->mlen) { /* ends one */
***************
*** 1589,1595 ****
scan = g->strip + 1;
do {
s = *scan++;
! switch (OP(s)) {
case OPLUS_:
plusnest++;
break;
--- 1589,1595 ----
scan = g->strip + 1;
do {
s = *scan++;
! switch ((int) OP(s)) {
case OPLUS_:
plusnest++;
break;
*** src/libc/posix/regex~1/regerror.c Tue Jun 13 01:35:08 1995
--- src/libc/posix/regex/regerror.c Wed Jul 8 05:45:32 1998
***************
*** 32,57 ****
*/
static struct rerr {
int code;
! char *name;
! char *explain;
} rerrs[] = {
! REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match",
! REG_BADPAT, "REG_BADPAT", "invalid regular expression",
! REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element",
! REG_ECTYPE, "REG_ECTYPE", "invalid character class",
! REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)",
! REG_ESUBREG, "REG_ESUBREG", "invalid backreference number",
! REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced",
! REG_EPAREN, "REG_EPAREN", "parentheses not balanced",
! REG_EBRACE, "REG_EBRACE", "braces not balanced",
! REG_BADBR, "REG_BADBR", "invalid repetition count(s)",
! REG_ERANGE, "REG_ERANGE", "invalid character range",
! REG_ESPACE, "REG_ESPACE", "out of memory",
! REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid",
! REG_EMPTY, "REG_EMPTY", "empty (sub)expression",
! REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug",
! REG_INVARG, "REG_INVARG", "invalid argument to regex routine",
! 0, "", "*** unknown regexp error code ***",
};
/*
--- 32,57 ----
*/
static struct rerr {
int code;
! const char *name;
! const char *explain;
} rerrs[] = {
! { REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match" },
! { REG_BADPAT, "REG_BADPAT", "invalid regular expression" },
! { REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element" },
! { REG_ECTYPE, "REG_ECTYPE", "invalid character class" },
! { REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)" },
! { REG_ESUBREG, "REG_ESUBREG", "invalid backreference number" },
! { REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced" },
! { REG_EPAREN, "REG_EPAREN", "parentheses not balanced" },
! { REG_EBRACE, "REG_EBRACE", "braces not balanced" },
! { REG_BADBR, "REG_BADBR", "invalid repetition count(s)" },
! { REG_ERANGE, "REG_ERANGE", "invalid character range" },
! { REG_ESPACE, "REG_ESPACE", "out of memory" },
! { REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid" },
! { REG_EMPTY, "REG_EMPTY", "empty (sub)expression" },
! { REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug" },
! { REG_INVARG, "REG_INVARG", "invalid argument to regex routine" },
! { 0, "", "*** unknown regexp error code ***" },
};
/*
***************
*** 87,93 ****
assert(strlen(convbuf) < sizeof(convbuf));
s = convbuf;
} else
! s = r->explain;
}
len = strlen(s) + 1;
--- 87,93 ----
assert(strlen(convbuf) < sizeof(convbuf));
s = convbuf;
} else
! (const char *) s = r->explain;
}
len = strlen(s) + 1;
***************
*** 115,126 ****
register struct rerr *r;
register size_t siz;
register char *p;
for (r = rerrs; r->code != 0; r++)
if (strcmp(r->name, preg->re_endp) == 0)
break;
if (r->code == 0)
! return("0");
sprintf(localbuf, "%d", r->code);
return(localbuf);
--- 115,129 ----
register struct rerr *r;
register size_t siz;
register char *p;
+ char *zero;
+
+ (const char *) zero = "0";
for (r = rerrs; r->code != 0; r++)
if (strcmp(r->name, preg->re_endp) == 0)
break;
if (r->code == 0)
! return(zero);
sprintf(localbuf, "%d", r->code);
return(localbuf);
*** src/libc/posix/regex~1/regex2.h Tue Jun 13 01:35:08 1995
--- src/libc/posix/regex/regex2.h Wed Jul 8 05:30:36 1998
***************
*** 39,46 ****
*/
typedef unsigned long sop; /* strip operator */
typedef long sopno;
! #define OPRMASK 0xf8000000
! #define OPDMASK 0x07ffffff
#define OPSHIFT ((unsigned)27)
#define OP(n) ((n)&OPRMASK)
#define OPND(n) ((n)&OPDMASK)
--- 39,46 ----
*/
typedef unsigned long sop; /* strip operator */
typedef long sopno;
! #define OPRMASK 0xf8000000U
! #define OPDMASK 0x07ffffffU
#define OPSHIFT ((unsigned)27)
#define OP(n) ((n)&OPRMASK)
#define OPND(n) ((n)&OPDMASK)
*** src/libc/posix/regex~1/regexec.c Tue Jun 13 01:35:08 1995
--- src/libc/posix/regex/regexec.c Wed Jul 8 05:49:58 1998
***************
*** 132,139 ****
return(REG_BADPAT);
eflags = GOODFLAGS(eflags);
! if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE))
! return(smatcher(g, (char *)string, nmatch, pmatch, eflags));
else
! return(lmatcher(g, (char *)string, nmatch, pmatch, eflags));
}
--- 132,139 ----
return(REG_BADPAT);
eflags = GOODFLAGS(eflags);
! if ((unsigned) g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE))
! return(smatcher(g, string, nmatch, pmatch, eflags));
else
! return(lmatcher(g, string, nmatch, pmatch, eflags));
}
*** src/libc/posix/regex~1/split.c Tue Jun 13 01:35:08 1995
--- src/libc/posix/regex/split.c Wed Jul 8 05:50:44 1998
***************
*** 2,7 ****
--- 2,9 ----
#include <stdio.h>
#include <string.h>
+ extern int split(char *string, char *fields[], int nfields, const char *sep);
+
/*
- split - divide a string into fields, like awk split()
= int split(char *string, char *fields[], int nfields, char *sep);
***************
*** 11,17 ****
char *string;
char *fields[]; /* list is not NULL-terminated */
int nfields; /* number of entries available in fields[] */
! char *sep; /* "" white, "c" single char, "ab" [ab]+ */
{
register char *p = string;
register char c; /* latest character */
--- 13,19 ----
char *string;
char *fields[]; /* list is not NULL-terminated */
int nfields; /* number of entries available in fields[] */
! const char *sep; /* "" white, "c" single char, "ab" [ab]+ */
{
register char *p = string;
register char c; /* latest character */
***************
*** 116,122 ****
c = *p++;
if (c == '\0')
return(fn);
! sepp = sep;
while ((sepc = *sepp++) != '\0' && sepc != c)
continue;
if (sepc != '\0') /* it was a separator */
--- 118,124 ----
c = *p++;
if (c == '\0')
return(fn);
! (const char *) sepp = sep;
while ((sepc = *sepp++) != '\0' && sepc != c)
continue;
if (sepc != '\0') /* it was a separator */
***************
*** 126,132 ****
*(p-1) = '\0';
for (;;) {
c = *p++;
! sepp = sep;
while ((sepc = *sepp++) != '\0' && sepc != c)
continue;
if (sepc == '\0') /* it wasn't a separator */
--- 128,134 ----
*(p-1) = '\0';
for (;;) {
c = *p++;
! (const char *) sepp = sep;
while ((sepc = *sepp++) != '\0' && sepc != c)
continue;
if (sepc == '\0') /* it wasn't a separator */
- Raw text -