1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-02-01 22:32:40 +00:00

Replace uses of atoi() with strtol() or stroul() as appropriate (#394)

As a side-effect of this change, we also resolve a a problem with
signed file version numbers, so that instead of version 2147483647
wrapping to -2147483648 we can go as far as 4294967296 before we
have issues.  Various sprintf() formats get changed from %d to %u.
The DOS version code is left behind as int versions.
This commit is contained in:
Nick Briggs
2021-09-08 09:58:01 -07:00
committed by GitHub
parent 85c4ebf0ac
commit 4f79f55c20
10 changed files with 125 additions and 76 deletions

View File

@@ -247,14 +247,35 @@ void close_unix_descriptors(void) /* Get ready to shut Maiko down */
int FindUnixPipes(void) {
char *envtmp;
int inttmp;
struct unixjob cleareduj;
DBPRINT(("Entering FindUnixPipes\n"));
UnixPipeIn = UnixPipeOut = StartTime = UnixPID = -1;
if ((envtmp = getenv("LDEPIPEIN"))) UnixPipeIn = atoi(envtmp);
if ((envtmp = getenv("LDEPIPEOUT"))) UnixPipeOut = atoi(envtmp);
if ((envtmp = getenv("LDESTARTTIME"))) StartTime = atoi(envtmp);
if ((envtmp = getenv("LDEUNIXPID"))) UnixPID = atoi(envtmp);
if ((envtmp = getenv("LDEPIPEIN"))) {
errno = 0;
inttmp = (int)strtol(envtmp, (char **)NULL, 10);
if (errno == 0)
UnixPipeIn = inttmp;
}
if ((envtmp = getenv("LDEPIPEOUT"))) {
errno = 0;
inttmp = (int)strtol(envtmp, (char **)NULL, 10);
if (errno == 0)
UnixPipeOut = inttmp;
}
if ((envtmp = getenv("LDESTARTTIME"))) {
errno = 0;
inttmp = (int)strtol(envtmp, (char **)NULL, 10);
if (errno == 0)
StartTime = inttmp;
}
if ((envtmp = getenv("LDEUNIXPID"))) {
errno = 0;
inttmp = (int)strtol(envtmp, (char **)NULL, 10);
if (errno == 0)
UnixPID = inttmp;
}
/* This is a good place to initialize stuff like the UJ table */
NPROCS = sysconf(_SC_OPEN_MAX);