The "no more" condition is now represented as ~0, instead of -1.
{
dVAR; dSP; dPOPss;
register unsigned char *s;
- register I32 ch;
- register I32 *sfirst;
- register I32 *snext;
+ U32 *sfirst;
+ U32 *snext;
STRLEN len;
MAGIC *mg = SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_study) : NULL;
RETPUSHNO;
}
- Newx(sfirst, 256 + len, I32);
+ Newx(sfirst, 256 + len, U32);
if (!sfirst)
DIE(aTHX_ "do_study: out of memory");
if (!mg)
mg = sv_magicext(sv, NULL, PERL_MAGIC_study, &PL_vtbl_regexp, NULL, 0);
mg->mg_ptr = (char *) sfirst;
- mg->mg_len = (256 + len) * sizeof(I32);
+ mg->mg_len = (256 + len) * sizeof(U32);
- snext = sfirst;
- for (ch = 256; ch; --ch)
- *snext++ = -1;
+ snext = sfirst + 256;
+ memset(sfirst, ~0, 256 * sizeof(U32));
while (len-- > 0) {
const U8 ch = s[len];
- if (sfirst[ch] >= 0)
- snext[len] = sfirst[ch];
- else
- snext[len] = -1;
- sfirst[ch] = (I32)len;
+ snext[len] = sfirst[ch];
+ sfirst[ch] = len;
}
RETPUSHYES;
mg = mg_find(sv, PERL_MAGIC_study);
assert(mg);
- if (((I32 *)mg->mg_ptr)[BmRARE(check)] != -1
+ if (((U32 *)mg->mg_ptr)[BmRARE(check)] != (U32)~0
|| ( BmRARE(check) == '\n'
&& (BmPREVIOUS(check) == SvCUR(check) - 1)
&& SvTAIL(check) ))
{
dVAR;
register const unsigned char *big;
- register I32 pos;
+ U32 pos;
register I32 previous;
register I32 first;
register const unsigned char *little;
register const unsigned char *littleend;
bool found = FALSE;
const MAGIC * mg;
- I32 *screamfirst;
- I32 *screamnext;
+ U32 *screamfirst;
+ U32 *screamnext;
+ U32 const nope = ~0;
PERL_ARGS_ASSERT_SCREAMINSTR;
assert(SvTYPE(littlestr) == SVt_PVMG);
assert(SvVALID(littlestr));
- screamfirst = (I32 *)mg->mg_ptr;
+ screamfirst = (U32 *)mg->mg_ptr;
screamnext = screamfirst + 256;
pos = *old_posp == -1
? screamfirst[BmRARE(littlestr)] : screamnext[*old_posp];
- if (pos == -1) {
+ if (pos == nope) {
cant_find:
if ( BmRARE(littlestr) == '\n'
&& BmPREVIOUS(littlestr) == SvCUR(littlestr) - 1) {
#endif
return NULL;
}
- while (pos < previous + start_shift) {
+ while ((I32)pos < previous + start_shift) {
pos = screamnext[pos];
- if (pos == -1)
+ if (pos == nope)
goto cant_find;
}
big -= previous;
do {
- if (pos >= stop_pos) break;
+ if ((I32)pos >= stop_pos) break;
if (big[pos] == first) {
const unsigned char *s = little;
const unsigned char *x = big + pos + 1;
++s;
}
if (s == littleend) {
- *old_posp = pos;
+ *old_posp = (I32)pos;
if (!last) return (char *)(big+pos);
found = TRUE;
}
}
pos = screamnext[pos];
- } while (pos != -1);
+ } while (pos != nope);
if (last && found)
return (char *)(big+(*old_posp));
check_tail: