aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Beppu <beppu@lbox.org>1999-12-22 17:57:31 +0000
committerJohn Beppu <beppu@lbox.org>1999-12-22 17:57:31 +0000
commit019513a59ffd966cca51d6616757295a46869e4a (patch)
tree5d03c4e7c4ba676fef529c52a4a55c46e246259e
parent38efa7902e7d266fbc78e1d39780ca0866d98dad (diff)
downloadbusybox-019513a59ffd966cca51d6616757295a46869e4a.tar.gz
added hooks for sort
-rw-r--r--applets/busybox.c3
-rw-r--r--busybox.c3
-rw-r--r--busybox.def.h1
-rw-r--r--coreutils/sort.c24
-rw-r--r--internal.h1
-rw-r--r--sort.c24
6 files changed, 52 insertions, 4 deletions
diff --git a/applets/busybox.c b/applets/busybox.c
index 895accd93..cd4ab8fcd 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -184,6 +184,9 @@ static const struct Applet applets[] = {
#ifdef BB_SLEEP //bin
{"sleep", sleep_main},
#endif
+#ifdef BB_SORT //bin
+ {"sort", sort_main},
+#endif
#ifdef BB_SYNC //bin
{"sync", sync_main},
#endif
diff --git a/busybox.c b/busybox.c
index 895accd93..cd4ab8fcd 100644
--- a/busybox.c
+++ b/busybox.c
@@ -184,6 +184,9 @@ static const struct Applet applets[] = {
#ifdef BB_SLEEP //bin
{"sleep", sleep_main},
#endif
+#ifdef BB_SORT //bin
+ {"sort", sort_main},
+#endif
#ifdef BB_SYNC //bin
{"sync", sync_main},
#endif
diff --git a/busybox.def.h b/busybox.def.h
index 3a64c1a54..3c290f7a4 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -64,6 +64,7 @@
//#define BB_SFDISK
#define BB_SED
#define BB_SLEEP
+#define BB_SORT
#define BB_SWAPONOFF
#define BB_SYNC
#define BB_SYSLOGD
diff --git a/coreutils/sort.c b/coreutils/sort.c
index d82351797..f3f9fca1d 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -90,6 +90,17 @@ line_newFromFile(FILE *src)
return NULL;
}
+/* Line destructor */
+static Line *
+line_release(Line *self)
+{
+ if (self->data) {
+ free(self->data);
+ free(self);
+ }
+ return self;
+}
+
/* Comparison */
@@ -148,7 +159,16 @@ list_writeToFile(List *self, FILE* dst)
static List *
list_release(List *self)
{
- return self;
+ Line *i;
+ Line *die;
+
+ i = self->head;
+ while (i) {
+ die = i;
+ i = die->next;
+ line_delete(die);
+ }
+ return self; /* bad poetry? */
}
@@ -195,4 +215,4 @@ sort_main(int argc, char **argv)
exit(0);
}
-/* $Id: sort.c,v 1.2 1999/12/22 00:30:29 beppu Exp $ */
+/* $Id: sort.c,v 1.3 1999/12/22 17:57:31 beppu Exp $ */
diff --git a/internal.h b/internal.h
index 6bb9341ef..05e3904e6 100644
--- a/internal.h
+++ b/internal.h
@@ -113,6 +113,7 @@ extern int sh_main(int argc, char** argv);
extern int sfdisk_main(int argc, char** argv);
extern int sed_main(int argc, char** argv);
extern int sleep_main(int argc, char** argv);
+extern int sort_main(int argc, char** argv);
extern int swap_on_off_main(int argc, char** argv);
extern int sync_main(int argc, char** argv);
extern int syslogd_main(int argc, char **argv);
diff --git a/sort.c b/sort.c
index d82351797..f3f9fca1d 100644
--- a/sort.c
+++ b/sort.c
@@ -90,6 +90,17 @@ line_newFromFile(FILE *src)
return NULL;
}
+/* Line destructor */
+static Line *
+line_release(Line *self)
+{
+ if (self->data) {
+ free(self->data);
+ free(self);
+ }
+ return self;
+}
+
/* Comparison */
@@ -148,7 +159,16 @@ list_writeToFile(List *self, FILE* dst)
static List *
list_release(List *self)
{
- return self;
+ Line *i;
+ Line *die;
+
+ i = self->head;
+ while (i) {
+ die = i;
+ i = die->next;
+ line_delete(die);
+ }
+ return self; /* bad poetry? */
}
@@ -195,4 +215,4 @@ sort_main(int argc, char **argv)
exit(0);
}
-/* $Id: sort.c,v 1.2 1999/12/22 00:30:29 beppu Exp $ */
+/* $Id: sort.c,v 1.3 1999/12/22 17:57:31 beppu Exp $ */