comparison th_regex.c @ 771:c17eadc60c3d

Rename th_ioctx struct to th_ioctx_t, for consistency. Breaks API.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 20 Feb 2023 23:33:45 +0200
parents 31bc1ed07cf5
children
comparison
equal deleted inserted replaced
770:79f888e4616f 771:c17eadc60c3d
7 */ 7 */
8 #include "th_regex.h" 8 #include "th_regex.h"
9 9
10 10
11 #ifdef TH_EXPERIMENTAL_REGEX_DEBUG 11 #ifdef TH_EXPERIMENTAL_REGEX_DEBUG
12 th_ioctx *th_dbg_fh = NULL; 12 th_ioctx_t *th_dbg_fh = NULL;
13 13
14 # define DBG_RE_PRINT(...) do { \ 14 # define DBG_RE_PRINT(...) do { \
15 if (th_dbg_fh != NULL) \ 15 if (th_dbg_fh != NULL) \
16 { \ 16 { \
17 th_regex_dump_indent(th_dbg_fh, level); \ 17 th_regex_dump_indent(th_dbg_fh, level); \
750 th_free(expr); 750 th_free(expr);
751 } 751 }
752 } 752 }
753 753
754 754
755 static void th_regex_dump_indent(th_ioctx *fh, const int level) 755 static void th_regex_dump_indent(th_ioctx_t *fh, const int level)
756 { 756 {
757 for (int indent = 0; indent < level; indent++) 757 for (int indent = 0; indent < level; indent++)
758 thfputs(" ", fh); 758 thfputs(" ", fh);
759 } 759 }
760 760
761 761
762 static void th_regex_dump_node(th_ioctx *fh, const th_regex_node_t *node) 762 static void th_regex_dump_node(th_ioctx_t *fh, const th_regex_node_t *node)
763 { 763 {
764 thfprintf(fh, 764 thfprintf(fh,
765 "%s %s ", 765 "%s %s ",
766 re_match_modes[node->mode], 766 re_match_modes[node->mode],
767 re_match_types[node->type]); 767 re_match_types[node->type]);
808 } 808 }
809 809
810 810
811 /** 811 /**
812 * Print out the contents of given regular expression structure @p expr 812 * Print out the contents of given regular expression structure @p expr
813 * in "human-readable" format to specified @c th_ioctx context. Typically 813 * in "human-readable" format to specified @c th_ioctx_t context. Typically
814 * useful for debugging purposes only. 814 * useful for debugging purposes only.
815 * 815 *
816 * @param[in,out] fh th_ioctx handle to be used for output, must be writable. 816 * @param[in,out] fh th_ioctx.handle to be used for output, must be writable.
817 * @param[in] level starting whitespace indentation level 817 * @param[in] level starting whitespace indentation level
818 * @param[in] expr regular expression structure to be "dumped" 818 * @param[in] expr regular expression structure to be "dumped"
819 */ 819 */
820 void th_regex_dump(th_ioctx *fh, const int level, const th_regex_t *expr) 820 void th_regex_dump(th_ioctx_t *fh, const int level, const th_regex_t *expr)
821 { 821 {
822 if (expr != NULL) 822 if (expr != NULL)
823 { 823 {
824 for (size_t nnode = 0; nnode < expr->nnodes; nnode++) 824 for (size_t nnode = 0; nnode < expr->nnodes; nnode++)
825 { 825 {