Wed Jan 23 16:39:04 2013 UTC ()
make history kind of work :-), turn libedit support on.


(christos)
diff -r1.35 -r1.36 src/bin/csh/Makefile
diff -r1.44 -r1.45 src/bin/csh/csh.c
diff -r1.24 -r1.25 src/bin/csh/csh.h
diff -r1.27 -r1.28 src/bin/csh/extern.h
diff -r1.18 -r1.19 src/bin/csh/hist.c
diff -r1.28 -r1.29 src/bin/csh/lex.c
diff -r1.30 -r1.31 src/bin/csh/set.c

cvs diff -r1.35 -r1.36 src/bin/csh/Makefile (expand / switch to unified diff)

--- src/bin/csh/Makefile 2013/01/22 22:40:31 1.35
+++ src/bin/csh/Makefile 2013/01/23 16:39:03 1.36
@@ -1,29 +1,30 @@ @@ -1,29 +1,30 @@
1# $NetBSD: Makefile,v 1.35 2013/01/22 22:40:31 christos Exp $ 1# $NetBSD: Makefile,v 1.36 2013/01/23 16:39:03 christos Exp $
2# @(#)Makefile 8.1 (Berkeley) 5/31/93 2# @(#)Makefile 8.1 (Berkeley) 5/31/93
3# 3#
4# C Shell with process control; VM/UNIX VAX Makefile 4# C Shell with process control; VM/UNIX VAX Makefile
5# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria 5# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
6# 6#
7# To profile, put -DPROF in DFLAGS and -pg in COPTS, and recompile. 7# To profile, put -DPROF in DFLAGS and -pg in COPTS, and recompile.
8 8
9.include <bsd.own.mk> 9.include <bsd.own.mk>
10 10
11PROG= csh 11PROG= csh
12DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS 12DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS
13# - Not integrated with history 13# - Editor history not always aligned with shell history,
 14# should implement internally
14# - Does not handle escaped prompts. 15# - Does not handle escaped prompts.
15# - Does not do completion 16# - Does not do completion
16# DFLAGS+=-DEDIT 17DFLAGS+=-DEDIT
17CPPFLAGS+=-I${.CURDIR} -I. ${DFLAGS} 18CPPFLAGS+=-I${.CURDIR} -I. ${DFLAGS}
18SRCS= alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \ 19SRCS= alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \
19 func.c glob.c hist.c init.c lex.c misc.c parse.c printf.c proc.c \ 20 func.c glob.c hist.c init.c lex.c misc.c parse.c printf.c proc.c \
20 sem.c set.c str.c time.c 21 sem.c set.c str.c time.c
21.PATH: ${NETBSDSRCDIR}/usr.bin/printf 22.PATH: ${NETBSDSRCDIR}/usr.bin/printf
22 23
23MLINKS= csh.1 limit.1 csh.1 alias.1 csh.1 bg.1 csh.1 dirs.1 csh.1 fg.1 \ 24MLINKS= csh.1 limit.1 csh.1 alias.1 csh.1 bg.1 csh.1 dirs.1 csh.1 fg.1 \
24 csh.1 foreach.1 csh.1 history.1 csh.1 jobs.1 csh.1 popd.1 \ 25 csh.1 foreach.1 csh.1 history.1 csh.1 jobs.1 csh.1 popd.1 \
25 csh.1 pushd.1 csh.1 rehash.1 csh.1 repeat.1 csh.1 suspend.1 \ 26 csh.1 pushd.1 csh.1 rehash.1 csh.1 repeat.1 csh.1 suspend.1 \
26 csh.1 stop.1 csh.1 source.1 27 csh.1 stop.1 csh.1 source.1
27 28
28DPSRCS+= errnum.h const.h 29DPSRCS+= errnum.h const.h
29CLEANFILES+= errnum.h const.h 30CLEANFILES+= errnum.h const.h
@@ -50,23 +51,23 @@ const.h: const.c @@ -50,23 +51,23 @@ const.h: const.c
50 51
51.if make(install) 52.if make(install)
52SUBDIR+=USD.doc 53SUBDIR+=USD.doc
53.endif 54.endif
54 55
55# XXX Only GCC 4.1 problem 56# XXX Only GCC 4.1 problem
56.if defined(HAVE_GCC) && ${HAVE_GCC} == 4 && ${MACHINE_ARCH} == "vax" 57.if defined(HAVE_GCC) && ${HAVE_GCC} == 4 && ${MACHINE_ARCH} == "vax"
57COPTS.parse.c+= -O0 58COPTS.parse.c+= -O0
58.endif 59.endif
59COPTS.err.c = -Wno-format-nonliteral 60COPTS.err.c = -Wno-format-nonliteral
60COPTS.printf.c = -Wno-format-nonliteral 61COPTS.printf.c = -Wno-format-nonliteral
61COPTS.proc.c = -Wno-format-nonliteral 62COPTS.proc.c = -Wno-format-nonliteral
62 63
63.if 0 64.if !empty(DFLAGS:M*EDIT)
64LDADD+=-ledit -lutil 65LDADD+=-ledit -lutil
65DPADD+=${LIBEDIT} ${LIBUTIL} 66DPADD+=${LIBEDIT} ${LIBUTIL}
66.else 67.else
67LDADD+=-lutil 68LDADD+=-lutil
68DPADD+=${LIBUTIL} 69DPADD+=${LIBUTIL}
69.endif 70.endif
70 71
71.include <bsd.prog.mk> 72.include <bsd.prog.mk>
72.include <bsd.subdir.mk> 73.include <bsd.subdir.mk>

