This is a discussion on [patch] KNF in touch within the mailing.openbsd.tech forums, part of the OpenBSD category; --> hello, I know that it's not very important but I made some fixes to touch so it's more KNF ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| hello, I know that it's not very important but I made some fixes to touch so it's more KNF compliant.. especially usage() and some declarations lineup.. if somebody thinks it's silly - sorry for the noise.. Index: touch.c ================================================== ================= RCS file: /cvs/src/usr.bin/touch/touch.c,v retrieving revision 1.12 diff -u -r1.12 touch.c --- touch.c 2005/04/20 19:16:34 1.12 +++ touch.c 2006/03/07 08:45:16 @@ -58,18 +58,18 @@ #include <tzfile.h> #include <unistd.h> -void stime_arg1(char *, struct timeval *); -void stime_arg2(char *, int, struct timeval *); -void stime_file(char *, struct timeval *); -void usage(void); +void stime_arg1(char *, struct timeval *); +void stime_arg2(char *, int, struct timeval *); +void stime_file(char *, struct timeval *); +__dead void usage(void); int main(int argc, char *argv[]) { - struct stat sb; - struct timeval tv[2]; - int aflag, cflag, mflag, ch, fd, len, rval, timeset; - char *p; + struct stat sb; + struct timeval tv[2]; + int aflag, cflag, mflag, ch, fd, len, rval, timeset; + char *p; setlocale(LC_ALL, ""); @@ -183,10 +183,10 @@ void stime_arg1(char *arg, struct timeval *tvp) { - struct tm *t; - time_t tmptime; - int yearset; - char *p; + struct tm *t; + time_t tmptime; + int yearset; + char *p; /* Start with the current time. */ tmptime = tvp[0].tv_sec; if ((t = localtime(&tmptime)) == NULL) @@ -242,8 +242,8 @@ void stime_arg2(char *arg, int year, struct timeval *tvp) { - struct tm *t; - time_t tmptime; + struct tm *t; + time_t tmptime; /* Start with the current time. */ tmptime = tvp[0].tv_sec; if ((t = localtime(&tmptime)) == NULL) @@ -275,7 +275,7 @@ void stime_file(char *fname, struct timeval *tvp) { - struct stat sb; + struct stat sb; if (stat(fname, &sb)) err(1, "%s", fname); @@ -286,7 +286,9 @@ __dead void usage(void) { + extern char *__progname; + (void)fprintf(stderr, - "usage: touch [-acm] [-r file] [-t time] file ...\n"); + "usage: %s [-acm] [-r file] [-t time] file ...\n", __progname); exit(1); } -- Przemyslaw Nowaczyk <p_nowaczyk@o2.pl> CS student @ Poznan University of Technology |