aboutsummaryrefslogtreecommitdiff
path: root/src/include/regex
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-02-14 19:53:28 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2021-02-14 19:53:42 -0500
commit2dd6733108f2bea07b0a3469e768bd900c0808b3 (patch)
tree6b9d7faf0edf3c1ccbb6fc3f959434e5931aa856 /src/include/regex
parentc7ecd6af010e2ac8c5530f3985e97f24531bfa5f (diff)
downloadpostgresql-2dd6733108f2bea07b0a3469e768bd900c0808b3.tar.gz
postgresql-2dd6733108f2bea07b0a3469e768bd900c0808b3.zip
Minor fixes to improve regex debugging code.
When REG_DEBUG is defined, ensure that an un-filled "struct cnfa" is all-zeroes, not just that it has nstates == 0. This is mainly so that looking at "struct subre" structs in gdb doesn't distract one with a lot of garbage fields during regex compilation. Adjust some places that print debug output to have suitable fflush calls afterwards. In passing, correct an erroneous ancient comment: the concatenation subre-s created by parsebranch() have op == '.' not ','. Noted while fooling around with some regex performance improvements.
Diffstat (limited to 'src/include/regex')
-rw-r--r--src/include/regex/regguts.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/include/regex/regguts.h b/src/include/regex/regguts.h
index 5d0e7a961c9..0a616562d03 100644
--- a/src/include/regex/regguts.h
+++ b/src/include/regex/regguts.h
@@ -368,7 +368,15 @@ struct cnfa
struct carc *arcs; /* the area for the lists */
};
+/*
+ * When debugging, it's helpful if an un-filled CNFA is all-zeroes.
+ * In production, though, we only require nstates to be zero.
+ */
+#ifdef REG_DEBUG
+#define ZAPCNFA(cnfa) memset(&(cnfa), 0, sizeof(cnfa))
+#else
#define ZAPCNFA(cnfa) ((cnfa).nstates = 0)
+#endif
#define NULLCNFA(cnfa) ((cnfa).nstates == 0)
/*