# HG changeset patch # User Rob Landley # Date 1171402911 18000 # Node ID c3d1d74d5d8f1e5fb829bf2b76a1fc907b101f60 # Parent 97d717829ff0a5859e3843478628655d506cc4bd MacOS X has a defective sed with no -r. diff -r 97d717829ff0 -r c3d1d74d5d8f Makefile --- a/Makefile Mon Feb 12 20:03:01 2007 -0500 +++ b/Makefile Tue Feb 13 16:41:51 2007 -0500 @@ -39,7 +39,7 @@ # Get list of toys/*.c files from .config -toysfiles = $(shell sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' .config | sort -u | tr A-Z a-z | grep -v '^toybox$$' | sed -r 's@(.*)@toys/\1.c@') +toysfiles = $(shell sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' .config | sort -u | tr A-Z a-z | grep -v '^toybox$$' | sed 's@\(.*\)@toys/\1.c@') # Compile toybox from source diff -r 97d717829ff0 -r c3d1d74d5d8f lib/portability.h --- a/lib/portability.h Mon Feb 12 20:03:01 2007 -0500 +++ b/lib/portability.h Tue Feb 13 16:41:51 2007 -0500 @@ -1,13 +1,30 @@ - // Humor glibc to get dprintf, then #define it to something more portable. #define _GNU_SOURCE #include #define fdprintf(...) dprintf(__VA_ARGS__) + +#ifndef __APPLE__ +#include #include #if __BYTE_ORDER == __BIG_ENDIAN #define IS_BIG_ENDIAN 1 +#else +#define IS_BIG_ENDIAN 0 +#endif + +#else + +#ifdef __BIG_ENDIAN__ +#define IS_BIG_ENDIAN 1 +#else +#define IS_BIG_ENDIAN 0 +#endif + +#endif + +#if IS_BIG_ENDIAN #define IS_LITTLE_ENDIAN 0 #define SWAP_BE16(x) (x) #define SWAP_BE32(x) (x) @@ -17,7 +34,6 @@ #define SWAP_LE64(x) bswap_64(x) #else #define IS_LITTLE_ENDIAN 1 -#define IS_BIG_ENDIAN 0 #define SWAP_BE16(x) bswap_16(x) #define SWAP_BE32(x) bswap_32(x) #define SWAP_BE64(x) bswap_64(x) diff -r 97d717829ff0 -r c3d1d74d5d8f toys/Config.in --- a/toys/Config.in Mon Feb 12 20:03:01 2007 -0500 +++ b/toys/Config.in Tue Feb 13 16:41:51 2007 -0500 @@ -172,6 +172,20 @@ The print working directory command prints the current directory. +config TOUCH + bool "touch" + default n + help + usage: touch [-acmrt] FILE... + + Change file timestamps/length. Create empty or sparse files. + + -a + -c + -m + -r + -t + config TOYSH bool "sh (toysh)" default n diff -r 97d717829ff0 -r c3d1d74d5d8f toys/toylist.h --- a/toys/toylist.h Mon Feb 12 20:03:01 2007 -0500 +++ b/toys/toylist.h Tue Feb 13 16:41:51 2007 -0500 @@ -31,6 +31,12 @@ struct dirtree *dt; }; +struct touch_data { + char *ref_file; + char *time; + long length; +}; + // "E:jJ:L:m:O:" #define MKE2FS_OPTSTRING "<1>2Fnqm#N#i#b#" @@ -75,6 +81,7 @@ USE_ONEIT(NEWTOY(oneit, "+p<1", TOYFLAG_SBIN)) USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN)) USE_TOYSH(OLDTOY(sh, toysh, "c:i", TOYFLAG_BIN)) +USE_TOUCH(NEWTOY(touch, "l#t:r:mca", TOYFLAG_BIN)) USE_TOYSH(NEWTOY(toysh, "c:i", TOYFLAG_BIN)) USE_WHICH(NEWTOY(which, "a", TOYFLAG_USR|TOYFLAG_BIN)) USE_YES(NEWTOY(yes, "", TOYFLAG_USR|TOYFLAG_BIN))