-# @(#)Makefile 8.1 (Berkeley) 6/4/93
+# $OpenBSD: Makefile,v 1.4 1997/01/16 05:18:27 millert Exp $
+# from: @(#)Makefile 8.1 (Berkeley) 6/4/93
LIB= edit
prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c \
help.c fcns.c
+MAN= editline.3 editrc.5
+
+MLINKS= editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \
+ editline.3 el_gets.3 editline.3 el_getc.3 editline.3 el_push.3 \
+ editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_source.3 \
+ editline.3 el_resize.3 editline.3 el_line.3 \
+ editline.3 el_insertstr.3 editline.3 el_deletestr.3 \
+ editline.3 history_init.3 editline.3 history_end.3 editline.3 history.3
+
# For speed and debugging
#SRCS= ${OSRCS} tokenizer.c history.c
# For protection
+/* $OpenBSD: test.c,v 1.3 1997/01/16 05:18:55 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
#endif /* not lint */
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: test.c,v 1.3 1997/01/16 05:18:55 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
+/* $OpenBSD: chared.c,v 1.2 1997/01/16 05:18:28 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: chared.c,v 1.2 1997/01/16 05:18:28 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
+/* $OpenBSD: chared.h,v 1.2 1997/01/16 05:18:29 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: common.c,v 1.2 1997/01/16 05:18:30 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: common.c,v 1.2 1997/01/16 05:18:30 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
EditLine *el;
int c;
{
- re_clear_lines(el);
- re_clear_display(el);
- return CC_REFRESH;
+ return CC_REDISPLAY;
}
*el->el_line.lastchar = '\0'; /* just in case */
if (el->el_history.eventno == 0) { /* save the current buffer away */
- (void) strncpy(el->el_history.buf, el->el_line.buffer, EL_BUFSIZ);
+ (void) strncpy(el->el_history.buf, el->el_line.buffer, EL_BUFSIZ - 1);
+ el->el_history.buf[EL_BUFSIZ - 1] = '\0';
el->el_history.last = el->el_history.buf +
(el->el_line.lastchar - el->el_line.buffer);
}
}
if (el->el_history.eventno == 0) {
- (void) strncpy(el->el_history.buf, el->el_line.buffer, EL_BUFSIZ);
+ (void) strncpy(el->el_history.buf, el->el_line.buffer, EL_BUFSIZ - 1);
+ el->el_history.buf[EL_BUFSIZ - 1] = '\0';
el->el_history.last = el->el_history.buf +
(el->el_line.lastchar - el->el_line.buffer);
}
+/* $OpenBSD: el.c,v 1.4 1997/01/16 05:18:31 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
+#else
+static char rcsid[] = "$OpenBSD: el.c,v 1.4 1997/01/16 05:18:31 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
#else
# include <varargs.h>
#endif
+#include <unistd.h>
#include "el.h"
/* el_init():
if ((fp = fopen(fname, "r")) == NULL) {
if (issetugid() != 0 || (ptr = getenv("HOME")) == NULL)
return -1;
- fname = strncpy(path, ptr, MAXPATHLEN);
- path[MAXPATHLEN-1] = '\0';
- (void) strncat(path, elpath, MAXPATHLEN - strlen(path));
+ fname = strncpy(path, ptr, sizeof(path) - 1);
+ path[sizeof(path) - 1] = '\0';
+ (void) strncat(path, elpath, sizeof(path) - strlen(path));
}
}
+/* $OpenBSD: el.h,v 1.2 1997/01/16 05:18:32 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: emacs.c,v 1.2 1997/01/16 05:18:32 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: emacs.c,v 1.2 1997/01/16 05:18:32 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
+/* $OpenBSD: hist.c,v 1.2 1997/01/16 05:18:33 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: hist.c,v 1.2 1997/01/16 05:18:33 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
int h;
if (el->el_history.eventno == 0) { /* if really the current line */
- (void) strncpy(el->el_line.buffer, el->el_history.buf, EL_BUFSIZ);
+ (void) strncpy(el->el_line.buffer, el->el_history.buf, EL_BUFSIZ - 1);
+ el->el_line.buffer[EL_BUFSIZ - 1] = '\0';
el->el_line.lastchar = el->el_line.buffer +
(el->el_history.last - el->el_history.buf);
return CC_ERROR;
}
- (void) strncpy(el->el_line.buffer, hp, EL_BUFSIZ);
+ (void) strncpy(el->el_line.buffer, hp, EL_BUFSIZ - 1);
+ el->el_line.buffer[EL_BUFSIZ - 1] = '\0';
el->el_line.lastchar = el->el_line.buffer + strlen(el->el_line.buffer);
if (el->el_line.lastchar > el->el_line.buffer) {
+/* $OpenBSD: hist.h,v 1.3 1997/01/16 05:18:34 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: histedit.h,v 1.3 1997/01/16 05:18:34 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
#define CC_CURSOR 5
#define CC_ERROR 6
#define CC_FATAL 7
+#define CC_REDISPLAY 8
/*
* Initialization, cleanup, and resetting
+/* $OpenBSD: history.c,v 1.3 1997/01/16 05:18:35 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: history.c,v 1.3 1997/01/16 05:18:35 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
+/* $OpenBSD: key.c,v 1.2 1997/01/16 05:18:36 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: key.c,v 1.2 1997/01/16 05:18:36 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
+/* $OpenBSD: key.h,v 1.2 1997/01/16 05:18:36 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
#!/bin/sh -
+# $OpenBSD: makelist,v 1.2 1997/01/16 05:18:37 millert Exp $
#
# Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved.
+/* $OpenBSD: map.c,v 1.2 1997/01/16 05:18:38 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: map.c,v 1.2 1997/01/16 05:18:38 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
+/* $OpenBSD: map.h,v 1.2 1997/01/16 05:18:39 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: parse.c,v 1.2 1997/01/16 05:18:39 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: parse.c,v 1.2 1997/01/16 05:18:39 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
*
* bind
* echotc
- * settc
* gettc
+ * history
+ * settc
+ * setty
*/
#include "sys.h"
#include "el.h"
char *ptr;
int i;
- for (ptr = argv[0]; *ptr && *ptr != ':'; ptr++)
- continue;
-
- if (*ptr == ':') {
- *ptr = '\0';
- if (el_match(el->el_prog, ptr))
+ if (argc < 1)
+ return -1;
+ ptr = strchr(argv[0], ':');
+ if (ptr != NULL) {
+ *ptr++ = '\0';
+ if (! el_match(el->el_prog, argv[0]))
return 0;
}
else
break;
}
}
- else if (*p == '^' && isalpha((unsigned char) *p)) {
+ else if (*p == '^' && isalpha((unsigned char) p[1])) {
p++;
c = (*p == '?') ? '\177' : (*p & 0237);
}
+/* $OpenBSD: parse.h,v 1.2 1997/01/16 05:18:40 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: prompt.c,v 1.2 1997/01/16 05:18:40 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: prompt.c,v 1.2 1997/01/16 05:18:40 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
+/* $OpenBSD: prompt.h,v 1.2 1997/01/16 05:18:41 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: read.c,v 1.2 1997/01/16 05:18:42 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
-
+#else
+static char rcsid[] = "$OpenBSD: read.c,v 1.2 1997/01/16 05:18:42 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
+
/*
* read.c: Clean this junk up! This is horrible code.
* Terminal read functions
re_refresh_cursor(el);
break;
+ case CC_REDISPLAY:
+ re_clear_lines(el);
+ re_clear_display(el);
+ /* FALLTHROUGH */
+
case CC_REFRESH:
el->el_state.argument = 1;
el->el_state.doingarg = 0;
+/* $OpenBSD: refresh.c,v 1.2 1997/01/16 05:18:42 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: refresh.c,v 1.2 1997/01/16 05:18:42 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
+/* $OpenBSD: refresh.h,v 1.2 1997/01/16 05:18:43 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: search.c,v 1.2 1997/01/16 05:18:44 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: search.c,v 1.2 1997/01/16 05:18:44 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
(void) strcpy(tmpbuf, el->el_search.patbuf);
el->el_search.patbuf[0] = '.';
el->el_search.patbuf[1] = '*';
- (void) strcpy(&el->el_search.patbuf[2], tmpbuf);
+ (void) strncpy(&el->el_search.patbuf[2], tmpbuf, EL_BUFSIZ - 3);
+ el->el_search.patbuf[EL_BUFSIZ - 1] = '\0';
el->el_search.patlen++;
el->el_search.patbuf[el->el_search.patlen++] = '.';
el->el_search.patbuf[el->el_search.patlen++] = '*';
+/* $OpenBSD: search.h,v 1.2 1997/01/16 05:18:44 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: sig.c,v 1.2 1997/01/16 05:18:45 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: sig.c,v 1.2 1997/01/16 05:18:45 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
+/* $OpenBSD: sig.h,v 1.2 1997/01/16 05:18:45 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: sys.h,v 1.2 1997/01/16 05:18:46 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: term.c,v 1.2 1997/01/16 05:18:47 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)term.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: term.c,v 1.2 1997/01/16 05:18:47 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
#include <stdlib.h>
#include <unistd.h>
#include "termcap.h" /* XXX: should be <termcap.h> */
+#include <sys/ioctl.h>
#include <sys/types.h>
#include "el.h"
+/* $OpenBSD: term.h,v 1.2 1997/01/16 05:18:48 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: termcap.h,v 1.2 1997/01/16 05:18:48 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: tokenizer.c,v 1.2 1997/01/16 05:18:49 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: tokenizer.c,v 1.2 1997/01/16 05:18:49 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
+/* $OpenBSD: tokenizer.h,v 1.2 1997/01/16 05:18:50 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: tty.c,v 1.2 1997/01/16 05:18:50 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: tty.c,v 1.2 1997/01/16 05:18:50 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*
+/* $OpenBSD: tty.h,v 1.2 1997/01/16 05:18:51 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
+/* $OpenBSD: vi.c,v 1.2 1997/01/16 05:18:52 millert Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*/
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
+#else
+static char rcsid[] = "$OpenBSD: vi.c,v 1.2 1997/01/16 05:18:52 millert Exp $";
+#endif
#endif /* not lint && not SCCSID */
/*