From 729130848477a8d90f9f54f524d8e2ee30974c18 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 6 Jan 2019 10:04:33 +0100 Subject: [PATCH] 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. --- include/libmes.h | 16 ++++++++-------- include/stdarg.h | 4 ++-- include/stdlib.h | 3 ++- lib/mes/abtol.c | 3 ++- lib/mes/dtoab.c | 2 +- lib/mes/itoa.c | 4 ++-- lib/mes/ltoa.c | 4 ++-- lib/mes/ltoab.c | 4 ++-- lib/mes/ntoab.c | 4 ++-- lib/mes/ultoa.c | 4 ++-- lib/mes/utoa.c | 4 ++-- lib/stdio/vfprintf.c | 13 +++++++------ lib/stdio/vprintf.c | 4 ++-- lib/stdio/vsnprintf.c | 11 ++++++----- lib/stdio/vsprintf.c | 4 ++-- lib/stdio/vsscanf.c | 1 + 16 files changed, 45 insertions(+), 40 deletions(-) diff --git a/include/libmes.h b/include/libmes.h index ef79f50d..16209caa 100644 --- a/include/libmes.h +++ b/include/libmes.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -31,13 +31,13 @@ int mes_open (char const *file_name, int flags, ...); int __mes_debug (); double abtod (char const** p, int base); long abtol (char const** p, int base); -char const* dtoab (double number, int base, int signed_p); -char const* ntoab (long number, int base, int signed_p); -char const* itoa (int number); -char const* ltoa (long number); -char const* ultoa (unsigned long number); -char const* utoa (unsigned number); -char const* ltoab (long x, int base); +char *dtoab (double number, int base, int signed_p); +char *itoa (int number); +char *ltoa (long number); +char *ltoab (long x, int base); +char *ntoab (long number, int base, int signed_p); +char *ultoa (unsigned long number); +char *utoa (unsigned number); int atoi (char const *s); int eputc (int c); int fdgetc (int fd); diff --git a/include/stdarg.h b/include/stdarg.h index f56b0dd2..b1b9bf8c 100644 --- a/include/stdarg.h +++ b/include/stdarg.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -31,7 +31,7 @@ #define __FOO_VARARGS 1 #endif -typedef long va_list; +typedef char* va_list; #define va_start(ap, last) (void)((ap) = (char*)(&(last) + 1)) #define va_arg(ap, type) (type)(((long*)((ap) = ((ap) + sizeof (void*))))[-1]) #define va_end(ap) (void)((ap) = 0) diff --git a/include/stdlib.h b/include/stdlib.h index 5d8d62f3..ce0b1a94 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -31,6 +31,7 @@ #include #include +double atof (char const *s); int atoi (char const *s); int atexit (void (*function) (void)); void * calloc (size_t nmemb, size_t size); diff --git a/lib/mes/abtol.c b/lib/mes/abtol.c index 64dc5c93..71c0dcbd 100644 --- a/lib/mes/abtol.c +++ b/lib/mes/abtol.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -19,6 +19,7 @@ */ #include +#include long abtol (char const **p, int base) diff --git a/lib/mes/dtoab.c b/lib/mes/dtoab.c index 1ae5604d..ed18dd0a 100644 --- a/lib/mes/dtoab.c +++ b/lib/mes/dtoab.c @@ -21,7 +21,7 @@ #include #include -char const* +char * dtoab (double d, int base, int signed_p) { static char dtoa_buf[40]; diff --git a/lib/mes/itoa.c b/lib/mes/itoa.c index cd330e88..95b6d034 100644 --- a/lib/mes/itoa.c +++ b/lib/mes/itoa.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,7 +20,7 @@ #include -char const* +char * itoa (int x) { return ntoab (x, 10, 1); diff --git a/lib/mes/ltoa.c b/lib/mes/ltoa.c index 82bed4d9..8b91566e 100644 --- a/lib/mes/ltoa.c +++ b/lib/mes/ltoa.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,7 +20,7 @@ #include -char const* +char * ltoa (long x) { return ntoab (x, 10, 1); diff --git a/lib/mes/ltoab.c b/lib/mes/ltoab.c index 090d3ca2..7aee68cc 100644 --- a/lib/mes/ltoab.c +++ b/lib/mes/ltoab.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,7 +20,7 @@ #include -char const* +char * ltoab (long x, int base) { return ntoab (x, base, 1); diff --git a/lib/mes/ntoab.c b/lib/mes/ntoab.c index 77e32247..1a520e56 100644 --- a/lib/mes/ntoab.c +++ b/lib/mes/ntoab.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,7 +20,7 @@ #include -char const* +char * ntoab (long x, int base, int signed_p) { static char itoa_buf[20]; diff --git a/lib/mes/ultoa.c b/lib/mes/ultoa.c index 40461f18..c3099d3e 100644 --- a/lib/mes/ultoa.c +++ b/lib/mes/ultoa.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,7 +20,7 @@ #include -char const* +char * ultoa (unsigned long x) { return ntoab (x, 10, 1); diff --git a/lib/mes/utoa.c b/lib/mes/utoa.c index c6e90e9b..742e04ce 100644 --- a/lib/mes/utoa.c +++ b/lib/mes/utoa.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,7 +20,7 @@ #include -char const* +char * utoa (unsigned x) { return ntoab (x, 10, 0); diff --git a/lib/stdio/vfprintf.c b/lib/stdio/vfprintf.c index 8c8d63d1..bd0e5bf5 100644 --- a/lib/stdio/vfprintf.c +++ b/lib/stdio/vfprintf.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -18,6 +18,7 @@ * along with GNU Mes. If not, see . */ +#include #include #include #include @@ -32,7 +33,7 @@ vfprintf (FILE* f, char const* format, va_list ap) if (*p != '%') { count++; - fputc (*p++, fd); + fputc (*p++, f); } else { @@ -87,7 +88,7 @@ vfprintf (FILE* f, char const* format, va_list ap) { case '%': { - fputc (*p, fd); + fputc (*p, f); count++; break; } @@ -95,7 +96,7 @@ vfprintf (FILE* f, char const* format, va_list ap) { char _c; _c = va_arg (ap, long); - fputc (_c, fd); + fputc (_c, f); break; } case 'd': @@ -109,7 +110,7 @@ vfprintf (FILE* f, char const* format, va_list ap) int base = c == 'o' ? 8 : c == 'x' || c == 'X' ? 16 : 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') strupr (s); int length = strlen (s); @@ -190,7 +191,7 @@ vfprintf (FILE* f, char const* format, va_list ap) case 'G': { double d = va_arg (ap, double); - char const *s = dtoab (d, 10, 1); + char *s = dtoab (d, 10, 1); if (c == 'E' || c == 'G') strupr (s); int length = strlen (s); diff --git a/lib/stdio/vprintf.c b/lib/stdio/vprintf.c index 850a9556..909d1fab 100644 --- a/lib/stdio/vprintf.c +++ b/lib/stdio/vprintf.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -24,5 +24,5 @@ int vprintf (char const* format, va_list ap) { - return vfprintf (STDOUT, format, ap); + return vfprintf (stdout, format, ap); } diff --git a/lib/stdio/vsnprintf.c b/lib/stdio/vsnprintf.c index 3fe5cb27..5b22b2b2 100644 --- a/lib/stdio/vsnprintf.c +++ b/lib/stdio/vsnprintf.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -18,8 +18,9 @@ * along with GNU Mes. If not, see . */ -#include -#include +#include +#include +#include int 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 : c == 'x' || c == 'X' ? 16 : 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') strupr (s); int length = strlen (s); @@ -205,7 +206,7 @@ vsnprintf (char *str, size_t size, char const* format, va_list ap) case 'G': { double d = va_arg (ap, double); - char const *s = dtoab (d, 10, 1); + char *s = dtoab (d, 10, 1); if (c == 'E' || c == 'G') strupr (s); int length = strlen (s); diff --git a/lib/stdio/vsprintf.c b/lib/stdio/vsprintf.c index 9953c3af..8a65b0d6 100644 --- a/lib/stdio/vsprintf.c +++ b/lib/stdio/vsprintf.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -18,8 +18,8 @@ * along with GNU Mes. If not, see . */ +#include #include -#include int vsprintf (char *str, char const* format, va_list ap) diff --git a/lib/stdio/vsscanf.c b/lib/stdio/vsscanf.c index 7bf82f85..d90af2fd 100644 --- a/lib/stdio/vsscanf.c +++ b/lib/stdio/vsscanf.c @@ -18,6 +18,7 @@ * along with GNU Mes. If not, see . */ +#include #include #include