diff options
Diffstat (limited to '')
-rw-r--r-- | c-api/compat-5.3.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/c-api/compat-5.3.c b/c-api/compat-5.3.c index eb62009..9b304c1 100644 --- a/c-api/compat-5.3.c +++ b/c-api/compat-5.3.c | |||
@@ -53,17 +53,17 @@ | |||
53 | static char* compat53_strerror (int en, char* buff, size_t sz) { | 53 | static char* compat53_strerror (int en, char* buff, size_t sz) { |
54 | #if COMPAT53_HAVE_STRERROR_R | 54 | #if COMPAT53_HAVE_STRERROR_R |
55 | /* use strerror_r here, because it's available on these specific platforms */ | 55 | /* use strerror_r here, because it's available on these specific platforms */ |
56 | if (sz > 0) | 56 | if (sz > 0) { |
57 | buff[0] = '\0'; | 57 | buff[0] = '\0'; |
58 | /* we don't care whether the GNU version or the XSI version is used: */ | 58 | /* we don't care whether the GNU version or the XSI version is used: */ |
59 | strerror_r(en, buff, sz); | 59 | strerror_r(en, buff, sz); |
60 | if (sz == 0 || buff[0] != '\0') | 60 | if (buff[0] == '\0') |
61 | return buff; /* strerror_r wrote into the buffer */ | 61 | /* buffer is unchanged, so we probably have called GNU strerror_r which |
62 | else | 62 | * returned a static constant string. Chances are that strerror will |
63 | /* buffer is unchanged, so we probably have called GNU strerror_r which | 63 | * return the same static constant string and therefore be thread-safe. */ |
64 | * returned a static constant string. Chances are that strerror will | 64 | return strerror(en); |
65 | * return the same static constant string and therefore be thread-safe. */ | 65 | } |
66 | return strerror(en); | 66 | return buff; /* sz is 0 *or* strerror_r wrote into the buffer */ |
67 | #elif COMPAT53_HAVE_STRERROR_S | 67 | #elif COMPAT53_HAVE_STRERROR_S |
68 | /* for MSVC and other C11 implementations, use strerror_s since it's | 68 | /* for MSVC and other C11 implementations, use strerror_s since it's |
69 | * provided by default by the libraries */ | 69 | * provided by default by the libraries */ |