aboutsummaryrefslogtreecommitdiff
path: root/coreutils/sort.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/sort.c')
-rw-r--r--coreutils/sort.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 3354385a4..195e13d13 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -12,13 +12,6 @@
12 * http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html 12 * http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
13 */ 13 */
14 14
15#include <ctype.h>
16#include <math.h>
17#include <stdio.h>
18#include <stdlib.h>
19#include <string.h>
20#include <time.h>
21#include <unistd.h>
22#include "busybox.h" 15#include "busybox.h"
23 16
24static int global_flags; 17static int global_flags;
@@ -104,7 +97,7 @@ static char *get_key(char *str, struct sort_key *key, int flags)
104 } 97 }
105 /* Make the copy */ 98 /* Make the copy */
106 if(end<start) end=start; 99 if(end<start) end=start;
107 str=bb_xstrndup(str+start,end-start); 100 str=xstrndup(str+start,end-start);
108 /* Handle -d */ 101 /* Handle -d */
109 if(flags&FLAG_d) { 102 if(flags&FLAG_d) {
110 for(start=end=0;str[end];end++) 103 for(start=end=0;str[end];end++)
@@ -222,7 +215,6 @@ static int compare_keys(const void *xarg, const void *yarg)
222 /* Perform fallback sort if necessary */ 215 /* Perform fallback sort if necessary */
223 if(!retval && !(global_flags&FLAG_s)) 216 if(!retval && !(global_flags&FLAG_s))
224 retval=strcmp(*(char **)xarg, *(char **)yarg); 217 retval=strcmp(*(char **)xarg, *(char **)yarg);
225//dprintf(2,"reverse=%d\n",flags&FLAG_r);
226 return ((flags&FLAG_r)?-1:1)*retval; 218 return ((flags&FLAG_r)?-1:1)*retval;
227} 219}
228 220
@@ -242,7 +234,7 @@ int sort_main(int argc, char **argv)
242#ifdef CONFIG_FEATURE_SORT_BIG 234#ifdef CONFIG_FEATURE_SORT_BIG
243 case 'o': 235 case 'o':
244 if(outfile) bb_error_msg_and_die("Too many -o."); 236 if(outfile) bb_error_msg_and_die("Too many -o.");
245 outfile=bb_xfopen(optarg,"w"); 237 outfile=xfopen(optarg,"w");
246 break; 238 break;
247 case 't': 239 case 't':
248 if(key_separator || optarg[1]) 240 if(key_separator || optarg[1])
@@ -289,7 +281,7 @@ int sort_main(int argc, char **argv)
289 /* Open input files and read data */ 281 /* Open input files and read data */
290 for(i=argv[optind] ? optind : optind-1;argv[i];i++) { 282 for(i=argv[optind] ? optind : optind-1;argv[i];i++) {
291 if(i<optind || (*argv[i]=='-' && !argv[i][1])) fp=stdin; 283 if(i<optind || (*argv[i]=='-' && !argv[i][1])) fp=stdin;
292 else fp=bb_xfopen(argv[i],"r"); 284 else fp=xfopen(argv[i],"r");
293 for(;;) { 285 for(;;) {
294 line=GET_LINE(fp); 286 line=GET_LINE(fp);
295 if(!line) break; 287 if(!line) break;