regex: Fix PCRE error code conversion

Use the shifted error codes for comparisions.

https://bugzilla.gnome.org/show_bug.cgi?id=677578
This commit is contained in:
Christian Persch 2012-06-06 21:54:08 +02:00
parent 3173fca9cc
commit d9e8d3e0f0

View File

@ -396,36 +396,36 @@ translate_compile_error (gint *errcode, const gchar **errmsg)
*errmsg = _("\\g is not followed by a braced name or an optionally " *errmsg = _("\\g is not followed by a braced name or an optionally "
"braced non-zero number"); "braced non-zero number");
break; break;
case 11: case 111:
*errcode = G_REGEX_ERROR_INTERNAL; *errcode = G_REGEX_ERROR_INTERNAL;
*errmsg = _("unexpected repeat"); *errmsg = _("unexpected repeat");
break; break;
case 23: case 123:
*errcode = G_REGEX_ERROR_INTERNAL; *errcode = G_REGEX_ERROR_INTERNAL;
*errmsg = _("code overflow"); *errmsg = _("code overflow");
break; break;
case 52: case 152:
*errcode = G_REGEX_ERROR_INTERNAL; *errcode = G_REGEX_ERROR_INTERNAL;
*errmsg = _("overran compiling workspace"); *errmsg = _("overran compiling workspace");
break; break;
case 53: case 153:
*errcode = G_REGEX_ERROR_INTERNAL; *errcode = G_REGEX_ERROR_INTERNAL;
*errmsg = _("previously-checked referenced subpattern not found"); *errmsg = _("previously-checked referenced subpattern not found");
break; break;
case 16: case 116:
/* This should not happen as we never pass a NULL erroffset */ /* This should not happen as we never pass a NULL erroffset */
g_warning ("erroffset passed as NULL"); g_warning ("erroffset passed as NULL");
*errcode = G_REGEX_ERROR_COMPILE; *errcode = G_REGEX_ERROR_COMPILE;
break; break;
case 17: case 117:
/* This should not happen as we check options before passing them /* This should not happen as we check options before passing them
* to pcre_compile2() */ * to pcre_compile2() */
g_warning ("unknown option bit(s) set"); g_warning ("unknown option bit(s) set");
*errcode = G_REGEX_ERROR_COMPILE; *errcode = G_REGEX_ERROR_COMPILE;
break; break;
case 32: case 132:
case 44: case 144:
case 45: case 145:
/* These errors should not happen as we are using an UTF8-enabled PCRE /* These errors should not happen as we are using an UTF8-enabled PCRE
* and we do not check if strings are valid */ * and we do not check if strings are valid */
g_warning ("%s", *errmsg); g_warning ("%s", *errmsg);