* compatibility veneer over @str_qword@.
*/
-char *str_getword(char **pp)
-{
- return (str_qword(pp, 0));
-}
+char *str_getword(char **pp) { return (str_qword(pp, 0)); }
/* --- @str_split@ --- *
*
*/
size_t str_split(char *p, char *v[], size_t c, char **rest)
-{
- return (str_qsplit(p, v, c, rest, 0));
-}
+ { return (str_qsplit(p, v, c, rest, 0)); }
-/* --- @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.
*
* '['.
*/
-int str_match(const char *p, const char *s)
+int str_matchx(const char *p, const char *s, unsigned f)
{
for (;;) {
char pch = *p++, pche, sch;
int sense;
+ if ((f & STRF_PREFIX) && !*s)
+ return (1);
switch (pch) {
case '?':
if (!*s)
s++;
break;
case '*':
- if (!*p)
+ if (!*p || (f & STRF_PREFIX))
return (1);
while (*s) {
if (str_match(p, s))
}
}
+/* --- @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.
+ */
+
+int str_match(const char *p, const char *s)
+ { return (str_matchx(p, s, 0)); }
+
/* --- @str_sanitize@ --- *
*
* Arguments: @char *d@ = destination buffer