* SORT_KEY [*] data type capable of storing a single key
* SORT_PREFIX(x) [*] add a name prefix (used on all global names
* defined by the sorter)
- * SORT_PRESORT include an in-core presorting pass. Beware, when in
+ * SORT_PRESORT include an in-core pre-sorting pass. Beware, when in
* the pre-sorting mode, it's quite possible that the
* comparison function will be called with both arguments
* identical.
+ * SORT_PRESORT_ONLY a C expression which, if evaluated to non-zero, makes
+ * the sorter stop after the pre-sorting pass, resulting
+ * in a file which is not necessarily sorted, but which
+ * contains long runs. Implies SORT_PRESORT.
* SORT_UNIFY merge items with identical keys
* SORT_UNIQUE all items have distinct keys (checked in debug mode)
* SORT_REGULAR all items are equally long and they don't contain
#define SORT_ASSERT_UNIQUE
#endif
+#ifdef SORT_PRESORT_ONLY
+#undef SORT_PRESORT
+#define SORT_PRESORT
+#else
+#define SORT_PRESORT_ONLY 0
+#endif
+
#ifdef SORT_REGULAR
static inline int
leftover = NULL;
while (cont)
{
- SWAP(out1, out2, tbuf);
+ if (!(SORT_PRESORT_ONLY))
+ SWAP(out1, out2, tbuf);
if (!out1)
out1 = bopen_tmp(sorter_stream_bufsize);
current = buffer;
#undef SORT_INPUT_FBPAIR
#undef SORT_OUTPUT_FILE
#undef SORT_OUTPUT_FB
+#undef SORT_PRESORT
+#undef SORT_PRESORT_ONLY
#endif /* !SORT_DECLARE_ONLY */