Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/coreutils/touch.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/coreutils/touch.c
r2725 r3232 8 8 */ 9 9 10 /* BB_AUDIT SUSv3 _NOT_ compliant -- options -a, -m , -r, -tnot supported. */10 /* BB_AUDIT SUSv3 _NOT_ compliant -- options -a, -m not supported. */ 11 11 /* http://www.opengroup.org/onlinepubs/007904975/utilities/touch.html */ 12 12 … … 19 19 20 20 #include "libbb.h" 21 22 //config:config TOUCH 23 //config: bool "touch" 24 //config: default y 25 //config: help 26 //config: touch is used to create or change the access and/or 27 //config: modification timestamp of specified files. 28 //config: 29 //config:config FEATURE_TOUCH_SUSV3 30 //config: bool "Add support for SUSV3 features (-d -t -r)" 31 //config: default y 32 //config: depends on TOUCH 33 //config: help 34 //config: Enable touch to use a reference file or a given date/time argument. 35 36 //applet:IF_TOUCH(APPLET_NOFORK(touch, touch, BB_DIR_BIN, BB_SUID_DROP, touch)) 37 38 //kbuild:lib-$(CONFIG_TOUCH) += touch.o 39 40 //usage:#define touch_trivial_usage 41 //usage: "[-c]" IF_FEATURE_TOUCH_SUSV3(" [-d DATE] [-t DATE] [-r FILE]") " FILE..." 42 //usage:#define touch_full_usage "\n\n" 43 //usage: "Update the last-modified date on the given FILE[s]\n" 44 //usage: "\n -c Don't create files" 45 //usage: IF_FEATURE_TOUCH_SUSV3( 46 //usage: "\n -d DT Date/time to use" 47 //usage: "\n -t DT Date/time to use" 48 //usage: "\n -r FILE Use FILE's date/time" 49 //usage: ) 50 //usage: 51 //usage:#define touch_example_usage 52 //usage: "$ ls -l /tmp/foo\n" 53 //usage: "/bin/ls: /tmp/foo: No such file or directory\n" 54 //usage: "$ touch /tmp/foo\n" 55 //usage: "$ ls -l /tmp/foo\n" 56 //usage: "-rw-rw-r-- 1 andersen andersen 0 Apr 15 01:11 /tmp/foo\n" 21 57 22 58 /* This is a NOFORK applet. Be very careful! */ … … 44 80 int status = EXIT_SUCCESS; 45 81 int opts; 46 #if ENABLE_ DESKTOP82 #if ENABLE_FEATURE_TOUCH_SUSV3 47 83 # if ENABLE_LONG_OPTS 48 84 static const char touch_longopts[] ALIGN1 = … … 63 99 #endif 64 100 65 #if ENABLE_ DESKTOP&& ENABLE_LONG_OPTS101 #if ENABLE_FEATURE_TOUCH_SUSV3 && ENABLE_LONG_OPTS 66 102 applet_long_options = touch_longopts; 67 103 #endif … … 69 105 * accepted data format differs a bit between -d and -t. 70 106 * We accept the same formats for both */ 71 opts = getopt32(argv, "c" IF_ DESKTOP("r:d:t:")107 opts = getopt32(argv, "c" IF_FEATURE_TOUCH_SUSV3("r:d:t:") 72 108 /*ignored:*/ "fma" 73 IF_ DESKTOP(, &reference_file)74 IF_ DESKTOP(, &date_str)75 IF_ DESKTOP(, &date_str)109 IF_FEATURE_TOUCH_SUSV3(, &reference_file) 110 IF_FEATURE_TOUCH_SUSV3(, &date_str) 111 IF_FEATURE_TOUCH_SUSV3(, &date_str) 76 112 ); 77 113 … … 92 128 time_t t; 93 129 94 //time(&t); 95 //localtime_r(&t, &tm_time); 96 memset(&tm_time, 0, sizeof(tm_time)); 130 //memset(&tm_time, 0, sizeof(tm_time)); 131 /* Better than memset: makes "HH:MM" dates meaningful */ 132 time(&t); 133 localtime_r(&t, &tm_time); 97 134 parse_datestr(date_str, &tm_time); 98 135
Note:
See TracChangeset
for help on using the changeset viewer.