cvs diff -r1.44 -r1.45 src/bin/csh/csh.c (expand / switch to unified diff)

--- src/bin/csh/csh.c 2013/01/22 20:35:29 1.44
+++ src/bin/csh/csh.c 2013/01/23 16:39:03 1.45
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: csh.c,v 1.44 2013/01/22 20:35:29 christos Exp $ */ 1/* $NetBSD: csh.c,v 1.45 2013/01/23 16:39:03 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1980, 1991, 1993 4 * Copyright (c) 1980, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993\ 34__COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993\
35 The Regents of the University of California. All rights reserved."); 35 The Regents of the University of California. All rights reserved.");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38#ifndef lint 38#ifndef lint
39#if 0 39#if 0
40static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93"; 40static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93";
41#else 41#else
42__RCSID("$NetBSD: csh.c,v 1.44 2013/01/22 20:35:29 christos Exp $"); 42__RCSID("$NetBSD: csh.c,v 1.45 2013/01/23 16:39:03 christos Exp $");
43#endif 43#endif
44#endif /* not lint */ 44#endif /* not lint */
45 45
46#include <sys/types.h> 46#include <sys/types.h>
47#include <sys/ioctl.h> 47#include <sys/ioctl.h>
48#include <sys/stat.h> 48#include <sys/stat.h>
49 49
50#include <errno.h> 50#include <errno.h>
51#include <fcntl.h> 51#include <fcntl.h>
52#include <locale.h> 52#include <locale.h>
53#include <paths.h> /* should this be included in pathnames.h instead? */ 53#include <paths.h> /* should this be included in pathnames.h instead? */
54#include <pwd.h> 54#include <pwd.h>
55#include <stdarg.h> 55#include <stdarg.h>
@@ -68,27 +68,27 @@ __RCSID("$NetBSD: csh.c,v 1.44 2013/01/2 @@ -68,27 +68,27 @@ __RCSID("$NetBSD: csh.c,v 1.44 2013/01/2
68 * C Shell 68 * C Shell
69 * 69 *
70 * Bill Joy, UC Berkeley, California, USA 70 * Bill Joy, UC Berkeley, California, USA
71 * October 1978, May 1980 71 * October 1978, May 1980
72 * 72 *
73 * Jim Kulp, IIASA, Laxenburg, Austria 73 * Jim Kulp, IIASA, Laxenburg, Austria
74 * April 1980 74 * April 1980
75 * 75 *
76 * Christos Zoulas, Cornell University 76 * Christos Zoulas, Cornell University
77 * June, 1991 77 * June, 1991
78 */ 78 */
79 79
80Char *dumphist[] = {STRhistory, STRmh, 0, 0}; 80Char *dumphist[] = {STRhistory, STRmh, 0, 0};
81Char *loadhist[] = {STRsource, STRmh, STRtildothist, 0}; 81Char *tildehist[] = {STRsource, STRmh, STRtildothist, 0};
82 82
83int nofile = 0; 83int nofile = 0;
84int batch = 0; 84int batch = 0;
85int enterhist = 0; 85int enterhist = 0;
86int fast = 0; 86int fast = 0;
87int mflag = 0; 87int mflag = 0;
88int nexececho = 0; 88int nexececho = 0;
89int nverbose = 0; 89int nverbose = 0;
90int prompt = 1; 90int prompt = 1;
91int quitit = 0; 91int quitit = 0;
92int reenter = 0; 92int reenter = 0;
93 93
94extern char **environ; 94extern char **environ;
@@ -532,28 +532,28 @@ notty: @@ -532,28 +532,28 @@ notty:
532#endif 532#endif
533 (void)sigprocmask(SIG_SETMASK, &osigset, NULL); 533 (void)sigprocmask(SIG_SETMASK, &osigset, NULL);
534 setintr = osetintr; 534 setintr = osetintr;
535 parintr = oparintr; 535 parintr = oparintr;
536 } 536 }
537 (void)srccat(value(STRhome), STRsldotcshrc); 537 (void)srccat(value(STRhome), STRsldotcshrc);
538 538
539 if (!fast && !arginp && !onelflg && !havhash) 539 if (!fast && !arginp && !onelflg && !havhash)
540 dohash(NULL, NULL); 540 dohash(NULL, NULL);
541 /* 541 /*
542 * Source history before .login so that it is available in .login 542 * Source history before .login so that it is available in .login
543 */ 543 */
544 if ((cp = value(STRhistfile)) != STRNULL) 544 if ((cp = value(STRhistfile)) != STRNULL)
545 loadhist[2] = cp; 545 tildehist[2] = cp;
546 dosource(loadhist, NULL); 546 dosource(tildehist, NULL);
547 if (loginsh) 547 if (loginsh)
548 (void)srccat(value(STRhome), STRsldotlogin); 548 (void)srccat(value(STRhome), STRsldotlogin);
549 } 549 }
550 550
551 /* 551 /*
552 * Now are ready for the -v and -x flags 552 * Now are ready for the -v and -x flags
553 */ 553 */
554 if (nverbose) 554 if (nverbose)
555 setNS(STRverbose); 555 setNS(STRverbose);
556 if (nexececho) 556 if (nexececho)
557 setNS(STRecho); 557 setNS(STRecho);
558 558
559 /* 559 /*

cvs diff -r1.24 -r1.25 src/bin/csh/csh.h (expand / switch to unified diff)

--- src/bin/csh/csh.h 2013/01/22 22:40:31 1.24
+++ src/bin/csh/csh.h 2013/01/23 16:39:03 1.25
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: csh.h,v 1.24 2013/01/22 22:40:31 christos Exp $ */ 1/* $NetBSD: csh.h,v 1.25 2013/01/23 16:39:03 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1980, 1991, 1993 4 * Copyright (c) 1980, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -542,17 +542,18 @@ Char *word_chars; @@ -542,17 +542,18 @@ Char *word_chars;
542 542
543Char *STR_SHELLPATH; 543Char *STR_SHELLPATH;
544 544
545#include <paths.h> 545#include <paths.h>
546#ifdef _PATH_BSHELL 546#ifdef _PATH_BSHELL
547Char *STR_BSHELL; 547Char *STR_BSHELL;
548#endif 548#endif
549Char *STR_WORD_CHARS; 549Char *STR_WORD_CHARS;
550Char **STR_environ; 550Char **STR_environ;
551 551
552#ifdef EDIT 552#ifdef EDIT
553#include <histedit.h> 553#include <histedit.h>
554EditLine *el; 554EditLine *el;
 555History *hi;
555#endif 556#endif
556int editing; 557int editing;
557 558
558#endif /* !_CSH_H_ */ 559#endif /* !_CSH_H_ */

