1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

regexp: Hide debugging code behind DEBUG_REGEXP

xmlRegexpPrint is now a deprecated no-op.
This commit is contained in:
Nick Wellnhofer
2025-02-22 20:31:45 +01:00
parent 4649f28f77
commit 6fc260760a
3 changed files with 46 additions and 33 deletions

View File

@ -47,6 +47,7 @@ XMLPUBFUN void xmlRegFreeRegexp(xmlRegexpPtr regexp);
XMLPUBFUN int XMLPUBFUN int
xmlRegexpExec (xmlRegexpPtr comp, xmlRegexpExec (xmlRegexpPtr comp,
const xmlChar *value); const xmlChar *value);
XML_DEPRECATED
XMLPUBFUN void XMLPUBFUN void
xmlRegexpPrint (FILE *output, xmlRegexpPrint (FILE *output,
xmlRegexpPtr regexp); xmlRegexpPtr regexp);

View File

@ -381,6 +381,7 @@ deprecated_funcs = {
'xmlRecoverDoc': True, 'xmlRecoverDoc': True,
'xmlRecoverFile': True, 'xmlRecoverFile': True,
'xmlRecoverMemory': True, 'xmlRecoverMemory': True,
'xmlRegexpPrint': True,
'xmlRegisterHTTPPostCallbacks': True, 'xmlRegisterHTTPPostCallbacks': True,
'xmlRelaxNGCleanupTypes': True, 'xmlRelaxNGCleanupTypes': True,
'xmlRelaxNGInitTypes': True, 'xmlRelaxNGInitTypes': True,

View File

@ -37,6 +37,8 @@
#define SIZE_MAX ((size_t) -1) #define SIZE_MAX ((size_t) -1)
#endif #endif
/* #define DEBUG_REGEXP */
#define MAX_PUSH 10000000 #define MAX_PUSH 10000000
#ifdef ERROR #ifdef ERROR
@ -930,6 +932,7 @@ xmlRegFreeParserCtxt(xmlRegParserCtxtPtr ctxt) {
* * * *
************************************************************************/ ************************************************************************/
#ifdef DEBUG_REGEXP
static void static void
xmlRegPrintAtomType(FILE *output, xmlRegAtomType type) { xmlRegPrintAtomType(FILE *output, xmlRegAtomType type) {
switch (type) { switch (type) {
@ -1302,6 +1305,42 @@ xmlRegPrintCompact(FILE* output, xmlRegexpPtr regexp)
fprintf(output, "%d counters:\n", 0); fprintf(output, "%d counters:\n", 0);
} }
static void
xmlRegexpPrintInternal(FILE *output, xmlRegexpPtr regexp) {
int i;
if (output == NULL)
return;
fprintf(output, " regexp: ");
if (regexp == NULL) {
fprintf(output, "NULL\n");
return;
}
if (regexp->compact) {
xmlRegPrintCompact(output, regexp);
return;
}
fprintf(output, "'%s' ", regexp->string);
fprintf(output, "\n");
fprintf(output, "%d atoms:\n", regexp->nbAtoms);
for (i = 0;i < regexp->nbAtoms; i++) {
fprintf(output, " %02d ", i);
xmlRegPrintAtom(output, regexp->atoms[i]);
}
fprintf(output, "%d states:", regexp->nbStates);
fprintf(output, "\n");
for (i = 0;i < regexp->nbStates; i++) {
xmlRegPrintState(output, regexp->states[i]);
}
fprintf(output, "%d counters:\n", regexp->nbCounters);
for (i = 0;i < regexp->nbCounters; i++) {
fprintf(output, " %d: min %d max %d\n", i, regexp->counters[i].min,
regexp->counters[i].max);
}
}
#endif /* DEBUG_REGEXP */
/************************************************************************ /************************************************************************
* * * *
* Finite Automata structures manipulations * * Finite Automata structures manipulations *
@ -5359,41 +5398,13 @@ xmlFAParseRegExp(xmlRegParserCtxtPtr ctxt, int top) {
* @output: the file for the output debug * @output: the file for the output debug
* @regexp: the compiled regexp * @regexp: the compiled regexp
* *
* Print the content of the compiled regular expression * DEPRECATED: Don't use.
*
* No-op since 2.14.0.
*/ */
void void
xmlRegexpPrint(FILE *output, xmlRegexpPtr regexp) { xmlRegexpPrint(FILE *output ATTRIBUTE_UNUSED,
int i; xmlRegexpPtr regexp ATTRIBUTE_UNUSED) {
if (output == NULL)
return;
fprintf(output, " regexp: ");
if (regexp == NULL) {
fprintf(output, "NULL\n");
return;
}
if (regexp->compact) {
xmlRegPrintCompact(output, regexp);
return;
}
fprintf(output, "'%s' ", regexp->string);
fprintf(output, "\n");
fprintf(output, "%d atoms:\n", regexp->nbAtoms);
for (i = 0;i < regexp->nbAtoms; i++) {
fprintf(output, " %02d ", i);
xmlRegPrintAtom(output, regexp->atoms[i]);
}
fprintf(output, "%d states:", regexp->nbStates);
fprintf(output, "\n");
for (i = 0;i < regexp->nbStates; i++) {
xmlRegPrintState(output, regexp->states[i]);
}
fprintf(output, "%d counters:\n", regexp->nbCounters);
for (i = 0;i < regexp->nbCounters; i++) {
fprintf(output, " %d: min %d max %d\n", i, regexp->counters[i].min,
regexp->counters[i].max);
}
} }
/** /**