summary refs log tree commit diff
path: root/Src/Modules
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2003-03-25 05:33:18 +0000
committerClint Adams <clint@users.sourceforge.net>2003-03-25 05:33:18 +0000
commit1761a3b14674350f51a074f104a4b141b6c0caa8 (patch)
tree20332d8587959a9460c8f09405872a9e0ba8c6e7 /Src/Modules
parent63de268fee7f7850d3c234d9c6aa9d3a99f1e871 (diff)
downloadzsh-1761a3b14674350f51a074f104a4b141b6c0caa8.tar.gz
zsh-1761a3b14674350f51a074f104a4b141b6c0caa8.tar.xz
zsh-1761a3b14674350f51a074f104a4b141b6c0caa8.zip
users/5986, 18380: arg support for echoti builtin.
Diffstat (limited to 'Src/Modules')
-rw-r--r--Src/Modules/terminfo.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/Src/Modules/terminfo.c b/Src/Modules/terminfo.c
index 744defc8c..c8e5c23fb 100644
--- a/Src/Modules/terminfo.c
+++ b/Src/Modules/terminfo.c
@@ -59,8 +59,8 @@ static Param terminfo_pm;
 static int
 bin_echoti(char *name, char **argv, Options ops, int func)
 {
-    char *s, *t;
-    int num;
+    char *s, *t, *u;
+    int num, argct;
 
     s = *argv++;
     /* This depends on the termcap stuff in init.c */
@@ -92,9 +92,28 @@ bin_echoti(char *name, char **argv, Options ops, int func)
 	zwarnnam(name, "no such terminfo capability: %s", s, 0);
 	return 1;
     }
-
-    tputs(t, 1, putchar);
+    /* count the number of arguments required */
+    for (argct = 0, u = t; *u; u++)
+        if (*u == '%') {
+            if (u++, (*u == 'd' || *u == '2' || *u == '3' || *u == '.' ||
+                      *u == '+'))
+                argct++;
+        }
+    /* check that the number of arguments provided is correct */
+    if (arrlen(argv) != argct) {
+        zwarnnam(name, (arrlen(argv) < argct) ? "not enough arguments" :
+                 "too many arguments", NULL, 0);
+        return 1;
+    }
+    /* output string, through the proper termcap functions */
+    if (!argct)
+        tputs(t, 1, putraw);
+    else {
+        num = (argv[1]) ? atoi(argv[1]) : atoi(*argv);
+        tputs(tparm(t, atoi(*argv)), num, putraw);
+    }
     return 0;
+
 }
 
 /**/