errno needs to be nulled in Linux.

Its previous value will be returned after checking.
This commit is contained in:
Holger Vogt 2021-09-01 23:16:58 +02:00
parent e84c210876
commit 1b3e192bfd
1 changed files with 6 additions and 3 deletions

View File

@ -68,7 +68,8 @@ static bool nooptran = TRUE;
void com_optran(wordlist* wl) {
wordlist* wltmp = wl;
char* stpstr;
int err, optrancom;
int err;
long int optrancom;
static bool dataset = FALSE;
static bool getdata = FALSE;
static int opiter = 1;
@ -96,8 +97,8 @@ void com_optran(wordlist* wl) {
getdata = TRUE;
}
int saved = errno;
errno = 0;
nooptran = FALSE;
/* wordlist with 6 parameters */
optrancom = strtol(wltmp->wl_word, &stpstr, 10);
@ -166,6 +167,8 @@ void com_optran(wordlist* wl) {
goto bugquit;
}
dataset = TRUE;
if (errno == 0)
errno = saved;
return;
bugquit:
fprintf(stderr, "Error in command 'optran'\n");