summaryrefslogtreecommitdiff
path: root/touch.c
diff options
context:
space:
mode:
authorErik Andersen2000-02-08 19:58:47 +0000
committerErik Andersen2000-02-08 19:58:47 +0000
commite49d5ecbbe51718fa925b6890a735e5937cc2aa2 (patch)
treec90bda10731ad9333ce3b404f993354c9fc104b8 /touch.c
parentc0bf817bbc5c7867fbe8fb76d5c39f8ee802692f (diff)
downloadbusybox-e49d5ecbbe51718fa925b6890a735e5937cc2aa2.zip
busybox-e49d5ecbbe51718fa925b6890a735e5937cc2aa2.tar.gz
Some formatting updates (ran the code through indent)
-Erik
Diffstat (limited to 'touch.c')
-rw-r--r--touch.c79
1 files changed, 37 insertions, 42 deletions
diff --git a/touch.c b/touch.c
index d2d3e94..a0f21ac 100644
--- a/touch.c
+++ b/touch.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
* Mini touch implementation for busybox
*
@@ -31,56 +32,50 @@
static const char touch_usage[] = "touch [-c] file [file ...]\n\n"
-"Update the last-modified date on the given file[s].\n";
+ "Update the last-modified date on the given file[s].\n";
-extern int
-touch_main(int argc, char **argv)
-{
- int fd;
- int create=TRUE;
- if (argc < 2) {
- usage( touch_usage);
- }
- argc--;
- argv++;
+extern int touch_main(int argc, char **argv)
+{
+ int fd;
+ int create = TRUE;
- /* Parse options */
- while (**argv == '-') {
- while (*++(*argv)) switch (**argv) {
- case 'c':
- create = FALSE;
- break;
- default:
- usage( touch_usage);
- exit( FALSE);
+ if (argc < 2) {
+ usage(touch_usage);
}
argc--;
argv++;
- }
- fd = open (*argv, (create==FALSE)? O_RDWR : O_RDWR | O_CREAT, 0644);
- if (fd < 0 ) {
- if (create==FALSE && errno == ENOENT)
- exit( TRUE);
- else {
- perror("touch");
- exit( FALSE);
+ /* Parse options */
+ while (**argv == '-') {
+ while (*++(*argv))
+ switch (**argv) {
+ case 'c':
+ create = FALSE;
+ break;
+ default:
+ usage(touch_usage);
+ exit(FALSE);
+ }
+ argc--;
+ argv++;
}
- }
- close( fd);
- if (utime (*argv, NULL)) {
- perror("touch");
- exit( FALSE);
- }
- else
- exit( TRUE);
-}
-
-
-
-
-
+ fd = open(*argv, (create == FALSE) ? O_RDWR : O_RDWR | O_CREAT, 0644);
+ if (fd < 0) {
+ if (create == FALSE && errno == ENOENT)
+ exit(TRUE);
+ else {
+ perror("touch");
+ exit(FALSE);
+ }
+ }
+ close(fd);
+ if (utime(*argv, NULL)) {
+ perror("touch");
+ exit(FALSE);
+ } else
+ exit(TRUE);
+}