X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/efae42a671ed553b5fd9967204aab11516010074..26f325c05cf0aa292589458b5c1aa8b5f5ab92ba:/str.h diff --git a/str.h b/str.h index 5c5d300..4f9c5c2 100644 --- a/str.h +++ b/str.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: str.h,v 1.4 2000/10/08 09:43:34 mdw Exp $ + * $Id: str.h,v 1.5 2004/04/08 01:36:13 mdw Exp $ * * Functions for hacking with strings * @@ -27,23 +27,6 @@ * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: str.h,v $ - * Revision 1.4 2000/10/08 09:43:34 mdw - * New quoted string handling and simple pattern matching. - * - * Revision 1.3 1999/12/10 23:42:04 mdw - * Change header file guard names. - * - * Revision 1.2 1999/05/26 20:52:57 mdw - * Add new `rest' argument for `str_split'. - * - * Revision 1.1 1999/05/17 20:37:01 mdw - * Some trivial string hacks. - * - */ - #ifndef MLIB_STR_H #define MLIB_STR_H @@ -127,10 +110,11 @@ extern char *str_getword(char **/*pp*/); extern size_t str_split(char */*p*/, char */*v*/[], size_t /*c*/, char **/*rest*/); -/* --- @str_match@ --- * +/* --- @str_matchx@ --- * * * Arguments: @const char *p@ = pointer to pattern string * @const char *s@ = string to compare with + * @unsigned f@ = various flags * * Returns: Nonzero if the pattern matches the string. * @@ -139,6 +123,22 @@ extern size_t str_split(char */*p*/, char */*v*/[], * '['. */ +#define STRF_PREFIX 1u /* Accept if @s@ is exhausted during + * the attempted match */ + +extern int str_matchx(const char */*p*/, const char */*s*/, unsigned /*f*/); + +/* --- @str_match@ --- * + * + * Arguments: @const char *p@ = pointer to pattern string + * @const char *s@ = string to compare with + * + * Returns: Nonzero if the pattern matches the string. + * + * Use: Does simple wildcard matching. Equivalent to @str_matchx@ + * with zero flags word. + */ + extern int str_match(const char */*p*/, const char */*s*/); /* --- @str_sanitize@ --- *