Index: libedit/readline.c =================================================================== --- libedit/readline.c (revision 238090) +++ libedit/readline.c (working copy) @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.90 2010/08/04 20:29:18 christos Exp $ */ +/* $NetBSD: readline.c,v 1.85 2009/09/07 21:24:33 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -118,10 +118,6 @@ VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal; KEYMAP_ENTRY_ARRAY emacs_meta_keymap; -#ifdef WIDECHAR -static ct_buffer_t conv; -#endif - /* * The current prompt string. */ @@ -154,7 +150,7 @@ /* stuff below is used internally by libedit for readline emulation */ -static TYPE(History) *h = NULL; +static History *h = NULL; static EditLine *e = NULL; static Function *map[256]; static jmp_buf topbuf; @@ -188,13 +184,13 @@ static HIST_ENTRY * _move_history(int op) { - TYPE(HistEvent) ev; + HistEvent ev; static HIST_ENTRY rl_he; - if (FUNW(history)(h, &ev, op) != 0) + if (history(h, &ev, op) != 0) return (HIST_ENTRY *) NULL; - rl_he.line = ct_encode_string(ev.str, &conv); + rl_he.line = ev.str; rl_he.data = NULL; return (&rl_he); @@ -268,7 +264,7 @@ int rl_initialize(void) { - TYPE(HistEvent) ev; + HistEvent ev; const LineInfo *li; int editmode = 1; struct termios t; @@ -276,7 +272,7 @@ if (e != NULL) el_end(e); if (h != NULL) - FUN(history,end)(h); + history_end(h); if (!rl_instream) rl_instream = stdin; @@ -292,13 +288,13 @@ e = el_init(rl_readline_name, rl_instream, rl_outstream, stderr); if (!editmode) - FUN(el,set)(e, EL_EDITMODE, 0); + el_set(e, EL_EDITMODE, 0); - h = FUN(history,init)(); + h = history_init(); if (!e || !h) return (-1); - FUNW(history)(h, &ev, H_SETSIZE, INT_MAX); /* unlimited */ + history(h, &ev, H_SETSIZE, INT_MAX); /* unlimited */ history_length = 0; max_input_history = INT_MAX; el_set(e, EL_HIST, history, h); @@ -309,7 +305,7 @@ /* for proper prompt printing in readline() */ if (rl_set_prompt("") == -1) { - FUN(history,end)(h); + history_end(h); el_end(e); return -1; } @@ -367,7 +363,7 @@ char * readline(const char *p) { - TYPE(HistEvent) ev; + HistEvent ev; const char * volatile prompt = p; int count; const char *ret; @@ -415,7 +411,7 @@ } else buf = NULL; - FUNW(history)(h, &ev, H_GETSIZE); + history(h, &ev, H_GETSIZE); history_length = ev.num; return buf; @@ -495,7 +491,7 @@ size_t len; char *pat; const char *rptr; - TYPE(HistEvent) ev; + HistEvent ev; idx = *cindex; if (cmd[idx++] != history_expansion_char) @@ -503,10 +499,10 @@ /* find out which event to take */ if (cmd[idx] == history_expansion_char || cmd[idx] == '\0') { - if (FUNW(history)(h, &ev, H_FIRST) != 0) + if (history(h, &ev, H_FIRST) != 0) return(NULL); *cindex = cmd[idx]? (idx + 1):idx; - return ct_encode_string(ev.str, &conv); + return(ev.str); } sign = 0; if (cmd[idx] == '-') { @@ -561,7 +557,7 @@ pat[len] = '\0'; } - if (FUNW(history)(h, &ev, H_CURR) != 0) { + if (history(h, &ev, H_CURR) != 0) { if (pat != last_search_pat) free(pat); return (NULL); @@ -580,7 +576,7 @@ if (ret == -1) { /* restore to end of list on failed search */ - FUNW(history)(h, &ev, H_FIRST); + history(h, &ev, H_FIRST); (void)fprintf(rl_outstream, "%s: Event not found\n", pat); if (pat != last_search_pat) free(pat); @@ -596,13 +592,13 @@ if (pat != last_search_pat) free(pat); - if (FUNW(history)(h, &ev, H_CURR) != 0) + if (history(h, &ev, H_CURR) != 0) return(NULL); *cindex = idx; - rptr = ct_encode_string(ev.str, &conv); + rptr = ev.str; /* roll back to original position */ - (void)FUNW(history)(h, &ev, H_SET, num); + (void)history(h, &ev, H_SET, num); return rptr; } @@ -1112,12 +1108,12 @@ void stifle_history(int max) { - TYPE(HistEvent) ev; + HistEvent ev; if (h == NULL || e == NULL) rl_initialize(); - if (FUNW(history)(h, &ev, H_SETSIZE, max) == 0) + if (history(h, &ev, H_SETSIZE, max) == 0) max_input_history = max; } @@ -1128,10 +1124,10 @@ int unstifle_history(void) { - TYPE(HistEvent) ev; + HistEvent ev; int omax; - FUNW(history)(h, &ev, H_SETSIZE, INT_MAX); + history(h, &ev, H_SETSIZE, INT_MAX); omax = max_input_history; max_input_history = INT_MAX; return (omax); /* some value _must_ be returned */ @@ -1289,14 +1285,13 @@ int read_history(const char *filename) { - TYPE(HistEvent) ev; + HistEvent ev; if (h == NULL || e == NULL) rl_initialize(); if (filename == NULL && (filename = _default_history_file()) == NULL) return errno; - return (FUNW(history)(h, &ev, H_LOAD, filename) == -1 ? - (errno ? errno : EINVAL) : 0); + return (history(h, &ev, H_LOAD, filename) == -1 ? (errno ? errno : EINVAL) : 0); } @@ -1306,14 +1301,13 @@ int write_history(const char *filename) { - TYPE(HistEvent) ev; + HistEvent ev; if (h == NULL || e == NULL) rl_initialize(); if (filename == NULL && (filename = _default_history_file()) == NULL) return errno; - return (FUNW(history)(h, &ev, H_SAVE, filename) == -1 ? - (errno ? errno : EINVAL) : 0); + return (history(h, &ev, H_SAVE, filename) == -1 ? (errno ? errno : EINVAL) : 0); } @@ -1326,29 +1320,29 @@ history_get(int num) { static HIST_ENTRY she; - TYPE(HistEvent) ev; + HistEvent ev; int curr_num; if (h == NULL || e == NULL) rl_initialize(); /* save current position */ - if (FUNW(history)(h, &ev, H_CURR) != 0) + if (history(h, &ev, H_CURR) != 0) return (NULL); curr_num = ev.num; /* start from the oldest */ - if (FUNW(history)(h, &ev, H_LAST) != 0) + if (history(h, &ev, H_LAST) != 0) return (NULL); /* error */ /* look forwards for event matching specified offset */ - if (FUNW(history)(h, &ev, H_NEXT_EVDATA, num, &she.data)) + if (history(h, &ev, H_NEXT_EVDATA, num, &she.data)) return (NULL); - she.line = ct_encode_string(ev.str, &conv); + she.line = ev.str; /* restore pointer to where it was */ - (void)FUNW(history)(h, &ev, H_SET, curr_num); + (void)history(h, &ev, H_SET, curr_num); return (&she); } @@ -1360,16 +1354,13 @@ int add_history(const char *line) { - TYPE(HistEvent) ev; - const Char *wline; + HistEvent ev; if (h == NULL || e == NULL) rl_initialize(); - wline = ct_decode_string(line, &conv); - - (void)FUNW(history)(h, &ev, H_ENTER, wline); - if (FUNW(history)(h, &ev, H_GETSIZE) == 0) + (void)history(h, &ev, H_ENTER, line); + if (history(h, &ev, H_GETSIZE) == 0) history_length = ev.num; return (!(history_length > 0)); /* return 0 if all is okay */ @@ -1383,7 +1374,7 @@ remove_history(int num) { HIST_ENTRY *he; - TYPE(HistEvent) ev; + HistEvent ev; if (h == NULL || e == NULL) rl_initialize(); @@ -1391,13 +1382,13 @@ if ((he = malloc(sizeof(*he))) == NULL) return NULL; - if (FUNW(history)(h, &ev, H_DELDATA, num, &he->data) != 0) { + if (history(h, &ev, H_DELDATA, num, &he->data) != 0) { free(he); return NULL; } - he->line = ct_encode_string(ev.str, &conv); - if (FUNW(history)(h, &ev, H_GETSIZE) == 0) + he->line = ev.str; + if (history(h, &ev, H_GETSIZE) == 0) history_length = ev.num; return he; @@ -1411,37 +1402,37 @@ replace_history_entry(int num, const char *line, histdata_t data) { HIST_ENTRY *he; - TYPE(HistEvent) ev; + HistEvent ev; int curr_num; if (h == NULL || e == NULL) rl_initialize(); /* save current position */ - if (FUNW(history)(h, &ev, H_CURR) != 0) + if (history(h, &ev, H_CURR) != 0) return NULL; curr_num = ev.num; /* start from the oldest */ - if (FUNW(history)(h, &ev, H_LAST) != 0) + if (history(h, &ev, H_LAST) != 0) return NULL; /* error */ if ((he = malloc(sizeof(*he))) == NULL) return NULL; /* look forwards for event matching specified offset */ - if (FUNW(history)(h, &ev, H_NEXT_EVDATA, num, &he->data)) + if (history(h, &ev, H_NEXT_EVDATA, num, &he->data)) goto out; - he->line = strdup(ct_encode_string(ev.str, &e->el_scratch)); + he->line = strdup(ev.str); if (he->line == NULL) goto out; - if (FUNW(history)(h, &ev, H_REPLACE, line, data)) + if (history(h, &ev, H_REPLACE, line, data)) goto out; /* restore pointer to where it was */ - if (FUNW(history)(h, &ev, H_SET, curr_num)) + if (history(h, &ev, H_SET, curr_num)) goto out; return he; @@ -1456,9 +1447,9 @@ void clear_history(void) { - TYPE(HistEvent) ev; + HistEvent ev; - (void)FUNW(history)(h, &ev, H_CLEAR); + history(h, &ev, H_CLEAR); history_length = 0; } @@ -1469,16 +1460,16 @@ int where_history(void) { - TYPE(HistEvent) ev; + HistEvent ev; int curr_num, off; - if (FUNW(history)(h, &ev, H_CURR) != 0) + if (history(h, &ev, H_CURR) != 0) return (0); curr_num = ev.num; - (void)FUNW(history)(h, &ev, H_FIRST); + history(h, &ev, H_FIRST); off = 1; - while (ev.num != curr_num && FUNW(history)(h, &ev, H_NEXT) == 0) + while (ev.num != curr_num && history(h, &ev, H_NEXT) == 0) off++; return (off); @@ -1502,22 +1493,22 @@ int history_total_bytes(void) { - TYPE(HistEvent) ev; + HistEvent ev; int curr_num; size_t size; - if (FUNW(history)(h, &ev, H_CURR) != 0) + if (history(h, &ev, H_CURR) != 0) return (-1); curr_num = ev.num; - (void)FUNW(history)(h, &ev, H_FIRST); + history(h, &ev, H_FIRST); size = 0; do - size += Strlen(ev.str) * sizeof(*ev.str); - while (FUNW(history)(h, &ev, H_NEXT) == 0); + size += strlen(ev.str); + while (history(h, &ev, H_NEXT) == 0); /* get to the same position as before */ - FUNW(history)(h, &ev, H_PREV_EVENT, curr_num); + history(h, &ev, H_PREV_EVENT, curr_num); return (int)(size); } @@ -1529,21 +1520,21 @@ int history_set_pos(int pos) { - TYPE(HistEvent) ev; + HistEvent ev; int curr_num; if (pos >= history_length || pos < 0) return (-1); - (void)FUNW(history)(h, &ev, H_CURR); + history(h, &ev, H_CURR); curr_num = ev.num; /* * use H_DELDATA to set to nth history (without delete) by passing * (void **)-1 */ - if (FUNW(history)(h, &ev, H_DELDATA, pos, (void **)-1)) { - (void)FUNW(history)(h, &ev, H_SET, curr_num); + if (history(h, &ev, H_DELDATA, pos, (void **)-1)) { + history(h, &ev, H_SET, curr_num); return(-1); } return (0); @@ -1578,23 +1569,21 @@ int history_search(const char *str, int direction) { - TYPE(HistEvent) ev; - const Char *strp; - const Char *wstr; + HistEvent ev; + const char *strp; int curr_num; - if (FUNW(history)(h, &ev, H_CURR) != 0) + if (history(h, &ev, H_CURR) != 0) return (-1); curr_num = ev.num; - wstr = ct_decode_string(str, &conv); for (;;) { - if ((strp = Strstr(ev.str, wstr)) != NULL) + if ((strp = strstr(ev.str, str)) != NULL) return (int) (strp - ev.str); - if (FUNW(history)(h, &ev, direction < 0 ? H_NEXT:H_PREV) != 0) + if (history(h, &ev, direction < 0 ? H_NEXT:H_PREV) != 0) break; } - (void)FUNW(history)(h, &ev, H_SET, curr_num); + history(h, &ev, H_SET, curr_num); return (-1); } @@ -1605,10 +1594,9 @@ int history_search_prefix(const char *str, int direction) { - TYPE(HistEvent) ev; + HistEvent ev; - return (FUNW(history)(h, &ev, direction < 0 ? - H_PREV_STR : H_NEXT_STR, str)); + return (history(h, &ev, direction < 0? H_PREV_STR:H_NEXT_STR, str)); } @@ -1621,31 +1609,29 @@ history_search_pos(const char *str, int direction __attribute__((__unused__)), int pos) { - TYPE(HistEvent) ev; + HistEvent ev; int curr_num, off; - const Char *wstr; off = (pos > 0) ? pos : -pos; pos = (pos > 0) ? 1 : -1; - if (FUNW(history)(h, &ev, H_CURR) != 0) + if (history(h, &ev, H_CURR) != 0) return (-1); curr_num = ev.num; - if (history_set_pos(off) != 0 || FUNW(history)(h, &ev, H_CURR) != 0) + if (history_set_pos(off) != 0 || history(h, &ev, H_CURR) != 0) return (-1); - wstr = ct_decode_string(str, &conv); + for (;;) { - if (Strstr(ev.str, wstr)) + if (strstr(ev.str, str)) return (off); - if (FUNW(history)(h, &ev, (pos < 0) ? H_PREV : H_NEXT) != 0) + if (history(h, &ev, (pos < 0) ? H_PREV : H_NEXT) != 0) break; } /* set "current" pointer back to previous state */ - (void)FUNW(history)(h, &ev, - pos < 0 ? H_NEXT_EVENT : H_PREV_EVENT, curr_num); + history(h, &ev, (pos < 0) ? H_NEXT_EVENT : H_PREV_EVENT, curr_num); return (-1); } @@ -1742,10 +1728,6 @@ int rl_complete(int ignore __attribute__((__unused__)), int invoking_key) { -#ifdef WIDECHAR - static ct_buffer_t wbreak_conv, sprefix_conv; -#endif - if (h == NULL || e == NULL) rl_initialize(); @@ -1761,8 +1743,7 @@ return fn_complete(e, (CPFunction *)rl_completion_entry_function, rl_attempted_completion_function, - ct_decode_string(rl_basic_word_break_characters, &wbreak_conv), - ct_decode_string(rl_special_prefixes, &sprefix_conv), + rl_basic_word_break_characters, rl_special_prefixes, _rl_completion_append_character_function, (size_t)rl_completion_query_items, &rl_completion_type, &rl_attempted_completion_over, @@ -2231,9 +2212,3 @@ rl_cleanup_after_signal(void) { } - -int -rl_on_new_line(void) -{ - return 0; -} Index: libedit/chared.c =================================================================== --- libedit/chared.c (revision 238090) +++ libedit/chared.c (working copy) @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: chared.c,v 1.25 2005/08/08 01:41:30 christos Exp $ + * $NetBSD: chared.c,v 1.27 2009/02/15 21:55:23 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -59,12 +59,12 @@ { c_undo_t *vu = &el->el_chared.c_undo; c_redo_t *r = &el->el_chared.c_redo; - unsigned int size; + size_t size; /* Save entire line for undo */ size = el->el_line.lastchar - el->el_line.buffer; vu->len = size; - vu->cursor = el->el_line.cursor - el->el_line.buffer; + vu->cursor = (int)(el->el_line.cursor - el->el_line.buffer); memcpy(vu->buf, el->el_line.buffer, size); /* save command info for redo */ @@ -83,7 +83,7 @@ { c_kill_t *k = &el->el_chared.c_kill; - memcpy(k->buf, ptr, size +0u); + memcpy(k->buf, ptr, (size_t)size); k->last = k->buf + size; } @@ -97,7 +97,7 @@ char *cp; if (el->el_line.lastchar + num >= el->el_line.limit) { - if (!ch_enlargebufs(el, num +0u)) + if (!ch_enlargebufs(el, (size_t)num)) return; /* can't go past end of buffer */ } @@ -118,7 +118,7 @@ { if (el->el_line.cursor + num > el->el_line.lastchar) - num = el->el_line.lastchar - el->el_line.cursor; + num = (int)(el->el_line.lastchar - el->el_line.cursor); if (el->el_map.current != el->el_map.emacs) { cv_undo(el); @@ -159,7 +159,7 @@ { if (el->el_line.cursor - num < el->el_line.buffer) - num = el->el_line.cursor - el->el_line.buffer; + num = (int)(el->el_line.cursor - el->el_line.buffer); if (el->el_map.current != el->el_map.emacs) { cv_undo(el); @@ -375,7 +375,7 @@ /* sanity */ return; - size = el->el_line.cursor - el->el_chared.c_vcmd.pos; + size = (int)(el->el_line.cursor - el->el_chared.c_vcmd.pos); if (size == 0) size = 1; el->el_line.cursor = el->el_chared.c_vcmd.pos; @@ -529,8 +529,7 @@ } private void -ch__clearmacro(el) - EditLine *el; +ch__clearmacro(EditLine *el) { c_macro_t *ma = &el->el_chared.c_macro; while (ma->level >= 0) @@ -542,9 +541,7 @@ * Returns 1 if successful, 0 if not. */ protected int -ch_enlargebufs(el, addlen) - EditLine *el; - size_t addlen; +ch_enlargebufs(EditLine *el, size_t addlen) { size_t sz, newsz; char *newbuffer, *oldbuf, *oldkbuf; @@ -695,12 +692,12 @@ c_gets(EditLine *el, char *buf, const char *prompt) { char ch; - int len; + ssize_t len; char *cp = el->el_line.buffer; if (prompt) { len = strlen(prompt); - memcpy(cp, prompt, len + 0u); + memcpy(cp, prompt, (size_t)len); cp += len; } len = 0; @@ -721,7 +718,7 @@ case '\010': /* Delete and backspace */ case '\177': - if (len <= 0) { + if (len == 0) { len = -1; break; } @@ -749,7 +746,7 @@ el->el_line.buffer[0] = '\0'; el->el_line.lastchar = el->el_line.buffer; el->el_line.cursor = el->el_line.buffer; - return len; + return (int)len; } @@ -771,6 +768,6 @@ ptr >= el->el_line.buffer && *ptr != '\n'; ptr--) continue; - return (el->el_line.cursor - ptr - 1); + return (int)(el->el_line.cursor - ptr - 1); } } Index: libedit/chared.h =================================================================== --- libedit/chared.h (revision 238090) +++ libedit/chared.h (working copy) @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * @(#)chared.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: chared.h,v 1.17 2006/03/06 21:11:56 christos Exp $ + * $NetBSD: chared.h,v 1.18 2009/02/15 21:55:23 christos Exp $ * $FreeBSD$ */ @@ -71,7 +71,7 @@ */ typedef struct c_undo_t { int len; /* length of saved line */ - int cursor; /* position of saved cursor */ + ssize_t cursor; /* position of saved cursor */ char *buf; /* full saved text */ } c_undo_t;