diff options
author | Rob Landley <rob@landley.net> | 2007-12-15 21:47:25 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2007-12-15 21:47:25 -0600 |
commit | bc07865a504c291b9c88e41b3481ee6b44334b4d (patch) | |
tree | 591494c428601e5324d91814cbcb690e4e530ba6 /toys | |
parent | 4e68de1ef854fadd74fcb63c3a5ad15dce457a4c (diff) | |
download | toybox-bc07865a504c291b9c88e41b3481ee6b44334b4d.tar.gz |
Start of "patch" support. Writes to stdout at the moment.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/Config.in | 13 | ||||
-rw-r--r-- | toys/toylist.h | 12 |
2 files changed, 25 insertions, 0 deletions
diff --git a/toys/Config.in b/toys/Config.in index 8f2cf6c5..3d1b168d 100644 --- a/toys/Config.in +++ b/toys/Config.in @@ -273,6 +273,19 @@ config ONEIT own session. Then oneit reaps zombies until the child exits, at which point it reboots (or with -p, powers off) the system. +config PATCH + bool "patch" + default n + help + usage: patch [-i file] [-p depth] [-Ru] + + Apply a unified diff to one or more files. + + -i Input file (defaults=stdin) + -p number of '/' to strip from start of file paths (default=all) + -R Reverse patch. + -u Ignored (only handles "unified" diffs) + config PWD bool "pwd" default y diff --git a/toys/toylist.h b/toys/toylist.h index 9d040265..9b992028 100644 --- a/toys/toylist.h +++ b/toys/toylist.h @@ -67,6 +67,16 @@ struct oneit_data { char *console; }; +struct patch_data { + char *infile; + long prefix; + + struct double_list *plines, *flines; + long oldline, oldlen, newline, newlen; + int context, state; + int filein, fileout, filepatch; +}; + struct sleep_data { long seconds; }; @@ -92,6 +102,7 @@ extern union toy_union { struct mkfifo_data mkfifo; struct netcat_data netcat; struct oneit_data oneit; + struct patch_data patch; struct sleep_data sleep; struct touch_data touch; struct toysh_data toysh; @@ -140,6 +151,7 @@ USE_MKFIFO(NEWTOY(mkfifo, "<1m:", TOYFLAG_BIN)) USE_NETCAT(OLDTOY(nc, netcat, "i#w#l@p#s:q#f:e", TOYFLAG_BIN)) USE_NETCAT(NEWTOY(netcat, "i#w#l@p#s:q#f:e", TOYFLAG_BIN)) USE_ONEIT(NEWTOY(oneit, "+<1c:p", TOYFLAG_SBIN)) +USE_PATCH(NEWTOY(patch, "up#i:R", TOYFLAG_USR|TOYFLAG_BIN)) USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN)) USE_READLINK(NEWTOY(readlink, "<1f", TOYFLAG_BIN)) USE_TOYSH(OLDTOY(sh, toysh, "c:i", TOYFLAG_BIN)) |