cvs diff -r1.27 -r1.28 src/bin/csh/extern.h (expand / switch to unified diff)

--- src/bin/csh/extern.h 2013/01/22 20:35:29 1.27
+++ src/bin/csh/extern.h 2013/01/23 16:39:03 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: extern.h,v 1.27 2013/01/22 20:35:29 christos Exp $ */ 1/* $NetBSD: extern.h,v 1.28 2013/01/23 16:39:03 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -165,40 +165,46 @@ void ginit(void); @@ -165,40 +165,46 @@ void ginit(void);
165Char **globall(Char **); 165Char **globall(Char **);
166void rscan(Char **, void (*)(int)); 166void rscan(Char **, void (*)(int));
167void tglob(Char **); 167void tglob(Char **);
168void trim(Char **); 168void trim(Char **);
169#ifdef FILEC 169#ifdef FILEC
170int sortscmp(const ptr_t, const ptr_t); 170int sortscmp(const ptr_t, const ptr_t);
171#endif /* FILEC */ 171#endif /* FILEC */
172 172
173/* 173/*
174 * hist.c 174 * hist.c
175 */ 175 */
176void dohist(Char **, struct command *); 176void dohist(Char **, struct command *);
177struct Hist *enthist(int, struct wordent *, int); 177struct Hist *enthist(int, struct wordent *, int);
 178#ifdef EDIT
 179void loadhist(struct Hist *);
 180#endif
