From: Jarkko Hietaniemi Date: Mon, 7 Oct 1996 19:03:00 +0000 (+0300) Subject: LC_COLLATE. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e5cf08def37eb3e6aae76e85f2a3156394cae970;p=p5sagit%2Fp5-mst-13.2.git LC_COLLATE. Restore the 5.003 gv_fullname() and gv_efullname() functions. Provide new 3-arg forms gv_fullname3() and gv_efullname3(). Big patch to add, document, and test LC_COLLATE support. sortcmp() sprouted a LC_COLLATE branch. --- diff --git a/pp_ctl.c b/pp_ctl.c index f533215..0c7e3d4 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -574,7 +574,7 @@ PP(pp_sort) if (!(cv && CvROOT(cv))) { if (gv) { SV *tmpstr = sv_newmortal(); - gv_efullname(tmpstr, gv, Nullch); + gv_efullname3(tmpstr, gv, Nullch); if (cv && CvXSUB(cv)) DIE("Xsub \"%s\" called in sort", SvPVX(tmpstr)); DIE("Undefined sort subroutine \"%s\" called", @@ -1114,7 +1114,7 @@ PP(pp_caller) RETURN; if (cx->cx_type == CXt_SUB) { /* So is cxstack[dbcxix]. */ sv = NEWSV(49, 0); - gv_efullname(sv, CvGV(cxstack[cxix].blk_sub.cv), Nullch); + gv_efullname3(sv, CvGV(cxstack[cxix].blk_sub.cv), Nullch); PUSHs(sv_2mortal(sv)); PUSHs(sv_2mortal(newSViv((I32)cx->blk_sub.hasargs))); } @@ -1202,6 +1202,36 @@ const void *b; if (!SvPOKp(str2)) return 1; + if (lc_collate_active) { /* NOTE: this is the LC_COLLATE branch */ + register char * pv1, * pv2, * pvx; + STRLEN cur1, cur2, curx; + + pv1 = SvPV(str1, cur1); + pvx = mem_collxfrm(pv1, cur1, &curx); + pv1 = pvx; + cur1 = curx; + + pv2 = SvPV(str2, cur2); + pvx = mem_collxfrm(pv2, cur2, &curx); + pv2 = pvx; + cur2 = curx; + + retval = memcmp((void *)pv1, (void *)pv2, cur1 < cur2 ? cur1 : cur2); + + Safefree(pv1); + Safefree(pv2); + + if (retval) + return retval < 0 ? -1 : 1; + + if (cur1 == cur2) + return 0; + else + return cur1 < cur2 ? -1 : 1; + } + + /* NOTE: this is the non-LC_COLLATE area */ + if (SvCUR(str1) < SvCUR(str2)) { /*SUPPRESS 560*/ if (retval = memcmp(SvPVX(str1), SvPVX(str2), SvCUR(str1))) @@ -1623,7 +1653,7 @@ PP(pp_goto) if (!CvROOT(cv) && !CvXSUB(cv)) { if (CvGV(cv)) { SV *tmpstr = sv_newmortal(); - gv_efullname(tmpstr, CvGV(cv), Nullch); + gv_efullname3(tmpstr, CvGV(cv), Nullch); DIE("Goto undefined subroutine &%s",SvPVX(tmpstr)); } DIE("Goto undefined subroutine"); @@ -1764,7 +1794,7 @@ PP(pp_goto) /* &xsub is not copying @_ */ SV *sv = GvSV(DBsub); save_item(sv); - gv_efullname(sv, CvGV(cv), Nullch); + gv_efullname3(sv, CvGV(cv), Nullch); /* We do not care about using sv to call CV, * just for info. */ }