mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
* gl/lib/strintcmp.c (strintcmp): Don’t assume that the input cannot contain ((char) -1), as this equals '\377' when char is signed (assuming 8-bit char). * src/sort.c (decimal_point): Now char, to make it clear that it’s always in char range now. (NON_CHAR): New constant. (traverse_raw_number): Return char not unsigned char; this is simpler and could be faster. All callers changed. (main): Do not convert decimal_point and thousands_sep to unsigned char, as this can mishandle comparisons on machines where char is signed and the input data contains ((char) -1). Use NON_CHAR, not -1, as an out-of-range value for thousands_sep.
35 lines
1.1 KiB
C
35 lines
1.1 KiB
C
/* Compare integer strings.
|
|
|
|
Copyright (C) 2005-2021 Free Software Foundation, Inc.
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
|
|
/* Written by Paul Eggert. */
|
|
|
|
#include <config.h>
|
|
|
|
#include "strnumcmp-in.h"
|
|
|
|
#include <limits.h>
|
|
|
|
/* Compare strings A and B as integers without explicitly converting
|
|
them to machine numbers, to avoid overflow problems and perhaps
|
|
improve performance. */
|
|
|
|
int
|
|
strintcmp (char const *a, char const *b)
|
|
{
|
|
return numcompare (a, b, CHAR_MAX + 1, CHAR_MAX + 1);
|
|
}
|