Avoid strcasecmp which does not exist on Windows
[yaz-moved-to-github.git] / src / sortspec.c
index 8d1e19c..7f272f5 100644 (file)
@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <yaz/matchstr.h>
 
 #include <yaz/z-core.h>
 #include <yaz/sortspec.h>
@@ -415,14 +416,15 @@ int yaz_solr_sortkeys_to_sort_spec(const char *solr_sortkeys, WRBUF w)
             nmem_strsplitx(nmem, " ", sortspec[i], &arg, &num_arg, 0);
 
             if (num_arg != 2)
-                return 0;
+                return -1;
+
+            if (yaz_matchstr(arg[1], "asc") &&
+                yaz_matchstr(arg[1], "desc"))
+                return -1;
 
             if (arg[1][0]) {
                 order = tolower(arg[1][0]);
             }
-            if (order != 'a' || order != 'd')
-                return 0;
-
             if (i)
                 wrbuf_puts(w, " ");