diff options
| author | markw <markw@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-04-17 17:47:33 +0000 |
|---|---|---|
| committer | markw <markw@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-04-17 17:47:33 +0000 |
| commit | 16888d71f7afcfcdf41f8134b59392d9f07ba7ae (patch) | |
| tree | 4a9bc24baf90df6a8651a40ad626000745f4d88a /coreutils | |
| parent | 983e225fca9ff72b2251fc3616ad95ecc2c63088 (diff) | |
| download | busybox-w32-16888d71f7afcfcdf41f8134b59392d9f07ba7ae.tar.gz busybox-w32-16888d71f7afcfcdf41f8134b59392d9f07ba7ae.tar.bz2 busybox-w32-16888d71f7afcfcdf41f8134b59392d9f07ba7ae.zip | |
Applied patch from I.Q. to fix problem with sort -n.
git-svn-id: svn://busybox.net/trunk/busybox@2360 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/sort.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c index 9707efa51..b84453d3a 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c | |||
| @@ -33,7 +33,8 @@ static int compare_ascii(const void *x, const void *y) | |||
| 33 | 33 | ||
| 34 | static int compare_numeric(const void *x, const void *y) | 34 | static int compare_numeric(const void *x, const void *y) |
| 35 | { | 35 | { |
| 36 | return atoi(*(char **)x) - atoi(*(char **)y); | 36 | int z = atoi(*(char **)x) - atoi(*(char **)y); |
| 37 | return z ? z : strcmp(*(char **)x, *(char **)y); | ||
| 37 | } | 38 | } |
| 38 | 39 | ||
| 39 | int sort_main(int argc, char **argv) | 40 | int sort_main(int argc, char **argv) |
| @@ -70,6 +71,7 @@ int sort_main(int argc, char **argv) | |||
| 70 | 71 | ||
| 71 | while ((line = get_line_from_file(fp)) != NULL) { | 72 | while ((line = get_line_from_file(fp)) != NULL) { |
| 72 | lines = xrealloc(lines, sizeof(char *) * (nlines + 1)); | 73 | lines = xrealloc(lines, sizeof(char *) * (nlines + 1)); |
| 74 | line[strlen(line) - 1] = '\0'; | ||
| 73 | lines[nlines++] = line; | 75 | lines[nlines++] = line; |
| 74 | } | 76 | } |
| 75 | } | 77 | } |
| @@ -81,10 +83,10 @@ int sort_main(int argc, char **argv) | |||
| 81 | #ifdef BB_FEATURE_SORT_REVERSE | 83 | #ifdef BB_FEATURE_SORT_REVERSE |
| 82 | if (reverse) | 84 | if (reverse) |
| 83 | for (i = nlines - 1; 0 <= i; i--) | 85 | for (i = nlines - 1; 0 <= i; i--) |
| 84 | fputs(lines[i], stdout); | 86 | puts(lines[i]); |
| 85 | else | 87 | else |
| 86 | #endif | 88 | #endif |
| 87 | for (i = 0; i < nlines; i++) | 89 | for (i = 0; i < nlines; i++) |
| 88 | fputs(lines[i], stdout); | 90 | puts(lines[i]); |
| 89 | return EXIT_SUCCESS; | 91 | return EXIT_SUCCESS; |
| 90 | } | 92 | } |
