From 203255bc1f947e03bf9c71658e4d0ece1a5ed29a Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 21 Aug 2015 20:59:32 +0100 Subject: [PATCH] termcap: add lost header information It's not clear who filed off most of the copyright info in the past (it's PD so they were entitled to even if it's rude), but we'll restore the proper credits --- Library/include/termcap.h | 13 ++++++------ Library/libs/termcap.c | 42 +++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/Library/include/termcap.h b/Library/include/termcap.h index c39322ad..691915b5 100644 --- a/Library/include/termcap.h +++ b/Library/include/termcap.h @@ -9,13 +9,12 @@ extern char *UP; extern char *BC; extern int ospeed; -extern int tgetent __P((char *, char *)); -extern int tgetflag __P((char *)); -extern int tgetnum __P((char *)); -extern char *tgetstr __P((char *, char **)); +extern int tgetent(char *, const char *); +extern int tgetflag(char *); +extern int tgetnum(char *); +extern char *tgetstr(char *, char **); -extern int tputs __P((char *, int, void (*outc)(int))); -extern char *tgoto __P((char *, int, int)); -extern char * tparam(char *, char *, int, int, int, int, int); /* VARARGS */ +extern int tputs __P((const char *, int, int (*outc)(int))); +extern char *tgoto __P((const char *, int, int)); #endif /* _TERMCAP_H */ diff --git a/Library/libs/termcap.c b/Library/libs/termcap.c index 8c142f1d..817eb253 100644 --- a/Library/libs/termcap.c +++ b/Library/libs/termcap.c @@ -1,4 +1,39 @@ -/* termcap - print termcap settings Author: Terrence Holm */ +/* + * termcap.c V1.1 20/7/87 agc Joypace Ltd + * + * Copyright Joypace Ltd, London, UK, 1987. All rights reserved. + * This file may be freely distributed provided that this notice + * remains attached. + * + * A public domain implementation of the termcap(3) routines. + * + * + * + * Klamer Schutte V1.2 Nov. 1988 + * + * - Can match multiple terminal names [tgetent] + * - Removal of **area assignments [tgetstr] + * + * Terrence W. Holm V1.3 May, Sep, Oct. 1988 + * + * - Correct when TERM != name and TERMCAP is defined [tgetent] + * - Correct the comparison for the terminal name [tgetent] + * - Correct the value of ^x escapes [tgetstr] + * - Added %r to reverse row/column [tgoto] + * - Fixed end of definition test [tgetnum/flag/str] + * + * Terrence W. Holm V1.4 Jan. 1989 + * + * - Incorporated Klamer's V1.2 fixes into V1.3 + * - Added %d, (old %d is now %2) [tgoto] + * - Allow '#' comments in definition file [tgetent] + * + * FIXME: + * - support the use of some kind of < 1024 byte buffer + * interface + * - avoid the use of stdio (state machine search for either + * [start of file]name: or \nname:) + */ #include #include @@ -26,7 +61,7 @@ extern char *UP; /* up cursor movement */ int tgetent(char *bp, char *name) { FILE *fp; - char *file; + const char *file; char *term; short len = strlen(name); @@ -42,8 +77,7 @@ int tgetent(char *bp, char *name) else if (*file != '/') if ((term = getenv("TERM")) != (char *) NULL && strcmp(term, name) == 0) { - *bp = '\0'; - strncat(bp, file, 1023); + strlcpy(bp, file, 1023); return (1); } else file = "/etc/termcap"; -- 2.34.1