summaryrefslogtreecommitdiff
path: root/src/join.c
AgeCommit message (Collapse)Author
2008-02-20join: avoid new leaksJames Youngman
* src/join.c (prevline): Make prevline module-level static, so that the allocated items can be freed at exit. (free_prevline): new atexit function; frees items in prevline[]. Use ARRAY_CARDINALITY, so include "argmatch.h" to get that. (main): Arrange for free_prevline to be called during exit. (get_line): Free prevline[which - 1] also, as that will have been allocated by dup_line.
2008-02-19join: new options: --check-order and --nocheck-order.James Youngman
* src/join.c: Support --check-order and --nocheck-order. New variables check_input_order, seen_unpairable and issued_disorder_warning[]. For --check-order, verify that the input files are in sorted order. For the default case, check the order only if there are unpairable lines. (join): Perform ordering checks after reaching EOF on either input. (usage): Mention --check-order and --nocheck-order. (dupline): Save a copy of the previously-read input line so that we can detect disorder on the input. (get_line): Temporarily save a copy of the previous line (by calling dupline) and check relative ordering (by calling checkorder) before returning the newly-read line. (getseq, join): Tell get_line which file we are reading from. (advance_seq): New function, factoring out some of the code commonly surrounding calls to getseq. (checkorder): New function. Verifies that a pair of consecutive input lines are in sorted order. * doc/coreutils.texi (join invocation): Document the new options --check-order and --nocheck-order. * tests/join/Test.pm (tv): Added tests for --check-order and --nocheck-order. * NEWS: Mention this new feature.
2007-07-23Update all copyright notices to use the newer form.Jim Meyering
2007-07-10Change "version 2" to "version 3" in all copyright notices.Jim Meyering
2007-03-28Help translators include translation team's web or email address.Jim Meyering
* src/system.h (emit_bug_reporting_address): New function. * src/base64.c: Use it rather than a literal printf. * src/basename.c, src/cat.c, src/chgrp.c, src/chmod.c: * src/chown.c, src/chroot.c, src/cksum.c, src/comm.c, src/cp.c: * src/csplit.c, src/cut.c, src/date.c, src/dd.c, src/df.c: * src/dircolors.c, src/dirname.c, src/du.c, src/echo.c, src/env.c: * src/expand.c, src/expr.c, src/factor.c, src/fmt.c, src/fold.c: * src/head.c, src/hostid.c, src/hostname.c, src/id.c, src/install.c: * src/join.c, src/kill.c, src/link.c, src/ln.c, src/logname.c: * src/ls.c, src/md5sum.c, src/mkdir.c, src/mkfifo.c, src/mknod.c: * src/mv.c, src/nice.c, src/nl.c, src/nohup.c, src/od.c: * src/paste.c, src/pathchk.c, src/pinky.c, src/pr.c, src/printenv.c: * src/printf.c, src/ptx.c, src/pwd.c, src/readlink.c, src/rm.c: * src/rmdir.c, src/seq.c, src/setuidgid.c, src/shred.c, src/shuf.c: * src/sleep.c, src/sort.c, src/split.c, src/stat.c, src/stty.c: * src/su.c, src/sum.c, src/sync.c, src/system.h, src/tac.c: * src/tail.c, src/tee.c, src/test.c, src/touch.c, src/tr.c: * src/true.c, src/tsort.c, src/tty.c, src/uname.c, src/unexpand.c: * src/uniq.c, src/unlink.c, src/uptime.c, src/users.c, src/wc.c: * src/who.c, src/whoami.c, src/yes.c: Likewise.
2006-12-13Remove some arbitrary restrictions on size fields,Paul Eggert
so that commands like "sort -k 18446744073709551616" no longer fail merely because 18446744073709551616 doesn't fit in uintmax_t. The trick is that these fields can all be treated as effectively infinity; their exact values don't matter, since no internal buffer can be that long. * src/join.c (string_to_join_field): Verify that SIZE_MAX <= ULONG_MAX if the code assumes this. Silently truncate too-large values to SIZE_MAX, as the remaining code will do the right thing in this case. * src/sort.c (parse_field_count): Likewise. * src/uniq.c (size_opt, main): Likewise. * tests/join/Test.pm (bigfield): New test. * tests/sort/Test.pm (bigfield): New test. * tests/uniq/Test.pm (121): New test. Signed-off-by: Jim Meyering <jim@meyering.net>
2006-07-09(is_blank): Remove; no longer needed. All usesPaul Eggert
replaced by isblank (to_uchar (...)).
2006-02-21(usage): Mention `sort -k 1b,1'.Paul Eggert
2006-02-18(usage): Use two spaces (not one) to separate theJim Meyering
--first-only option string from its description, so help2man formats the derived man page properly.
2005-08-12Cosmetic: use X2NREALLOC (only two arguments) rather than x2nrealloc (with ↵Jim Meyering
three).
2005-07-09Don't include stdio.h; no longer needed.Paul Eggert
2005-07-03Include stdio--.h, not stdio-safer.h.Paul Eggert
(main): Use fopen, not fopen_safer.
2005-06-16Don't embed `this'-style quotes in format strings.Jim Meyering
Rather than this: error (..., "...`%s'...", arg); do this: error (..., "...%s...", quote (arg));
2005-05-19(decode_field_spec): Add an abort afterJim Meyering
`error (EXIT_FAILURE, ...' to avoid a gcc warning in caller, about variables being used uninitialized.
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-14Update FSF postal mail address.Jim Meyering
2005-04-26Remove posixver.h and its uses.Paul Eggert
(obsolete_usage): Remove. (join_field_1, join_field_2): Initialize to SIZE_MAX to indicate they haven't been set yet. (tab): Now int, not char. Initialize to -1 to indicate white space separates columns, so that we can use NUL as a separator. All uses changed. (OBSOLETE_LONG_OPTIONS, get_option): Remove. (string_to_join_field): Remove ERR_MSG_FMT arg; a single format suffices. Use xstrtoul for sizes; it suffices. (decode_field_spec): Report an error and exit on failure. Return void, not bool. (add_field_list): Likewise. (set_join_field): New function. (enum operand_status): New enum. (add_file_name): New args OPERAND_STATUS, JOPTION_COUNT, PREV_OPTC_STATUS, OPTC_STATUS to handle the bewildering array of possibilities with obsolete option parsing. (main): Use it. Do not depend on POSIX version. Check for conflicting options. Parse obsolete options -j1 and -j2 so that it is a pure extension to POSIX 1003.1-2001. Allow '-t\0' to specify a NUL tab, stealing the code from 'sort'.
2005-04-11Include stdio-safer.h.Paul Eggert
(main): Use fopen_safer. Simplify the resulting code.
2004-12-08Undo previous change; it's already there.Paul Eggert
2004-12-08(usage): Mention that input files should be sorted.Paul Eggert
2004-12-02(keycmp): Assume setlocale exists.Paul Eggert
2004-09-21Remove unused "case 0".Paul Eggert
2004-06-21Standardize on the diagnostics given when someone givesJim Meyering
too few operands ("missing operand after `xxx'") or too many operands ("extra operand `xxx'"). Include "quote.h" and/or "error.h" if it wasn't already being included. (add_file_name, main): Likewise.
2004-04-17(add_file_name): Declare function to be `static'.Jim Meyering
2004-04-17(string_to_join_field): Declare function to be `static'.Jim Meyering
2004-03-10`join -1 x' would give a misleading diagnosticJim Meyering
(string_to_join_field): Report that a non-numeric field number is invalid, rather than `so large that it is not representable'.
2004-01-21(usage): Use EXIT_SUCCESS, not 0, for clarity.Jim Meyering
(usage): Don't bother normalizing exit status since the arg is already the correct exit status now.
2003-12-30Include posixver.h.Jim Meyering
(obsolete_usage): New var. (longopts): Put obsolete options first. (OBSOLETE_LONG_OPTIONS): New constant. (get_option, add_file_name): New functions. (main): Use them to support new behavior. (usage): Remove documentation for -j1 FIELD and -j2 FIELD. Do not mark -j FIELD as obsolescent; it is longstanding UNIX tradition and is a valid extension to POSIX.
2003-12-30remove trailing blankJim Meyering
2003-12-30(add_field_list): Don't use alloca with unboundedJim Meyering
size; just modify the argument, which is no longer const *. Various other minor cleanups, mostly to avoid the need for casts. (extract_field): Renamed from ADD_FIELD, as it's now a function. (struct field.beg): Now char *, not unsigned char const *. All uses changed. It shouldn't be const since xmemcoll writes on its arguments. (extract_field): Likewise, for 2nd arg. (keycmp): Remove now-unnecessary cast of xmemcoll args. (is_blank): New function, to avoid need to cast arg to unsigned char. (extract_field): Use it. (xfields): Rewrite pretty much from scratch. (hard_LC_COLLATE): Now bool, not int. (get_line, getseq, add_field_list): Now returns bool, not int. (decode_field_spec, add_field_list): Return true on success (not false), for consistency with the rest of the code. All uses changed. (tab): Now char, not unsigned char. This wasn't 100% necessary but is slightly cleaner. (prjoin): Hoist (tab ? tab : ' ') expression, to help the compiler. (empty_filler): Now const *. (make_blank): Remove; wasn't needed. Remove all calls. (main): Don't set uni_blank.nfields; zero is fine.
2003-12-27Include "quote.h".Jim Meyering
(min, max): Remove definitions. Make a few function parameters and corresponding locals `const'. Use bool for boolean variables. Use size_t (not int) for all counters and related index variables. (prjoin): Remove now-useless assertion. (string_to_join_field): New function. (main): Accept join fields as large as SIZE_MAX. (keycmp): Rename `min' to MIN and max to MAX.
2003-12-20[struct seq]: Change types of members count and allocJim Meyering
from `int' to `size_t'.
2003-11-19(usage): Mention that FILE1 and FILE2 must be sortedJim Meyering
on the join fields. Suggestion from Bruce Robertson.
2003-11-04(ADD_FIELD, initseq, getseq): Use x2nrealloc rather than xrealloc.Jim Meyering
2003-11-04(initseq, add_field, make_blank): Use `sizeof *var' ratherJim Meyering
than `sizeof EXPLICIT_TYPE'. The former is more maintainable and usually shorter.
2003-10-18Most .c files (AUTHORS): Revert the WRITTEN_BY/AUTHORS changeJim Meyering
of 2003-09-19. Now, AUTHORS is a comma-separated list of strings. Update the call to parse_long_options so that `AUTHORS, NULL' are the last parameters. * src/true.c (main): Append NULL to version_etc argument list. * src/sys2.h (case_GETOPT_VERSION_CHAR): Likewise.
2003-09-28Remove unnecessary cast of alloca, since now it's guaranteed to be (void *).Jim Meyering
2003-09-23(get_line): Report error right away if I/O fails,Jim Meyering
so that the proper errno value is used.
2003-09-18(WRITTEN_BY): Rename from AUTHORS.Jim Meyering
Begin each WRITTEN_BY string with `Written by ' and end it with `.'. Mark each WRITTEN_BY string as translatable.
2003-07-23Don't include headers already included by system.h:Jim Meyering
Don't include closeout.h.
2003-06-18Reflect renaming: readline -> readlinebuffer.Jim Meyering
2003-06-17(main): Call initialize_main.Jim Meyering
2003-05-13(delseq, freeline): Don't apply cast to argument of free.Jim Meyering
2003-04-11Remove anachronistic casts of xmalloc,Jim Meyering
xrealloc, and xcalloc return values and of xrealloc's first argument.
2003-02-19(usage): Change wording in --help output:Jim Meyering
use FILENUM instead of `SIDE' and say what FILENUM means.
2002-08-31Change `exit (0)' to `exit (EXIT_SUCCESS)',Jim Meyering
`exit (1)' to `exit (EXIT_FAILURE)', and `usage (1)' to `usage (EXIT_FAILURE)'.
2002-07-02(usage): Use the PACKAGE_BUGREPORT e-mail address, rather than hard-coding it.Jim Meyering
2002-04-30(keycmp): Replace #ifdef ENABLE_NLS with if (HAVE_SETLOCALE).Jim Meyering
(hard_LC_COLLATE): Define even if ! ENABLE_NLS. (main): Always initialize hard_LC_COLLATE. Put initialization next to other locale-related stuff.
2002-01-22Include xmemcoll.h, not memcoll.h.Jim Meyering
Use xmemcoll instead of memcoll.
2002-01-21(keycmp): Don't assume that the difference between two size_t values can beJim Meyering
stored in an int; this doesn't work, for example, on 64-bit Solaris. Also, fix the type of two locals to be size_t instead of int.