diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-14 21:14:57 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-14 21:14:57 +0200 |
commit | 1e7d0cb3d24a59e89d2c63ca106c4d8da8f3bdcf (patch) | |
tree | c03f5236d6eaa373c8d609eaa9b85bbd9922d7d2 /src/search.c | |
parent | ab0d97147d8c19eabc41b11698dff13cd04d67ae (diff) | |
download | sciteco-hsrex.tar.gz |
fixuphsrex
Diffstat (limited to 'src/search.c')
-rw-r--r-- | src/search.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/search.c b/src/search.c index 81d2074..8ea97ad 100644 --- a/src/search.c +++ b/src/search.c @@ -574,7 +574,6 @@ teco_state_search_process(teco_machine_main_t *ctx, const teco_string_t *str, gs !search_reg->vtable->set_integer(search_reg, TECO_FAILURE, error)) return FALSE; - g_auto(regex_t) re = {0}; teco_string_t pattern = *str; g_autofree gchar *re_pattern; /* NOTE: teco_pattern2regexp() modifies str pointer */ @@ -585,20 +584,24 @@ teco_state_search_process(teco_machine_main_t *ctx, const teco_string_t *str, gs #ifdef DEBUG g_printf("REGEXP: %s\n", re_pattern); #endif - if (!*re_pattern) - goto failure; + if (!*re_pattern) { + teco_interface_ssm(SCI_GOTOPOS, teco_search_parameters.dot, 0); + return TRUE; + } + /* * FIXME: We don't have to escape null characters in re_pattern. */ + g_auto(regex_t) re; #if 0 gint rc = ctx->expectstring.machine.codepage == SC_CP_UTF8 - ? re_wcomp(&re, re_pattern, strlen(re_pattern), flags) - : re_comp(&re, re_pattern, strlen(re_pattern), flags); + ? re_wcomp(&re, (guchar *)re_pattern, strlen(re_pattern), flags) + : re_comp(&re, (guchar *)re_pattern, strlen(re_pattern), flags); #endif // FIXME: Apparently this is the ASCII-only version, while re_wcomp() is the widechar version // which expects UTF-32. // This means that teco_pattern2regexp() would have to return an UTF-32 version. - gint rc = re_comp(&re, re_pattern, strlen(re_pattern), flags); + gint rc = re_comp(&re, (guchar *)re_pattern, strlen(re_pattern), flags); if (rc) goto failure; |