From 41c126759ef82ad240346451e46170895af2421c Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Tue, 29 Dec 2020 13:37:20 +0100 Subject: [PATCH] mescc: Mes C Library: Prepare for M2-Planet 1.7.0. * lib/m2/ntoab.c (ntoab): Declare variables at toplevel. * lib/mes/abtol.c (abtol): Likewise. * lib/posix/getenv.c (getenv): Likewise. * lib/posix/setenv.c (setenv): Likewise. --- lib/m2/ntoab.c | 4 ++-- lib/mes/abtol.c | 4 ++-- lib/posix/getenv.c | 5 +++-- lib/posix/setenv.c | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/m2/ntoab.c b/lib/m2/ntoab.c index f2d2e3ad..076fb727 100644 --- a/lib/m2/ntoab.c +++ b/lib/m2/ntoab.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -38,6 +38,7 @@ ntoab (long x, int base, int signed_p) int sign_p = 0; unsigned u; + unsigned i; if (signed_p != 0 && x < 0) { sign_p = 1; @@ -48,7 +49,6 @@ ntoab (long x, int base, int signed_p) do { - unsigned i; i = u % base; u = u / base; if (i > 9) diff --git a/lib/mes/abtol.c b/lib/mes/abtol.c index df868225..1f297b4a 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,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -27,6 +27,7 @@ abtol (char const **p, int base) char const *s = p[0]; int i = 0; int sign_p = 0; + int m = '0'; if (base == 0) base = 10; while (isspace (s[0]) != 0) @@ -41,7 +42,6 @@ abtol (char const **p, int base) while (isnumber (s[0], base) != 0) { i = i * base; - int m = '0'; if (s[0] > '9') m = 'a' - 10; i = i + s[0] - m; diff --git a/lib/posix/getenv.c b/lib/posix/getenv.c index cf630e25..9130f76d 100644 --- a/lib/posix/getenv.c +++ b/lib/posix/getenv.c @@ -1,6 +1,6 @@ /* * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -30,6 +30,7 @@ getenv (char const *s) { /* eputs ("\ngetenv s="); eputs (s); eputs ("\n"); */ char **p = environ; + char *q; int length = strlen (s); while (p[0] != 0) @@ -38,7 +39,7 @@ getenv (char const *s) if (strncmp (s, p[0], length) == 0) { /* eputs ("found!\n"); */ - char *q = p[0] + length; + q = p[0] + length; if (q[0] == '=') return q + 1; } diff --git a/lib/posix/setenv.c b/lib/posix/setenv.c index a5ee8ff8..321a5ab1 100644 --- a/lib/posix/setenv.c +++ b/lib/posix/setenv.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -30,12 +30,13 @@ setenv (char const *s, char const *v, int overwrite_p) { char **p = environ; int length = strlen (s); + char* q; while (p[0] != 0) { if (strncmp (s, p[0], length) == 0) { - char *q = p[0] + length; + q = p[0] + length; if (q[0] == '=') break; }