void *malloc (size_t);
void qsort (void *base, size_t nmemb, size_t size, int (*compar)(void const *, void const *));
void *realloc (void *p, size_t size);
-double strtod (char const *nptr, char **endptr);
-float strtof (char const *nptr, char **endptr);
-long double strtold (char const *nptr, char **endptr);
-long strtol (char const *nptr, char **endptr, int base);
-long long strtoll (char const *nptr, char **endptr, int base);
-unsigned long strtoul (char const *nptr, char **endptr, int base);
-unsigned long long strtoull (char const *nptr, char **endptr, int base);
+double strtod (char const *string, char **tailptr);
+float strtof (char const *string, char **tailptr);
+long double strtold (char const *string, char **tailptr);
+long strtol (char const *string, char **tailptr, int base);
+long long strtoll (char const *string, char **tailptr, int base);
+unsigned long strtoul (char const *string, char **tailptr, int base);
+unsigned long long strtoull (char const *string, char **tailptr, int base);
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
int
gettimeofday (struct timeval *tv, struct timezone *tz)
{
+ eputs ("gettimeofday stub\n");
return 0;
}
}
double
-strtod (char const *nptr, char **endptr)
+strtod (char const *string, char **tailptr)
{
eputs ("strtod stub\n");
}
float
-strtof (char const *nptr, char **endptr)
+strtof (char const *string, char **tailptr)
{
- return strtod (nptr, endptr);
+ return strtod (string, tailptr);
}
long double
-strtold (char const *nptr, char **endptr)
+strtold (char const *string, char **tailptr)
{
- return strtod (nptr, endptr);
+ return strtod (string, tailptr);
}
long
-strtol (char const *nptr, char **endptr, int base)
+strtol (char const *string, char **tailptr, int base)
{
- if (!strncmp (nptr, "0x", 2))
+ if (!strncmp (string, "0x", 2))
{
- char const *p = nptr + 2;
- return abtoi (&p, 16);
+ string += 2;
+ base = 16;
}
- return abtoi (&nptr, base);
+ if (tailptr)
+ {
+ *tailptr = string;
+ return abtoi (tailptr, base);
+ }
+ char **p = &string;
+ return abtoi (p, base);
+}
+
+#if 1
+
+long long int
+strtoll (char const *string, char **tailptr, int base)
+{
+ return strtol (string, tailptr, base);
+}
+
+unsigned long
+strtoul (char const *string, char **tailptr, int base)
+{
+ return strtol (string, tailptr, base);
+}
+
+unsigned long long
+strtoull (char const *string, char **tailptr, int base)
+{
+ return strtol (string, tailptr, base);
}
+#else
+
long long int
-strtoll (char const *nptr, char **endptr, int base)
+strtoll (char const *string, char **tailptr, int base)
{
eputs ("strtoll stub\n");
return 0;
}
unsigned long
-strtoul (char const *nptr, char **endptr, int base)
+strtoul (char const *string, char **tailptr, int base)
{
eputs ("strtoul stub\n");
return 0;
}
unsigned long long
-strtoull (char const *p, char **endptr, int base)
+strtoull (char const *string, char **tailptr, int base)
{
- *endptr = p;
- return abtoi (endptr, base);
+ // *endptr = p;
+ // return abtoi (endptr, base);
+ eputs ("strtoull stub\n");
+ return 0;
}
-time_t time (time_t *tloc)
+#endif
+
+time_t
+time (time_t *tloc)
{
+ eputs ("time stub\n");
return 0;
}
return p;
}
-
int
islower (int c)
{
return c >= 'a' && c <= 'z';
}
+
int
isupper (int c)
{
--- /dev/null
+/* -*-comment-start: "//";comment-end:""-*-
+ * Mes --- Maxwell Equations of Software
+ * Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of Mes.
+ *
+ * Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mes. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libmes.h>
+#include <stdlib.h>
+
+int
+main ()
+{
+ eputs ("0x12\n");
+ if (strtol ("0x12", 0, 0) != 18)
+ 1;
+
+ eputs ("012\n");
+ if (strtol ("012", 0, 0) != 10)
+ 2;
+
+ eputs ("-1\n");
+ if (strtol ("-1", 0, 0) != -1)
+ 3;
+
+ eputs ("-1\n");
+ if (strtoul ("-1", 0, 0) != -1)
+ 4;
+
+ char *p = "16";
+ int n = strtol (p, (char **)&p, 0);
+ eputs ("p="); eputs (p); eputs ("\n");
+ if (*p != 0)
+ return 5;
+
+ p = "0x12";
+ n = strtol (p, (char **)&p, 0);
+ eputs ("p="); eputs (p); eputs ("\n");
+ if (*p != 0)
+ return 5;
+
+
+ return 0;
+}