X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Flibpspp%2Fstr.c;h=9a7c6da8bfa8c36e50cca3cfd7b7bfe99a6cf0db;hb=430f3a7cd6d9175a54a9e97fb91d5fc912fcfea4;hp=b88493d47fabafff46fd36a724cdcc1ad3e26d68;hpb=d1500de2094e42e1d461ecfdd0b69fca4af511bf;p=pspp-builds.git diff --git a/src/libpspp/str.c b/src/libpspp/str.c index b88493d4..9a7c6da8 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -546,6 +546,23 @@ ss_match_char (struct substring *ss, char c) 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