1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-06-30 19:45:23 +00:00

Rename ret to n for consistency with other utility functions

This commit is contained in:
John Zaitseff 2018-08-24 14:53:18 +10:00
parent aed5e8a46d
commit d553aca98c

View File

@ -575,7 +575,7 @@ void init_locale (void)
ssize_t xwcsfmon (wchar_t *restrict buf, size_t maxsize, ssize_t xwcsfmon (wchar_t *restrict buf, size_t maxsize,
const char *restrict format, double val) const char *restrict format, double val)
{ {
ssize_t ret; ssize_t n;
char *s = xmalloc(BUFSIZE); char *s = xmalloc(BUFSIZE);
@ -589,7 +589,7 @@ ssize_t xwcsfmon (wchar_t *restrict buf, size_t maxsize,
following code overcomes these limitations by using snprintf(). */ following code overcomes these limitations by using snprintf(). */
if (! is_posix_locale) { if (! is_posix_locale) {
ret = strfmon(s, BUFSIZE, format, val); n = strfmon(s, BUFSIZE, format, val);
} else { } else {
/* The current implementation assumes the monetary decimal point /* The current implementation assumes the monetary decimal point
is overridden to "." (ie, MOD_POSIX_MON_DECIMAL_POINT == "."), is overridden to "." (ie, MOD_POSIX_MON_DECIMAL_POINT == "."),
@ -613,29 +613,29 @@ ssize_t xwcsfmon (wchar_t *restrict buf, size_t maxsize,
if (strcmp(format, "%n") == 0) { if (strcmp(format, "%n") == 0) {
if (val >= 0.0) { if (val >= 0.0) {
ret = snprintf(s, BUFSIZE, MOD_POSIX_FMT_POS, val); n = snprintf(s, BUFSIZE, MOD_POSIX_FMT_POS, val);
} else { } else {
ret = snprintf(s, BUFSIZE, MOD_POSIX_FMT_NEG, -val); n = snprintf(s, BUFSIZE, MOD_POSIX_FMT_NEG, -val);
} }
} else if (strcmp(format, "%!n") == 0) { } else if (strcmp(format, "%!n") == 0) {
if (val >= 0.0) { if (val >= 0.0) {
ret = snprintf(s, BUFSIZE, MOD_POSIX_FMT_POS_NOSYM, val); n = snprintf(s, BUFSIZE, MOD_POSIX_FMT_POS_NOSYM, val);
} else { } else {
ret = snprintf(s, BUFSIZE, MOD_POSIX_FMT_NEG_NOSYM, -val); n = snprintf(s, BUFSIZE, MOD_POSIX_FMT_NEG_NOSYM, -val);
} }
} else { } else {
// Other strfmon() formats are not supported // Other strfmon() formats are not supported
errno = EINVAL; errno = EINVAL;
ret = -1; n = -1;
} }
} }
if (ret >= BUFSIZE) { if (n >= BUFSIZE) {
// Truncate the too-long output with a terminating NUL // Truncate the too-long output with a terminating NUL
s[BUFSIZE - 1] = '\0'; s[BUFSIZE - 1] = '\0';
} }
if (ret >= 0) { if (n >= 0) {
xmbstowcs(buf, s, maxsize); xmbstowcs(buf, s, maxsize);
/* Some buggy implementations of strfmon(), such as that on /* Some buggy implementations of strfmon(), such as that on
@ -655,7 +655,7 @@ ssize_t xwcsfmon (wchar_t *restrict buf, size_t maxsize,
} }
free(s); free(s);
return ret; return n;
} }