Skip to content

Commit

Permalink
Time-Piece: Use isSPACE, not isspace
Browse files Browse the repository at this point in the history
The latter gives results that are dependent on the program's underlying
locale, and so may be inconsistent.

If locale dependence is actually desired, isSPACE_LC should be used, as
it knows about various things the module writer shouldn't have to
concern themselves with.  It is supported since 5.004
  • Loading branch information
khwilliamson committed Jan 27, 2023
1 parent bb5e68f commit 85f4cb3
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions cpan/Time-Piece/Piece.xs
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ _strptime(pTHX_ const char *buf, const char *fmt, struct tm *tm, int *got_GMT)
c = *ptr++;

if (c != '%') {
if (isspace((unsigned char)c))
while (*buf != 0 && isspace((unsigned char)*buf))
if (isSPACE((unsigned char)c))
while (*buf != 0 && isSPACE((unsigned char)*buf))
buf++;
else if (c != *buf++)
return 0;
Expand Down Expand Up @@ -480,9 +480,9 @@ label:

case 'n': /* whitespace */
case 't':
if (!isspace((unsigned char)*buf))
if (!isSPACE((unsigned char)*buf))
return 0;
while (isspace((unsigned char)*buf))
while (isSPACE((unsigned char)*buf))
buf++;
break;

Expand Down Expand Up @@ -523,7 +523,7 @@ label:

case 'M':
case 'S':
if (*buf == 0 || isspace((unsigned char)*buf))
if (*buf == 0 || isSPACE((unsigned char)*buf))
break;

if (!isdigit((unsigned char)*buf))
Expand All @@ -546,8 +546,8 @@ label:
tm->tm_sec = i;
}

if (*buf != 0 && isspace((unsigned char)*buf))
while (*ptr != 0 && !isspace((unsigned char)*ptr))
if (*buf != 0 && isSPACE((unsigned char)*buf))
while (*ptr != 0 && !isSPACE((unsigned char)*ptr))
ptr++;
break;

Expand Down Expand Up @@ -580,8 +580,8 @@ label:

tm->tm_hour = i;

if (*buf != 0 && isspace((unsigned char)*buf))
while (*ptr != 0 && !isspace((unsigned char)*ptr))
if (*buf != 0 && isSPACE((unsigned char)*buf))
while (*ptr != 0 && !isSPACE((unsigned char)*ptr))
ptr++;
break;

Expand Down Expand Up @@ -660,8 +660,8 @@ label:
if (i > 53)
return 0;

if (*buf != 0 && isspace((unsigned char)*buf))
while (*ptr != 0 && !isspace((unsigned char)*ptr))
if (*buf != 0 && isSPACE((unsigned char)*buf))
while (*ptr != 0 && !isSPACE((unsigned char)*ptr))
ptr++;
break;

Expand All @@ -679,8 +679,8 @@ label:
tm->tm_wday = i;

buf++;
if (*buf != 0 && isspace((unsigned char)*buf))
while (*ptr != 0 && !isspace((unsigned char)*ptr))
if (*buf != 0 && isSPACE((unsigned char)*buf))
while (*ptr != 0 && !isSPACE((unsigned char)*ptr))
ptr++;
break;

Expand Down Expand Up @@ -708,8 +708,8 @@ label:

tm->tm_mday = i;

if (*buf != 0 && isspace((unsigned char)*buf))
while (*ptr != 0 && !isspace((unsigned char)*ptr))
if (*buf != 0 && isSPACE((unsigned char)*buf))
while (*ptr != 0 && !isSPACE((unsigned char)*ptr))
ptr++;
break;

Expand Down Expand Up @@ -763,8 +763,8 @@ label:

tm->tm_mon = i - 1;

if (*buf != 0 && isspace((unsigned char)*buf))
while (*ptr != 0 && !isspace((unsigned char)*ptr))
if (*buf != 0 && isSPACE((unsigned char)*buf))
while (*ptr != 0 && !isSPACE((unsigned char)*ptr))
ptr++;
break;

Expand Down Expand Up @@ -817,7 +817,7 @@ label:

case 'Y':
case 'y':
if (*buf == 0 || isspace((unsigned char)*buf))
if (*buf == 0 || isSPACE((unsigned char)*buf))
break;

if (!isdigit((unsigned char)*buf))
Expand All @@ -838,8 +838,8 @@ label:

tm->tm_year = i;

if (*buf != 0 && isspace((unsigned char)*buf))
while (*ptr != 0 && !isspace((unsigned char)*ptr))
if (*buf != 0 && isSPACE((unsigned char)*buf))
while (*ptr != 0 && !isSPACE((unsigned char)*ptr))
ptr++;
break;

Expand Down

0 comments on commit 85f4cb3

Please sign in to comment.