use Py_CHARMASK
This commit is contained in:
parent
760dd1031a
commit
7f7f274839
|
@ -35,7 +35,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "modsupport.h"
|
#include "modsupport.h"
|
||||||
|
|
||||||
#include "regexpr.h"
|
#include "regexpr.h"
|
||||||
#include "ctype.h"
|
#include <ctype.h>
|
||||||
|
|
||||||
static object *RegexError; /* Exception */
|
static object *RegexError; /* Exception */
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ symcomp(pattern, gdict)
|
||||||
++o; /* eat the '>' */
|
++o; /* eat the '>' */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!isalnum(*o) && *o != '_') {
|
if (!isalnum(Py_CHARMASK(*o)) && *o != '_') {
|
||||||
o = backtrack;
|
o = backtrack;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ strop_split(self, args)
|
||||||
{
|
{
|
||||||
int len, i, j, err;
|
int len, i, j, err;
|
||||||
char *s;
|
char *s;
|
||||||
char c;
|
|
||||||
object *list, *item;
|
object *list, *item;
|
||||||
|
|
||||||
if (!getargs(args, "s#", &s, &len))
|
if (!getargs(args, "s#", &s, &len))
|
||||||
|
@ -52,13 +51,11 @@ strop_split(self, args)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < len) {
|
while (i < len) {
|
||||||
while (i < len &&
|
while (i < len && isspace(Py_CHARMASK(s[i]))) {
|
||||||
((c = s[i]), isspace(c))) {
|
|
||||||
i = i+1;
|
i = i+1;
|
||||||
}
|
}
|
||||||
j = i;
|
j = i;
|
||||||
while (i < len &&
|
while (i < len && isspace(Py_CHARMASK(s[i]))) {
|
||||||
!((c = s[i]), isspace(c))) {
|
|
||||||
i = i+1;
|
i = i+1;
|
||||||
}
|
}
|
||||||
if (j < i) {
|
if (j < i) {
|
||||||
|
@ -269,20 +266,19 @@ strop_strip(self, args)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int len, i, j;
|
int len, i, j;
|
||||||
char c;
|
|
||||||
|
|
||||||
if (!getargs(args, "s#", &s, &len))
|
if (!getargs(args, "s#", &s, &len))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < len && ((c = s[i]), isspace(c))) {
|
while (i < len && isspace(Py_CHARMASK(s[i]))) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
j = len;
|
j = len;
|
||||||
do {
|
do {
|
||||||
j--;
|
j--;
|
||||||
} while (j >= i && ((c = s[j]), isspace(c)));
|
} while (j >= i && isspace(Py_CHARMASK(s[i])));
|
||||||
j++;
|
j++;
|
||||||
|
|
||||||
if (i == 0 && j == len) {
|
if (i == 0 && j == len) {
|
||||||
|
@ -312,7 +308,7 @@ strop_lower(self, args)
|
||||||
s_new = getstringvalue(new);
|
s_new = getstringvalue(new);
|
||||||
changed = 0;
|
changed = 0;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
char c = *s++;
|
int c = Py_CHARMASK(*s++);
|
||||||
if (isupper(c)) {
|
if (isupper(c)) {
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*s_new = tolower(c);
|
*s_new = tolower(c);
|
||||||
|
@ -347,7 +343,7 @@ strop_upper(self, args)
|
||||||
s_new = getstringvalue(new);
|
s_new = getstringvalue(new);
|
||||||
changed = 0;
|
changed = 0;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
char c = *s++;
|
int c = Py_CHARMASK(*s++);
|
||||||
if (islower(c)) {
|
if (islower(c)) {
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*s_new = toupper(c);
|
*s_new = toupper(c);
|
||||||
|
@ -382,7 +378,7 @@ strop_swapcase(self, args)
|
||||||
s_new = getstringvalue(new);
|
s_new = getstringvalue(new);
|
||||||
changed = 0;
|
changed = 0;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
char c = *s++;
|
int c = Py_CHARMASK(*s++);
|
||||||
if (islower(c)) {
|
if (islower(c)) {
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*s_new = toupper(c);
|
*s_new = toupper(c);
|
||||||
|
@ -530,7 +526,7 @@ initstrop()
|
||||||
|
|
||||||
/* Create 'whitespace' object */
|
/* Create 'whitespace' object */
|
||||||
n = 0;
|
n = 0;
|
||||||
for (c = 1; c < 256; c++) {
|
for (c = 0; c < 256; c++) {
|
||||||
if (isspace(c))
|
if (isspace(c))
|
||||||
buf[n++] = c;
|
buf[n++] = c;
|
||||||
}
|
}
|
||||||
|
@ -541,7 +537,7 @@ initstrop()
|
||||||
}
|
}
|
||||||
/* Create 'lowercase' object */
|
/* Create 'lowercase' object */
|
||||||
n = 0;
|
n = 0;
|
||||||
for (c = 1; c < 256; c++) {
|
for (c = 0; c < 256; c++) {
|
||||||
if (islower(c))
|
if (islower(c))
|
||||||
buf[n++] = c;
|
buf[n++] = c;
|
||||||
}
|
}
|
||||||
|
@ -553,7 +549,7 @@ initstrop()
|
||||||
|
|
||||||
/* Create 'uppercase' object */
|
/* Create 'uppercase' object */
|
||||||
n = 0;
|
n = 0;
|
||||||
for (c = 1; c < 256; c++) {
|
for (c = 0; c < 256; c++) {
|
||||||
if (isupper(c))
|
if (isupper(c))
|
||||||
buf[n++] = c;
|
buf[n++] = c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -753,7 +753,8 @@ eval_code(co, globals, locals, owner, arg)
|
||||||
/* XXX move into writeobject() ? */
|
/* XXX move into writeobject() ? */
|
||||||
char *s = getstringvalue(v);
|
char *s = getstringvalue(v);
|
||||||
int len = getstringsize(v);
|
int len = getstringsize(v);
|
||||||
if (len > 0 && isspace(s[len-1]) &&
|
if (len > 0 &&
|
||||||
|
isspace(Py_CHARMASK(s[len-1])) &&
|
||||||
s[len-1] != ' ')
|
s[len-1] != ' ')
|
||||||
softspace(w, 0);
|
softspace(w, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -608,12 +608,12 @@ parsestr(s)
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
if (isxdigit(*s)) {
|
if (isxdigit(Py_CHARMASK(*s))) {
|
||||||
sscanf(s, "%x", &c);
|
sscanf(s, "%x", &c);
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
do {
|
do {
|
||||||
s++;
|
s++;
|
||||||
} while (isxdigit(*s));
|
} while (isxdigit(Py_CHARMASK(*s)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
|
@ -26,6 +26,14 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Convert a possibly signed character to a nonnegative int */
|
||||||
|
/* XXX This assumes characters are 8 bits wide */
|
||||||
|
#ifdef __CHAR_UNSIGNED__
|
||||||
|
#define Py_CHARMASK(c) (c)
|
||||||
|
#else
|
||||||
|
#define Py_CHARMASK(c) ((c) & 0xff)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "rename2.h"
|
#include "rename2.h"
|
||||||
|
|
||||||
/* strtol and strtoul, renamed to avoid conflicts */
|
/* strtol and strtoul, renamed to avoid conflicts */
|
||||||
|
@ -70,7 +78,7 @@ int base;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip leading white space */
|
/* skip leading white space */
|
||||||
while (*str && isspace(*str))
|
while (*str && isspace(Py_CHARMASK(*str)))
|
||||||
str++;
|
str++;
|
||||||
|
|
||||||
/* check for leading 0 or 0x for auto-base or base 16 */
|
/* check for leading 0 or 0x for auto-base or base 16 */
|
||||||
|
@ -99,7 +107,7 @@ int base;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do the conversion */
|
/* do the conversion */
|
||||||
while (c = *str)
|
while (c = Py_CHARMASK(*str))
|
||||||
{
|
{
|
||||||
if (isdigit(c) && c - '0' < base)
|
if (isdigit(c) && c - '0' < base)
|
||||||
c -= '0';
|
c -= '0';
|
||||||
|
@ -143,7 +151,7 @@ int base;
|
||||||
long result;
|
long result;
|
||||||
char sign;
|
char sign;
|
||||||
|
|
||||||
while (*str && isspace(*str))
|
while (*str && isspace(Py_CHARMASK(*str)))
|
||||||
str++;
|
str++;
|
||||||
|
|
||||||
sign = *str;
|
sign = *str;
|
||||||
|
|
Loading…
Reference in New Issue