X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fstring-array.c;h=d162593b2cfb4102dd30a959cb1fc306276f0241;hb=b77c6aad5965c16e888af6c7e8be8c24569bda21;hp=d4badf4638df124681e964f78286a9cb3fda02bc;hpb=7aee1bc71c08f2c5b69243cb1ca792c8e7615faa;p=pspp diff --git a/src/libpspp/string-array.c b/src/libpspp/string-array.c index d4badf4638..d162593b2c 100644 --- a/src/libpspp/string-array.c +++ b/src/libpspp/string-array.c @@ -23,6 +23,7 @@ #include #include "libpspp/array.h" +#include "libpspp/i18n.h" #include "libpspp/str.h" #include "gl/xalloc.h" @@ -253,6 +254,36 @@ string_array_uniq (struct string_array *sa) sa->n = n; } +/* Returns true if A and B contain the same strings in the same order, + false otherwise. */ +bool +string_array_equal (const struct string_array *a, + const struct string_array *b) +{ + if (a->n != b->n) + return false; + + for (size_t i = 0; i < a->n; i++) + if (strcmp (a->strings[i], b->strings[i])) + return false; + return true; +} + +/* Returns true if A and B contain the same strings in the same order, + false otherwise. */ +bool +string_array_equal_case (const struct string_array *a, + const struct string_array *b) +{ + if (a->n != b->n) + return false; + + for (size_t i = 0; i < a->n; i++) + if (utf8_strcasecmp (a->strings[i], b->strings[i])) + return false; + return true; +} + /* Divides STRING into tokens at DELIMITERS and adds each token to SA. */ void string_array_parse (struct string_array *sa, struct substring string,