mescc: Mes C Library: Fix compile warnings.

* include/libmes.h (dtoab, itoa, ltoa, ntoab, ultoa, utoa): Return
char* (WAS: char const*).
* lib/*/*c: Update, add missing includes.
This commit is contained in:
Jan Nieuwenhuizen 2019-01-06 10:04:33 +01:00
parent 2183f4bb2a
commit 15c8c9857a
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
16 changed files with 45 additions and 40 deletions

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -31,13 +31,13 @@ int mes_open (char const *file_name, int flags, ...);
int __mes_debug (); int __mes_debug ();
double abtod (char const** p, int base); double abtod (char const** p, int base);
long abtol (char const** p, int base); long abtol (char const** p, int base);
char const* dtoab (double number, int base, int signed_p); char *dtoab (double number, int base, int signed_p);
char const* ntoab (long number, int base, int signed_p); char *itoa (int number);
char const* itoa (int number); char *ltoa (long number);
char const* ltoa (long number); char *ltoab (long x, int base);
char const* ultoa (unsigned long number); char *ntoab (long number, int base, int signed_p);
char const* utoa (unsigned number); char *ultoa (unsigned long number);
char const* ltoab (long x, int base); char *utoa (unsigned number);
int atoi (char const *s); int atoi (char const *s);
int eputc (int c); int eputc (int c);
int fdgetc (int fd); int fdgetc (int fd);

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -31,7 +31,7 @@
#define __FOO_VARARGS 1 #define __FOO_VARARGS 1
#endif #endif
typedef long va_list; typedef char* va_list;
#define va_start(ap, last) (void)((ap) = (char*)(&(last) + 1)) #define va_start(ap, last) (void)((ap) = (char*)(&(last) + 1))
#define va_arg(ap, type) (type)(((long*)((ap) = ((ap) + sizeof (void*))))[-1]) #define va_arg(ap, type) (type)(((long*)((ap) = ((ap) + sizeof (void*))))[-1])
#define va_end(ap) (void)((ap) = 0) #define va_end(ap) (void)((ap) = 0)

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -31,6 +31,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <alloca.h> #include <alloca.h>
double atof (char const *s);
int atoi (char const *s); int atoi (char const *s);
int atexit (void (*function) (void)); int atexit (void (*function) (void));
void * calloc (size_t nmemb, size_t size); void * calloc (size_t nmemb, size_t size);

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -19,6 +19,7 @@
*/ */
#include <libmes.h> #include <libmes.h>
#include <ctype.h>
long long
abtol (char const **p, int base) abtol (char const **p, int base)

View File

@ -21,7 +21,7 @@
#include <libmes.h> #include <libmes.h>
#include <limits.h> #include <limits.h>
char const* char *
dtoab (double d, int base, int signed_p) dtoab (double d, int base, int signed_p)
{ {
static char dtoa_buf[40]; static char dtoa_buf[40];

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -20,7 +20,7 @@
#include <libmes.h> #include <libmes.h>
char const* char *
itoa (int x) itoa (int x)
{ {
return ntoab (x, 10, 1); return ntoab (x, 10, 1);

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -20,7 +20,7 @@
#include <libmes.h> #include <libmes.h>
char const* char *
ltoa (long x) ltoa (long x)
{ {
return ntoab (x, 10, 1); return ntoab (x, 10, 1);

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -20,7 +20,7 @@
#include <libmes.h> #include <libmes.h>
char const* char *
ltoab (long x, int base) ltoab (long x, int base)
{ {
return ntoab (x, base, 1); return ntoab (x, base, 1);

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -20,7 +20,7 @@
#include <libmes.h> #include <libmes.h>
char const* char *
ntoab (long x, int base, int signed_p) ntoab (long x, int base, int signed_p)
{ {
static char itoa_buf[20]; static char itoa_buf[20];

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -20,7 +20,7 @@
#include <libmes.h> #include <libmes.h>
char const* char *
ultoa (unsigned long x) ultoa (unsigned long x)
{ {
return ntoab (x, 10, 1); return ntoab (x, 10, 1);

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -20,7 +20,7 @@
#include <libmes.h> #include <libmes.h>
char const* char *
utoa (unsigned x) utoa (unsigned x)
{ {
return ntoab (x, 10, 0); return ntoab (x, 10, 0);

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -18,6 +18,7 @@
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <libmes.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -32,7 +33,7 @@ vfprintf (FILE* f, char const* format, va_list ap)
if (*p != '%') if (*p != '%')
{ {
count++; count++;
fputc (*p++, fd); fputc (*p++, f);
} }
else else
{ {
@ -87,7 +88,7 @@ vfprintf (FILE* f, char const* format, va_list ap)
{ {
case '%': case '%':
{ {
fputc (*p, fd); fputc (*p, f);
count++; count++;
break; break;
} }
@ -95,7 +96,7 @@ vfprintf (FILE* f, char const* format, va_list ap)
{ {
char _c; char _c;
_c = va_arg (ap, long); _c = va_arg (ap, long);
fputc (_c, fd); fputc (_c, f);
break; break;
} }
case 'd': case 'd':
@ -109,7 +110,7 @@ vfprintf (FILE* f, char const* format, va_list ap)
int base = c == 'o' ? 8 int base = c == 'o' ? 8
: c == 'x' || c == 'X' ? 16 : c == 'x' || c == 'X' ? 16
: 10; : 10;
char const *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X'); char *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X');
if (c == 'X') if (c == 'X')
strupr (s); strupr (s);
int length = strlen (s); int length = strlen (s);
@ -190,7 +191,7 @@ vfprintf (FILE* f, char const* format, va_list ap)
case 'G': case 'G':
{ {
double d = va_arg (ap, double); double d = va_arg (ap, double);
char const *s = dtoab (d, 10, 1); char *s = dtoab (d, 10, 1);
if (c == 'E' || c == 'G') if (c == 'E' || c == 'G')
strupr (s); strupr (s);
int length = strlen (s); int length = strlen (s);

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -24,5 +24,5 @@
int int
vprintf (char const* format, va_list ap) vprintf (char const* format, va_list ap)
{ {
return vfprintf (STDOUT, format, ap); return vfprintf (stdout, format, ap);
} }

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -18,8 +18,9 @@
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdio.h> #include <libmes.h>
#include <stdlib.h> #include <stdarg.h>
#include <string.h>
int int
vsnprintf (char *str, size_t size, char const* format, va_list ap) vsnprintf (char *str, size_t size, char const* format, va_list ap)
@ -114,7 +115,7 @@ vsnprintf (char *str, size_t size, char const* format, va_list ap)
int base = c == 'o' ? 8 int base = c == 'o' ? 8
: c == 'x' || c == 'X' ? 16 : c == 'x' || c == 'X' ? 16
: 10; : 10;
char const *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X'); char *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X');
if (c == 'X') if (c == 'X')
strupr (s); strupr (s);
int length = strlen (s); int length = strlen (s);
@ -205,7 +206,7 @@ vsnprintf (char *str, size_t size, char const* format, va_list ap)
case 'G': case 'G':
{ {
double d = va_arg (ap, double); double d = va_arg (ap, double);
char const *s = dtoab (d, 10, 1); char *s = dtoab (d, 10, 1);
if (c == 'E' || c == 'G') if (c == 'E' || c == 'G')
strupr (s); strupr (s);
int length = strlen (s); int length = strlen (s);

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -18,8 +18,8 @@
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
int int
vsprintf (char *str, char const* format, va_list ap) vsprintf (char *str, char const* format, va_list ap)

View File

@ -18,6 +18,7 @@
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <libmes.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>