diff options
Diffstat (limited to 'lib/wcsncmp-impl.h')
-rw-r--r-- | lib/wcsncmp-impl.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/wcsncmp-impl.h b/lib/wcsncmp-impl.h index 4ab49ebb3a..72cfce7ac4 100644 --- a/lib/wcsncmp-impl.h +++ b/lib/wcsncmp-impl.h @@ -27,8 +27,9 @@ wcsncmp (const wchar_t *s1, const wchar_t *s2, size_t n) n--; continue; } - /* Note that wc1 and wc2 each have at most 31 bits. */ - return (int)wc1 - (int)wc2; + /* ISO C requires wcsncmp to work with all wchar_t values. + We cannot assume that wc1 and wc2 are in the range 0..INT_MAX. */ + return _GL_CMP (wc1, wc2); /* > 0 if wc1 > wc2, < 0 if wc1 < wc2, = 0 if wc1 and wc2 are both '\0'. */ } |