From: Nirbhay Choubey Date: July 27 2011 7:56am Subject: bzr push into mysql-trunk branch (nirbhay.choubey:3238 to 3239) WL#5945 List-Archive: http://lists.mysql.com/commits/140478 Message-Id: <201107270756.p6R7uQX5029711@acsmt358.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3239 Nirbhay Choubey 2011-07-27 WL#5945 : Improve libedit library Merged from head of NetBSD CVS tree. modified: cmd-line-utils/libedit/README cmd-line-utils/libedit/chartype.c cmd-line-utils/libedit/el.c cmd-line-utils/libedit/eln.c cmd-line-utils/libedit/history.c cmd-line-utils/libedit/read.c 3238 Nirbhay Choubey 2011-07-01 [merge] Merging to mysql-trunk-wl5945. added: cmd-line-utils/libedit/chartype.c cmd-line-utils/libedit/chartype.h cmd-line-utils/libedit/eln.c modified: cmd-line-utils/libedit/README cmd-line-utils/libedit/chared.c cmd-line-utils/libedit/chared.h cmd-line-utils/libedit/common.c cmd-line-utils/libedit/el.c cmd-line-utils/libedit/el.h cmd-line-utils/libedit/el_term.h cmd-line-utils/libedit/emacs.c cmd-line-utils/libedit/filecomplete.c cmd-line-utils/libedit/filecomplete.h cmd-line-utils/libedit/hist.c cmd-line-utils/libedit/hist.h cmd-line-utils/libedit/histedit.h cmd-line-utils/libedit/history.c cmd-line-utils/libedit/key.c cmd-line-utils/libedit/key.h cmd-line-utils/libedit/makelist.sh cmd-line-utils/libedit/map.c cmd-line-utils/libedit/map.h cmd-line-utils/libedit/np/strlcat.c cmd-line-utils/libedit/np/strlcpy.c cmd-line-utils/libedit/np/unvis.c cmd-line-utils/libedit/np/vis.c cmd-line-utils/libedit/np/vis.h cmd-line-utils/libedit/parse.c cmd-line-utils/libedit/parse.h cmd-line-utils/libedit/prompt.c cmd-line-utils/libedit/prompt.h cmd-line-utils/libedit/read.c cmd-line-utils/libedit/read.h cmd-line-utils/libedit/readline.c cmd-line-utils/libedit/readline/readline.h cmd-line-utils/libedit/refresh.c cmd-line-utils/libedit/refresh.h cmd-line-utils/libedit/search.c cmd-line-utils/libedit/search.h cmd-line-utils/libedit/sig.c cmd-line-utils/libedit/sig.h cmd-line-utils/libedit/sys.h cmd-line-utils/libedit/term.c cmd-line-utils/libedit/tokenizer.c cmd-line-utils/libedit/tty.c cmd-line-utils/libedit/tty.h cmd-line-utils/libedit/vi.c === modified file 'cmd-line-utils/libedit/README' --- a/cmd-line-utils/libedit/README 2011-07-01 11:21:11 +0000 +++ b/cmd-line-utils/libedit/README 2011-07-27 07:55:09 +0000 @@ -42,7 +42,7 @@ then merge remaining bits by hand. All marked with XXXMYSQL to make them easier to identify and merge. To generate a 'clean' diff against upstream you can use the above commands but use - cvs co -D "2011/04/13 08:00:00" [..] + cvs co -D "2011/07/27 11:00:00" [..] to fetch the baseline of most recent merge. === modified file 'cmd-line-utils/libedit/chartype.c' --- a/cmd-line-utils/libedit/chartype.c 2011-05-13 08:32:47 +0000 +++ b/cmd-line-utils/libedit/chartype.c 2011-07-27 07:55:09 +0000 @@ -1,4 +1,4 @@ -/* $NetBSD: chartype.c,v 1.4 2010/04/15 00:55:57 christos Exp $ */ +/* $NetBSD: chartype.c,v 1.5 2011/07/27 02:18:30 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -88,27 +88,20 @@ ct_encode_string(const Char *s, ct_buffe dst = conv->cbuff; while (*s) { - used = ct_encode_char(dst, (int)(conv->csize - - (dst - conv->cbuff)), *s); - if (used == -1) { /* failed to encode, need more buffer space */ + used = conv->csize - (dst - conv->cbuff); + if (used < 5) { used = dst - conv->cbuff; ct_conv_buff_resize(conv, conv->csize + CT_BUFSIZ, 0); if (!conv->cbuff) return NULL; dst = conv->cbuff + used; - /* don't increment s here - we want to retry it! */ } - else - ++s; + used = ct_encode_char(dst, 5, *s); + if (used == -1) /* failed to encode, need more buffer space */ + abort(); + ++s; dst += used; } - if (dst >= (conv->cbuff + conv->csize)) { - used = dst - conv->cbuff; - ct_conv_buff_resize(conv, conv->csize + 1, 0); - if (!conv->cbuff) - return NULL; - dst = conv->cbuff + used; - } *dst = '\0'; return conv->cbuff; } === modified file 'cmd-line-utils/libedit/el.c' --- a/cmd-line-utils/libedit/el.c 2011-05-13 08:32:47 +0000 +++ b/cmd-line-utils/libedit/el.c 2011-07-27 07:55:09 +0000 @@ -1,4 +1,4 @@ -/* $NetBSD: el.c,v 1.62 2011/03/20 12:36:14 bouyer Exp $ */ +/* $NetBSD: el.c,v 1.63 2011/07/26 21:03:17 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -553,6 +553,8 @@ el_source(EditLine *el, const char *fnam return (-1); while ((ptr = fgetln(fp, &len)) != NULL) { + if (*ptr == '\n') + continue; /* Empty line. */ dptr = ct_decode_string(ptr, &el->el_scratch); if (!dptr) continue; === modified file 'cmd-line-utils/libedit/eln.c' --- a/cmd-line-utils/libedit/eln.c 2011-05-13 08:32:47 +0000 +++ b/cmd-line-utils/libedit/eln.c 2011-07-27 07:55:09 +0000 @@ -1,4 +1,4 @@ -/* $NetBSD: eln.c,v 1.9 2010/11/04 13:53:12 christos Exp $ */ +/* $NetBSD: eln.c,v 1.10 2011/06/20 09:11:17 mrg Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -274,7 +274,7 @@ el_get(EditLine *el, int op, ...) case EL_RPROMPT_ESC: { el_pfunc_t *p = va_arg(ap, el_pfunc_t *); char *c = va_arg(ap, char *); - wchar_t wc; + wchar_t wc = 0; ret = prompt_get(el, p, &wc, op); *c = (unsigned char)wc; break; === modified file 'cmd-line-utils/libedit/history.c' --- a/cmd-line-utils/libedit/history.c 2011-05-13 08:32:47 +0000 +++ b/cmd-line-utils/libedit/history.c 2011-07-27 07:55:09 +0000 @@ -1,4 +1,4 @@ -/* $NetBSD: history.c,v 1.38 2011/01/16 03:05:51 christos Exp $ */ +/* $NetBSD: history.c,v 1.39 2011/07/27 02:23:29 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -464,23 +464,25 @@ history_def_delete(history_t *h, private int history_def_insert(history_t *h, TYPE(HistEvent) *ev, const Char *str) { + hentry_t *c; - h->cursor = (hentry_t *) h_malloc(sizeof(hentry_t)); - if (h->cursor == NULL) + c = h_malloc(sizeof(*c)); + if (c == NULL) goto oomem; - if ((h->cursor->ev.str = h_strdup(str)) == NULL) { - h_free((ptr_t)h->cursor); + if ((c->ev.str = h_strdup(str)) == NULL) { + h_free((ptr_t)c); goto oomem; } - h->cursor->data = NULL; - h->cursor->ev.num = ++h->eventid; - h->cursor->next = h->list.next; - h->cursor->prev = &h->list; - h->list.next->prev = h->cursor; - h->list.next = h->cursor; + c->data = NULL; + c->ev.num = ++h->eventid; + c->next = h->list.next; + c->prev = &h->list; + h->list.next->prev = c; + h->list.next = c; h->cur++; + h->cursor = c; - *ev = h->cursor->ev; + *ev = c->ev; return (0); oomem: he_seterrev(ev, _HE_MALLOC_FAILED); @@ -498,7 +500,7 @@ history_def_enter(ptr_t p, TYPE(HistEven if ((h->flags & H_UNIQUE) != 0 && h->list.next != &h->list && Strcmp(h->list.next->ev.str, str) == 0) - return (0); + return (0); if (history_def_insert(h, ev, str) == -1) return (-1); /* error, keep error message */ @@ -550,6 +552,7 @@ history_def_clear(ptr_t p, TYPE(HistEven while (h->list.prev != &h->list) history_def_delete(h, ev, h->list.prev); + h->cursor = &h->list; h->eventid = 0; h->cur = 0; } @@ -793,7 +796,7 @@ history_save(TYPE(History) *h, const cha TYPE(HistEvent) ev; int i = -1, retval; size_t len, max_size; - char *ptr; + char *ptr, *str; #ifdef WIDECHAR static ct_buffer_t conv; #endif @@ -811,7 +814,8 @@ history_save(TYPE(History) *h, const cha for (i = 0, retval = HLAST(h, &ev); retval != -1; retval = HPREV(h, &ev), i++) { - len = Strlen(ev.str) * 4; + str = ct_encode_string(ev.str, &conv); + len = strlen(str) * 4; if (len >= max_size) { char *nptr; max_size = (len + 1024) & ~1023; @@ -822,7 +826,7 @@ history_save(TYPE(History) *h, const cha } ptr = nptr; } - (void) strvis(ptr, ct_encode_string(ev.str, &conv), VIS_WHITE); + (void) strvis(ptr, str, VIS_WHITE); (void) fprintf(fp, "%s\n", ptr); } oomem: === modified file 'cmd-line-utils/libedit/read.c' --- a/cmd-line-utils/libedit/read.c 2011-05-13 08:32:47 +0000 +++ b/cmd-line-utils/libedit/read.c 2011-07-27 07:55:09 +0000 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.58 2011/02/18 20:53:05 christos Exp $ */ +/* $NetBSD: read.c,v 1.61 2011/07/09 23:54:39 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -351,7 +351,11 @@ read_char(EditLine *el, Char *cp) } goto again; } - } else /* we don't support other multibyte charsets */ + } else if (isascii((unsigned char)cbuf[0]) || + /* we don't support other multibyte charsets */ + ++cbp != 1 || + /* Try non-ASCII characters in a 8-bit character set */ + (bytes = ct_mbtowc(cp, cbuf, cbp)) != 1) #endif *cp = (unsigned char)cbuf[0]; No bundle (reason: useless for push emails).