summaryrefslogtreecommitdiffstats
path: root/usr.bin/touch
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2013-09-05 20:18:59 +0000
committersjg <sjg@FreeBSD.org>2013-09-05 20:18:59 +0000
commit62bb1062226d3ce6a2350808256a25508978352d (patch)
tree22b131dceb13c3df96da594fbaadb693504797c7 /usr.bin/touch
parent72ab90509b3a51ab361bf710338f2ef44a4e360d (diff)
parent04932445481c2cb89ff69a83b961bdef3d64757e (diff)
downloadFreeBSD-src-62bb1062226d3ce6a2350808256a25508978352d.zip
FreeBSD-src-62bb1062226d3ce6a2350808256a25508978352d.tar.gz
Merge from head
Diffstat (limited to 'usr.bin/touch')
-rw-r--r--usr.bin/touch/touch.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/usr.bin/touch/touch.c b/usr.bin/touch/touch.c
index d42d9af..4439c07 100644
--- a/usr.bin/touch/touch.c
+++ b/usr.bin/touch/touch.c
@@ -56,12 +56,12 @@ static const char sccsid[] = "@(#)touch.c 8.1 (Berkeley) 6/6/93";
#include <time.h>
#include <unistd.h>
-void stime_arg1(char *, struct timeval *);
-void stime_arg2(char *, int, struct timeval *);
-void stime_darg(char *, struct timeval *);
-void stime_file(char *, struct timeval *);
-int timeoffset(char *);
-void usage(char *);
+static void stime_arg1(const char *, struct timeval *);
+static void stime_arg2(const char *, int, struct timeval *);
+static void stime_darg(const char *, struct timeval *);
+static void stime_file(const char *, struct timeval *);
+static int timeoffset(const char *);
+static void usage(const char *);
int
main(int argc, char *argv[])
@@ -78,7 +78,7 @@ main(int argc, char *argv[])
Aflag = aflag = cflag = mflag = timeset = 0;
stat_f = stat;
utimes_f = utimes;
- if (gettimeofday(&tv[0], NULL))
+ if (gettimeofday(&tv[0], NULL) == -1)
err(1, "gettimeofday");
while ((ch = getopt(argc, argv, "A:acd:fhmr:t:")) != -1)
@@ -115,7 +115,6 @@ main(int argc, char *argv[])
timeset = 1;
stime_arg1(optarg, tv);
break;
- case '?':
default:
usage(myname);
}
@@ -235,8 +234,8 @@ main(int argc, char *argv[])
#define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2;
-void
-stime_arg1(char *arg, struct timeval *tvp)
+static void
+stime_arg1(const char *arg, struct timeval *tvp)
{
time_t now;
struct tm *t;
@@ -290,14 +289,17 @@ stime_arg1(char *arg, struct timeval *tvp)
t->tm_isdst = -1; /* Figure out DST. */
tvp[0].tv_sec = tvp[1].tv_sec = mktime(t);
if (tvp[0].tv_sec == -1)
-terr: errx(1,
- "out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]");
+ goto terr;
tvp[0].tv_usec = tvp[1].tv_usec = 0;
+ return;
+
+terr:
+ errx(1, "out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]");
}
-void
-stime_arg2(char *arg, int year, struct timeval *tvp)
+static void
+stime_arg2(const char *arg, int year, struct timeval *tvp)
{
time_t now;
struct tm *t;
@@ -326,8 +328,8 @@ stime_arg2(char *arg, int year, struct timeval *tvp)
tvp[0].tv_usec = tvp[1].tv_usec = 0;
}
-void
-stime_darg(char *arg, struct timeval *tvp)
+static void
+stime_darg(const char *arg, struct timeval *tvp)
{
struct tm t = { .tm_sec = 0 };
const char *fmt, *colon;
@@ -372,7 +374,7 @@ bad:
/* Calculate a time offset in seconds, given an arg of the format [-]HHMMSS. */
int
-timeoffset(char *arg)
+timeoffset(const char *arg)
{
int offset;
int isneg;
@@ -400,8 +402,8 @@ timeoffset(char *arg)
return (offset);
}
-void
-stime_file(char *fname, struct timeval *tvp)
+static void
+stime_file(const char *fname, struct timeval *tvp)
{
struct stat sb;
@@ -411,8 +413,8 @@ stime_file(char *fname, struct timeval *tvp)
TIMESPEC_TO_TIMEVAL(tvp + 1, &sb.st_mtim);
}
-void
-usage(char *myname)
+static void
+usage(const char *myname)
{
fprintf(stderr, "usage: %s [-A [-][[hh]mm]SS] [-achm] [-r file] "
"[-t [[CC]YY]MMDDhhmm[.SS]]\n"
OpenPOWER on IntegriCloud