(ss_match_char_in): New function.
+2008-03-04 Ben Pfaff <blp@gnu.org>
+
+ Patch #6441. Reviewed by John Darrington.
+
+ * str.c (ss_match_char_in): New function.
+
2008-02-18 Ben Pfaff <blp@gnu.org>
Patch #6426. Thanks to John Darrington for review.
return false;
}
+/* If the first character in SS is in MATCH, removes it and
+ returns the character that was removed.
+ Otherwise, returns EOF without changing the string. */
+int
+ss_match_char_in (struct substring *ss, struct substring match)
+{
+ int c = EOF;
+ if (ss->length > 0
+ && memchr (match.string, ss->string[0], match.length) != NULL)
+ {
+ c = ss->string[0];
+ ss->string++;
+ ss->length--;
+ }
+ return c;
+}
+
/* If SS begins with TARGET, removes it and returns true.
Otherwise, returns false without changing SS. */
bool
size_t *save_idx, struct substring *token);
void ss_advance (struct substring *, size_t);
bool ss_match_char (struct substring *, char);
+int ss_match_char_in (struct substring *, struct substring);
bool ss_match_string (struct substring *, const struct substring);
int ss_get_char (struct substring *);
size_t ss_get_chars (struct substring *, size_t cnt, struct substring *);