Date: Sat, 10 Mar 2012 14:35:09 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r232780 - head/usr.sbin/watch Message-ID: <201203101435.q2AEZ9Em060229@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Sat Mar 10 14:35:09 2012 New Revision: 232780 URL: http://svn.freebsd.org/changeset/base/232780 Log: Fix whitespace. MFC after: 1 week Modified: head/usr.sbin/watch/watch.c Modified: head/usr.sbin/watch/watch.c ============================================================================== --- head/usr.sbin/watch/watch.c Sat Mar 10 11:25:53 2012 (r232779) +++ head/usr.sbin/watch/watch.c Sat Mar 10 14:35:09 2012 (r232780) @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #define MSG_CHANGE "Snoop device change by user request." #define MSG_NOWRITE "Snoop device change due to write failure." - #define DEV_NAME_LEN 1024 /* for /dev/ttyXX++ */ #define MIN_SIZE 256 @@ -65,27 +64,26 @@ static void detach_snp(void); static void set_dev(const char *); static void ask_dev(char *, const char *); -int opt_reconn_close = 0; -int opt_reconn_oflow = 0; -int opt_interactive = 1; -int opt_timestamp = 0; +int opt_reconn_close = 0; +int opt_reconn_oflow = 0; +int opt_interactive = 1; +int opt_timestamp = 0; int opt_write = 0; int opt_no_switch = 0; const char *opt_snpdev; -char dev_name[DEV_NAME_LEN]; -int snp_io; -int std_in = 0, std_out = 1; - - -int clear_ok = 0; -struct termios otty; -char tbuf[1024], gbuf[1024]; - +char dev_name[DEV_NAME_LEN]; +int snp_io; +int std_in = 0, std_out = 1; + +int clear_ok = 0; +struct termios otty; +char tbuf[1024], gbuf[1024]; static void clear(void) { + if (clear_ok) tputs(gbuf, 1, putchar); fflush(stdout); @@ -94,8 +92,9 @@ clear(void) static void timestamp(const char *buf) { - time_t t; - char btmp[1024]; + time_t t; + char btmp[1024]; + clear(); printf("\n---------------------------------------------\n"); t = time(NULL); @@ -109,11 +108,11 @@ timestamp(const char *buf) static void set_tty(void) { - struct termios ntty; + struct termios ntty; tcgetattr (std_in, &otty); ntty = otty; - ntty.c_lflag &= ~ICANON; /* disable canonical operation */ + ntty.c_lflag &= ~ICANON; /* disable canonical operation */ ntty.c_lflag &= ~ECHO; #ifdef FLUSHO ntty.c_lflag &= ~FLUSHO; @@ -124,11 +123,11 @@ set_tty(void) #ifdef IEXTEN ntty.c_lflag &= ~IEXTEN; #endif - ntty.c_cc[VMIN] = 1; /* minimum of one character */ - ntty.c_cc[VTIME] = 0; /* timeout value */ + ntty.c_cc[VMIN] = 1; /* minimum of one character */ + ntty.c_cc[VTIME] = 0; /* timeout value */ - ntty.c_cc[VINTR] = 07; /* ^G */ - ntty.c_cc[VQUIT] = 07; /* ^G */ + ntty.c_cc[VINTR] = 07; /* ^G */ + ntty.c_cc[VQUIT] = 07; /* ^G */ tcsetattr (std_in, TCSANOW, &ntty); } @@ -138,7 +137,6 @@ unset_tty(void) tcsetattr (std_in, TCSANOW, &otty); } - static void fatal(int error, const char *buf) { @@ -169,7 +167,6 @@ open_snp(void) return (f); } - static void cleanup(int signo __unused) { @@ -180,7 +177,6 @@ cleanup(int signo __unused) exit(EX_OK); } - static void usage(void) { @@ -191,7 +187,8 @@ usage(void) static void setup_scr(void) { - char *cbuf = gbuf, *term; + char *cbuf = gbuf, *term; + if (!opt_interactive) return; if ((term = getenv("TERM"))) @@ -226,11 +223,10 @@ attach_snp(void) timestamp("Logging Started."); } - static void set_dev(const char *name) { - char buf[DEV_NAME_LEN]; + char buf[DEV_NAME_LEN]; struct stat sb; if (strlen(name) > 5 && !strncmp(name, _PATH_DEV, sizeof _PATH_DEV - 1)) { @@ -256,8 +252,8 @@ set_dev(const char *name) void ask_dev(char *dbuf, const char *msg) { - char buf[DEV_NAME_LEN]; - int len; + char buf[DEV_NAME_LEN]; + int len; clear(); unset_tty(); @@ -284,10 +280,10 @@ ask_dev(char *dbuf, const char *msg) int main(int ac, char *av[]) { - int ch, res, rv, nread; + int ch, res, rv, nread; size_t b_size = MIN_SIZE; - char *buf, chb[READB_LEN]; - fd_set fd_s; + char *buf, chb[READB_LEN]; + fd_set fd_s; (void) setlocale(LC_TIME, ""); @@ -296,7 +292,6 @@ main(int ac, char *av[]) else opt_interactive = 0; - while ((ch = getopt(ac, av, "Wciotnf:")) != -1) switch (ch) { case 'W': @@ -382,7 +377,7 @@ main(int ac, char *av[]) detach_snp(); if (opt_no_switch) fatal(EX_IOERR, - "write failed"); + "write failed"); ask_dev(dev_name, MSG_NOWRITE); set_dev(dev_name); } @@ -439,4 +434,3 @@ main(int ac, char *av[]) } /* While */ return(0); } -
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203101435.q2AEZ9Em060229>