diff options
author | Jim Warner <james.warner@comcast.net> | 2022-06-27 00:00:00 -0500 |
---|---|---|
committer | Craig Small <csmall@dropbear.xyz> | 2022-07-03 21:33:07 +1000 |
commit | be7e171597b21f6a572f5027f7e1feeb52ec27fb (patch) | |
tree | d2c991eec082d8b6f737a4fe50a33e3f1f1a1b7e | |
parent | aa6a792bf9d3d4b7ccbb53907e6c57ec1bcccf4b (diff) | |
download | procps-ng-be7e171597b21f6a572f5027f7e1feeb52ec27fb.tar.gz |
top: if line editing, account for invisible characters <=== port of newlib b0adacf1
______________________________ original newlib message
If we're deleting a character or operating in overtype
mode, we must account for the potential of 'invisible'
characters. When one follows any character about to be
deleted or replaced both multi-byte sequences must go.
Without this change, there exists the possibility that
top might report some error where no error is apparent
to the user. For example, with 'other filtering' (o/O)
the user could see "unrecognized field name 'COMMAND'"
where the quoted column name appears perfectly normal.
Or maybe a sequences like the 'combining acute accent'
gets applied to an existing character instead of being
deleted as one expects when its parent was eliminated.
So, henceforth whenever any character is being deleted
we will now check for a following 'invisible' sequence
then eliminate it along with that preceding character.
[ admittedly, these scenarios are very rare yet they ]
[ may occur, especially when recalling some previous ]
[ multi-byte strings for editing. and, since we will ]
[ be interacting with a user, performance won't be a ]
[ factor so extra checks for a zero wcwidth is fine. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
-rw-r--r-- | top/top.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -1337,6 +1337,7 @@ static char *ioline (const char *prompt) { #define chkCUR { if (cur < 0) cur = 0; if (cur > len) cur = len; } // thank goodness ol' memmove will safely allow strings to overlap #define sqzSTR { i = utfTOT(pos); while (i < 0) i = utfTOT(--pos); \ + if (!utfCOL(pos + i)) i += utfTOT(pos + i); \ memmove(&buf[pos], &buf[pos + i], bufMAX-(pos + i)); \ memset(&buf[bufMAX - i], '\0', i); } #define expSTR(X) if (bufNXT < bufMAX && scrNXT < Screen_cols) { \ |