aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Beppu <beppu@lbox.org>1999-12-22 23:02:12 +0000
committerJohn Beppu <beppu@lbox.org>1999-12-22 23:02:12 +0000
commit568cb7b45f8ec1e0f6e6cad296c5431e66785a6b (patch)
tree4625d9aadc868432eff0a9a3ce8140fdd54b6255
parentd19385e160593e45f1334f207a8f6ba3487ef188 (diff)
downloadbusybox-w32-568cb7b45f8ec1e0f6e6cad296c5431e66785a6b.tar.gz
busybox-w32-568cb7b45f8ec1e0f6e6cad296c5431e66785a6b.tar.bz2
busybox-w32-568cb7b45f8ec1e0f6e6cad296c5431e66785a6b.zip
oops.. qsort(2) misunderstanding on my part.
it's ok, now.
-rw-r--r--coreutils/sort.c29
-rw-r--r--sort.c29
2 files changed, 48 insertions, 10 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c
index bab832f80..e5f229648 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Mini find implementation for busybox 2 * Mini sort implementation for busybox
3 * 3 *
4 * 4 *
5 * Copyright (C) 1999 by Lineo, inc. 5 * Copyright (C) 1999 by Lineo, inc.
@@ -107,12 +107,23 @@ line_release(Line *self)
107 107
108/* Comparison */ 108/* Comparison */
109 109
110/* ascii order */
110static int 111static int
111compare_ascii(const void *a, const void *b) 112compare_ascii(const void *a, const void *b)
112{ 113{
113 return 0; 114 Line **doh;
115 Line *x, *y;
116
117 doh = (Line **) a;
118 x = (Line *) *doh;
119 doh = (Line **) b;
120 y = (Line *) *doh;
121
122 // fprintf(stdout, "> %p: %s< %p: %s", x, x->data, y, y->data);
123 return strcmp(x->data, y->data);
114} 124}
115 125
126/* numeric order */
116static int 127static int
117compare_numeric(const void *a, const void *b) 128compare_numeric(const void *a, const void *b)
118{ 129{
@@ -173,7 +184,7 @@ list_sort(List *self, Compare *compare)
173 } 184 }
174 185
175 /* apply qsort */ 186 /* apply qsort */
176 qsort(self->sorted, sizeof(Line*), self->len, compare); 187 qsort(self->sorted, self->len, sizeof(Line*), compare);
177 return self; 188 return self;
178} 189}
179 190
@@ -260,10 +271,18 @@ sort_main(int argc, char **argv)
260 exit(0); 271 exit(0);
261} 272}
262 273
263/* $Id: sort.c,v 1.5 1999/12/22 22:27:01 beppu Exp $ */ 274/* $Id: sort.c,v 1.6 1999/12/22 23:02:12 beppu Exp $ */
264/* 275/*
265 * $Log: sort.c,v $ 276 * $Log: sort.c,v $
277 * Revision 1.6 1999/12/22 23:02:12 beppu
278 * oops.. qsort(2) misunderstanding on my part.
279 * it's ok, now.
280 *
266 * Revision 1.5 1999/12/22 22:27:01 beppu 281 * Revision 1.5 1999/12/22 22:27:01 beppu
267 * playing w/ $Log$ 282 * playing w/ $Log: sort.c,v $
283 * playing w/ Revision 1.6 1999/12/22 23:02:12 beppu
284 * playing w/ oops.. qsort(2) misunderstanding on my part.
285 * playing w/ it's ok, now.
286 * playing w/
268 * 287 *
269 */ 288 */
diff --git a/sort.c b/sort.c
index bab832f80..e5f229648 100644
--- a/sort.c
+++ b/sort.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Mini find implementation for busybox 2 * Mini sort implementation for busybox
3 * 3 *
4 * 4 *
5 * Copyright (C) 1999 by Lineo, inc. 5 * Copyright (C) 1999 by Lineo, inc.
@@ -107,12 +107,23 @@ line_release(Line *self)
107 107
108/* Comparison */ 108/* Comparison */
109 109
110/* ascii order */
110static int 111static int
111compare_ascii(const void *a, const void *b) 112compare_ascii(const void *a, const void *b)
112{ 113{
113 return 0; 114 Line **doh;
115 Line *x, *y;
116
117 doh = (Line **) a;
118 x = (Line *) *doh;
119 doh = (Line **) b;
120 y = (Line *) *doh;
121
122 // fprintf(stdout, "> %p: %s< %p: %s", x, x->data, y, y->data);
123 return strcmp(x->data, y->data);
114} 124}
115 125
126/* numeric order */
116static int 127static int
117compare_numeric(const void *a, const void *b) 128compare_numeric(const void *a, const void *b)
118{ 129{
@@ -173,7 +184,7 @@ list_sort(List *self, Compare *compare)
173 } 184 }
174 185
175 /* apply qsort */ 186 /* apply qsort */
176 qsort(self->sorted, sizeof(Line*), self->len, compare); 187 qsort(self->sorted, self->len, sizeof(Line*), compare);
177 return self; 188 return self;
178} 189}
179 190
@@ -260,10 +271,18 @@ sort_main(int argc, char **argv)
260 exit(0); 271 exit(0);
261} 272}
262 273
263/* $Id: sort.c,v 1.5 1999/12/22 22:27:01 beppu Exp $ */ 274/* $Id: sort.c,v 1.6 1999/12/22 23:02:12 beppu Exp $ */
264/* 275/*
265 * $Log: sort.c,v $ 276 * $Log: sort.c,v $
277 * Revision 1.6 1999/12/22 23:02:12 beppu
278 * oops.. qsort(2) misunderstanding on my part.
279 * it's ok, now.
280 *
266 * Revision 1.5 1999/12/22 22:27:01 beppu 281 * Revision 1.5 1999/12/22 22:27:01 beppu
267 * playing w/ $Log$ 282 * playing w/ $Log: sort.c,v $
283 * playing w/ Revision 1.6 1999/12/22 23:02:12 beppu
284 * playing w/ oops.. qsort(2) misunderstanding on my part.
285 * playing w/ it's ok, now.
286 * playing w/
268 * 287 *
269 */ 288 */