changeset 100:c3d1d74d5d8f

MacOS X has a defective sed with no -r.
author Rob Landley <rob@landley.net>
date Tue, 13 Feb 2007 16:41:51 -0500
parents 97d717829ff0
children ff85a83e7d7e
files Makefile lib/portability.h toys/Config.in toys/toylist.h
diffstat 4 files changed, 40 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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
 
--- 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 <stdio.h>
 #define fdprintf(...) dprintf(__VA_ARGS__)
 
+
+#ifndef __APPLE__
+#include <byteswap.h>
 #include <endian.h>
 
 #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)
--- 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
--- 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))