lineeditor: fix endian-issue writing character as int - sfeed_curses - sfeed curses UI (now part of sfeed, development is in sfeed)
HTML git clone git://git.codemadness.org/sfeed_curses
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit de853505e857aa93057cb3724f83b5b82a099f85
DIR parent d05b6dc39d336a276c4e44aee6945723d5876382
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 20 Dec 2020 03:06:51 +0100
lineeditor: fix endian-issue writing character as int
Also simplify writing the sequence.
Tested and noticed on Debian 6, MIPS (32-bit big-endian).
Diffstat:
M sfeed_curses.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
---
DIR diff --git a/sfeed_curses.c b/sfeed_curses.c
@@ -982,15 +982,12 @@ lineeditor(void)
if (!nchars)
continue;
input[--nchars] = '\0';
- ch = '\b'; /* back */
- write(1, &ch, 1);
- ch = ' '; /* blank */
- write(1, &ch, 1);
- ch = '\b'; /* back */
- write(1, &ch, 1);
+ write(1, "\b \b", 3); /* back, blank, back */
continue;
} else if (ch >= ' ') {
- write(1, &ch, 1);
+ input[nchars] = ch;
+ write(1, &input[nchars], 1);
+ nchars++;
} else if (ch < 0) {
switch (sigstate) {
case 0:
@@ -1004,7 +1001,6 @@ lineeditor(void)
free(input);
return NULL;
}
- input[nchars++] = ch;
}
return input;
}