X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fsort-test.c;h=448abdc31b517fe72e0b39e0c64898613b005a96;hb=157acec25f2e60c76607edc3d62cf23fe47f4efe;hp=2f61b1528d783b71fe27172bd276d381f38ccdc7;hpb=23f2f5abfec1098ce98afa88b8308b869d59216c;p=libucw.git diff --git a/lib/sort-test.c b/lib/sort-test.c index 2f61b152..448abdc3 100644 --- a/lib/sort-test.c +++ b/lib/sort-test.c @@ -8,13 +8,15 @@ #include struct key { - char line[1024]; + char line[4096]; }; #define SORT_KEY struct key #define SORT_PREFIX(x) s_##x +#define SORT_PRESORT #define SORT_INPUT_FILE #define SORT_OUTPUT_FILE +#define SORT_UNIFY static inline int s_compare(struct key *a, struct key *b) @@ -34,16 +36,53 @@ s_copy_data(struct fastbuf *src UNUSED, struct fastbuf *dest, struct key *k) bputsn(dest, k->line); } +static inline byte * +s_fetch_item(struct fastbuf *src UNUSED, struct key *k, byte *limit UNUSED) +{ + byte *end = (byte *) k->line + strlen(k->line) + 1; +#if 0 /* Testing splits */ + uns r = random_max(10000); + if (end + r <= limit) + return end + r; + else + return NULL; +#else + return end; +#endif +} + +static inline void +s_store_item(struct fastbuf *f, struct key *k) +{ + s_copy_data(NULL, f, k); +} + +#ifdef SORT_UNIFY +static inline void +s_merge_data(struct fastbuf *src1 UNUSED, struct fastbuf *src2 UNUSED, struct fastbuf *dest, struct key *k1, struct key *k2 UNUSED) +{ + s_copy_data(NULL, dest, k1); +} + +static inline struct key * +s_merge_items(struct key *a, struct key *b UNUSED) +{ + return a; +} +#endif + #include "lib/sorter.h" int main(int argc, char **argv) { log_init(NULL); - cf_read(DEFAULT_CONFIG); if (cf_getopt(argc, argv, CF_SHORT_OPTS, CF_NO_LONG_OPTS, NULL) >= 0 || optind != argc - 2) - die("Usage: sort-test "); + { + fputs("This program supports only the following command-line arguments:\n" CF_USAGE, stderr); + exit(1); + } s_sort(argv[optind], argv[optind+1]); return 0;