X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fstr.c;h=45187ef12bbc75a6d108ea4eaa3cbbaf6c58106f;hb=5327d77be2296f6be3f532c20456eab839dc7c62;hp=3046daee6d1bc4390b7793bacd2ada894ef83bb7;hpb=b525a9596e60d5ae4c6c464b4a426b77ade3dd72;p=pspp diff --git a/src/libpspp/str.c b/src/libpspp/str.c index 3046daee6d..45187ef12b 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -615,6 +615,21 @@ ss_match_string (struct substring *ss, const struct substring target) return false; } +/* If SS begins with TARGET, except possibly for case differences, removes it + and returns true. Otherwise, returns false without changing SS. */ +bool +ss_match_string_case (struct substring *ss, const struct substring target) +{ + size_t length = ss_length (target); + if (ss_equals_case (ss_head (*ss, length), target)) + { + ss_advance (ss, length); + return true; + } + else + return false; +} + /* Removes the first byte from SS and returns it. If SS is empty, returns EOF without modifying SS. */ int @@ -1677,6 +1692,18 @@ ds_put_unichar (struct string *st, ucs4_t uc) st->ss.length += u8_uctomb (CHAR_CAST (uint8_t *, ds_end (st)), uc, 6); } +/* Appends N copies of S to ST. */ +void +ds_put_substring_multiple (struct string *dst, struct substring src, size_t n) +{ + char *p = ds_put_uninit (dst, n * src.length); + for (size_t i = 0; i < n; i++) + { + memcpy (p, src.string, src.length); + p += src.length; + } +} + /* If relocation has been enabled, replace ST, with its relocated version */ void