#include <config.h>
#include "format.h"
#include <ctype.h>
-#include <assert.h>
+#include "error.h"
#include <stdlib.h>
#include "error.h"
#include "lexer.h"
char *sp, *ep;
int idx;
- sp = ep = ds_value (&tokstr);
+ sp = ep = ds_c_str (&tokstr);
while (isalpha ((unsigned char) *ep))
ep++;
/* 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. */
{
/* No match. */
msg (SE, _("%.*s is not a valid data format."),
- (int) (ep - sp), ds_value (&tokstr));
+ (int) (ep - sp), ds_c_str (&tokstr));
idx = -1;
}
}
idx = -1;
}
- if (cp != NULL)
- *cp = ep;
+ if (cp != NULL)
+ {
+ if (idx != -1)
+ *cp = ep;
+ else
+ *cp = NULL;
+ }
return idx;
}
if (cp2 == cp && type != FMT_X)
{
msg (SE, _("Data format %s does not specify a width."),
- ds_value (&tokstr));
+ ds_c_str (&tokstr));
return 0;
}
if (*cp)
{
- msg (SE, _("Data format %s is not valid."), ds_value (&tokstr));
+ msg (SE, _("Data format %s is not valid."), ds_c_str (&tokstr));
return 0;
}
lex_get ();