Show the error instead of just OOPS.

Don't return E2BIG for digit problems.
This commit is contained in:
christos 2006-08-27 08:28:38 +00:00
parent 52c2319234
commit bd5f306da4

View File

@ -1,4 +1,4 @@
/* $NetBSD: tgoto.c,v 1.23 2005/02/04 15:52:08 perry Exp $ */ /* $NetBSD: tgoto.c,v 1.24 2006/08/27 08:28:38 christos Exp $ */
/* /*
* Copyright (c) 1980, 1993 * Copyright (c) 1980, 1993
@ -34,7 +34,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)tgoto.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)tgoto.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: tgoto.c,v 1.23 2005/02/04 15:52:08 perry Exp $"); __RCSID("$NetBSD: tgoto.c,v 1.24 2006/08/27 08:28:38 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -43,10 +43,12 @@ __RCSID("$NetBSD: tgoto.c,v 1.23 2005/02/04 15:52:08 perry Exp $");
#include <termcap.h> #include <termcap.h>
#include <termcap_private.h> #include <termcap_private.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define CTRL(c) ((c) & 037) #define CTRL(c) ((c) & 037)
#define MAXRETURNSIZE 64 #define MAXRETURNSIZE 128
char *UP; char *UP;
char *BC; char *BC;
@ -80,10 +82,10 @@ tgoto(const char *CM, int destcol, int destline)
{ {
static char result[MAXRETURNSIZE]; static char result[MAXRETURNSIZE];
if (t_goto(NULL, CM, destcol, destline, result, MAXRETURNSIZE) >= 0) if (t_goto(NULL, CM, destcol, destline, result, sizeof(result)) == -1)
return result; (void)snprintf(result, sizeof(result), "OOPS (%s)",
else strerror(errno));
return ("OOPS"); return result;
} }
/* /*
@ -103,7 +105,7 @@ t_goto(struct tinfo *info, const char *CM, int destcol, int destline,
int oncol = 0; int oncol = 0;
int which = destline; int which = destline;
char *buf_lim = buffer + limit; char *buf_lim = buffer + limit;
char dig_buf[3 * sizeof(which)]; char dig_buf[64];
char *ap = added; char *ap = added;
char *eap = &added[sizeof(added) / sizeof(added[0])]; char *eap = &added[sizeof(added) / sizeof(added[0])];
int k; int k;
@ -155,7 +157,7 @@ t_goto(struct tinfo *info, const char *CM, int destcol, int destline,
if (c != 'd') { if (c != 'd') {
c -= '0'; c -= '0';
if (k > c) { if (k > c) {
errno = E2BIG; errno = EINVAL;
return -1; return -1;
} }
while (k < c) while (k < c)