Source-Changes-HG archive

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

[src/trunk]: src/lib/libterminfo Fix tparm.



details:   https://anonhg.NetBSD.org/src/rev/058fac92f4d8
branches:  trunk
changeset: 770106:058fac92f4d8
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Oct 03 20:13:48 2011 +0000

description:
Fix tparm.
As we now go via tiparm, store nums as int to conserve memory.

diffstat:

 lib/libterminfo/tparm.c |  29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diffs (113 lines):

diff -r 1be8c602abbe -r 058fac92f4d8 lib/libterminfo/tparm.c
--- a/lib/libterminfo/tparm.c   Mon Oct 03 19:22:59 2011 +0000
+++ b/lib/libterminfo/tparm.c   Mon Oct 03 20:13:48 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tparm.c,v 1.6 2011/10/03 12:31:51 roy Exp $ */
+/* $NetBSD: tparm.c,v 1.7 2011/10/03 20:13:48 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: tparm.c,v 1.6 2011/10/03 12:31:51 roy Exp $");
+__RCSID("$NetBSD: tparm.c,v 1.7 2011/10/03 20:13:48 roy Exp $");
 
 #include <assert.h>
 #include <ctype.h>
@@ -43,18 +43,18 @@
 static TERMINAL *dumbterm; /* For non thread safe functions */
 
 typedef struct {
-       long nums[20];
+       int nums[20];
        char *strings[20];
        size_t offset;
 } TPSTACK;
 
 typedef struct {
-       long num;
+       int num;
        char *string;
 } TPVAR;
 
 static int
-push(long num, char *string, TPSTACK *stack)
+push(int num, char *string, TPSTACK *stack)
 {
        if (stack->offset > sizeof(stack->nums)) {
                errno = E2BIG;
@@ -67,7 +67,7 @@
 }
 
 static int
-pop(long *num, char **string, TPSTACK *stack)
+pop(int *num, char **string, TPSTACK *stack)
 {
        if (stack->offset == 0) {
                if (num)
@@ -114,7 +114,7 @@
 }
 
 static size_t
-onum(TERMINAL *term, const char *fmt, long num, int len)
+onum(TERMINAL *term, const char *fmt, int num, int len)
 {
        size_t l;
 
@@ -133,8 +133,8 @@
 {
        const char *sp;
        char c, fmt[64], *fp, *ostr;
-       long val, val2;
-       long dnums[26]; /* dynamic variables a-z, not preserved */
+       int val, val2;
+       int dnums[26]; /* dynamic variables a-z, not preserved */
        size_t l, max;
        TPSTACK stack;
        TPVAR params[9];
@@ -150,6 +150,7 @@
          still work with non thread safe functions (which sadly are still the
          norm and standard).
        */
+
        if (term == NULL) {
                if (dumbterm == NULL) {
                        dumbterm = malloc(sizeof(*dumbterm));
@@ -171,7 +172,7 @@
 
        /*
          Make a first pass through the string so we can work out
-         which parameters are longs and which are char *.
+         which parameters are ints and which are char *.
          Basically we only use char * if %p[1-9] is followed by %l or %s.
        */
        memset(&piss, 0, sizeof(piss));
@@ -315,7 +316,7 @@
                                l = 0;
                        else
                                l = strlen(ostr);
-                       if (onum(term, "%d", (long)l, 0) == 0)
+                       if (onum(term, "%d", (int)l, 0) == 0)
                                return NULL;
                        break;
                case 'd': /* FALLTHROUGH */
@@ -357,7 +358,7 @@
                                params[1].num++;
                        break;
                case '\'':
-                       if (push((long)(unsigned char)*str++, NULL, &stack))
+                       if (push((int)(unsigned char)*str++, NULL, &stack))
                                return NULL;
                        while (*str != '\0' && *str != '\'')
                                str++;
@@ -530,6 +531,6 @@
 {
        int p1 = lp1, p2 = lp2, p3 = lp3, p4 = lp4, p5 = lp5;
        int p6 = lp6, p7 = lp7, p8 = lp8, p9 = lp9;
-       
-       return tiparm(NULL, str, p1, p2, p3, p4, p5, p6, p7, p8, p9);
+
+       return tiparm(str, p1, p2, p3, p4, p5, p6, p7, p8, p9);
 }



Home | Main Index | Thread Index | Old Index