Commit Graph

24 Commits

Author SHA1 Message Date
Andrew Borodin 6718b3ec26 Indentation using GNU indent-2.2.13.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03:00
Andrew Borodin f1cf92f435 Indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:55 +03:00
Andrew Borodin 49624e473b Ticket #4450: support PCRE2 in the search engine.
* m4.include/ax_path_lib_pcre.m4: replace by recent version from GNU
Autoconf Archive.
  * m4.include/ax_check_pcre2.m4: get grom GNU Autoconf Archive.
  * m4.include/mc-check-search-type.m4: support both PCRE versions.
  * */*/Makefile.am: remove @CHECK_CFLAGS@ and @PCRE_LIBS@ ads they are
added via AX_PATH_LIB_PCRE and AX_CHECK_PCRE2.
  * lib/search.h, lib/search/: add support of PCRE2. Thanks broly <gagan@hotmail.com>
for the initial patch.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-25 10:07:41 +03:00
Andrew Borodin 47b116b773 mc_search: refactoring.
(mc_search_t): use GString to keep original search string. Join search string
and charset to structure.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-10 21:07:40 +03:00
Andrew Borodin 0222169206 (mc_search_prepare): cache result.
mc_search_struct: add new member prepared.result to keep the result of
the mc_search_prepare() first call. It can be used to check a regexp
before call of mc_search_run() in a loop.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-04-10 17:42:43 +03:00
Andrew Borodin 975bf17d3b mc_search_struct: rename member: conditions -> prepared_conditions.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-04-10 17:42:43 +03:00
Andrew Borodin d35df9ad60 Use argument names in function declarations.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2021-06-20 15:14:56 +03:00
Andreas Mohr e4badcf7bc (mc_search_set_error): cleanup compile warning on older gcc compilers:
search.c: In function 'mc_search_set_error':
search.c:497:36: error: declaration of 'mc_search' shadows a global declaration [-Werror=shadow]
search.c:419:1: error: shadowed declaration is here [-Werror=shadow]

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-07-29 09:29:36 +03:00
Andrew Borodin 8252345666 Allow search be interruptible.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-05-22 14:16:19 +03:00
Andrew Borodin 1c22d44970 Ticket #3637: fix memory leaks in search engine.
(mc_search_set_error): new search API to set the code and message
of search error.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-05-22 14:16:19 +03:00
Andrew Borodin c5714eee34 Use STR_E_NOTFOUND message where required.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-01-01 11:48:08 +03:00
Andreas Mohr a3a78d9daf Fix compiler warning at search.c
search.c:56:12: warning: implicit conversion changes signedness: 'int' to 'mc_search_type_t' [-Wsign-conversion]
    {NULL, -1}
    ~      ^~
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-01-01 11:48:07 +03:00
Andreas Mohr 5007d309bc Fix -Wconversion warning for mc_search_new().
mc_search_new() parameter orignial_len use once only.
Factor out into own function mc_search_new_len().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-01-01 11:48:07 +03:00
Andrew Borodin 2c7dfe7341 (mc_search_prepare_replace_str2): make replace_str const.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2015-02-26 09:12:08 +03:00
Andrew Borodin 941a1eac1d Search: better support of --disable-charset
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-09-21 13:35:56 +04:00
Andrew Borodin 66da276200 Ticket 3069: fix of case-sensitive search
...if file encoding and locale are different.

Example: locale is KOI8-R, file encoding is UTF-8. Note: those encodings
are not same.

File content is following (in Russian):

йцукен
Йцукен

The difference is in first line char only: Й (lowercase letter) and й
(uppercase letter).  The search of Ê gives the result Й independently of
case sensitivity. й isn't found.
If switch "All charsets" on, nothing is found.

The main idea of fix is modification of search API to allow set of search
pattern charset and use if within search engine.
Old API:
mc_search_new (pattern, pattern_len);
New API:
mc_search_new (pattern, pattern_len, pattern_charset);

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-09-21 13:35:31 +04:00
Andrew Borodin d0955f3793 Search callbacks should return mc_search_cbret_t not int.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-06-03 14:21:03 +03:00
Andrew Borodin bbf534e7d7 Don't mix mc_search_cb_ret_t and int as result of search callback.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2012-05-08 18:57:55 +04:00
Vitaliy Filippov fb7b01eeb9 Despite of the fact that algorithm now ignores the absence of closing curly
brace '}' (which probably isn't 100% correct), this should be checked in tests
for replace_handle_esc_seq function, not process_escape_sequence - it is the
replace_handle_esq_seq who decides whether it is an escape sequence or not.

Also, \x{4344} is usually a code for wide character (UTF-8), and not for "CD".
So we can either ignore the higher bits, or generate wide character codes...
The second would be convenient, but would also introduce a hard-coded UTF-8 charset.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2011-07-08 17:28:07 +03:00
Andrew Borodin 1192d34bd1 Clean up some empty lines.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2010-11-24 10:27:46 +03:00
Slava Zanko feb733663f Code indentation in lib directory
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2010-11-24 10:27:20 +03:00
Andrew Borodin 4892044e71 Remove extra check before mc_search free() call.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2010-11-24 10:27:20 +03:00
Andrew Borodin e70db42deb Grammar.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2010-05-05 16:24:13 +04:00
Slava Zanko 25155c311a Move all interface includes from subdirs lib/*/*.h into lib/*.h
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2010-01-26 10:30:25 +02:00