Casts by Jack to shut up the Mac compiler.

This commit is contained in:
Guido van Rossum 1997-08-18 15:31:24 +00:00
parent bad3c013d2
commit ed2554a396
4 changed files with 32 additions and 32 deletions

View File

@ -130,7 +130,7 @@ regobj_match(re, args)
} }
Py_XDECREF(re->re_lastok); Py_XDECREF(re->re_lastok);
re->re_lastok = NULL; re->re_lastok = NULL;
result = _Py_re_match(&re->re_patbuf, buffer, size, offset, result = _Py_re_match(&re->re_patbuf, (unsigned char *)buffer, size, offset,
&re->re_regs); &re->re_regs);
if (result < -1) { if (result < -1) {
/* Serious failure of some sort; if re_match didn't /* Serious failure of some sort; if re_match didn't
@ -174,7 +174,7 @@ regobj_search(re, args)
range = size - offset; range = size - offset;
Py_XDECREF(re->re_lastok); Py_XDECREF(re->re_lastok);
re->re_lastok = NULL; re->re_lastok = NULL;
result = _Py_re_search(&re->re_patbuf, buffer, size, offset, range, result = _Py_re_search(&re->re_patbuf, (unsigned char *)buffer, size, offset, range,
&re->re_regs); &re->re_regs);
if (result < -1) { if (result < -1) {
/* Serious failure of some sort; if re_match didn't /* Serious failure of some sort; if re_match didn't
@ -423,9 +423,9 @@ newregexobject(pattern, translate, givenpat, groupindex)
char *error; char *error;
re->re_patbuf.buffer = NULL; re->re_patbuf.buffer = NULL;
re->re_patbuf.allocated = 0; re->re_patbuf.allocated = 0;
re->re_patbuf.fastmap = re->re_fastmap; re->re_patbuf.fastmap = (unsigned char *)re->re_fastmap;
if (translate) { if (translate) {
re->re_patbuf.translate = PyString_AsString(translate); re->re_patbuf.translate = (unsigned char *)PyString_AsString(translate);
if (!re->re_patbuf.translate) if (!re->re_patbuf.translate)
goto finally; goto finally;
Py_INCREF(translate); Py_INCREF(translate);
@ -439,7 +439,7 @@ newregexobject(pattern, translate, givenpat, groupindex)
re->re_realpat = pattern; re->re_realpat = pattern;
Py_INCREF(givenpat); Py_INCREF(givenpat);
re->re_givenpat = givenpat; re->re_givenpat = givenpat;
error = re_compile_pattern(pat, size, &re->re_patbuf); error = (char *)re_compile_pattern((unsigned char *)pat, size, &re->re_patbuf);
if (error != NULL) { if (error != NULL) {
PyErr_SetString(RegexError, error); PyErr_SetString(RegexError, error);
goto finally; goto finally;

View File

@ -1535,36 +1535,36 @@ unsigned char *re_compile_pattern(unsigned char *regex, int size, regexp_t bufp)
STORE(Cend); STORE(Cend);
SET_FIELDS; SET_FIELDS;
if(!re_optimize(bufp)) if(!re_optimize(bufp))
return "Optimization error"; return (unsigned char *)"Optimization error";
return NULL; return NULL;
op_error: op_error:
SET_FIELDS; SET_FIELDS;
return "Badly placed special character"; return (unsigned char *)"Badly placed special character";
bad_match_register: bad_match_register:
SET_FIELDS; SET_FIELDS;
return "Bad match register number"; return (unsigned char *)"Bad match register number";
hex_error: hex_error:
SET_FIELDS; SET_FIELDS;
return "Bad hexadecimal number"; return (unsigned char *)"Bad hexadecimal number";
parenthesis_error: parenthesis_error:
SET_FIELDS; SET_FIELDS;
return "Badly placed parenthesis"; return (unsigned char *)"Badly placed parenthesis";
out_of_memory: out_of_memory:
SET_FIELDS; SET_FIELDS;
return "Out of memory"; return (unsigned char *)"Out of memory";
ends_prematurely: ends_prematurely:
SET_FIELDS; SET_FIELDS;
return "Regular expression ends prematurely"; return (unsigned char *)"Regular expression ends prematurely";
too_complex: too_complex:
SET_FIELDS; SET_FIELDS;
return "Regular expression too complex"; return (unsigned char *)"Regular expression too complex";
} }
#undef CHARAT #undef CHARAT

View File

@ -141,7 +141,7 @@ reop_match(self, args)
"casefold")) == NULL) "casefold")) == NULL)
return NULL; return NULL;
bufp.translate = PyString_AsString(casefold); bufp.translate = (unsigned char*)PyString_AsString(casefold);
} }
else else
bufp.translate=NULL; bufp.translate=NULL;
@ -241,7 +241,7 @@ reop_search(self, args)
"casefold")) == NULL) "casefold")) == NULL)
return NULL; return NULL;
bufp.translate = PyString_AsString(casefold); bufp.translate = (unsigned char *)PyString_AsString(casefold);
} }
else else
bufp.translate=NULL; bufp.translate=NULL;
@ -339,7 +339,7 @@ reop_expand_escape(self, args)
string[1]='\\'; string[1]='\\';
string[length+4]='\0'; string[length+4]='\0';
memcpy(string+2, pattern+index-1, length+1); memcpy(string+2, pattern+index-1, length+1);
v=PyRun_String(string, Py_eval_input, v=PyRun_String((char *)string, Py_eval_input,
PyEval_GetGlobals(), PyEval_GetLocals()); PyEval_GetGlobals(), PyEval_GetLocals());
free(string); free(string);
/* The evaluation raised an exception */ /* The evaluation raised an exception */
@ -657,7 +657,7 @@ reop__expand(self, args)
if (!PyArg_ParseTuple(args, "OS", &match_obj, &repl_obj)) if (!PyArg_ParseTuple(args, "OS", &match_obj, &repl_obj))
return NULL; return NULL;
repl=PyString_AsString(repl_obj); repl=(unsigned char *)PyString_AsString(repl_obj);
size=PyString_Size(repl_obj); size=PyString_Size(repl_obj);
results=PyList_New(0); results=PyList_New(0);
if (results==NULL) return NULL; if (results==NULL) return NULL;
@ -671,7 +671,7 @@ reop__expand(self, args)
if (start!=i) if (start!=i)
{ {
PyList_Append(results, PyList_Append(results,
PyString_FromStringAndSize(repl+start, i-start)); PyString_FromStringAndSize((char *)repl+start, i-start));
total_len += i-start; total_len += i-start;
} }
i++; i++;
@ -742,7 +742,7 @@ reop__expand(self, args)
if (start!=i) if (start!=i)
{ {
PyList_Append(results, PyString_FromStringAndSize(repl+start, i-start)); PyList_Append(results, PyString_FromStringAndSize((char *)repl+start, i-start));
total_len += i-start; total_len += i-start;
} }
@ -758,7 +758,7 @@ reop__expand(self, args)
return NULL; return NULL;
} }
repl=PyString_AsString(newstring); repl=(unsigned char *)PyString_AsString(newstring);
for (pos=i=0; i<PyList_Size(results); i++) for (pos=i=0; i<PyList_Size(results); i++)
{ {
PyObject *item=PyList_GetItem(results, i); PyObject *item=PyList_GetItem(results, i);
@ -963,10 +963,10 @@ initreop()
goto finally; goto finally;
/* Initialize reop.casefold constant */ /* Initialize reop.casefold constant */
if (!(v = PyString_FromStringAndSize((unsigned char *)NULL, 256))) if (!(v = PyString_FromStringAndSize((char *)NULL, 256)))
goto finally; goto finally;
if (!(s = PyString_AsString(v))) if (!(s = (unsigned char *)PyString_AsString(v)))
goto finally; goto finally;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
@ -990,7 +990,7 @@ initreop()
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
j[0] = i; j[0] = i;
k = PyString_FromStringAndSize(j, 1); k = PyString_FromStringAndSize((char *)j, 1);
if (k == NULL) if (k == NULL)
goto finally; goto finally;
v = PyInt_FromLong(re_syntax_table[i]); v = PyInt_FromLong(re_syntax_table[i]);

View File

@ -210,7 +210,7 @@ PyZlib_decompress(self, args)
inflateEnd(&zst); inflateEnd(&zst);
return NULL; return NULL;
} }
zst.next_out = PyString_AsString(result_str) + r_strlen; zst.next_out = (unsigned char *)PyString_AsString(result_str) + r_strlen;
zst.avail_out=r_strlen; zst.avail_out=r_strlen;
r_strlen = r_strlen << 1; r_strlen = r_strlen << 1;
break; break;
@ -369,7 +369,7 @@ PyZlib_objcompress(self, args)
"Can't allocate memory to compress data"); "Can't allocate memory to compress data");
return NULL; return NULL;
} }
self->zst.next_out = PyString_AsString(RetVal); self->zst.next_out = (unsigned char *)PyString_AsString(RetVal);
self->zst.avail_out = length; self->zst.avail_out = length;
while (self->zst.avail_in != 0 && err == Z_OK) while (self->zst.avail_in != 0 && err == Z_OK)
{ {
@ -380,7 +380,7 @@ PyZlib_objcompress(self, args)
"Can't allocate memory to compress data"); "Can't allocate memory to compress data");
return NULL; return NULL;
} }
self->zst.next_out = PyString_AsString(RetVal) + length; self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length;
self->zst.avail_out = length; self->zst.avail_out = length;
length = length << 1; length = length << 1;
} }
@ -419,7 +419,7 @@ PyZlib_objdecompress(self, args)
self->zst.avail_in=inplen; self->zst.avail_in=inplen;
self->zst.next_in=input; self->zst.next_in=input;
self->zst.avail_out = length = DEFAULTALLOC; self->zst.avail_out = length = DEFAULTALLOC;
self->zst.next_out = PyString_AsString(RetVal); self->zst.next_out = (unsigned char *)PyString_AsString(RetVal);
err = Z_OK; err = Z_OK;
while (self->zst.avail_in != 0 && err == Z_OK) while (self->zst.avail_in != 0 && err == Z_OK)
@ -433,7 +433,7 @@ PyZlib_objdecompress(self, args)
"Can't allocate memory to compress data"); "Can't allocate memory to compress data");
return NULL; return NULL;
} }
self->zst.next_out = PyString_AsString(RetVal) + length; self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length;
self->zst.avail_out = length; self->zst.avail_out = length;
length = length << 1; length = length << 1;
} }
@ -474,7 +474,7 @@ PyZlib_flush(self, args)
"Can't allocate memory to compress data"); "Can't allocate memory to compress data");
return NULL; return NULL;
} }
self->zst.next_out = PyString_AsString(RetVal); self->zst.next_out = (unsigned char *)PyString_AsString(RetVal);
self->zst.avail_out = length; self->zst.avail_out = length;
while (err == Z_OK) while (err == Z_OK)
{ {
@ -485,7 +485,7 @@ PyZlib_flush(self, args)
"Can't allocate memory to compress data"); "Can't allocate memory to compress data");
return NULL; return NULL;
} }
self->zst.next_out = PyString_AsString(RetVal) + length; self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length;
self->zst.avail_out = length; self->zst.avail_out = length;
length = length << 1; length = length << 1;
} }
@ -534,7 +534,7 @@ PyZlib_unflush(self, args)
return NULL; return NULL;
} }
self->zst.avail_in=0; self->zst.avail_in=0;
self->zst.next_out = PyString_AsString(RetVal); self->zst.next_out = (unsigned char *)PyString_AsString(RetVal);
length = self->zst.avail_out = DEFAULTALLOC; length = self->zst.avail_out = DEFAULTALLOC;
err = Z_OK; err = Z_OK;
@ -549,7 +549,7 @@ PyZlib_unflush(self, args)
"Can't allocate memory to decompress data"); "Can't allocate memory to decompress data");
return NULL; return NULL;
} }
self->zst.next_out = PyString_AsString(RetVal) + length; self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length;
self->zst.avail_out = length; self->zst.avail_out = length;
length = length << 1; length = length << 1;
} }