histedit.c (18016) | histedit.c (20425) |
---|---|
1/*- 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * | 1/*- 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * |
36 * $Id: histedit.c,v 1.5 1996/09/01 10:20:12 peter Exp $ | 36 * $Id: histedit.c,v 1.6 1996/09/03 13:35:09 peter Exp $ |
37 */ 38 39#ifndef lint | 37 */ 38 39#ifndef lint |
40static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95"; | 40static char const sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95"; |
41#endif /* not lint */ 42 43#include <sys/param.h> 44#include <paths.h> 45#include <stdio.h> 46#include <stdlib.h> 47#include <unistd.h> 48/* --- 23 unchanged lines hidden (view full) --- 72 73STATIC char *fc_replace __P((const char *, char *, char *)); 74 75/* 76 * Set history and editing status. Called whenever the status may 77 * have changed (figures out what to do). 78 */ 79void | 41#endif /* not lint */ 42 43#include <sys/param.h> 44#include <paths.h> 45#include <stdio.h> 46#include <stdlib.h> 47#include <unistd.h> 48/* --- 23 unchanged lines hidden (view full) --- 72 73STATIC char *fc_replace __P((const char *, char *, char *)); 74 75/* 76 * Set history and editing status. Called whenever the status may 77 * have changed (figures out what to do). 78 */ 79void |
80histedit() | 80histedit() |
81{ 82 83#define editing (Eflag || Vflag) 84 85 if (iflag) { 86 if (!hist) { 87 /* 88 * turn history on 89 */ 90 INTOFF; 91 hist = history_init(); 92 INTON; 93 94 if (hist != NULL) | 81{ 82 83#define editing (Eflag || Vflag) 84 85 if (iflag) { 86 if (!hist) { 87 /* 88 * turn history on 89 */ 90 INTOFF; 91 hist = history_init(); 92 INTON; 93 94 if (hist != NULL) |
95 sethistsize(); | 95 sethistsize(histsizeval()); |
96 else 97 out2str("sh: can't initialize history\n"); 98 } 99 if (editing && !el && isatty(0)) { /* && isatty(2) ??? */ 100 /* 101 * turn editing on 102 */ 103 INTOFF; --- 36 unchanged lines hidden (view full) --- 140 hist = NULL; 141 } 142 INTON; 143 } 144} 145 146 147void | 96 else 97 out2str("sh: can't initialize history\n"); 98 } 99 if (editing && !el && isatty(0)) { /* && isatty(2) ??? */ 100 /* 101 * turn editing on 102 */ 103 INTOFF; --- 36 unchanged lines hidden (view full) --- 140 hist = NULL; 141 } 142 INTON; 143 } 144} 145 146 147void |
148sethistsize() | 148sethistsize(hs) 149 const char *hs; |
149{ | 150{ |
150 char *cp; | |
151 int histsize; 152 153 if (hist != NULL) { | 151 int histsize; 152 153 if (hist != NULL) { |
154 cp = lookupvar("HISTSIZE"); 155 if (cp == NULL || *cp == '\0' || 156 (histsize = atoi(cp)) < 0) | 154 if (hs == NULL || *hs == '\0' || 155 (histsize = atoi(hs)) < 0) |
157 histsize = 100; 158 history(hist, H_EVENT, histsize); 159 } 160} 161 162/* 163 * This command is provided since POSIX decided to standardize 164 * the Korn shell fc command. Oh well... --- 248 unchanged lines hidden (view full) --- 413 STACKSTRNUL(dest); 414 dest = grabstackstr(dest); 415 416 return (dest); 417} 418 419int 420not_fcnumber(s) | 156 histsize = 100; 157 history(hist, H_EVENT, histsize); 158 } 159} 160 161/* 162 * This command is provided since POSIX decided to standardize 163 * the Korn shell fc command. Oh well... --- 248 unchanged lines hidden (view full) --- 412 STACKSTRNUL(dest); 413 dest = grabstackstr(dest); 414 415 return (dest); 416} 417 418int 419not_fcnumber(s) |
421 char *s; | 420 char *s; |
422{ | 421{ |
423 if (s == NULL) { 424 /* NULL is not a fc_number */ | 422 if (s == NULL) |
425 return (1); | 423 return (1); |
426 } 427 if (*s == '-') 428 s++; | 424 if (*s == '-') 425 s++; |
429 return (!is_number(s)); 430} 431 432int 433str_to_event(str, last) 434 char *str; 435 int last; 436{ --- 44 unchanged lines hidden --- | 426 return (!is_number(s)); 427} 428 429int 430str_to_event(str, last) 431 char *str; 432 int last; 433{ --- 44 unchanged lines hidden --- |