1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

SHOPT_MULTIBYTE-related cleanup (re: 8477d2ce)

As of 8477d2ce, the mbwide() macro (which tests if we're in a
multibyte locale, i.e. UTF-8) is redefined as a constant 0 if we're
compiling without SHOPT_MULTIBYTE. See src/cmd/ksh93/include/defs.h

The other multibyte macros use mbwide() as well, so they all revert
to the single-byte fallbacks in that case, and the multibyte code
in them is never compiled. See src/lib/libast/include/ast.h

Consequently we can now do a bit of cleanup and get rid of many of
the '#if SHOPT_MULTIBYTE' directives, as the compiler optimiser
will happily remove the multibyte-specific code. This increases the
legibility of the ksh code.

I'm taking the opportunity to fix a few typos and whitespace
formatting glitches as well.
This commit is contained in:
Martijn Dekker 2020-08-29 22:45:04 +01:00
parent 7c5d39fa04
commit f8feed1bd2
9 changed files with 28 additions and 76 deletions

View file

@ -31,10 +31,6 @@
#include "edit.h"
#include "history.h"
#if !SHOPT_MULTIBYTE
#define mbchar(p) (*(unsigned char*)p++)
#endif
static char *fmtx(const char *string)
{
register const char *cp = string;

View file

@ -1013,9 +1013,7 @@ int hist_match(register History_t *hp,off_t offset,char *string,int *coffset)
{
register unsigned char *first, *cp;
register int m,n,c=1,line=0;
#if SHOPT_MULTIBYTE
mbinit();
#endif /* SHOPT_MULTIBYTE */
sfseek(hp->histfp,offset,SEEK_SET);
if(!(cp = first = (unsigned char*)sfgetr(hp->histfp,0,0)))
return(-1);
@ -1033,10 +1031,8 @@ int hist_match(register History_t *hp,off_t offset,char *string,int *coffset)
break;
if(*cp=='\n')
line++;
#if SHOPT_MULTIBYTE
if((c=mbsize(cp)) < 0)
c = 1;
#endif /* SHOPT_MULTIBYTE */
cp += c;
m -= c;
}