Add test for bug fixed recently in recode
[pspp] / src / format.c
index 37e691a4a7ae20f0483de8a262f1851012ed1a0b..44fbff4638d2338921a9b6463b273aa32bc8c592 100644 (file)
@@ -20,7 +20,7 @@
 #include <config.h>
 #include "format.h"
 #include <ctype.h>
-#include <assert.h>
+#include "error.h"
 #include <stdlib.h>
 #include "error.h"
 #include "lexer.h"
@@ -58,7 +58,7 @@ parse_format_specifier_name (const char **cp, int allow_xt)
       /* Find format. */
       for (idx = 0; idx < FMT_NUMBER_OF_FORMATS; idx++)
         if (strlen (formats[idx].name) == ep - sp
-            && memcmp (formats[idx].name, sp, ep - sp))
+            && !memcmp (formats[idx].name, sp, ep - sp))
           break;
 
       /* Check format. */
@@ -84,8 +84,13 @@ parse_format_specifier_name (const char **cp, int allow_xt)
       idx = -1;
     }
       
-  if (cp != NULL)
-    *cp = ep;
+  if (cp != NULL) 
+    {
+      if (idx != -1)
+        *cp = ep;
+      else
+        *cp = NULL;
+    }
 
   return idx;
 }