From 07f2e831c15e761da9406ce50ef7fc383f901a96 Mon Sep 17 00:00:00 2001 From: Alfons Hoogervorst Date: Fri, 28 Dec 2001 19:22:46 +0000 Subject: [PATCH] cleanup namespace and put where it belongs so the stuff should compile on *BSD --- ChangeLog.claws | 6 ++++++ configure.in | 2 +- src/string_match.c | 46 ++++++++++++++++++++++++++++------------------ src/string_match.h | 28 ++++++---------------------- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index d83f894af..5165891fb 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,9 @@ +2001-12-28 [alfons] 0.6.6claws29 + + * src/string_match.[ch] + clean up name space + allow compilation *BSD + 2001-12-27 [alfons] 0.6.6claws28 * src/filter.c diff --git a/configure.in b/configure.in index 227083e6c..909692a8e 100644 --- a/configure.in +++ b/configure.in @@ -8,7 +8,7 @@ MINOR_VERSION=6 MICRO_VERSION=6 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws28 +EXTRA_VERSION=claws29 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl diff --git a/src/string_match.c b/src/string_match.c index 114fb593c..a70366606 100644 --- a/src/string_match.c +++ b/src/string_match.c @@ -18,28 +18,19 @@ */ #include +#include +#include #include "string_match.h" +/* the size used for regexec in string_remove_match */ +#define STRING_MATCH_MR_SIZE 30 -int string_match_regexp(char * txt, char * rexp, - int size, regmatch_t matches[], - int cflags, int eflags) -{ - regex_t re; - int problem; - g_return_val_if_fail(txt, 0); - g_return_val_if_fail(rexp, 0); +static int string_match_regexp (char * txt, char * rexp, + int size, regmatch_t matches[], + int cflags, int eflags); - problem = regcomp(&re, rexp, cflags); - if (problem == 0) { - problem = regexec(&re, txt, size, matches, eflags); - } - regfree(&re); - return problem == 0; -} - -int string_remove_match(char * txt, char * rexp, int cflags, int eflags) +int string_remove_match(char *txt, char *rexp, int cflags, int eflags) { regmatch_t matches[STRING_MATCH_MR_SIZE]; int foundp; @@ -67,7 +58,7 @@ int string_remove_match(char * txt, char * rexp, int cflags, int eflags) } } -int string_remove_all_matches(char * txt, char * rexp, int cflags, int eflags) +int string_remove_all_matches(char *txt, char *rexp, int cflags, int eflags) { int pos = 0; int pos0 = pos; @@ -84,3 +75,22 @@ int string_remove_all_matches(char * txt, char * rexp, int cflags, int eflags) } return pos; } + +static int string_match_regexp(char * txt, char * rexp, + int size, regmatch_t matches[], + int cflags, int eflags) +{ + regex_t re; + int problem; + + g_return_val_if_fail(txt, 0); + g_return_val_if_fail(rexp, 0); + + problem = regcomp(&re, rexp, cflags); + if (problem == 0) { + problem = regexec(&re, txt, size, matches, eflags); + } + regfree(&re); + return problem == 0; +} + diff --git a/src/string_match.h b/src/string_match.h index a338894b5..0bd5f78be 100644 --- a/src/string_match.h +++ b/src/string_match.h @@ -17,38 +17,22 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#ifndef __STRING_MATCH_H__ -#define __STRING_MATCH_H__ - -#include -#include - - -/* the size used for regexec in string_remove_match */ -/* this is probably not the most clever way to define this here, though */ -#define STRING_MATCH_MR_SIZE 30 - - -/* match a REXP in TXT, return non-zero if found */ -/* for documentation of SIZE, MATCHES, CFLAGS, and EFLAGS see "man regex" */ -/* MATCHES will be updated by regexec */ -int string_match_regexp(char * txt, char * rexp, \ - int size, regmatch_t matches[], \ - int cflags, int eflags); +#ifndef STRING_MATCH_H__ +#define STRING_MATCH_H__ /* remove substring matching REXP from TXT. Destructive! */ /* for documentation of CFLAGS and EFLAGS see "man regex" */ /* returns -1 = not found; N = next find pos */ /* if the match is an empty string (e.g. "x\?"), the find position will be increased by 1 */ -int string_remove_match(char * txt, char * rexp, int cflags, int eflags); +int string_remove_match (char *txt, char *rexp, int cflags, int eflags); /* remove all substrings matching REXP from TXT. Destructive! */ /* for documentation of CFLAGS and EFLAGS see "man regex" */ /* returns position of last replacement (i.e. TXT has been modified up to this position, use this as the starting point for further mangling) */ -int string_remove_all_matches(char * txt, char * rexp, int cflags, int eflags); +int string_remove_all_matches (char *txt, char *rexp, int cflags, int eflags); + +#endif /* STRING_MATCH_H__ */ -#endif -- 2.25.1