View | Details | Raw Unified | Return to bug 15418
Collapse All | Expand All

(-)tput.c (-22 / +29 lines)
Lines 47-52 Link Here
47
#include <termcap.h>
47
#include <termcap.h>
48
#include <stdio.h>
48
#include <stdio.h>
49
#include <stdlib.h>
49
#include <stdlib.h>
50
#include <string.h>
50
#include <unistd.h>
51
#include <unistd.h>
51
52
52
#undef putchar
53
#undef putchar
Lines 139-172 Link Here
139
	    "too many arguments (%d) for capability `%s'";
140
	    "too many arguments (%d) for capability `%s'";
140
	static char erresc[] =
141
	static char erresc[] =
141
	    "unknown %% escape `%c' for capability `%s'";
142
	    "unknown %% escape `%c' for capability `%s'";
143
	static char errcap[] =
144
	    "unexpected end of capability `%s'";
142
	char *cp;
145
	char *cp;
143
	int arg_need, arg_rows, arg_cols;
146
	int arg_need, arg_rows, arg_cols;
144
147
145
	/* Count how many values we need for this capability. */
148
	/* Count how many values we need for this capability. */
146
	for (cp = str, arg_need = 0; *cp != '\0'; cp++)
149
	for (cp = str, arg_need = 0; *cp != '\0'; cp++)
147
		if (*cp == '%')
150
		if (*cp == '%')
148
			    switch (*++cp) {
151
			switch (*++cp) {
149
			    case 'd':
152
			case 'p':
150
			    case '2':
153
				if (*++cp == '\0') {
151
			    case '3':
154
					warnx(errcap, cap);
152
			    case '.':
155
					cp--;
153
			    case '+':
156
					break;
154
				    arg_need++;
157
				}
155
				    break;
158
				if (*cp >= '1' && *cp <= '9' && *cp > arg_need)
156
			    case '%':
159
					arg_need = *cp - '0';
157
			    case '>':
160
				break;
158
			    case 'i':
161
			case '\'':
159
			    case 'r':
162
				if (*++cp == '\0') {
160
			    case 'n':
163
					warnx(errcap, cap);
161
			    case 'B':
164
					cp--;
162
			    case 'D':
165
				}
163
				    break;
166
				break;
164
			    default:
167
			case '\0':
165
				/*
168
				warnx(errcap, cap);
166
				 * hpux has lot's of them, but we complain
169
				cp--;
167
				 */
170
				break;
168
				 warnx(erresc, *cp, cap);
171
			default:
169
			    }
172
				if (strchr("%:# 0123456789.doxXs" /* + */
173
				    "cPg{l+-*/m&|^=><AO!~i?te;", *cp) == NULL)
174
					warnx(erresc, *cp, cap);
175
				break;
176
			}
170
177
171
	/* And print them. */
178
	/* And print them. */
172
	switch (arg_need) {
179
	switch (arg_need) {

Return to bug 15418