Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/crypto/dist/heimdal/lib/roken don't expose struct winsize ne...
details: https://anonhg.NetBSD.org/src/rev/58999d24cc41
branches: trunk
changeset: 751095:58999d24cc41
user: christos <christos%NetBSD.org@localhost>
date: Sun Jan 24 16:42:12 2010 +0000
description:
don't expose struct winsize needlessly.
diffstat:
crypto/dist/heimdal/lib/roken/get_window_size.c | 59 ++++++++++++++++--------
crypto/dist/heimdal/lib/roken/getarg.c | 7 +--
crypto/dist/heimdal/lib/roken/roken.h.in | 4 +-
3 files changed, 42 insertions(+), 28 deletions(-)
diffs (144 lines):
diff -r e013b9d61b42 -r 58999d24cc41 crypto/dist/heimdal/lib/roken/get_window_size.c
--- a/crypto/dist/heimdal/lib/roken/get_window_size.c Sun Jan 24 16:26:09 2010 +0000
+++ b/crypto/dist/heimdal/lib/roken/get_window_size.c Sun Jan 24 16:42:12 2010 +0000
@@ -34,7 +34,7 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
__RCSID("$Heimdal: get_window_size.c 21005 2007-06-08 01:54:35Z lha $"
- "$NetBSD: get_window_size.c,v 1.5 2010/01/20 15:03:50 tsutsui Exp $");
+ "$NetBSD: get_window_size.c,v 1.6 2010/01/24 16:42:12 christos Exp $");
#endif
#include <stdlib.h>
@@ -62,22 +62,34 @@
#include "roken.h"
int ROKEN_LIB_FUNCTION
-get_window_size(int fd, struct winsize *wp)
+get_window_size(int fd, int *lines, int *columns)
{
- int ret = -1;
+ int ret;
+ char *s;
- memset(wp, 0, sizeof(*wp));
-
#if defined(TIOCGWINSZ)
- ret = ioctl(fd, TIOCGWINSZ, wp);
+ {
+ struct winsize ws;
+ ret = ioctl(fd, TIOCGWINSZ, &ws);
+ if (ret != -1) {
+ if (lines)
+ *lines = ws.ws_row;
+ if (columns)
+ *columns = ws.ws_col;
+ return 0;
+ }
+ }
#elif defined(TIOCGSIZE)
{
struct ttysize ts;
ret = ioctl(fd, TIOCGSIZE, &ts);
- if(ret == 0) {
- wp->ws_row = ts.ts_lines;
- wp->ws_col = ts.ts_cols;
+ if (ret != -1) {
+ if (lines)
+ *lines = ts.ws_lines;
+ if (columns)
+ *columns = ts.ts_cols;
+ return 0;
}
}
#elif defined(HAVE__SCRSIZE)
@@ -85,19 +97,24 @@
int dst[2];
_scrsize(dst);
- wp->ws_row = dst[1];
- wp->ws_col = dst[0];
- ret = 0;
+ if (lines)
+ *lines = dst[1];
+ if (columns)
+ *columns = dst[0];
+ return 0;
}
#endif
- if (ret != 0) {
- char *s;
- if((s = getenv("COLUMNS")))
- wp->ws_col = atoi(s);
- if((s = getenv("LINES")))
- wp->ws_row = atoi(s);
- if(wp->ws_col > 0 && wp->ws_row > 0)
- ret = 0;
+ if (columns) {
+ ` if ((s = getenv("COLUMNS")))
+ *columns = atoi(s);
+ else
+ return -1;
}
- return ret;
+ if (lines) {
+ if ((s = getenv("LINES")))
+ *lines = atoi(s);
+ else
+ return -1;
+ }
+ return 0;
}
diff -r e013b9d61b42 -r 58999d24cc41 crypto/dist/heimdal/lib/roken/getarg.c
--- a/crypto/dist/heimdal/lib/roken/getarg.c Sun Jan 24 16:26:09 2010 +0000
+++ b/crypto/dist/heimdal/lib/roken/getarg.c Sun Jan 24 16:42:12 2010 +0000
@@ -34,7 +34,7 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
__RCSID("$Heimdal: getarg.c 21005 2007-06-08 01:54:35Z lha $"
- "$NetBSD: getarg.c,v 1.5 2010/01/20 15:03:50 tsutsui Exp $");
+ "$NetBSD: getarg.c,v 1.6 2010/01/24 16:42:12 christos Exp $");
#endif
#include <stdio.h>
@@ -209,7 +209,6 @@
size_t max_len = 0;
char buf[128];
int col = 0, columns;
- struct winsize ws;
if (progname == NULL)
progname = getprogname();
@@ -218,9 +217,7 @@
mandoc_template(args, num_args, progname, extra_string);
return;
}
- if(get_window_size(2, &ws) == 0)
- columns = ws.ws_col;
- else
+ if(get_window_size(2, NULL, &columns) == -1)
columns = 80;
col = 0;
col += fprintf (stderr, "Usage: %s", progname);
diff -r e013b9d61b42 -r 58999d24cc41 crypto/dist/heimdal/lib/roken/roken.h.in
--- a/crypto/dist/heimdal/lib/roken/roken.h.in Sun Jan 24 16:26:09 2010 +0000
+++ b/crypto/dist/heimdal/lib/roken/roken.h.in Sun Jan 24 16:42:12 2010 +0000
@@ -33,7 +33,7 @@
*/
/* $Heimdal: roken.h.in 18612 2006-10-19 16:35:16Z lha $
- $NetBSD: roken.h.in,v 1.5 2008/03/22 08:37:21 mlelstv Exp $ */
+ $NetBSD: roken.h.in,v 1.6 2010/01/24 16:42:12 christos Exp $ */
#include <stdio.h>
#include <stdlib.h>
@@ -429,7 +429,7 @@
};
#endif
-int ROKEN_LIB_FUNCTION get_window_size(int fd, struct winsize *);
+int ROKEN_LIB_FUNCTION get_window_size(int, int *, int *);
#ifndef HAVE_VSYSLOG
void ROKEN_LIB_FUNCTION vsyslog(int, const char *, va_list);
Home |
Main Index |
Thread Index |
Old Index