summaryrefslogtreecommitdiff
path: root/lib/libtermlib/tparm.c
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1996-06-02 23:47:52 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1996-06-02 23:47:52 +0000
commit9f4ee1df3fd4656aaf61ec44d350ac03c1b7f697 (patch)
treeadd518fe9c65460b84813b7f09967a045a134840 /lib/libtermlib/tparm.c
parent0e56afa254340259276b8e317691dcc14d9815dc (diff)
Some format strings were not handled entirely right, fixed.
Remove unused argument to internal _tparm
Diffstat (limited to 'lib/libtermlib/tparm.c')
-rw-r--r--lib/libtermlib/tparm.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/lib/libtermlib/tparm.c b/lib/libtermlib/tparm.c
index f803e23661f..6e163dbfd5a 100644
--- a/lib/libtermlib/tparm.c
+++ b/lib/libtermlib/tparm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tparm.c,v 1.1 1996/05/31 05:40:02 tholo Exp $ */
+/* $OpenBSD: tparm.c,v 1.2 1996/06/02 23:47:51 tholo Exp $ */
/*
* Copyright (c) 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
@@ -31,7 +31,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: tparm.c,v 1.1 1996/05/31 05:40:02 tholo Exp $";
+static char rcsid[] = "$OpenBSD: tparm.c,v 1.2 1996/06/02 23:47:51 tholo Exp $";
#endif
#include <stdio.h>
@@ -56,7 +56,7 @@ static __inline void push __P((int));
static __inline int popnum __P((void));
static __inline char *popstr __P((void));
-static char *_tparm __P((const char *, char *, size_t, va_list));
+static char *_tparm __P((const char *, char *, va_list));
static union {
unsigned int num;
@@ -86,21 +86,20 @@ popstr()
}
static char *
-_tparm(str, buf, len, ap)
+_tparm(str, buf, ap)
const char *str;
char *buf;
- size_t len;
va_list ap;
{
int param[10], variable[26];
- int pops, num, i, level, incr;
+ int pops, num, i, level;
+ char *bufp, len;
const char *p;
- char *bufp;
if (str == NULL)
return NULL;
- for (p = str, pops = 0, num = 0, incr = 0; *p != '\0'; p++)
+ for (p = str, pops = 0, num = 0; *p != '\0'; p++)
if (*p == '%' && *(p + 1) != '\0') {
switch (p[1]) {
case '%':
@@ -109,7 +108,6 @@ _tparm(str, buf, len, ap)
case 'i':
if (pops < 2)
pops = 2;
- incr++;
break;
case 'p':
p++;
@@ -133,10 +131,6 @@ _tparm(str, buf, len, ap)
for (i = 0; i < MAX(pops, num); i++)
param[i] = va_arg(ap, int); /* XXX arg size might be different than int */
- if (pops == 0)
- for (i = pops = num; i > 0; i--)
- push(param[i - 1]);
-
stackidx = 0;
bufp = buf;
@@ -153,8 +147,7 @@ _tparm(str, buf, len, ap)
bufp += strlen(bufp);
break;
case '0':
- str++;
- len = *str & 0xFF;
+ len = *++str;
if (len == '2' || len == '3') {
if (*++str == 'd') {
if (len == '2')
@@ -201,7 +194,7 @@ _tparm(str, buf, len, ap)
break;
case 'p':
str++;
- if (isdigit(*str))
+ if (*str != '0' && isdigit(*str))
push(param[*str - '1']);
break;
case 'P':
@@ -222,7 +215,7 @@ _tparm(str, buf, len, ap)
num = 0;
str++;
while (isdigit(*str))
- num = num * 10 + *str++ - '0';
+ num = num * 10 + (*str++ - '0');
push(num);
break;
case '+':
@@ -316,8 +309,6 @@ _tparm(str, buf, len, ap)
else
break;
}
- else if (*str == 'e' && level == 0)
- break;
}
if (*str)
str++;
@@ -356,7 +347,7 @@ tparm(va_alist)
#else
va_start(ap, str);
#endif
- p = _tparm(str, buf, sizeof(buf) - 1, ap);
+ p = _tparm(str, buf, ap);
va_end(ap);
return(p);
}