Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/external/bsd/heimdal Replicate changes to get_window_...



details:   https://anonhg.NetBSD.org/src/rev/bc5276b587b1
branches:  trunk
changeset: 764274:bc5276b587b1
user:      elric <elric%NetBSD.org@localhost>
date:      Thu Apr 14 18:12:08 2011 +0000

description:
Replicate changes to get_window_size() made in previous location:

        revision 1.7
        date: 2010/01/24 16:45:57;  author: christos;  state: Exp;
        make the window size function return the lines and columns
        variables separately instead of depending on the existance
        of struct winsize. Technically I should bump the library
        version or version the symbol, but nothing seems to use
        this outside the library!

diffstat:

 crypto/external/bsd/heimdal/dist/lib/roken/get_window_size.c |  65 +++++++----
 crypto/external/bsd/heimdal/dist/lib/roken/getarg.c          |   7 +-
 crypto/external/bsd/heimdal/dist/lib/roken/roken.h.in        |   2 +-
 crypto/external/bsd/heimdal/include/roken.h                  |   2 +-
 4 files changed, 45 insertions(+), 31 deletions(-)

diffs (149 lines):

diff -r a26380e8fa69 -r bc5276b587b1 crypto/external/bsd/heimdal/dist/lib/roken/get_window_size.c
--- a/crypto/external/bsd/heimdal/dist/lib/roken/get_window_size.c      Thu Apr 14 18:02:07 2011 +0000
+++ b/crypto/external/bsd/heimdal/dist/lib/roken/get_window_size.c      Thu Apr 14 18:12:08 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: get_window_size.c,v 1.1.1.1 2011/04/13 18:15:41 elric Exp $    */
+/*     $NetBSD: get_window_size.c,v 1.2 2011/04/14 18:12:08 elric Exp $        */
 
 /*
  * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
@@ -60,32 +60,46 @@
 #include <krb5/roken.h>
 
 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
-get_window_size(int fd, struct winsize *wp)
+get_window_size(int fd, int *lines, int *columns)
 {
-    int ret = -1;
-
-    memset(wp, 0, sizeof(*wp));
+    int ret;
+    char *s;
 
 #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)
     {
        int dst[2];
-       
-       _scrsize(dst);
-       wp->ws_row = dst[1];
-       wp->ws_col = dst[0];
-       ret = 0;
+       
+       _scrsize(dst);
+       if (lines)
+           *lines = dst[1];
+       if (columns)
+           *columns = dst[0];
+       return 0;
     }
 #elif defined(_WIN32)
     {
@@ -102,14 +116,17 @@
         }
     }
 #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 a26380e8fa69 -r bc5276b587b1 crypto/external/bsd/heimdal/dist/lib/roken/getarg.c
--- a/crypto/external/bsd/heimdal/dist/lib/roken/getarg.c       Thu Apr 14 18:02:07 2011 +0000
+++ b/crypto/external/bsd/heimdal/dist/lib/roken/getarg.c       Thu Apr 14 18:12:08 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getarg.c,v 1.1.1.1 2011/04/13 18:15:41 elric Exp $     */
+/*     $NetBSD: getarg.c,v 1.2 2011/04/14 18:12:08 elric Exp $ */
 
 /*
  * Copyright (c) 1997 - 2002 Kungliga Tekniska Högskolan
@@ -230,7 +230,6 @@
     size_t i, max_len = 0;
     char buf[128];
     int col = 0, columns;
-    struct winsize ws;
 
     if (progname == NULL)
        progname = getprogname();
@@ -242,9 +241,7 @@
        mandoc_template(args, num_args, progname, extra_string, i18n);
        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, "%s: %s", usage, progname);
diff -r a26380e8fa69 -r bc5276b587b1 crypto/external/bsd/heimdal/dist/lib/roken/roken.h.in
--- a/crypto/external/bsd/heimdal/dist/lib/roken/roken.h.in     Thu Apr 14 18:02:07 2011 +0000
+++ b/crypto/external/bsd/heimdal/dist/lib/roken/roken.h.in     Thu Apr 14 18:12:08 2011 +0000
@@ -759,7 +759,7 @@
 };
 #endif
 
-ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, struct winsize *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, int *, int *);
 
 #ifndef HAVE_VSYSLOG
 #define vsyslog rk_vsyslog
diff -r a26380e8fa69 -r bc5276b587b1 crypto/external/bsd/heimdal/include/roken.h
--- a/crypto/external/bsd/heimdal/include/roken.h       Thu Apr 14 18:02:07 2011 +0000
+++ b/crypto/external/bsd/heimdal/include/roken.h       Thu Apr 14 18:12:08 2011 +0000
@@ -201,7 +201,7 @@
     issuid(void);
 
 
-ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, struct winsize *);
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, int *, int *);
 
 
 



Home | Main Index | Thread Index | Old Index