mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 22:11:54 +02:00
21943, 21945: ZLE_UNICODE_SUPPORT -> MULTIBYTE_SUPPORT;
use multibyte versions of nicechar wherever possible.
This commit is contained in:
parent
5f11a38bea
commit
aea7715261
20 changed files with 131 additions and 117 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,6 +1,16 @@
|
|||
2005-10-28 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 21942: Src/Zle/zle_fresh.c: another bug found when deleting
|
||||
* 21943, 21945: configure.ac, Src/prompt.c, Src/string.c,
|
||||
Src/system.h, Src/utils.c, Src/zsh.h, Src/Zle/complist.c,
|
||||
Src/Zle/compmatch.c, Src/Zle/compresult.c, Src/Zle/zle.h,
|
||||
Src/Zle/zle_hist.c, Src/Zle/zle_keymap.c, Src/Zle/zle_main.c,
|
||||
Src/Zle/zle_misc.c, Src/Zle/zle_refresh.c, Src/Zle/zle_thingy.c,
|
||||
Src/Zle/zle_tricky.c, Src/Zle/zle_utils.c, Src/Zle/zle_vi.c:
|
||||
Replace ZLE_UNICODE_SUPPORT by MULTIBYTE_SUPPORT throughout.
|
||||
Use multibyte versions of "nicechar" functions wherever
|
||||
possible.
|
||||
|
||||
* 21942: Src/Zle/zle_refresh.c: another bug found when deleting
|
||||
an extra-wide character.
|
||||
|
||||
2005-10-26 Peter Stephenson <pws@csr.com>
|
||||
|
|
|
@ -559,7 +559,7 @@ clnicezputs(Listcols colors, char *s, int ml)
|
|||
int i = 0, col = 0, ask, oml = ml;
|
||||
char *t;
|
||||
ZLE_CHAR_T cc;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* ums is the untokenized, unmetafied string (length umlen)
|
||||
* uptr is a pointer into it
|
||||
|
@ -1940,7 +1940,7 @@ msearchpop(int *backp)
|
|||
static Cmatch **
|
||||
msearch(Cmatch **ptr, int ins, int back, int rep, int *wrapp)
|
||||
{
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/* MB_CUR_MAX may not be constant */
|
||||
VARARR(char, s, MB_CUR_MAX+1);
|
||||
#else
|
||||
|
@ -1953,7 +1953,7 @@ msearch(Cmatch **ptr, int ins, int back, int rep, int *wrapp)
|
|||
msearchpush(ptr, back);
|
||||
|
||||
if (ins) {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
if (lastchar_wide_valid)
|
||||
{
|
||||
int len = wctomb(s, lastchar_wide);
|
||||
|
|
|
@ -1584,7 +1584,7 @@ sub_match(Cmdata md, char *str, int len, int sfx)
|
|||
{
|
||||
int ret = 0, l, ind, add;
|
||||
char *p, *q;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
int fulllen = len;
|
||||
char *fullstr = str;
|
||||
mbstate_t ps;
|
||||
|
@ -1619,7 +1619,7 @@ sub_match(Cmdata md, char *str, int len, int sfx)
|
|||
|| (l < md->len && q[-1] == Meta)))
|
||||
l--;
|
||||
}
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* Make sure we don't end in the middle of a multibyte character.
|
||||
* Don't need to do this if the match ended at the start
|
||||
|
|
|
@ -2146,15 +2146,15 @@ iprintm(Cmgroup g, Cmatch *mp, UNUSED(int mc), UNUSED(int ml), int lastc, int wi
|
|||
printfmt(m->disp, 0, 1, 0);
|
||||
return;
|
||||
}
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
len = mb_niceformat(m->disp, shout, NULL);
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
len = mb_niceformat(m->disp, shout, NULL, 0);
|
||||
#else
|
||||
nicezputs(m->disp, shout);
|
||||
len = niceztrlen(m->disp);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
len = mb_niceformat(m->str, shout, NULL);
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
len = mb_niceformat(m->str, shout, NULL, 0);
|
||||
#else
|
||||
nicezputs(m->str, shout);
|
||||
len = niceztrlen(m->str);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
typedef wchar_t ZLE_CHAR_T;
|
||||
typedef wchar_t *ZLE_STRING_T;
|
||||
typedef wint_t ZLE_INT_T;
|
||||
|
@ -67,9 +67,7 @@ typedef wint_t ZLE_INT_T;
|
|||
* Functions that operate on a metafied string.
|
||||
* These versions handle multibyte characters.
|
||||
*/
|
||||
#define ZMB_nicewidth(s) mb_niceformat(s, NULL, NULL)
|
||||
#define ZMB_niceputs(s, stream) (void)mb_niceformat(s, stream, NULL)
|
||||
#define ZMB_niceztrdup(s) mb_niceztrdup(s)
|
||||
#define ZMB_nicewidth(s) mb_niceformat(s, NULL, NULL, 0)
|
||||
|
||||
/* Functions that operate on ZLE_CHAR_T. */
|
||||
#define ZC_iblank iswspace
|
||||
|
@ -84,7 +82,7 @@ typedef wint_t ZLE_INT_T;
|
|||
|
||||
#define LASTFULLCHAR lastchar_wide
|
||||
|
||||
#else /* Not ZLE_UNICODE_SUPPORT: old single-byte code */
|
||||
#else /* Not MULTIBYTE_SUPPORT: old single-byte code */
|
||||
|
||||
typedef int ZLE_CHAR_T;
|
||||
typedef unsigned char *ZLE_STRING_T;
|
||||
|
@ -111,8 +109,6 @@ typedef int ZLE_INT_T;
|
|||
* These versions don't handle multibyte characters.
|
||||
*/
|
||||
#define ZMB_nicewidth niceztrlen
|
||||
#define ZMB_niceputs nicezputs
|
||||
#define ZMB_niceztrdup(s) nicedup(s, 0)
|
||||
|
||||
#define ZC_nicechar nicechar
|
||||
|
||||
|
|
|
@ -1108,7 +1108,7 @@ doisearch(char **args, int dir)
|
|||
} else if (cmd == Th(z_magicspace)) {
|
||||
fixmagicspace();
|
||||
} else if (cmd == Th(z_selfinsert)) {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
if (!lastchar_wide_valid)
|
||||
getrestchar(lastchar);
|
||||
#else
|
||||
|
@ -1305,7 +1305,7 @@ getvisrchstr(void)
|
|||
if(cmd == Th(z_selfinsertunmeta)) {
|
||||
fixunmeta();
|
||||
} else {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
if (!lastchar_wide_valid)
|
||||
getrestchar(lastchar);
|
||||
#else
|
||||
|
|
|
@ -725,7 +725,7 @@ scanlistmaps(HashNode hn, int list)
|
|||
fputs("-- ", stdout);
|
||||
quotedzputs(n->nam, stdout);
|
||||
} else
|
||||
ZMB_niceputs(n->nam, stdout);
|
||||
nicezputs(n->nam, stdout);
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
|
@ -818,7 +818,7 @@ bin_bindkey_meta(char *name, char *kmname, Keymap km, UNUSED(char **argv), UNUSE
|
|||
zwarnnam(name, "keymap `%s' is protected", kmname, 0);
|
||||
return 1;
|
||||
}
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
zwarnnam(name, "warning: `bindkey -m' disables multibyte support",
|
||||
NULL, 0);
|
||||
#endif
|
||||
|
@ -1051,7 +1051,7 @@ bindlistout(struct bindstate *bs)
|
|||
if (bs->flags & BS_LIST)
|
||||
quotedzputs(bs->bind->nam, stdout);
|
||||
else
|
||||
ZMB_niceputs(bs->bind->nam, stdout);
|
||||
nicezputs(bs->bind->nam, stdout);
|
||||
} else
|
||||
printbind(bs->str, stdout);
|
||||
putchar('\n');
|
||||
|
|
|
@ -100,7 +100,7 @@ int mark;
|
|||
/**/
|
||||
mod_export int
|
||||
lastchar;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/**/
|
||||
mod_export ZLE_INT_T lastchar_wide;
|
||||
/**/
|
||||
|
@ -633,7 +633,7 @@ getbyte(int keytmout, int *timeout)
|
|||
if (timeout)
|
||||
*timeout = 0;
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* Reading a single byte always invalidates the status
|
||||
* of lastchar_wide. We may fix this up in getrestchar
|
||||
|
@ -737,7 +737,7 @@ getfullchar(int keytmout)
|
|||
{
|
||||
int inchar = getbyte(keytmout, NULL);
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
return getrestchar(inchar);
|
||||
#else
|
||||
return inchar;
|
||||
|
@ -746,7 +746,7 @@ getfullchar(int keytmout)
|
|||
|
||||
|
||||
/**/
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* Get the remainder of a character if we support multibyte
|
||||
* input strings. It may not require any more input, but
|
||||
|
@ -1048,7 +1048,7 @@ execzlefunc(Thingy func, char **args)
|
|||
|
||||
if(func->flags & DISABLED) {
|
||||
/* this thingy is not the name of a widget */
|
||||
char *nm = ZMB_niceztrdup(func->nam);
|
||||
char *nm = nicedup(func->nam, 0);
|
||||
char *msg = tricat("No such widget `", nm, "'");
|
||||
|
||||
zsfree(nm);
|
||||
|
@ -1104,7 +1104,7 @@ execzlefunc(Thingy func, char **args)
|
|||
|
||||
if(prog == &dummy_eprog) {
|
||||
/* the shell function doesn't exist */
|
||||
char *nm = ZMB_niceztrdup(w->u.fnnam);
|
||||
char *nm = nicedup(w->u.fnnam, 0);
|
||||
char *msg = tricat("No such shell function `", nm, "'");
|
||||
|
||||
zsfree(nm);
|
||||
|
@ -1422,7 +1422,7 @@ describekeybriefly(UNUSED(char **args))
|
|||
if (!func)
|
||||
is = bindztrdup(str);
|
||||
else
|
||||
is = ZMB_niceztrdup(func->nam);
|
||||
is = nicedup(func->nam, 0);
|
||||
msg = appstr(msg, is);
|
||||
zsfree(is);
|
||||
showmsg(msg);
|
||||
|
@ -1466,7 +1466,7 @@ whereis(UNUSED(char **args))
|
|||
if (!(ff.func = executenamedcommand("Where is: ")))
|
||||
return 1;
|
||||
ff.found = 0;
|
||||
ff.msg = ZMB_niceztrdup(ff.func->nam);
|
||||
ff.msg = nicedup(ff.func->nam, 0);
|
||||
scankeymap(curkeymap, 1, scanfindfunc, &ff);
|
||||
if (!ff.found)
|
||||
ff.msg = appstr(ff.msg, " is not bound to any key");
|
||||
|
|
|
@ -60,7 +60,7 @@ doinsert(ZLE_STRING_T zstr, int len)
|
|||
mod_export int
|
||||
selfinsert(UNUSED(char **args))
|
||||
{
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/* wint_t and wchar_t not neccessarily the same size */
|
||||
wchar_t tmp;
|
||||
|
||||
|
@ -82,7 +82,7 @@ fixunmeta(void)
|
|||
lastchar &= 0x7f;
|
||||
if (lastchar == '\r')
|
||||
lastchar = '\n';
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* TODO: can we do this better?
|
||||
* We need a wide character to insert.
|
||||
|
@ -529,7 +529,7 @@ digitargument(UNUSED(char **args))
|
|||
{
|
||||
int sign = (zmult < 0) ? -1 : 1;
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* It's too dangerous to allow metafied input. See
|
||||
* universalargument for comments on (possibly suboptimal) handling
|
||||
|
@ -953,7 +953,7 @@ executenamedcommand(char *prmt)
|
|||
if (len == NAMLEN || cmd != Th(z_selfinsert))
|
||||
feep = 1;
|
||||
else {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
if (!lastchar_wide_valid)
|
||||
getrestchar(lastchar);
|
||||
if (iswcntrl(lastchar_wide))
|
||||
|
@ -1137,7 +1137,7 @@ iremovesuffix(ZLE_CHAR_T c, int keep)
|
|||
zsfree(suffixfunc);
|
||||
suffixfunc = NULL;
|
||||
} else {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/* TODO: best I can think of for now... */
|
||||
int sl = (unsigned int)c <= 256 ? suffixlen[c] : 0;
|
||||
#else
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include "zle.mdh"
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* We use a wint_t here, since we need an invalid character as a
|
||||
* placeholder and wint_t guarantees that we can use WEOF to do this.
|
||||
|
@ -178,7 +178,7 @@ int cost;
|
|||
void
|
||||
zwcputc(ZLE_INT_T c)
|
||||
{
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
char mbtmp[MB_CUR_MAX + 1];
|
||||
mbstate_t mbstate;
|
||||
int i;
|
||||
|
@ -197,7 +197,7 @@ zwcputc(ZLE_INT_T c)
|
|||
static int
|
||||
zwcwrite(REFRESH_STRING s, size_t i)
|
||||
{
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
size_t j;
|
||||
|
||||
for (j = 0; j < i; j++)
|
||||
|
@ -625,7 +625,7 @@ zrefresh(void)
|
|||
*rpms.s++ = ZWC(' ');
|
||||
while ((++t0) & 7);
|
||||
}
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
else if (iswprint(*t)) {
|
||||
int width = wcwidth(*t);
|
||||
if (width > rpms.sen - rpms.s) {
|
||||
|
@ -663,7 +663,7 @@ zrefresh(void)
|
|||
if (nextline(&rpms, 1))
|
||||
break;
|
||||
}
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
*rpms.s++ = ((*t == 127) || (*t > 255)) ? ZWC('?') :
|
||||
(*t | ZWC('@'));
|
||||
#else
|
||||
|
@ -698,7 +698,7 @@ zrefresh(void)
|
|||
snextline(&rpms);
|
||||
u = statusline;
|
||||
for (; u < statusline + statusll; u++) {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
if (iswprint(*u)) {
|
||||
int width = wcwidth(*u);
|
||||
/* Handle wide characters as above */
|
||||
|
@ -1071,12 +1071,12 @@ refreshline(int ln)
|
|||
for (;;) {
|
||||
if (*nl && *ol && nl[1] == ol[1]) {
|
||||
/* skip only if second chars match */
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
int ccs_was = ccs;
|
||||
#endif
|
||||
/* skip past all matching characters */
|
||||
for (; *nl && (*nl == *ol); nl++, ol++, ccs++) ;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/* Make sure ol and nl are pointing to real characters */
|
||||
while ((*nl == WEOF || *ol == WEOF) && ccs > ccs_was) {
|
||||
nl--;
|
||||
|
@ -1152,7 +1152,7 @@ refreshline(int ln)
|
|||
tc_delchars(i);
|
||||
ol += i;
|
||||
char_ins -= i;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
while (*ol == WEOF) {
|
||||
ol++;
|
||||
char_ins--;
|
||||
|
@ -1191,13 +1191,13 @@ refreshline(int ln)
|
|||
}
|
||||
/* we can't do any fancy tricks, so just dump the single character
|
||||
and keep on trying */
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
do {
|
||||
#endif
|
||||
zputc(*nl);
|
||||
nl++, ol++;
|
||||
ccs++, vcs++;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* Make sure we always overwrite the complete width of
|
||||
* a character that was there before.
|
||||
|
@ -1336,7 +1336,7 @@ tc_rightcurs(int ct)
|
|||
think.
|
||||
*/
|
||||
if (vln == 0 && i < lpromptw && !(termflags & TERM_SHORT)) {
|
||||
#ifndef ZLE_UNICODE_SUPPORT
|
||||
#ifndef MULTIBYTE_SUPPORT
|
||||
if ((int)strlen(lpromptbuf) == lpromptw)
|
||||
fputs(lpromptbuf + i, shout);
|
||||
else
|
||||
|
@ -1432,7 +1432,7 @@ singlerefresh(ZLE_STRING_T tmpline, int tmpll, int tmpcs)
|
|||
int t0, /* tmp */
|
||||
vsiz, /* size of new video buffer */
|
||||
nvcs = 0; /* new video cursor column */
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* converted lprompt and pointer: no WEOF hack here since
|
||||
* we always output the full prompt and count its width.
|
||||
|
@ -1448,7 +1448,7 @@ singlerefresh(ZLE_STRING_T tmpline, int tmpll, int tmpcs)
|
|||
for (vsiz = 1 + lpromptw, t0 = 0; t0 != tmpll; t0++, vsiz++)
|
||||
if (tmpline[t0] == ZWC('\t'))
|
||||
vsiz = (vsiz | 7) + 1;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
else if (iswprint(tmpline[t0]))
|
||||
vsiz += wcwidth(tmpline[t0]);
|
||||
#endif
|
||||
|
@ -1465,7 +1465,7 @@ singlerefresh(ZLE_STRING_T tmpline, int tmpll, int tmpcs)
|
|||
}
|
||||
|
||||
/* only use last part of prompt */
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* Convert the entire lprompt so that we know how to count
|
||||
* characters.
|
||||
|
@ -1514,7 +1514,7 @@ singlerefresh(ZLE_STRING_T tmpline, int tmpll, int tmpcs)
|
|||
} else if (tmpline[t0] == ZWC('\n')) {
|
||||
*vp++ = ZWC('\\');
|
||||
*vp++ = ZWC('n');
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
} else if (iswprint(tmpline[t0])) {
|
||||
int width;
|
||||
*vp++ = tmpline[t0];
|
||||
|
|
|
@ -519,15 +519,15 @@ scanlistwidgets(HashNode hn, int list)
|
|||
quotedzputs(w->u.fnnam, stdout);
|
||||
}
|
||||
} else {
|
||||
ZMB_niceputs(t->nam, stdout);
|
||||
nicezputs(t->nam, stdout);
|
||||
if (w->flags & WIDGET_NCOMP) {
|
||||
fputs(" -C ", stdout);
|
||||
ZMB_niceputs(w->u.comp.wid, stdout);
|
||||
nicezputs(w->u.comp.wid, stdout);
|
||||
fputc(' ', stdout);
|
||||
ZMB_niceputs(w->u.comp.func, stdout);
|
||||
nicezputs(w->u.comp.func, stdout);
|
||||
} else if(strcmp(t->nam, w->u.fnnam)) {
|
||||
fputs(" (", stdout);
|
||||
ZMB_niceputs(w->u.fnnam, stdout);
|
||||
nicezputs(w->u.fnnam, stdout);
|
||||
fputc(')', stdout);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2244,7 +2244,7 @@ listlist(LinkList l)
|
|||
if (isset(LISTROWSFIRST)) {
|
||||
for (col = 1, p = data, lenp = lens; *p;
|
||||
p++, lenp++, col++) {
|
||||
ZMB_niceputs(*p, shout);
|
||||
nicezputs(*p, shout);
|
||||
if (col == ncols) {
|
||||
col = 0;
|
||||
if (p[1])
|
||||
|
@ -2262,7 +2262,7 @@ listlist(LinkList l)
|
|||
for (f = data, fl = lens, line = 0; line < nlines;
|
||||
f++, fl++, line++) {
|
||||
for (col = 1, p = f, lenp = fl; *p; col++) {
|
||||
ZMB_niceputs(*p, shout);
|
||||
nicezputs(*p, shout);
|
||||
if (col == ncols)
|
||||
break;
|
||||
if ((i = (pack ? widths[col - 1] : longest) - *lenp + 2) > 0)
|
||||
|
@ -2276,7 +2276,7 @@ listlist(LinkList l)
|
|||
}
|
||||
} else {
|
||||
for (p = data; *p; p++) {
|
||||
ZMB_niceputs(*p, shout);
|
||||
nicezputs(*p, shout);
|
||||
putc('\n', shout);
|
||||
}
|
||||
}
|
||||
|
@ -2367,7 +2367,7 @@ void
|
|||
fixmagicspace(void)
|
||||
{
|
||||
lastchar = ' ';
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* This is redundant if the multibyte encoding extends ASCII,
|
||||
* since lastchar is a full character, but it's safer anyway...
|
||||
|
@ -2386,7 +2386,7 @@ magicspace(char **args)
|
|||
int ret;
|
||||
fixmagicspace();
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* TODO: bangchar should really be a multibyte string representing
|
||||
* a single character, since there's no fundamental reason why
|
||||
|
|
|
@ -132,7 +132,7 @@ zlelineasstring(ZLE_STRING_T instr, int inll, int incs, int *outllp,
|
|||
{
|
||||
int outcs, outll;
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
char *s;
|
||||
int i, j;
|
||||
size_t mb_len = 0;
|
||||
|
@ -167,7 +167,7 @@ zlelineasstring(ZLE_STRING_T instr, int inll, int incs, int *outllp,
|
|||
* metafiable characters.
|
||||
*/
|
||||
if (outcsp != NULL || outllp != NULL) {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
unsigned char *strp = (unsigned char *)s;
|
||||
#else
|
||||
unsigned char *strp = instr;
|
||||
|
@ -189,7 +189,7 @@ zlelineasstring(ZLE_STRING_T instr, int inll, int incs, int *outllp,
|
|||
*outllp = outll;
|
||||
}
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
if (useheap)
|
||||
{
|
||||
unsigned char *ret =
|
||||
|
@ -242,7 +242,7 @@ stringaszleline(unsigned char *instr, int incs,
|
|||
{
|
||||
ZLE_STRING_T outstr;
|
||||
int ll, sz;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
mbstate_t ps;
|
||||
#endif
|
||||
|
||||
|
@ -274,7 +274,7 @@ stringaszleline(unsigned char *instr, int incs,
|
|||
*outsz = ll;
|
||||
outstr = (ZLE_STRING_T)zalloc(sz);
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
if (ll) {
|
||||
char *inptr = (char *)instr;
|
||||
wchar_t *outptr = outstr;
|
||||
|
@ -785,7 +785,7 @@ showmsg(char const *msg)
|
|||
char const *p;
|
||||
int up = 0, cc = 0;
|
||||
ZLE_CHAR_T c;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
char *umsg;
|
||||
int ulen, ret;
|
||||
size_t width;
|
||||
|
@ -795,7 +795,7 @@ showmsg(char const *msg)
|
|||
trashzle();
|
||||
clearflag = isset(USEZLE) && !termflags && isset(ALWAYSLASTPROMPT);
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
umsg = ztrdup(msg);
|
||||
p = unmetafy(umsg, &ulen);
|
||||
memset(&ps, 0, sizeof(ps));
|
||||
|
|
|
@ -135,7 +135,7 @@ vigetkey(void)
|
|||
} else if (cmd == Th(z_vicmdmode)) {
|
||||
return ZLEEOF;
|
||||
}
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
if (!lastchar_wide_valid)
|
||||
{
|
||||
getrestchar(lastchar);
|
||||
|
@ -830,7 +830,7 @@ vicapslockpanic(UNUSED(char **args))
|
|||
statusline = ZWS("press a lowercase key to continue");
|
||||
statusll = ZS_strlen(statusline);
|
||||
zrefresh();
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
while (!iswlower(getfullchar(0)));
|
||||
#else
|
||||
while (!islower(getfullchar(0)));
|
||||
|
|
22
Src/prompt.c
22
Src/prompt.c
|
@ -736,7 +736,7 @@ addbufspc(int need)
|
|||
void
|
||||
stradd(char *d)
|
||||
{
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
char *ums, *ups;
|
||||
int upslen;
|
||||
mbstate_t ps;
|
||||
|
@ -861,7 +861,7 @@ countprompt(char *str, int *wp, int *hp, int overf)
|
|||
{
|
||||
int w = 0, h = 1;
|
||||
int s = 1;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
int mbret, wcw, multi = 0;
|
||||
char inchar;
|
||||
mbstate_t mbs;
|
||||
|
@ -887,13 +887,13 @@ countprompt(char *str, int *wp, int *hp, int overf)
|
|||
w++;
|
||||
else if (s) {
|
||||
if (*str == Meta) {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
inchar = *++str ^ 32;
|
||||
#else
|
||||
str++;
|
||||
#endif
|
||||
} else {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* Don't look for tab or newline in the middle
|
||||
* of a multibyte character. Otherwise, we are
|
||||
|
@ -910,14 +910,14 @@ countprompt(char *str, int *wp, int *hp, int overf)
|
|||
h++;
|
||||
continue;
|
||||
}
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
}
|
||||
|
||||
inchar = *str;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
mbret = mbrtowc(&wc, &inchar, 1, &mbs);
|
||||
if (mbret >= -1) {
|
||||
if (mbret > 0) {
|
||||
|
@ -1044,7 +1044,7 @@ prompttrunc(int arg, int truncchar, int doprint, int endchar)
|
|||
int twidth, maxwidth;
|
||||
int ntrunc = strlen(t);
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/* Use screen width of string */
|
||||
twidth = mb_width(t);
|
||||
#else
|
||||
|
@ -1076,7 +1076,7 @@ prompttrunc(int arg, int truncchar, int doprint, int endchar)
|
|||
*/
|
||||
char *fulltextptr, *fulltext;
|
||||
int remw;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
mbstate_t mbs;
|
||||
memset(&mbs, 0, sizeof(mbstate_t));
|
||||
#endif
|
||||
|
@ -1111,7 +1111,7 @@ prompttrunc(int arg, int truncchar, int doprint, int endchar)
|
|||
fulltextptr++;
|
||||
}
|
||||
} else {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* Normal text: build up a multibyte character.
|
||||
*/
|
||||
|
@ -1170,7 +1170,7 @@ prompttrunc(int arg, int truncchar, int doprint, int endchar)
|
|||
* maximum width.
|
||||
*/
|
||||
char *skiptext = ptr;
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
mbstate_t mbs;
|
||||
memset(&mbs, 0, sizeof(mbstate_t));
|
||||
#endif
|
||||
|
@ -1180,7 +1180,7 @@ prompttrunc(int arg, int truncchar, int doprint, int endchar)
|
|||
for (; *skiptext != Outpar && *skiptext;
|
||||
skiptext++);
|
||||
} else {
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
char inchar;
|
||||
wchar_t cc;
|
||||
int ret;
|
||||
|
|
|
@ -55,7 +55,7 @@ ztrdup(const char *s)
|
|||
}
|
||||
|
||||
/**/
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/**/
|
||||
mod_export wchar_t *
|
||||
wcs_ztrdup(const wchar_t *s)
|
||||
|
@ -69,7 +69,7 @@ wcs_ztrdup(const wchar_t *s)
|
|||
return t;
|
||||
}
|
||||
/**/
|
||||
#endif /* ZLE_UNICODE_SUPPORT */
|
||||
#endif /* MULTIBYTE_SUPPORT */
|
||||
|
||||
|
||||
/* concatenate s1, s2, and s3 in dynamically allocated buffer */
|
||||
|
|
|
@ -692,13 +692,13 @@ extern short ospeed;
|
|||
#endif
|
||||
|
||||
/*
|
||||
* The ZLE_UNICODE_SUPPORT configure-define specifies that we want to enable
|
||||
* The MULTIBYTE_SUPPORT configure-define specifies that we want to enable
|
||||
* complete Unicode conversion between wide characters and multibyte strings.
|
||||
*/
|
||||
#if defined ZLE_UNICODE_SUPPORT \
|
||||
#if defined MULTIBYTE_SUPPORT \
|
||||
|| (defined HAVE_WCHAR_H && defined HAVE_WCTOMB && defined __STDC_ISO_10646__)
|
||||
/*
|
||||
* If ZLE_UNICODE_SUPPORT is not defined, these includes provide a subset of
|
||||
* If MULTIBYTE_SUPPORT is not defined, these includes provide a subset of
|
||||
* Unicode support that makes the \u and \U printf escape sequences work.
|
||||
*/
|
||||
# include <wchar.h>
|
||||
|
|
60
Src/utils.c
60
Src/utils.c
|
@ -35,7 +35,7 @@
|
|||
/**/
|
||||
char *scriptname;
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* The wordchars variable turned into a wide character array.
|
||||
* This is much more convenient for testing.
|
||||
|
@ -156,7 +156,11 @@ zerrmsg(const char *fmt, const char *str, int num)
|
|||
putc('%', stderr);
|
||||
break;
|
||||
case 'c':
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
zputs(wcs_nicechar(num, NULL, NULL), stderr);
|
||||
#else
|
||||
zputs(nicechar(num), stderr);
|
||||
#endif
|
||||
break;
|
||||
case 'e':
|
||||
/* print the corresponding message for this errno */
|
||||
|
@ -219,6 +223,10 @@ putshout(int c)
|
|||
* Note that the returned string is metafied, so that it must be
|
||||
* treated like any other zsh internal string (and not, for example,
|
||||
* output directly).
|
||||
*
|
||||
* This function is used even if MULTIBYTE_SUPPORT is defined: we
|
||||
* use it as a fallback in case we couldn't identify a wide character
|
||||
* in a multibyte string.
|
||||
*/
|
||||
|
||||
/**/
|
||||
|
@ -270,7 +278,7 @@ nicechar(int c)
|
|||
}
|
||||
|
||||
/**/
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* The number of bytes we need to allocate for a "nice" representation
|
||||
* of a multibyte character.
|
||||
|
@ -380,7 +388,7 @@ wcs_nicechar(wchar_t c, size_t *widthp, char **swidep)
|
|||
return buf;
|
||||
}
|
||||
/**/
|
||||
#endif /* ZLE_UNICODE_SUPPORT */
|
||||
#endif /* MULTIBYTE_SUPPORT */
|
||||
|
||||
|
||||
/* Output a string's visible representation. */
|
||||
|
@ -394,19 +402,6 @@ nicefputs(char *s, FILE *f)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Return the length of the visible representation of a string. */
|
||||
|
||||
/**/
|
||||
size_t
|
||||
nicestrlen(char *s)
|
||||
{
|
||||
size_t l = 0;
|
||||
|
||||
for (; *s; s++)
|
||||
l += strlen(nicechar(STOUC(*s)));
|
||||
return l;
|
||||
}
|
||||
|
||||
/* get a symlink-free pathname for s relative to PWD */
|
||||
|
||||
/**/
|
||||
|
@ -2542,7 +2537,7 @@ inittyptab(void)
|
|||
typtab[t0] = IDIGIT | IALNUM | IWORD | IIDENT | IUSER;
|
||||
for (t0 = 'a'; t0 <= 'z'; t0++)
|
||||
typtab[t0] = typtab[t0 - 'a' + 'A'] = IALPHA | IALNUM | IIDENT | IUSER | IWORD;
|
||||
#ifndef ZLE_UNICODE_SUPPORT
|
||||
#ifndef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* This really doesn't seem to me the right thing to do when
|
||||
* we have multibyte character support... it was a hack to assume
|
||||
|
@ -2575,7 +2570,7 @@ inittyptab(void)
|
|||
}
|
||||
typtab[STOUC(*s == Meta ? *++s ^ 32 : *s)] |= ISEP;
|
||||
}
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
if (wordchars) {
|
||||
char *wordchars_unmeta;
|
||||
const char *wordchars_ptr;
|
||||
|
@ -2602,7 +2597,7 @@ inittyptab(void)
|
|||
#endif
|
||||
for (s = wordchars ? wordchars : DEFAULT_WORDCHARS; *s; s++) {
|
||||
int c = STOUC(*s == Meta ? *++s ^ 32 : *s);
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
if (!isascii(c)) {
|
||||
/*
|
||||
* If we have support for multibyte characters, we don't
|
||||
|
@ -2623,7 +2618,7 @@ inittyptab(void)
|
|||
}
|
||||
|
||||
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* iword() macro extended to support wide characters.
|
||||
*/
|
||||
|
@ -2715,7 +2710,7 @@ zarrdup(char **s)
|
|||
}
|
||||
|
||||
/**/
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/**/
|
||||
mod_export wchar_t **
|
||||
wcs_zarrdup(wchar_t **s)
|
||||
|
@ -2729,7 +2724,7 @@ wcs_zarrdup(wchar_t **s)
|
|||
return y;
|
||||
}
|
||||
/**/
|
||||
#endif /* ZLE_UNICODE_SUPPORT */
|
||||
#endif /* MULTIBYTE_SUPPORT */
|
||||
|
||||
/**/
|
||||
static char *
|
||||
|
@ -3329,6 +3324,7 @@ zputs(char const *s, FILE *stream)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifndef MULTIBYTE_SUPPORT
|
||||
/* Create a visibly-represented duplicate of a string. */
|
||||
|
||||
/**/
|
||||
|
@ -3356,6 +3352,7 @@ nicedup(char const *s, int heap)
|
|||
*p = '\0';
|
||||
return heap ? dupstring(buf) : ztrdup(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**/
|
||||
mod_export char *
|
||||
|
@ -3364,6 +3361,8 @@ nicedupstring(char const *s)
|
|||
return nicedup(s, 1);
|
||||
}
|
||||
|
||||
|
||||
#ifndef MULTIBYTE_SUPPORT
|
||||
/* Unmetafy and output a string, displaying special characters readably. */
|
||||
|
||||
/**/
|
||||
|
@ -3387,6 +3386,7 @@ nicezputs(char const *s, FILE *stream)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Return the length of the visible representation of a metafied string. */
|
||||
|
||||
/**/
|
||||
|
@ -3409,9 +3409,11 @@ niceztrlen(char const *s)
|
|||
}
|
||||
return l;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**/
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
/*
|
||||
* Version of both nicezputs() and niceztrlen() for use with multibyte
|
||||
* characters. Input is a metafied string; output is the screen width of
|
||||
|
@ -3421,11 +3423,13 @@ niceztrlen(char const *s)
|
|||
*
|
||||
* If outstrp is not NULL, set *outstrp to a zalloc'd version of
|
||||
* the output (still metafied).
|
||||
*
|
||||
* If "heap" is non-zero, use the heap for *outstrp, else zalloc.
|
||||
*/
|
||||
|
||||
/**/
|
||||
mod_export size_t
|
||||
mb_niceformat(const char *s, FILE *stream, char **outstrp)
|
||||
mb_niceformat(const char *s, FILE *stream, char **outstrp, int heap)
|
||||
{
|
||||
size_t l = 0, newl, ret;
|
||||
int umlen, outalloc, outleft;
|
||||
|
@ -3500,7 +3504,7 @@ mb_niceformat(const char *s, FILE *stream, char **outstrp)
|
|||
if (outstrp) {
|
||||
*outptr = '\0';
|
||||
/* Use more efficient storage for returned string */
|
||||
*outstrp = ztrdup(outstr);
|
||||
*outstrp = heap ? dupstring(outstr) : ztrdup(outstr);
|
||||
free(outstr);
|
||||
}
|
||||
|
||||
|
@ -3511,11 +3515,11 @@ mb_niceformat(const char *s, FILE *stream, char **outstrp)
|
|||
|
||||
/**/
|
||||
mod_export char *
|
||||
mb_niceztrdup(const char *s)
|
||||
nicedup(const char *s, int heap)
|
||||
{
|
||||
char *retstr;
|
||||
|
||||
(void)mb_niceformat(s, NULL, &retstr);
|
||||
(void)mb_niceformat(s, NULL, &retstr, heap);
|
||||
|
||||
return retstr;
|
||||
}
|
||||
|
@ -3564,7 +3568,7 @@ mb_width(const char *s)
|
|||
}
|
||||
|
||||
/**/
|
||||
#endif /* ZLE_UNICODE_SUPPORT */
|
||||
#endif /* MULTIBYTE_SUPPORT */
|
||||
|
||||
/* check for special characters in the string */
|
||||
|
||||
|
|
|
@ -1432,7 +1432,7 @@ struct histent {
|
|||
|
||||
Histent up; /* previous line (moving upward) */
|
||||
Histent down; /* next line (moving downward) */
|
||||
#ifdef ZLE_UNICODE_SUPPORT
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
wchar_t *zle_text; /* the edited history line */
|
||||
#else
|
||||
unsigned char *zle_text; /* the edited history line */
|
||||
|
@ -1928,3 +1928,7 @@ typedef unsigned char *(*ZleGetLineFn) _((int *, int *));
|
|||
#define EXITHOOK (zshhooks + 0)
|
||||
#define BEFORETRAPHOOK (zshhooks + 1)
|
||||
#define AFTERTRAPHOOK (zshhooks + 2)
|
||||
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
#define nicezputs(str, outs) (void)mb_niceformat((str), (outs), NULL, 0)
|
||||
#endif
|
||||
|
|
|
@ -2087,10 +2087,10 @@ AC_HELP_STRING([--enable-multibyte], [support multibyte chars in the zsh line ed
|
|||
zsh_cv_c_zle_unicode_support=yes,
|
||||
zsh_cv_c_zle_unicode_support=no)])
|
||||
])
|
||||
AH_TEMPLATE([ZLE_UNICODE_SUPPORT],
|
||||
[Define to 1 if you want unicode support in the line editor.])
|
||||
AH_TEMPLATE([MULTIBYTE_SUPPORT],
|
||||
[Define to 1 if you want support for multibyte character sets.])
|
||||
if test $zsh_cv_c_zle_unicode_support = yes; then
|
||||
AC_DEFINE(ZLE_UNICODE_SUPPORT)
|
||||
AC_DEFINE(MULTIBYTE_SUPPORT)
|
||||
fi
|
||||
|
||||
dnl ---------------
|
||||
|
|
Loading…
Reference in a new issue