Adopt use of gnulib for portability.
[pspp-builds.git] / src / data-in.c
index 0ce42fa652a4085fe457ba134e284c9767f5014a..879ad10bd4fc3442a0be3935eb7ba5b0c70875a4 100644 (file)
@@ -14,8 +14,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA. */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
 
 #include <config.h>
 #include "data-in.h"
@@ -26,9 +26,9 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include "bool.h"
+#include <stdbool.h>
 #include "error.h"
-#include "getline.h"
+#include "getl.h"
 #include "calendar.h"
 #include "lexer.h"
 #include "magic.h"
 #include "settings.h"
 #include "str.h"
 #include "var.h"
-\f
-#include "debug-print.h"
 
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+#include "debug-print.h"
 \f
 /* Specialized error routine. */
 
@@ -212,9 +214,7 @@ parse_numeric (struct data_in *i)
       return false;
     }
   
-  if (have_char (i)
-      && (tolower (*i->s) == 'e' || tolower (*i->s) == 'd'
-         || (type == FMT_E && (*i->s == '+' || *i->s == '-'))))
+  if (have_char (i) && strchr ("eEdD-+", *i->s))
     {
       /* Get the exponent specified after the `e' or `E'.  */
       long exp;
@@ -457,7 +457,9 @@ parse_Z (struct data_in *i)
 static inline bool
 parse_IB (struct data_in *i)
 {
+#ifndef WORDS_BIGENDIAN
   char buf[64];
+#endif
   const char *p;
 
   unsigned char xor;
@@ -468,7 +470,7 @@ parse_IB (struct data_in *i)
   p = i->s;
 #else
   memcpy (buf, i->s, i->e - i->s);
-  mm_reverse (buf, i->e - i->s);
+  buf_reverse (buf, i->e - i->s);
   p = buf;
 #endif
 
@@ -760,7 +762,7 @@ parse_enum (struct data_in *i, const char *what,
     if ((ep->can_abbreviate
          && lex_id_match_len (ep->name, strlen (ep->name), name, length))
         || (!ep->can_abbreviate && length == strlen (ep->name)
-            && !memcmp (name, ep->name, length)))
+            && !buf_compare_case (name, ep->name, length)))
       {
         *output = ep->value;
         return true;
@@ -1363,6 +1365,8 @@ data_in (struct data_in *i)
 {
   const struct fmt_desc *const fmt = &formats[i->format.type];
 
+  assert (check_input_specifier (&i->format, 0));
+
   /* Check that we've got a string to work with. */
   if (i->e == i->s || i->format.w <= 0)
     {