1
0
mirror of https://git.zap.org.au/git/trader.git synced 2025-01-03 14:57:41 -05:00

More (slight) code clean-ups

This commit is contained in:
John Zaitseff 2011-08-26 03:22:25 +10:00
parent cb67513bb9
commit 4c99f9a57f

View File

@ -1949,10 +1949,12 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
clen = wcswidth(buf, bufsize); // clen is number of column positions
if (clen < 0) {
err_exit("gettxline: illegal character in string: `%ls'", buf);
err_exit(_("gettxline: illegal character in string: `%ls'"), buf);
}
// Find the point from which buf should be displayed to screen
/* Find the point from which buf should be displayed to screen. cpos
is the cursor position (0 to width-1), st is the offset in buf[]
from which to start printing the string on the screen. */
cpos_end(buf, &cpos, &st, clen, width, len);
redraw = true;
@ -1992,7 +1994,7 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
clen = wcswidth(buf, bufsize);
if (clen == -1) {
err_exit("gettxline: illegal character in string: `%ls'",
err_exit(_("gettxline: illegal character in string: `%ls'"),
buf);
}
@ -2310,18 +2312,18 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
wchar_t c = buf[pos - 1];
buf[pos - 1] = buf[pos - 2];
buf[pos - 2] = c;
// pos, cpos and st stay the same
mod = true;
redraw = true;
} else {
wchar_t c = buf[pos];
int w = wcwidth(c);
buf[pos] = buf[pos - 1];
buf[pos - 1] = c;
pos++;
cpos_inc(buf, &cpos, &st, w, width);
mod = true;
redraw = true;
}
@ -2362,8 +2364,7 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
width);
}
while (pos > 0 && (iswalnum(buf[pos - 1])
|| (pos > 1
&& wcwidth(buf[pos - 1]) == 0
|| (pos > 1 && wcwidth(buf[pos - 1]) == 0
&& iswalnum(buf[pos - 2])))) {
/* Treat zero-width characters preceded by an
alphanumeric character as alphanumeric. */
@ -2382,8 +2383,7 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
cpos_inc(buf, &cpos, &st,
wcwidth(buf[pos - 1]), width);
}
while (pos < len
&& (iswalnum(buf[pos])
while (pos < len && (iswalnum(buf[pos])
|| wcwidth(buf[pos]) == 0)) {
/* Treat zero-width characters following an
alphanumeric character as alphanumeric. */
@ -2406,12 +2406,11 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
i++;
ww += wcwidth(buf[i - 1]);
}
while (i < len
&& (iswalnum(buf[i])
while (i < len && (iswalnum(buf[i])
|| wcwidth(buf[pos]) == 0)) {
/* Treat zero-width characters
following an alphanumeric
character as alphanumeric. */
/* Treat zero-width characters following
an alphanumeric character as
alphanumeric. */
i++;
ww += wcwidth(buf[i - 1]);
}
@ -2427,7 +2426,7 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
case L'\\':
case L' ':
// Delete all surrounding spaces; if key == ' ',
// Delete all surrounding spaces; if key == L' ',
// also insert one space
{
int i = pos;
@ -2480,8 +2479,7 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
cpos_inc(buf, &cpos, &st,
wcwidth(buf[pos - 1]), width);
}
while (pos < len
&& (iswalnum(buf[pos])
while (pos < len && (iswalnum(buf[pos])
|| wcwidth(buf[pos]) == 0)) {
buf[pos] = towupper(buf[pos]);
pos++;
@ -2500,8 +2498,7 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
cpos_inc(buf, &cpos, &st,
wcwidth(buf[pos - 1]), width);
}
while (pos < len
&& (iswalnum(buf[pos])
while (pos < len && (iswalnum(buf[pos])
|| wcwidth(buf[pos]) == 0)) {
buf[pos] = towlower(buf[pos]);
pos++;
@ -2517,14 +2514,13 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
// Convert current letter to upper case,
// following letters to lower case
{
bool first = true;
while (pos < len && ! iswalnum(buf[pos])) {
pos++;
cpos_inc(buf, &cpos, &st,
wcwidth(buf[pos - 1]), width);
}
while (pos < len
&& (iswalnum(buf[pos])
bool first = true;
while (pos < len && (iswalnum(buf[pos])
|| wcwidth(buf[pos]) == 0)) {
if (first) {
buf[pos] = towupper(buf[pos]);
@ -2566,8 +2562,7 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
ww += w;
cpos_dec(buf, &cpos, &st, w, width);
}
while (i > 0
&& (iswalnum(buf[i - 1])
while (i > 0 && (iswalnum(buf[i - 1])
|| (i > 1 && wcwidth(buf[i - 1]) == 0
&& iswalnum(buf[i - 2])))) {
/* Treat zero-width characters preceded by an