aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/patch.c
AgeCommit message (Collapse)Author
2020-02-02Canonicalize the usage: lines for the POSIX toys.Elliott Hughes
This only touches 24 of the 68 toys/posix/ files --- the others were already canonical. Potentially contentious, so worth stating explicitly, is that there were 8 matches for "COMMAND..." amongst all existing help output, with 7 matches for various inconsistent variants involving something with "ARG", so I resolved that in favor of using "COMMAND..." (which is also shorter overall, and avoids nested []s).
2019-12-21Add patch -F (fuzz factor)Rob Landley
2019-12-21Tighten up unquote_file()Rob Landley
2019-12-20patch: support [FILE [PATCH]] arguments.Elliott Hughes
POSIX only mentions -i/stdin, but GNU patch -- and Larry Wall's patch 1.3, found via https://en.wikipedia.org/wiki/Patch_(Unix) -- also support supplying the name of the file to patch and the name of the patch file as optional arguments. The AOSP build makes use of this syntax to patch snakeyaml to remove references to java.beans.* stuff.
2019-09-11Add NOP -f, -g#, and --no-backup-if-mismatch options.Rob Landley
(All ignored, because they disable stuff we don't do.)
2019-08-29diff and patch: support special characters in filenames with quoting as well ↵William Haddon
as unusual timestamp formats After further research and testing, I've produced a patch which handles all filenames with special characters by copying the GNU quoting behavior, and also treats anything following a tab as a timestamp. This increases both ability to handle possible filenames and ability to apply patches found in the field. In diff, quote and escape filenames according to the following rules. * Surround the filename with quotes if it contains a byte less than 0x20, a byte greater than or equal to 0x80, space, backslash, or quote. * Replace alert, backspace, form feed, newline, carriage return, tab, vertical tab, backslash, and quote with \a, \b, \f, \n, \r, \t, \v, \\, and \", respectively. * Replace other bytes less than 0x20 or greater than or equal to 0x80 with a backslash followed by the three octal digits representing the value of the byte. * Treat valid UTF-8 characters involving sequences of bytes greater than or equal to 0x80 the same as other sequences of such bytes. In patch, process quoted and escaped filenames according to the following rules. * If the filename does not begin with a quote, do not modify the filename. * Remove quotes surrounding the filename. * In quoted filenames, replace \a, \b, \f, \n, \r, \t, \v, \\, and \" with alert, backspace, form feed, newline, carriage return, tab, vertical tab, backslash, and quote, respectively. * In quoted filenames, replace a backslash followed by octal digits with the byte with that value in octal. Also, in patch, treat anything on a +++ or --- line following a tab character after the beginning of the filename as a timestamp, rather than part of the filename.
2019-01-14Minor cleanups to patch. (Mostly whitespace and brackets.)Rob Landley
2019-01-13Better support patching files with tabs in the name.Rob Landley
Patch dates are optional these days, and I should properly work back from the end and only peel off properly formatted tab+date, but "tab followed by digit" is probably good enough and nobody's ever complained about just tab. And we still don't support patching filenames with newlines in them...)
2019-01-12patch: add -s to the synopsis line and fix typos.Elliott Hughes
2019-01-11patch: add -s/--quiet.Elliott Hughes
Used by AOSP build. Also switch to new FLAG macro. Bug: http://b/122739027
2018-12-04Clean up some --help formatting.Elliott Hughes
Be consistent about upper versus lower case. (Upper seems to have the majority, so I went with that, though I'm happy to provide the opposite patch as long as we're consistent!) Be consistent about using \t. (Though saving a few bytes seems like it might be better done in the code that generates help.h rather than directly in the source, since tabs make careful ASCII art layout hard enough that we regularly have things misaligned.) Remove trailing periods (most of which seem to have been added by me). Always use the US "human readable" rather than my British "human-readable", and be more consistent about declaring whether we're showing multiples of 1000 or 1024. Just say "verbose" rather than adding a useless "mode" or "output".
2018-08-25Convert more argument variables in GLOBALS() to new style.Rob Landley
2018-04-08Add mkpath() for common case of mkpathat(), and #define magic constants.Rob Landley
2016-08-04Make xopen() skip stdin/stdout/stderr, add xopen_stdio() if you want stdout,Rob Landley
add xopenro() that takes one argument and understands "-" means stdin, and switch over lots of users.
2016-06-30Add patch -d and --dry-runRob Landley
2015-11-01Last patch broke creating new file as a patch, fix it.Rob Landley
(Matches beginning and EOF at once.)
2015-11-01Fix applying patch hunks with trailing context to the start of the file.Rob Landley
2014-08-05Fix a couple patch bugs concerning error output.Rob Landley
2014-06-28Use dlist_terminate() in patch.Rob Landley
2014-03-11Move mkpathat to lib, remove redundant function used by patch.Rob Landley
2013-10-31Make the patch -x option (only enabled with CONFIG_DEBUG) provide more ↵Rob Landley
information about why a patch didn't apply. (Offset of first nonmatching character at each line during seek phase.)
2013-09-09Adjust patch to use dlist_pop()Rob Landley
2013-03-21Fix a bug in patch I fixed back in 2010 but forgot to apply here.Rob Landley
2012-11-13Reindent to two spaces per level. Remove vi: directives that haven't worked ↵Rob Landley
right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
2012-11-12Yet another attempt to get the fiddly patch file creation logic right.Rob Landley
2012-11-10Fix reversed test: patch creates a file if /dev/null or dated the epoch ↵Rob Landley
_and_ first hunk being replaced is 0 lines at start of file, not one or the other.
2012-10-08New build infrastructure to generate FLAG_ macros and TT alias, #define ↵Rob Landley
FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
2012-10-07Missing line in patch -l. Oops.Rob Landley
2012-10-06patch -l (loose match)Rob Landley
2012-08-25Regularize command headers, update links to standards documents.Rob Landley
2012-08-25Move commands into "posix", "lsb", and "other" menus/directories.Rob Landley