summaryrefslogtreecommitdiff
path: root/src/sort.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-10-14 14:12:48 +0000
committerJim Meyering <jim@meyering.net>1997-10-14 14:12:48 +0000
commitbf5606ff49c6de1a6e4a2d486ac88980fdf54dba (patch)
tree357c882edfddd845529a0c8ce13bead7d2ad6f53 /src/sort.c
parent3f7506491bd8a08020cd40ecf574e353a66e4ea7 (diff)
downloadcoreutils-bf5606ff49c6de1a6e4a2d486ac88980fdf54dba.tar.xz
(fraccompare): Indent.
Move dcls of S and N into if block.
Diffstat (limited to 'src/sort.c')
-rw-r--r--src/sort.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/sort.c b/src/sort.c
index 4c59a4c8c..59342b577 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -934,10 +934,10 @@ findlines (struct buffer *buf, struct lines *lines)
if digit return -1, else 0
return 0
- As can be clearly seen, the above implementation duplicates code,
- and thus there is place for improvement:
+ The above implementation duplicates code, and thus there is room
+ for improvement:
the difference in code of a and b, is solved by using a
- refernce to s, assigned to either a or b. and using n
+ reference to s, assigned to either a or b. and using n
to denote return value.
the difference in either that start being a digit or
the decimal point, is solved by testing if either is
@@ -945,12 +945,16 @@ findlines (struct buffer *buf, struct lines *lines)
if *a or *b is a decimal_point
skip all chars where *a == *b
- if *a and *b are digits return *a - *b
+ if *a and *b are digits
+ return *a - *b
s is b, and return code is -1
- if *a is a digit or *a is a decimal_pointm then s is a, return code 1
+ if *a is a digit or *a is a decimal_point
+ s is a
+ return code 1
skip decimal_point in s
skip zeroes in s
- if *s is a digit, return n
+ if *s is a digit
+ return n
return 0 */
#ifdef ENABLE_NLS
@@ -958,25 +962,31 @@ findlines (struct buffer *buf, struct lines *lines)
static int
fraccompare (register const char *a, register const char *b)
{
- register const char *s;
- int n = -1;
-
if (!nls_fraction_found)
nls_fraction_found = 1;
+
if (*a == decimal_point || *b == decimal_point)
{
- if (*a == *b)
- do {
+ register const char *s;
+ int n = -1;
+
+ while (*a == *b)
+ {
++a;
++b;
- } while (*a == *b && ISDIGIT (*a));
+ if (ISDIGIT (*a))
+ break;
+ }
+
if (ISDIGIT (*a) && ISDIGIT (*b))
return (*a) - (*b);
+
s = b;
- if (*a == decimal_point || (ISDIGIT (*a) && *b != decimal_point)) {
- s = a;
- n = 1;
- }
+ if (*a == decimal_point || (ISDIGIT (*a) && *b != decimal_point))
+ {
+ s = a;
+ n = 1;
+ }
if (*s == decimal_point)
++s;
while (*s == NUMERIC_ZERO)