- add libbb function str_tolower to convert a string to lowercase.
[oweals/busybox.git] / coreutils / touch.c
index e1af7d0dce5458dcd212361f0b31ed4850ce47c5..5f81b2380858dd9086e3c43b06be775c71ace2b0 100644 (file)
  * Also, exiting on a failure was a bug.  All args should be processed.
  */
 
-#include <stdio.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <utime.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
 #include "busybox.h"
 
+/* This is a NOFORK applet. Be very careful! */
+
+int touch_main(int argc, char **argv);
 int touch_main(int argc, char **argv)
 {
        int fd;
-       int flags;
        int status = EXIT_SUCCESS;
-
-       flags = getopt32(argc, argv, "c");
+       int flags = getopt32(argc, argv, "c");
 
        argv += optind;
 
@@ -42,8 +36,8 @@ int touch_main(int argc, char **argv)
 
        do {
                if (utime(*argv, NULL)) {
-                       if (errno == ENOENT) {  /* no such file*/
-                               if (flags & 1) {        /* Creation is disabled, so ignore. */
+                       if (errno == ENOENT) {  /* no such file */
+                               if (flags) {    /* Creation is disabled, so ignore. */
                                        continue;
                                }
                                /* Try to create the file. */