178void savehist(struct wordent *); 181void savehist(struct wordent *);
179 182
180/* 183/*
181 * lex.c 184 * lex.c
182 */ 185 */
183void addla(Char *); 186void addla(Char *);
184void bseek(struct Ain *); 187void bseek(struct Ain *);
185void btell(struct Ain *); 188void btell(struct Ain *);
186void btoeof(void); 189void btoeof(void);
187void copylex(struct wordent *, struct wordent *); 190void copylex(struct wordent *, struct wordent *);
188Char *domod(Char *, int); 191Char *domod(Char *, int);
189void freelex(struct wordent *); 192void freelex(struct wordent *);
190int lex(struct wordent *); 193int lex(struct wordent *);
191void prlex(FILE *, struct wordent *); 194void prlex(FILE *, struct wordent *);
 195#ifdef EDIT
 196int sprlex(char **, struct wordent *);
 197#endif
192int readc(int); 198int readc(int);
193void settell(void); 199void settell(void);
194void unreadc(int); 200void unreadc(int);
195 201
196/* 202/*
197 * misc.c 203 * misc.c
198 */ 204 */
199int any(const char *, int); 205int any(const char *, int);
200Char **blkcat(Char **, Char **); 206Char **blkcat(Char **, Char **);
201Char **blkcpy(Char **, Char **); 207Char **blkcpy(Char **, Char **);
202Char **blkend(Char **); 208Char **blkend(Char **);
203void blkfree(Char **); 209void blkfree(Char **);
204int blklen(Char **); 210int blklen(Char **);

cvs diff -r1.18 -r1.19 src/bin/csh/hist.c (expand / switch to unified diff)

