Added minor tweak to t_getstr, by passing a NULL area pointer the size
of the requested capability will be returned in the limit parameter.
This commit is contained in:
parent
f61d8fd937
commit
540421553f
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: termcap.3,v 1.14 1999/08/16 08:34:33 blymn Exp $
|
||||
.\" $NetBSD: termcap.3,v 1.15 1999/08/17 12:13:24 blymn Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -311,6 +311,12 @@ there was no termcap entry for the given
|
||||
.Fa id ,
|
||||
E2BIG indicates the retrieved entry would have overflowed
|
||||
.Fa area .
|
||||
If t_getstr is called with
|
||||
.Fa area
|
||||
being NULL then the size required to hold the capability string will be
|
||||
returned in
|
||||
.Fa limit
|
||||
so the caller can allocate enough storage to hold the capability.
|
||||
.Pp
|
||||
The
|
||||
.Fn t_goto
|
||||
@ -366,13 +372,12 @@ argument. The interpretation of the contents of
|
||||
is dependent soley on the implementation of
|
||||
.Fa outc.
|
||||
.Pp
|
||||
NOTE: If the termcap entry would exceed the 1024 buffer passed to
|
||||
.Fa tgetent
|
||||
then a special capability of
|
||||
NOTE: A special capability of
|
||||
.Fa ZZ
|
||||
is added to the end of the termcap. The number that follows this entry
|
||||
is the address of the buffer allocated to hold the full termcap entry. The
|
||||
caller may retrieve the pointer to the extended buffer by performing a
|
||||
is added to the end of the termcap entry retrieved. The number that follows
|
||||
this entry is the address of the buffer allocated to hold the full termcap
|
||||
entry. The caller may retrieve the pointer to the extended buffer by
|
||||
performing a
|
||||
.Fn tgetstr
|
||||
to retrieve the
|
||||
.Fa ZZ
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: termcap.c,v 1.19 1999/08/16 08:34:33 blymn Exp $ */
|
||||
/* $NetBSD: termcap.c,v 1.20 1999/08/17 12:13:24 blymn Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)termcap.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: termcap.c,v 1.19 1999/08/16 08:34:33 blymn Exp $");
|
||||
__RCSID("$NetBSD: termcap.c,v 1.20 1999/08/17 12:13:24 blymn Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -291,17 +291,22 @@ t_getstr(info, id, area, limit)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* check if there is room for the new entry to be put into area */
|
||||
if (limit != NULL && (*limit < i)) {
|
||||
errno = E2BIG;
|
||||
if (area != NULL) {
|
||||
/* check if there is room for the new entry to be put into area */
|
||||
if (limit != NULL && (*limit < i)) {
|
||||
errno = E2BIG;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(*area, s);
|
||||
*area += i + 1;
|
||||
if (limit != NULL) *limit -= i;
|
||||
|
||||
return (s);
|
||||
} else {
|
||||
*limit = i;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(*area, s);
|
||||
*area += i + 1;
|
||||
if (limit != NULL) *limit -= i;
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user