Add handling for SCS (Select Character Set) escape sequences:
\e(X, \e)X, \e*X, \e+X. These sequences are now properly skipped
when calculating string width.
Addresses: https://github.com/util-linux/util-linux/issues/4121
Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
if (*e == 'm')
p = e + 1;
}
+ /* try detect SCS sequences "\e(X", "\e)X", "\e*X", "\e+X" and skip on success */
+ else if (*p && (*p == '(' || *p == ')' || *p == '*' || *p == '+')) {
+ p++; /* skip the SCS introducer */
+ if (p <= last)
+ p++; /* skip the character */
+ }
continue;
}
#ifdef HAVE_WIDECHAR