--- src/bin/csh/hist.c 2007/07/16 18:26:10 1.18
+++ src/bin/csh/hist.c 2013/01/23 16:39:03 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: hist.c,v 1.18 2007/07/16 18:26:10 christos Exp $ */ 1/* $NetBSD: hist.c,v 1.19 2013/01/23 16:39:03 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1980, 1991, 1993 4 * Copyright (c) 1980, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: hist.c,v 1.18 2007/07/16 18:26:10 christos Exp $"); 37__RCSID("$NetBSD: hist.c,v 1.19 2013/01/23 16:39:03 christos Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42 42
43#include <stdarg.h> 43#include <stdarg.h>
44#include <stdlib.h> 44#include <stdlib.h>
45 45
46#include "csh.h" 46#include "csh.h"
47#include "extern.h" 47#include "extern.h"
48 48
49static void hfree(struct Hist *); 49static void hfree(struct Hist *);
50static void dohist1(struct Hist *, int *, int, int); 50static void dohist1(struct Hist *, int *, int, int);
@@ -72,31 +72,55 @@ savehist(struct wordent *sp) @@ -72,31 +72,55 @@ savehist(struct wordent *sp)
72 break; 72 break;
73 } 73 }
74 histlen = histlen * 10 + *p++ - '0'; 74 histlen = histlen * 10 + *p++ - '0';
75 } 75 }
76 } 76 }
77 for (hp = &Histlist; (np = hp->Hnext) != NULL;) 77 for (hp = &Histlist; (np = hp->Hnext) != NULL;)
78 if (eventno - np->Href >= histlen || histlen == 0) 78 if (eventno - np->Href >= histlen || histlen == 0)
79 hp->Hnext = np->Hnext, hfree(np); 79 hp->Hnext = np->Hnext, hfree(np);
80 else 80 else
81 hp = np; 81 hp = np;
82 (void) enthist(++eventno, sp, 1); 82 (void) enthist(++eventno, sp, 1);
83} 83}
84 84
 85#ifdef EDIT
 86void
 87loadhist(struct Hist *hp) {
 88 char *h = NULL;
 89
 90 if (hi == NULL || hp == NULL)
 91 return;
 92 loadhist(hp->Hnext);
 93 if (sprlex(&h, &hp->Hlex) != -1) {
 94 HistEvent ev;
 95 history(hi, &ev, H_ENTER, h);
 96 }
 97}
 98#endif
 99
85struct Hist * 100struct Hist *
86enthist(int event, struct wordent *lp, int docopy) 101enthist(int event, struct wordent *lp, int docopy)
87{ 102{
88 struct Hist *np; 103 struct Hist *np;
89 104
 105#ifdef EDIT
 106 if (hi) {
 107 char *h = NULL;
 108 if (sprlex(&h, lp) != -1) {
 109 HistEvent ev;
 110 history(hi, &ev, H_ENTER, h);
 111 }
 112 }
 113#endif
90 np = (struct Hist *)xmalloc((size_t)sizeof(*np)); 114 np = (struct Hist *)xmalloc((size_t)sizeof(*np));
91 np->Hnum = np->Href = event; 115 np->Hnum = np->Href = event;
92 if (docopy) { 116 if (docopy) {
93 copylex(&np->Hlex, lp); 117 copylex(&np->Hlex, lp);
94 } 118 }
95 else { 119 else {
96 np->Hlex.next = lp->next; 120 np->Hlex.next = lp->next;
97 lp->next->prev = &np->Hlex; 121 lp->next->prev = &np->Hlex;
98 np->Hlex.prev = lp->prev; 122 np->Hlex.prev = lp->prev;
99 lp->prev->next = &np->Hlex; 123 lp->prev->next = &np->Hlex;
100 } 124 }
101 np->Hnext = Histlist.Hnext; 125 np->Hnext = Histlist.Hnext;
102 Histlist.Hnext = np; 126 Histlist.Hnext = np;

cvs diff -r1.28 -r1.29 src/bin/csh/lex.c (expand / switch to unified diff)

--- src/bin/csh/lex.c 2013/01/22 20:35:29 1.28
+++ src/bin/csh/lex.c 2013/01/23 16:39:03 1.29
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lex.c,v 1.28 2013/01/22 20:35:29 christos Exp $ */ 1/* $NetBSD: lex.c,v 1.29 2013/01/23 16:39:03 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1980, 1991, 1993 4 * Copyright (c) 1980, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: lex.c,v 1.28 2013/01/22 20:35:29 christos Exp $"); 37__RCSID("$NetBSD: lex.c,v 1.29 2013/01/23 16:39:03 christos Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <sys/ioctl.h> 41#include <sys/ioctl.h>
42#include <sys/types.h> 42#include <sys/types.h>
43 43
44#include <errno.h> 44#include <errno.h>
45#include <stdarg.h> 45#include <stdarg.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <string.h> 47#include <string.h>
48#include <termios.h> 48#include <termios.h>
49#include <unistd.h> 49#include <unistd.h>
50 50
@@ -178,26 +178,56 @@ prlex(FILE *fp, struct wordent *sp0) @@ -178,26 +178,56 @@ prlex(FILE *fp, struct wordent *sp0)
178 struct wordent *sp; 178 struct wordent *sp;
179 179
180 sp = sp0->next; 180 sp = sp0->next;
181 for (;;) { 181 for (;;) {
182 (void)fprintf(fp, "%s", vis_str(sp->word)); 182 (void)fprintf(fp, "%s", vis_str(sp->word));
183 sp = sp->next; 183 sp = sp->next;
184 if (sp == sp0) 184 if (sp == sp0)
185 break; 185 break;
186 if (sp->word[0] != '\n') 186 if (sp->word[0] != '\n')
187 (void) fputc(' ', fp); 187 (void) fputc(' ', fp);
188 } 188 }
189} 189}
190 190
 191#ifdef EDIT
 192int
 193sprlex(char **s, struct wordent *sp0)
 194{
 195 struct wordent *sp;
 196
 197 sp = sp0->next;
 198 char *os = *s;
 199 for (;;) {
 200 char *w = vis_str(sp->word);
 201 if (os == NULL) {
 202 if (asprintf(s, "%s", w) < 0)
 203 return -1;
 204 os = *s;
 205 } else if (*os != '\n') {
 206 if (asprintf(s, "%s %s", os, w) < 0) {
 207 free(os);
 208 return 1;
 209 }
 210 free(os);
 211 os = *s;
 212 }
 213 sp = sp->next;
 214 if (sp == sp0)
 215 break;
 216 }
 217 return 0;
 218}
 219#endif
 220
191void 221void
192copylex(struct wordent *hp, struct wordent *fp) 222copylex(struct wordent *hp, struct wordent *fp)
193{ 223{
194 struct wordent *wdp; 224 struct wordent *wdp;
195 225
196 wdp = hp; 226 wdp = hp;
197 fp = fp->next; 227 fp = fp->next;
198 do { 228 do {
199 struct wordent *new; 229 struct wordent *new;
200 230
201 new = (struct wordent *)xmalloc((size_t)sizeof(*wdp)); 231 new = (struct wordent *)xmalloc((size_t)sizeof(*wdp));
202 new->prev = wdp; 232 new->prev = wdp;
203 new->next = hp; 233 new->next = hp;

cvs diff -r1.30 -r1.31 src/bin/csh/set.c (expand / switch to unified diff)

--- src/bin/csh/set.c 2013/01/22 20:35:29 1.30
+++ src/bin/csh/set.c 2013/01/23 16:39:03 1.31
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: set.c,v 1.30 2013/01/22 20:35:29 christos Exp $ */ 1/* $NetBSD: set.c,v 1.31 2013/01/23 16:39:03 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1980, 1991, 1993 4 * Copyright (c) 1980, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)set.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)set.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: set.c,v 1.30 2013/01/22 20:35:29 christos Exp $"); 37__RCSID("$NetBSD: set.c,v 1.31 2013/01/23 16:39:03 christos Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42 42
43#include <stdarg.h> 43#include <stdarg.h>
44#include <stdlib.h> 44#include <stdlib.h>
45 45
46#ifndef SHORT_STRINGS 46#ifndef SHORT_STRINGS
47#include <string.h> 47#include <string.h>
48#endif /* SHORT_STRINGS */ 48#endif /* SHORT_STRINGS */
49 49
50#include "csh.h" 50#include "csh.h"
@@ -166,31 +166,36 @@ doset(Char **v, struct command *t) @@ -166,31 +166,36 @@ doset(Char **v, struct command *t)
166 166
167 /* and now mirror home with HOME */ 167 /* and now mirror home with HOME */
168 Setenv(STRHOME, cp); 168 Setenv(STRHOME, cp);
169 /* fix directory stack for new tilde home */ 169 /* fix directory stack for new tilde home */
170 dtilde(); 170 dtilde();
171 xfree((ptr_t)cp); 171 xfree((ptr_t)cp);
172 } 172 }
173#ifdef FILEC 173#ifdef FILEC
174 else if (eq(vp, STRfilec)) 174 else if (eq(vp, STRfilec))
175 filec = 1; 175 filec = 1;
176#endif 176#endif
177#ifdef EDIT 177#ifdef EDIT
178 else if (eq(vp, STRedit)) { 178 else if (eq(vp, STRedit)) {
179 editing = 1; 179 HistEvent ev;
180 el = el_init_fd(getprogname(), cshin, cshout, csherr, 180 editing = 1;
181 SHIN, SHOUT, SHERR); 181 el = el_init_fd(getprogname(), cshin, cshout, csherr,
182 el_set(el, EL_EDITOR, "emacs"); 182 SHIN, SHOUT, SHERR);
183 el_set(el, EL_PROMPT, printpromptstr); 183 el_set(el, EL_EDITOR, "emacs");
 184 el_set(el, EL_PROMPT, printpromptstr);
 185 hi = history_init();
 186 history(hi, &ev, H_SETSIZE, getn(value(STRhistory)));
 187 loadhist(Histlist.Hnext);
 188 el_set(el, EL_HIST, history, hi);
184 } 189 }
185#endif 190#endif
186 } while ((p = *v++) != NULL); 191 } while ((p = *v++) != NULL);
187} 192}
188 193
189static Char * 194static Char *
190getinx(Char *cp, int *ip) 195getinx(Char *cp, int *ip)
191{ 196{
192 *ip = 0; 197 *ip = 0;
193 *cp++ = 0; 198 *cp++ = 0;
194 while (*cp && Isdigit(*cp)) 199 while (*cp && Isdigit(*cp))
195 *ip = *ip * 10 + *cp++ - '0'; 200 *ip = *ip * 10 + *cp++ - '0';
196 if (*cp++ != ']') 201 if (*cp++ != ']')
@@ -506,27 +511,29 @@ unset(Char **v, struct command *t) @@ -506,27 +511,29 @@ unset(Char **v, struct command *t)
506 if (adrof(STRhistchars) == 0) { 511 if (adrof(STRhistchars) == 0) {
507 HIST = '!'; 512 HIST = '!';
508 HISTSUB = '^'; 513 HISTSUB = '^';
509 } 514 }
510 else if (adrof(STRwordchars) == 0) 515 else if (adrof(STRwordchars) == 0)
511 word_chars = STR_WORD_CHARS; 516 word_chars = STR_WORD_CHARS;
512#ifdef FILEC 517#ifdef FILEC
513 else if (adrof(STRfilec) == 0) 518 else if (adrof(STRfilec) == 0)
514 filec = 0; 519 filec = 0;
515#endif 520#endif
516#ifdef EDIT 521#ifdef EDIT
517 else if (adrof(STRedit) == 0) { 522 else if (adrof(STRedit) == 0) {
518 el_end(el); 523 el_end(el);
 524 history_end(hi);
519 el = NULL; 525 el = NULL;
 526 hi = NULL;
520 editing = 0; 527 editing = 0;
521 } 528 }
522#endif 529#endif
523} 530}
524 531
525void 532void
526unset1(Char *v[], struct varent *head) 533unset1(Char *v[], struct varent *head)
527{ 534{
528 struct varent *vp; 535 struct varent *vp;
529 int cnt; 536 int cnt;
530 537
531 while (*++v) { 538 while (*++v) {
532 cnt = 0; 539 cnt = 0;