Fix warnings: ex_cmds.c: do_ascii(): Garbage value (2): MI.

Problems   : Assigned value is garbage or undefined @ 127.
             Assigned value is garbage or undefined @ 152.
Diagnostic : Multithreading issues.
Rationale  : Error could only occurr if global `enc_utf8` changed while
             the function is executing.
Resolution : Use local copy of global var.
This commit is contained in:
Eliseo Martínez 2014-11-07 20:46:56 +01:00
parent 3080672650
commit 9c3a3e1381

View File

@ -90,8 +90,9 @@ void do_ascii(exarg_T *eap)
int cc[MAX_MCO]; int cc[MAX_MCO];
int ci = 0; int ci = 0;
int len; int len;
const bool l_enc_utf8 = enc_utf8;
if (enc_utf8) if (l_enc_utf8)
c = utfc_ptr2char(get_cursor_pos_ptr(), cc); c = utfc_ptr2char(get_cursor_pos_ptr(), cc);
else else
c = gchar_cursor(); c = gchar_cursor();
@ -123,20 +124,20 @@ void do_ascii(exarg_T *eap)
vim_snprintf((char *)IObuff, IOSIZE, vim_snprintf((char *)IObuff, IOSIZE,
_("<%s>%s%s %d, Hex %02x, Octal %03o"), _("<%s>%s%s %d, Hex %02x, Octal %03o"),
transchar(c), buf1, buf2, cval, cval, cval); transchar(c), buf1, buf2, cval, cval, cval);
if (enc_utf8) if (l_enc_utf8)
c = cc[ci++]; c = cc[ci++];
else else
c = 0; c = 0;
} }
/* Repeat for combining characters. */ /* Repeat for combining characters. */
while (has_mbyte && (c >= 0x100 || (enc_utf8 && c >= 0x80))) { while (has_mbyte && (c >= 0x100 || (l_enc_utf8 && c >= 0x80))) {
len = (int)STRLEN(IObuff); len = (int)STRLEN(IObuff);
/* This assumes every multi-byte char is printable... */ /* This assumes every multi-byte char is printable... */
if (len > 0) if (len > 0)
IObuff[len++] = ' '; IObuff[len++] = ' ';
IObuff[len++] = '<'; IObuff[len++] = '<';
if (enc_utf8 && utf_iscomposing(c) if (l_enc_utf8 && utf_iscomposing(c)
# ifdef USE_GUI # ifdef USE_GUI
&& !gui.in_use && !gui.in_use
# endif # endif
@ -148,7 +149,7 @@ void do_ascii(exarg_T *eap)
: _("> %d, Hex %08x, Octal %o"), c, c, c); : _("> %d, Hex %08x, Octal %o"), c, c, c);
if (ci == MAX_MCO) if (ci == MAX_MCO)
break; break;
if (enc_utf8) if (l_enc_utf8)
c = cc[ci++]; c = cc[ci++];
else else
c = 0; c = 0;