photomosaics

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 8bf5bfcd8caa1dd8a88341c7a3795882e8486a27
parent 30662c5b3c8fe5dcd7a416163396e5a4e08cb2cb
Author: Wilson Gheen <wilson@wilsonrgheen.com>
Date:   Tue, 17 Jan 2023 15:52:42 -0600

Isolate errno in `parse_num` from possible errors in `setlocale`

Diffstat:
Mphotomosaics.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/photomosaics.c b/photomosaics.c @@ -53,8 +53,8 @@ static bool parse_num(const char *str, NUM_TYPES type, void *out) { char *endptr; const char *old_locale = setlocale(LC_ALL, NULL); setlocale(LC_ALL|~LC_NUMERIC, ""); - errno = 0; int my_errno = 0; + errno = 0; switch(type) { case L: @@ -77,8 +77,9 @@ static bool parse_num(const char *str, NUM_TYPES type, void *out) { break; } + int their_errno = errno; setlocale(LC_ALL, old_locale); - if(errno) return false; + if((errno=their_errno)) return false; if(my_errno) { errno = my_errno; return false;