Kaydet (Commit) d19c04a8 authored tarafından Guido van Rossum's avatar Guido van Rossum

Change [_Py_]re_compile_pattern() to return a char*.

Since it only returns an error message (or NULL) there's no reason
for it to be unsigned char *, and various compilers like this better.
üst 5ade0849
...@@ -439,7 +439,7 @@ newregexobject(pattern, translate, givenpat, groupindex) ...@@ -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 = (char *)re_compile_pattern((unsigned char *)pat, size, &re->re_patbuf); error = _Py_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;
......
...@@ -1157,7 +1157,7 @@ else \ ...@@ -1157,7 +1157,7 @@ else \
} \ } \
} }
unsigned char *re_compile_pattern(unsigned char *regex, int size, regexp_t bufp) char *re_compile_pattern(unsigned char *regex, int size, regexp_t bufp)
{ {
int a; int a;
int pos; int pos;
...@@ -1535,36 +1535,36 @@ unsigned char *re_compile_pattern(unsigned char *regex, int size, regexp_t bufp) ...@@ -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 (unsigned char *)"Optimization error"; return "Optimization error";
return NULL; return NULL;
op_error: op_error:
SET_FIELDS; SET_FIELDS;
return (unsigned char *)"Badly placed special character"; return "Badly placed special character";
bad_match_register: bad_match_register:
SET_FIELDS; SET_FIELDS;
return (unsigned char *)"Bad match register number"; return "Bad match register number";
hex_error: hex_error:
SET_FIELDS; SET_FIELDS;
return (unsigned char *)"Bad hexadecimal number"; return "Bad hexadecimal number";
parenthesis_error: parenthesis_error:
SET_FIELDS; SET_FIELDS;
return (unsigned char *)"Badly placed parenthesis"; return "Badly placed parenthesis";
out_of_memory: out_of_memory:
SET_FIELDS; SET_FIELDS;
return (unsigned char *)"Out of memory"; return "Out of memory";
ends_prematurely: ends_prematurely:
SET_FIELDS; SET_FIELDS;
return (unsigned char *)"Regular expression ends prematurely"; return "Regular expression ends prematurely";
too_complex: too_complex:
SET_FIELDS; SET_FIELDS;
return (unsigned char *)"Regular expression too complex"; return "Regular expression too complex";
} }
#undef CHARAT #undef CHARAT
......
...@@ -101,7 +101,7 @@ int re_set_syntax(int syntax); ...@@ -101,7 +101,7 @@ int re_set_syntax(int syntax);
/* This sets the syntax to use and returns the previous syntax. The /* This sets the syntax to use and returns the previous syntax. The
* syntax is specified by a bit mask of the above defined bits. */ * syntax is specified by a bit mask of the above defined bits. */
unsigned char *re_compile_pattern(unsigned char *regex, int regex_size, regexp_t compiled); char *re_compile_pattern(unsigned char *regex, int regex_size, regexp_t compiled);
/* This compiles the regexp (given in regex and length in regex_size). /* This compiles the regexp (given in regex and length in regex_size).
* This returns NULL if the regexp compiled successfully, and an error * This returns NULL if the regexp compiled successfully, and an error
* message if an error was encountered. The buffer field must be * message if an error was encountered. The buffer field must be
...@@ -138,7 +138,7 @@ extern int re_syntax; ...@@ -138,7 +138,7 @@ extern int re_syntax;
extern unsigned char re_syntax_table[256]; extern unsigned char re_syntax_table[256];
void re_compile_initialize(); void re_compile_initialize();
int re_set_syntax(); int re_set_syntax();
unsigned char *re_compile_pattern(); char *re_compile_pattern();
int re_match(); int re_match();
int re_search(); int re_search();
void re_compile_fastmap(); void re_compile_fastmap();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment