summaryrefslogtreecommitdiff
path: root/coreutils/sort.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
committerRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
commitd921b2ecc0d294ad4bf8c7458fc52a60c28727d2 (patch)
treee4a2769349867c441cf2983d83097bb66701a733 /coreutils/sort.c
parent6dce0b6fa79f2d4bb7e9d90e1fbc0f6beb25f855 (diff)
downloadbusybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.gz
busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.bz2
busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.zip
Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only had one user), clean up lots of #includes... General cleanup pass. What I've been doing for the last couple days. And it conflicts! I've removed httpd.c from this checkin due to somebody else touching that file. It builds for me. I have to catch a bus. (Now you know why I'm looking forward to Mercurial.)
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;