Module Name:    src
Committed By:   christos
Date:           Sun Jan 24 16:42:12 UTC 2010

Modified Files:
        src/crypto/dist/heimdal/lib/roken: get_window_size.c getarg.c
            roken.h.in

Log Message:
don't expose struct winsize needlessly.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/crypto/dist/heimdal/lib/roken/get_window_size.c \
    src/crypto/dist/heimdal/lib/roken/getarg.c \
    src/crypto/dist/heimdal/lib/roken/roken.h.in

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/crypto/dist/heimdal/lib/roken/get_window_size.c
diff -u src/crypto/dist/heimdal/lib/roken/get_window_size.c:1.5 src/crypto/dist/heimdal/lib/roken/get_window_size.c:1.6
--- src/crypto/dist/heimdal/lib/roken/get_window_size.c:1.5	Wed Jan 20 10:03:50 2010
+++ src/crypto/dist/heimdal/lib/roken/get_window_size.c	Sun Jan 24 11:42:12 2010
@@ -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;
+    }
+    if (lines) {
+	if ((s = getenv("LINES")))
+	    *lines = atoi(s);
+	else
+	    return -1;
     }
-    return ret;
+    return 0;
 }
Index: src/crypto/dist/heimdal/lib/roken/getarg.c
diff -u src/crypto/dist/heimdal/lib/roken/getarg.c:1.5 src/crypto/dist/heimdal/lib/roken/getarg.c:1.6
--- src/crypto/dist/heimdal/lib/roken/getarg.c:1.5	Wed Jan 20 10:03:50 2010
+++ src/crypto/dist/heimdal/lib/roken/getarg.c	Sun Jan 24 11:42:12 2010
@@ -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);
Index: src/crypto/dist/heimdal/lib/roken/roken.h.in
diff -u src/crypto/dist/heimdal/lib/roken/roken.h.in:1.5 src/crypto/dist/heimdal/lib/roken/roken.h.in:1.6
--- src/crypto/dist/heimdal/lib/roken/roken.h.in:1.5	Sat Mar 22 04:37:21 2008
+++ src/crypto/dist/heimdal/lib/roken/roken.h.in	Sun Jan 24 11:42:12 2010
@@ -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);

Reply via email to