Deleted Added
full compact
16,20c16
< * 3. All advertising materials mentioning features or use of this software
< * must display the following acknowledgement:
< * This product includes software developed by the University of
< * California, Berkeley and its contributors.
< * 4. Neither the name of the University nor the names of its contributors
---
> * 3. Neither the name of the University nor the names of its contributors
36c32
< * $NetBSD: hist.c,v 1.8 2001/01/10 07:45:41 jdolecek Exp $
---
> * $NetBSD: hist.c,v 1.15 2003/11/01 23:36:39 christos Exp $
43c39
< __FBSDID("$FreeBSD: head/lib/libedit/hist.c 84334 2001-10-01 23:00:29Z obrien $");
---
> __FBSDID("$FreeBSD: head/lib/libedit/hist.c 148834 2005-08-07 20:55:59Z stefanf $");
133c129
< (void) strncpy(el->el_line.buffer, hp,
---
> (void) strlcpy(el->el_line.buffer, hp,
137,144c133,138
< if (el->el_line.lastchar > el->el_line.buffer) {
< if (el->el_line.lastchar[-1] == '\n')
< el->el_line.lastchar--;
< if (el->el_line.lastchar[-1] == ' ')
< el->el_line.lastchar--;
< if (el->el_line.lastchar < el->el_line.buffer)
< el->el_line.lastchar = el->el_line.buffer;
< }
---
> if (el->el_line.lastchar > el->el_line.buffer
> && el->el_line.lastchar[-1] == '\n')
> el->el_line.lastchar--;
> if (el->el_line.lastchar > el->el_line.buffer
> && el->el_line.lastchar[-1] == ' ')
> el->el_line.lastchar--;
156,157c150,151
< /* hist_list()
< * List history entries
---
> /* hist_command()
> * process a history command
160,161c154
< /*ARGSUSED*/
< hist_list(EditLine *el, int argc, char **argv)
---
> hist_command(EditLine *el, int argc, const char **argv)
163a157,158
> int num;
> HistEvent ev;
167,170c162,183
< for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el))
< (void) fprintf(el->el_outfile, "%d %s",
< el->el_history.ev.num, str);
< return (0);
---
>
> if (argc == 1 || strcmp(argv[1], "list") == 0) {
> /* List history entries */
>
> for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el))
> (void) fprintf(el->el_outfile, "%d %s",
> el->el_history.ev.num, str);
> return (0);
> }
>
> if (argc != 3)
> return (-1);
>
> num = (int)strtol(argv[2], NULL, 0);
>
> if (strcmp(argv[1], "size") == 0)
> return history(el->el_history.ref, &ev, H_SETSIZE, num);
>
> if (strcmp(argv[1], "unique") == 0)
> return history(el->el_history.ref, &ev, H_SETUNIQUE, num);
>
> return -1;