From: Jarkko Hietaniemi Date: Thu, 13 Dec 2001 14:19:28 +0000 (+0000) Subject: Unadorned numbers evil. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e7ae6809ba5905bb2ce7c09e88c6e2bdb5c913af;p=p5sagit%2Fp5-mst-13.2.git Unadorned numbers evil. p4raw-id: //depot/perl@13672 --- diff --git a/pp.c b/pp.c index 2fd40da..9237a8b 100644 --- a/pp.c +++ b/pp.c @@ -3210,7 +3210,7 @@ PP(pp_ucfirst) STRLEN slen; if (DO_UTF8(sv)) { - U8 tmpbuf[UTF8_MAXLEN*2+1]; + U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; STRLEN ulen; STRLEN tculen; @@ -3265,7 +3265,7 @@ PP(pp_lcfirst) if (DO_UTF8(sv) && (s = (U8*)SvPV(sv, slen)) && slen && UTF8_IS_START(*s)) { STRLEN ulen; - U8 tmpbuf[UTF8_MAXLEN*2+1]; + U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; U8 *tend; UV uv; @@ -3322,7 +3322,7 @@ PP(pp_uc) STRLEN ulen; register U8 *d; U8 *send; - U8 tmpbuf[UTF8_MAXLEN*2+1]; + U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; s = (U8*)SvPV(sv,len); if (!len) { @@ -3389,7 +3389,7 @@ PP(pp_lc) STRLEN ulen; register U8 *d; U8 *send; - U8 tmpbuf[UTF8_MAXLEN*2+1]; + U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; s = (U8*)SvPV(sv,len); if (!len) { diff --git a/regcomp.c b/regcomp.c index a0f32f8..53d8947 100644 --- a/regcomp.c +++ b/regcomp.c @@ -2988,7 +2988,7 @@ tryagain: char *oldp, *s; STRLEN numlen; STRLEN ulen; - U8 tmpbuf[UTF8_MAXLEN*2+1]; + U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; parse_start = RExC_parse - 1; diff --git a/regexec.c b/regexec.c index 4b073d2..35a0a6c 100644 --- a/regexec.c +++ b/regexec.c @@ -932,8 +932,8 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, char *strend, char *sta ln = STR_LEN(c); if (UTF) { STRLEN ulen1, ulen2; - U8 tmpbuf1[UTF8_MAXLEN*2+1]; - U8 tmpbuf2[UTF8_MAXLEN*2+1]; + U8 tmpbuf1[UTF8_MAXLEN_UCLC+1]; + U8 tmpbuf2[UTF8_MAXLEN_UCLC+1]; to_utf8_lower((U8*)m, tmpbuf1, &ulen1); to_utf8_upper((U8*)m, tmpbuf2, &ulen2); @@ -2285,7 +2285,7 @@ S_regmatch(pTHX_ regnode *prog) char *l = locinput; char *e; STRLEN ulen; - U8 tmpbuf[UTF8_MAXLEN*2+1]; + U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; e = s + ln; while (s < e) { if (l >= PL_regeol) @@ -2558,8 +2558,8 @@ S_regmatch(pTHX_ regnode *prog) */ if (OP(scan) == REFF) { STRLEN ulen1, ulen2; - U8 tmpbuf1[UTF8_MAXLEN*2+1]; - U8 tmpbuf2[UTF8_MAXLEN*2+1]; + U8 tmpbuf1[UTF8_MAXLEN_UCLC+1]; + U8 tmpbuf2[UTF8_MAXLEN_UCLC+1]; while (s < e) { if (l >= PL_regeol) sayNO; @@ -3364,8 +3364,8 @@ S_regmatch(pTHX_ regnode *prog) else { /* UTF */ if (OP(text_node) == EXACTF || OP(text_node) == REFF) { STRLEN ulen1, ulen2; - U8 tmpbuf1[UTF8_MAXLEN*2+1]; - U8 tmpbuf2[UTF8_MAXLEN*2+1]; + U8 tmpbuf1[UTF8_MAXLEN_UCLC+1]; + U8 tmpbuf2[UTF8_MAXLEN_UCLC+1]; to_utf8_lower((U8*)s, tmpbuf1, &ulen1); to_utf8_upper((U8*)s, tmpbuf2, &ulen2); @@ -4110,7 +4110,7 @@ S_reginclass(pTHX_ register regnode *n, register U8* p, register bool do_utf8) match = TRUE; else if (flags & ANYOF_FOLD) { STRLEN ulen; - U8 tmpbuf[UTF8_MAXLEN*2+1]; + U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; toLOWER_utf8(p, tmpbuf, &ulen); if (swash_fetch(sw, tmpbuf, do_utf8)) diff --git a/utf8.c b/utf8.c index 747b78c..3a8c13a 100644 --- a/utf8.c +++ b/utf8.c @@ -903,7 +903,7 @@ Perl_is_uni_punct(pTHX_ UV c) bool Perl_is_uni_xdigit(pTHX_ UV c) { - U8 tmpbuf[UTF8_MAXLEN*2+1]; + U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; uvchr_to_utf8(tmpbuf, (UV)c); return is_utf8_xdigit(tmpbuf); } @@ -911,7 +911,7 @@ Perl_is_uni_xdigit(pTHX_ UV c) UV Perl_to_uni_upper(pTHX_ UV c, U8* p, STRLEN *lenp) { - U8 tmpbuf[UTF8_MAXLEN*2+1]; + U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; uvchr_to_utf8(tmpbuf, (UV)c); return to_utf8_upper(tmpbuf, p, lenp); } @@ -919,7 +919,7 @@ Perl_to_uni_upper(pTHX_ UV c, U8* p, STRLEN *lenp) UV Perl_to_uni_title(pTHX_ UV c, U8* p, STRLEN *lenp) { - U8 tmpbuf[UTF8_MAXLEN*2+1]; + U8 tmpbuf[UTF8_MAXLEN_UCLC+1]; uvchr_to_utf8(tmpbuf, (UV)c); return to_utf8_title(tmpbuf, p, lenp); } @@ -1596,8 +1596,8 @@ Perl_ibcmp_utf8(pTHX_ const char *s1, bool u1, register I32 len1, const char *s2 STRLEN la, lb; UV ca, cb; STRLEN ulen1, ulen2; - U8 tmpbuf1[UTF8_MAXLEN*3+1]; - U8 tmpbuf2[UTF8_MAXLEN*3+1]; + U8 tmpbuf1[UTF8_MAXLEN_FOLD+1]; + U8 tmpbuf2[UTF8_MAXLEN_FOLD+1]; while (a < ae && b < be) { if (u1) { diff --git a/utf8.h b/utf8.h index 01c6199..1c2243e 100644 --- a/utf8.h +++ b/utf8.h @@ -135,7 +135,12 @@ END_EXTERN_C #define isIDFIRST_lazy(p) isIDFIRST_lazy_if(p,1) #define isALNUM_lazy(p) isALNUM_lazy_if(p,1) -#define UTF8_MAXLEN 13 /* how wide can a single UTF8 encoded character become */ +/* how wide can a single UTF8 encoded character become */ +#define UTF8_MAXLEN 13 +/* how wide a character can become when upper/lowercased */ +#define UTF8_MAXLEN_UCLC (UTF8_MAXLEN*2) +/* how wide a character can become when casefolded */ +#define UTF8_MAXLEN_FOLD (UTF8_MAXLEN*3) #define IN_BYTES (PL_curcop->op_private & HINT_BYTES) #define DO_UTF8(sv) (SvUTF8(sv) && !IN_BYTES)