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.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2020-12-29 13:37:20 +01:00
parent 74d7d097e4
commit 41c126759e
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
4 changed files with 10 additions and 8 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,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -38,6 +38,7 @@ ntoab (long x, int base, int signed_p)
int sign_p = 0; int sign_p = 0;
unsigned u; unsigned u;
unsigned i;
if (signed_p != 0 && x < 0) if (signed_p != 0 && x < 0)
{ {
sign_p = 1; sign_p = 1;
@ -48,7 +49,6 @@ ntoab (long x, int base, int signed_p)
do do
{ {
unsigned i;
i = u % base; i = u % base;
u = u / base; u = u / base;
if (i > 9) if (i > 9)

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,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -27,6 +27,7 @@ abtol (char const **p, int base)
char const *s = p[0]; char const *s = p[0];
int i = 0; int i = 0;
int sign_p = 0; int sign_p = 0;
int m = '0';
if (base == 0) if (base == 0)
base = 10; base = 10;
while (isspace (s[0]) != 0) while (isspace (s[0]) != 0)
@ -41,7 +42,6 @@ abtol (char const **p, int base)
while (isnumber (s[0], base) != 0) while (isnumber (s[0], base) != 0)
{ {
i = i * base; i = i * base;
int m = '0';
if (s[0] > '9') if (s[0] > '9')
m = 'a' - 10; m = 'a' - 10;
i = i + s[0] - m; i = i + s[0] - m;

View file

@ -1,6 +1,6 @@
/* /*
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -30,6 +30,7 @@ getenv (char const *s)
{ {
/* eputs ("\ngetenv s="); eputs (s); eputs ("\n"); */ /* eputs ("\ngetenv s="); eputs (s); eputs ("\n"); */
char **p = environ; char **p = environ;
char *q;
int length = strlen (s); int length = strlen (s);
while (p[0] != 0) while (p[0] != 0)
@ -38,7 +39,7 @@ getenv (char const *s)
if (strncmp (s, p[0], length) == 0) if (strncmp (s, p[0], length) == 0)
{ {
/* eputs ("found!\n"); */ /* eputs ("found!\n"); */
char *q = p[0] + length; q = p[0] + length;
if (q[0] == '=') if (q[0] == '=')
return q + 1; return q + 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,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -30,12 +30,13 @@ setenv (char const *s, char const *v, int overwrite_p)
{ {
char **p = environ; char **p = environ;
int length = strlen (s); int length = strlen (s);
char* q;
while (p[0] != 0) while (p[0] != 0)
{ {
if (strncmp (s, p[0], length) == 0) if (strncmp (s, p[0], length) == 0)
{ {
char *q = p[0] + length; q = p[0] + length;
if (q[0] == '=') if (q[0] == '=')
break; break;
} }