X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fstr.c;h=2a592b9064d88368547216404cc759cb9da21b8b;hb=981adc6169ffe7227de286f92f70edf684d37a2b;hp=45187ef12bbc75a6d108ea4eaa3cbbaf6c58106f;hpb=50e00137bfcc4eb3d4ae753a5e57e7a444194c96;p=pspp diff --git a/src/libpspp/str.c b/src/libpspp/str.c index 45187ef12b..2a592b9064 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -758,6 +758,14 @@ ss_starts_with (struct substring ss, struct substring prefix) && !memcmp (ss.string, prefix.string, prefix.length)); } +/* Returns true if SS starts with PREFIX in any case, false otherwise. */ +bool +ss_starts_with_case (struct substring ss, struct substring prefix) +{ + return (ss.length >= prefix.length + && !memcasecmp (ss.string, prefix.string, prefix.length)); +} + /* Returns true if SS ends with SUFFIX, false otherwise. */ bool ss_ends_with (struct substring ss, struct substring suffix) @@ -767,6 +775,15 @@ ss_ends_with (struct substring ss, struct substring suffix) suffix.length)); } +/* Returns true if SS ends with SUFFIX in any case, false otherwise. */ +bool +ss_ends_with_case (struct substring ss, struct substring suffix) +{ + return (ss.length >= suffix.length + && !memcasecmp (&ss.string[ss.length - suffix.length], suffix.string, + suffix.length)); +} + /* Returns the number of contiguous bytes at the beginning of SS that are in SKIP_SET. */ size_t