From bc07865a504c291b9c88e41b3481ee6b44334b4d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 15 Dec 2007 21:47:25 -0600 Subject: Start of "patch" support. Writes to stdout at the moment. --- toys/Config.in | 13 +++++++++++++ toys/toylist.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) (limited to 'toys') 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)) -- cgit v1.2.3