Skip to content

Commit 14eb098

Browse files
committed
Rename _isQUOTEMETA to isQUOTEMETA
The former is undefined behavior in C in some situations. The rules are detailed in "Choosing legal symbol names" in perlhacktips This commit omits the underscore and makes the macro available only to the core and extensions. I think I didn't know about PERL_CORE when I created this macro, so used the leading underscore to discourage its use from anyone who stumbled upon its existence. The reason not to make it public was my uncertainty about if it was the correct thing to do; my not expecting that it would be useful outside of core; and the extra work needed to make it a polished interface. I think now that if someone requested it be made public, that could safely be done.
1 parent af99360 commit 14eb098

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

ext/XS-APItest/APItest.xs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6723,7 +6723,7 @@ test_UTF8_IS_REPLACEMENT(char *s, STRLEN len)
67236723
bool
67246724
test_isQUOTEMETA(UV ord)
67256725
CODE:
6726-
RETVAL = _isQUOTEMETA(ord);
6726+
RETVAL = isQUOTEMETA(ord);
67276727
OUTPUT:
67286728
RETVAL
67296729

handy.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,9 @@ END_EXTERN_C
16911691
( (! cBOOL(FITS_IN_8_BITS(c))) \
16921692
|| (PL_charclass[(U8) (c)] & CC_mask_(CC_NONLATIN1_FOLD_)))
16931693

1694-
# define _isQUOTEMETA(c) generic_isCC_(c, CC_QUOTEMETA_)
1694+
# if defined(PERL_CORE) || defined(PERL_IN_XS_APITEST)
1695+
# define isQUOTEMETA(c) generic_isCC_(c, CC_QUOTEMETA_)
1696+
# endif
16951697

16961698
/* is c a control character for which we have a mnemonic? */
16971699
# if defined(PERL_CORE) || defined(PERL_EXT)
@@ -1822,7 +1824,9 @@ END_EXTERN_C
18221824
/* The following are not fully accurate in the above-ASCII range. I (khw)
18231825
* don't think it's necessary to be so for the purposes where this gets
18241826
* compiled */
1825-
# define isQUOTEMETA_(c) (FITS_IN_8_BITS(c) && ! isWORDCHAR_L1(c))
1827+
# if defined(PERL_CORE) || defined(PERL_IN_XS_APITEST)
1828+
# define isQUOTEMETA(c) (FITS_IN_8_BITS(c) && ! isWORDCHAR_L1(c))
1829+
# endif
18261830

18271831
/* Many of the macros later in this file are defined in terms of these. By
18281832
* implementing them with a function, which converts the class number into

pp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5073,7 +5073,7 @@ PP(pp_quotemeta)
50735073
bool to_quote = FALSE;
50745074

50755075
if (UTF8_IS_INVARIANT(*s)) {
5076-
if (_isQUOTEMETA(*s)) {
5076+
if (isQUOTEMETA(*s)) {
50775077
to_quote = TRUE;
50785078
}
50795079
}
@@ -5086,7 +5086,7 @@ PP(pp_quotemeta)
50865086
IN_LC_RUNTIME(LC_CTYPE)
50875087
||
50885088
#endif
5089-
_isQUOTEMETA(EIGHT_BIT_UTF8_TO_NATIVE(*s, *(s + 1))))
5089+
isQUOTEMETA(EIGHT_BIT_UTF8_TO_NATIVE(*s, *(s + 1))))
50905090
{
50915091
to_quote = TRUE;
50925092
}
@@ -5108,7 +5108,7 @@ PP(pp_quotemeta)
51085108
}
51095109
else if (IN_UNI_8_BIT) {
51105110
while (len--) {
5111-
if (_isQUOTEMETA(*s))
5111+
if (isQUOTEMETA(*s))
51125112
*d++ = '\\';
51135113
*d++ = *s++;
51145114
}

0 commit comments

Comments
 (0)