summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-06-12 13:26:24 -0600
committerKarl Williamson <khw@cpan.org>2014-06-12 13:32:55 -0600
commit130c5df3625bd130cd1e2771308fcd4eb66cebb2 (patch)
treeb392e738e720e177e0baaab4b1b45240bde7fd2b
parentea2b4f53c45208ee2de6be74295a6a50e35d4929 (diff)
downloadperl-130c5df3625bd130cd1e2771308fcd4eb66cebb2.tar.gz
Allow to compile if don't have LC_CTYPE etc defined
Commit d6ded95025185cb1ec8ca3ba5879cab881d8b180 introduced the ability to specify individual category parameters to 'use locale'. However in doing so, it causes Perl to not be able to compile on platforms that don't have some or all of those categories defined, such as Android. This commit uses #ifdefs to remedy that.
-rw-r--r--ext/POSIX/POSIX.xs6
-rw-r--r--op.c11
-rw-r--r--perl.h2
-rw-r--r--pp.c101
-rw-r--r--pp_sort.c8
-rw-r--r--pp_sys.c2
6 files changed, 105 insertions, 25 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 8f2ff10dd2..974a975f4a 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -1754,8 +1754,10 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
if (SvUTF8(fmt)
|| (! is_ascii_string((U8*) buf, len)
&& is_utf8_string((U8*) buf, len)
- && _is_cur_LC_category_utf8(LC_TIME)))
- {
+#ifdef USE_LOCALE_TiME
+ && _is_cur_LC_category_utf8(LC_TIME)
+#endif
+ )) {
SvUTF8_on(sv);
}
}
diff --git a/op.c b/op.c
index b21f8402e2..193189bf69 100644
--- a/op.c
+++ b/op.c
@@ -3524,21 +3524,27 @@ S_fold_constants(pTHX_ OP *o)
case OP_UC:
case OP_LC:
case OP_FC:
+#ifdef USE_LOCALE_CTYPE
if (IN_LC_COMPILETIME(LC_CTYPE))
goto nope;
+#endif
break;
case OP_SLT:
case OP_SGT:
case OP_SLE:
case OP_SGE:
case OP_SCMP:
+#ifdef USE_LOCALE_COLLATE
if (IN_LC_COMPILETIME(LC_COLLATE))
goto nope;
+#endif
break;
case OP_SPRINTF:
/* XXX what about the numeric ops? */
+#ifdef USE_LOCALE_NUMERIC
if (IN_LC_COMPILETIME(LC_NUMERIC))
goto nope;
+#endif
break;
case OP_PACK:
if (!cLISTOPo->op_first->op_sibling
@@ -4738,10 +4744,13 @@ Perl_newPMOP(pTHX_ I32 type, I32 flags)
if (PL_hints & HINT_RE_TAINT)
pmop->op_pmflags |= PMf_RETAINT;
+#ifdef USE_LOCALE_CTYPE
if (IN_LC_COMPILETIME(LC_CTYPE)) {
set_regex_charset(&(pmop->op_pmflags), REGEX_LOCALE_CHARSET);
}
- else if (IN_UNI_8_BIT) {
+ else
+#endif
+ if (IN_UNI_8_BIT) {
set_regex_charset(&(pmop->op_pmflags), REGEX_UNICODE_CHARSET);
}
if (PL_hints & HINT_RE_FLAGS) {
diff --git a/perl.h b/perl.h
index e55e8217f8..4c5e8f026f 100644
--- a/perl.h
+++ b/perl.h
@@ -5411,6 +5411,8 @@ typedef struct am_table_short AMTS;
#define STORE_LC_NUMERIC_SET_TO_NEEDED()
#define DECLARE_STORE_LC_NUMERIC_SET_TO_NEEDED()
#define RESTORE_LC_NUMERIC()
+#define LOCK_NUMERIC_STANDARD()
+#define UNLOCK_NUMERIC_STANDARD()
#define Atof my_atof
#define IN_LOCALE_RUNTIME 0
diff --git a/pp.c b/pp.c
index 9218f5b869..e57f426924 100644
--- a/pp.c
+++ b/pp.c
@@ -2133,9 +2133,13 @@ PP(pp_sle)
tryAMAGICbin_MG(amg_type, AMGf_set);
{
dPOPTOPssrl;
- const int cmp = (IN_LC_RUNTIME(LC_COLLATE)
- ? sv_cmp_locale_flags(left, right, 0)
- : sv_cmp_flags(left, right, 0));
+ const int cmp =
+#ifdef USE_LC_COLLATE
+ (IN_LC_RUNTIME(LC_COLLATE))
+ ? sv_cmp_locale_flags(left, right, 0)
+ :
+#endif
+ sv_cmp_flags(left, right, 0);
SETs(boolSV(cmp * multiplier < rhs));
RETURN;
}
@@ -2169,9 +2173,13 @@ PP(pp_scmp)
tryAMAGICbin_MG(scmp_amg, 0);
{
dPOPTOPssrl;
- const int cmp = (IN_LC_RUNTIME(LC_COLLATE)
- ? sv_cmp_locale_flags(left, right, 0)
- : sv_cmp_flags(left, right, 0));
+ const int cmp =
+#ifdef USE_LC_COLLATE
+ (IN_LC_RUNTIME(LC_COLLATE))
+ ? sv_cmp_locale_flags(left, right, 0)
+ :
+#endif
+ sv_cmp_flags(left, right, 0);
SETi( cmp );
RETURN;
}
@@ -3506,10 +3514,22 @@ PP(pp_ucfirst)
doing_utf8 = TRUE;
ulen = UTF8SKIP(s);
if (op_type == OP_UCFIRST) {
- _to_utf8_title_flags(s, tmpbuf, &tculen, IN_LC_RUNTIME(LC_CTYPE));
+ _to_utf8_title_flags(s, tmpbuf, &tculen,
+#ifdef USE_LOCALE_CTYPE
+ IN_LC_RUNTIME(LC_CTYPE)
+#else
+ 0
+#endif
+ );
}
else {
- _to_utf8_lower_flags(s, tmpbuf, &tculen, IN_LC_RUNTIME(LC_CTYPE));
+ _to_utf8_lower_flags(s, tmpbuf, &tculen,
+#ifdef USE_LOCALE_CTYPE
+ IN_LC_RUNTIME(LC_CTYPE)
+#else
+ 0
+#endif
+ );
}
/* we can't do in-place if the length changes. */
@@ -3527,13 +3547,18 @@ PP(pp_ucfirst)
if (op_type == OP_LCFIRST) {
/* lower case the first letter: no trickiness for any character */
- *tmpbuf = (IN_LC_RUNTIME(LC_CTYPE))
+ *tmpbuf =
+#ifdef USE_LOCALE_CTYPE
+ (IN_LC_RUNTIME(LC_CTYPE))
? toLOWER_LC(*s)
- : (IN_UNI_8_BIT)
+ :
+#endif
+ (IN_UNI_8_BIT)
? toLOWER_LATIN1(*s)
: toLOWER(*s);
}
/* is ucfirst() */
+#ifdef USE_LOCALE_CTYPE
else if (IN_LC_RUNTIME(LC_CTYPE)) {
if (IN_UTF8_CTYPE_LOCALE) {
goto do_uni_rules;
@@ -3543,6 +3568,7 @@ PP(pp_ucfirst)
locales have upper and title case
different */
}
+#endif
else if (! IN_UNI_8_BIT) {
*tmpbuf = toUPPER(*s); /* Returns caseless for non-ascii, or
* on EBCDIC machines whatever the
@@ -3686,10 +3712,12 @@ PP(pp_ucfirst)
SvCUR_set(dest, need - 1);
}
}
+#ifdef USE_LOCALE_CTYPE
if (IN_LC_RUNTIME(LC_CTYPE)) {
TAINT;
SvTAINTED_on(dest);
}
+#endif
if (dest != source && SvTAINTED(source))
SvTAINT(dest);
SvSETMAGIC(dest);
@@ -3717,9 +3745,13 @@ PP(pp_uc)
(SvTEMP(source) && !SvSMAGICAL(source) && SvREFCNT(source) == 1))
&& !SvREADONLY(source) && SvPOK(source)
&& !DO_UTF8(source)
- && ((IN_LC_RUNTIME(LC_CTYPE))
+ && (
+#ifdef USE_LOCALE_CTYPE
+ (IN_LC_RUNTIME(LC_CTYPE))
? ! IN_UTF8_CTYPE_LOCALE
- : ! IN_UNI_8_BIT))
+ :
+#endif
+ ! IN_UNI_8_BIT))
{
/* We can convert in place. The reason we can't if in UNI_8_BIT is to
@@ -3784,7 +3816,13 @@ PP(pp_uc)
* and copy it to the output buffer */
u = UTF8SKIP(s);
- uv = _to_utf8_upper_flags(s, tmpbuf, &ulen, IN_LC_RUNTIME(LC_CTYPE));
+ uv = _to_utf8_upper_flags(s, tmpbuf, &ulen,
+#ifdef USE_LOCALE_CTYPE
+ IN_LC_RUNTIME(LC_CTYPE)
+#else
+ 0
+#endif
+ );
#define GREEK_CAPITAL_LETTER_IOTA 0x0399
#define COMBINING_GREEK_YPOGEGRAMMENI 0x0345
if (uv == GREEK_CAPITAL_LETTER_IOTA
@@ -3827,6 +3865,7 @@ PP(pp_uc)
/* Use locale casing if in locale; regular style if not treating
* latin1 as having case; otherwise the latin1 casing. Do the
* whole thing in a tight loop, for speed, */
+#ifdef USE_LOCALE_CTYPE
if (IN_LC_RUNTIME(LC_CTYPE)) {
if (IN_UTF8_CTYPE_LOCALE) {
goto do_uni_rules;
@@ -3834,7 +3873,9 @@ PP(pp_uc)
for (; s < send; d++, s++)
*d = (U8) toUPPER_LC(*s);
}
- else if (! IN_UNI_8_BIT) {
+ else
+#endif
+ if (! IN_UNI_8_BIT) {
for (; s < send; d++, s++) {
*d = toUPPER(*s);
}
@@ -3929,10 +3970,12 @@ PP(pp_uc)
SvCUR_set(dest, d - (U8*)SvPVX_const(dest));
}
} /* End of isn't utf8 */
+#ifdef USE_LOCALE_CTYPE
if (IN_LC_RUNTIME(LC_CTYPE)) {
TAINT;
SvTAINTED_on(dest);
}
+#endif
if (dest != source && SvTAINTED(source))
SvTAINT(dest);
SvSETMAGIC(dest);
@@ -3990,7 +4033,13 @@ PP(pp_lc)
const STRLEN u = UTF8SKIP(s);
STRLEN ulen;
- _to_utf8_lower_flags(s, tmpbuf, &ulen, IN_LC_RUNTIME(LC_CTYPE));
+ _to_utf8_lower_flags(s, tmpbuf, &ulen,
+#ifdef USE_LOCALE_CTYPE
+ IN_LC_RUNTIME(LC_CTYPE)
+#else
+ 0
+#endif
+ );
/* Here is where we would do context-sensitive actions. See the
* commit message for 86510fb15 for why there isn't any */
@@ -4027,11 +4076,14 @@ PP(pp_lc)
/* Use locale casing if in locale; regular style if not treating
* latin1 as having case; otherwise the latin1 casing. Do the
* whole thing in a tight loop, for speed, */
+#ifdef USE_LOCALE_CTYPE
if (IN_LC_RUNTIME(LC_CTYPE)) {
for (; s < send; d++, s++)
*d = toLOWER_LC(*s);
}
- else if (! IN_UNI_8_BIT) {
+ else
+#endif
+ if (! IN_UNI_8_BIT) {
for (; s < send; d++, s++) {
*d = toLOWER(*s);
}
@@ -4047,10 +4099,12 @@ PP(pp_lc)
SvCUR_set(dest, d - (U8*)SvPVX_const(dest));
}
}
+#ifdef USE_LOCALE_CTYPE
if (IN_LC_RUNTIME(LC_CTYPE)) {
TAINT;
SvTAINTED_on(dest);
}
+#endif
if (dest != source && SvTAINTED(source))
SvTAINT(dest);
SvSETMAGIC(dest);
@@ -4081,7 +4135,7 @@ PP(pp_quotemeta)
}
}
else if (UTF8_IS_DOWNGRADEABLE_START(*s)) {
-
+#ifdef USE_LOCALE_CTYPE
/* In locale, we quote all non-ASCII Latin1 chars.
* Otherwise use the quoting rules */
if (IN_LC_RUNTIME(LC_CTYPE)
@@ -4089,6 +4143,7 @@ PP(pp_quotemeta)
{
to_quote = TRUE;
}
+#endif
}
else if (is_QUOTEMETA_high(s)) {
to_quote = TRUE;
@@ -4146,7 +4201,10 @@ PP(pp_fc)
U8 tmpbuf[UTF8_MAXBYTES_CASE + 1];
const bool full_folding = TRUE;
const U8 flags = ( full_folding ? FOLD_FLAGS_FULL : 0 )
- | ( IN_LC_RUNTIME(LC_CTYPE) ? FOLD_FLAGS_LOCALE : 0 );
+#ifdef USE_LOCALE_CTYPE
+ | ( IN_LC_RUNTIME(LC_CTYPE) ? FOLD_FLAGS_LOCALE : 0 )
+#endif
+ ;
/* This is a facsimile of pp_lc, but with a thousand bugs thanks to me.
* You are welcome(?) -Hugmeir
@@ -4194,6 +4252,7 @@ PP(pp_fc)
SvUTF8_on(dest);
} /* Unflagged string */
else if (len) {
+#ifdef USE_LOCALE_CTYPE
if ( IN_LC_RUNTIME(LC_CTYPE) ) { /* Under locale */
if (IN_UTF8_CTYPE_LOCALE) {
goto do_uni_folding;
@@ -4201,7 +4260,9 @@ PP(pp_fc)
for (; s < send; d++, s++)
*d = (U8) toFOLD_LC(*s);
}
- else if ( !IN_UNI_8_BIT ) { /* Under nothing, or bytes */
+ else
+#endif
+ if ( !IN_UNI_8_BIT ) { /* Under nothing, or bytes */
for (; s < send; d++, s++)
*d = toFOLD(*s);
}
@@ -4273,10 +4334,12 @@ PP(pp_fc)
*d = '\0';
SvCUR_set(dest, d - (U8*)SvPVX_const(dest));
+#ifdef USE_LOCALE_CTYPE
if (IN_LC_RUNTIME(LC_CTYPE)) {
TAINT;
SvTAINTED_on(dest);
}
+#endif
if (SvTAINTED(source))
SvTAINT(dest);
SvSETMAGIC(dest);
diff --git a/pp_sort.c b/pp_sort.c
index 391480be7d..86a5e36708 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1727,11 +1727,15 @@ PP(pp_sort)
? ( ( ( priv & OPpSORT_INTEGER) || all_SIVs)
? ( overloading ? S_amagic_i_ncmp : S_sv_i_ncmp)
: ( overloading ? S_amagic_ncmp : S_sv_ncmp ) )
- : ( IN_LC_RUNTIME(LC_COLLATE)
+ : (
+#ifdef USE_LOCALE_COLLATE
+ IN_LC_RUNTIME(LC_COLLATE)
? ( overloading
? (SVCOMPARE_t)S_amagic_cmp_locale
: (SVCOMPARE_t)sv_cmp_locale_static)
- : ( overloading ? (SVCOMPARE_t)S_amagic_cmp : (SVCOMPARE_t)sv_cmp_static)),
+ :
+#endif
+ ( overloading ? (SVCOMPARE_t)S_amagic_cmp : (SVCOMPARE_t)sv_cmp_static)),
sort_flags);
}
if ((priv & OPpSORT_REVERSE) != 0) {
diff --git a/pp_sys.c b/pp_sys.c
index e30433fc0f..18b3d8ebf7 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3468,7 +3468,7 @@ PP(pp_fttext)
odd++;
#else
else if (*s & 128) {
-#ifdef USE_LOCALE
+#ifdef USE_LOCALE_CTYPE
if (IN_LC_RUNTIME(LC_CTYPE) && isALPHA_LC(*s))
continue;
#endif