Previous discussion at [1]. But patch suggested in [1] might cause regressions due to removal of code.
Reproducer scripts are provided in iso_and_utf_sh.tar Reproducer steps : 1. bash iso.sh > iso_vars.sh 2. ksh -x iso_vars.sh 2>&1 | tail -3 + VAR8595=$'/a/\xe7foo/ab\xe3c' + VAR8596=$'/a/\xe7foo/ab\xe3c\nVAR8597=/a/\xe7foo/ab\xe3c' iso_vars.sh: line 8596: ": invalid variable name Expected output : "invalid variable name" error should not appear. glibc sets MB_LEN_MAX to 16 which is higher than most of the multibyte character sets require. For most of the multibyte character sets, 6 should be a sufficient maximum length. Compiling ksh using '-DCUSTOM_MB_LEN_MAX=6' with attached patch fixes this issue. [1] https://www.mail-archive.com/ast-users@lists.research.att.com/msg01091.html -- -- Siteshwar Vashisht
From e8cfa3b28df709fb46fb16cdb3e4fd8edf01975d Mon Sep 17 00:00:00 2001 From: Siteshwar Vashisht <svashi...@redhat.com> Date: Mon, 24 Apr 2017 22:43:50 +0200 Subject: [PATCH] Fix parsing of iso8859 characters --- src/cmd/ksh93/sh/fcin.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cmd/ksh93/sh/fcin.c b/src/cmd/ksh93/sh/fcin.c index ea6ea6b..413bb94 100644 --- a/src/cmd/ksh93/sh/fcin.c +++ b/src/cmd/ksh93/sh/fcin.c @@ -156,6 +156,10 @@ extern void fcrestore(Fcin_t *fp) # define MB_LEN_MAX (IOBSIZE/2) #endif +#if !defined CUSTOM_MB_LEN_MAX +#define CUSTOM_MB_LEN_MAX MB_LEN_MAX +#endif + struct Extra { unsigned char buff[2*MB_LEN_MAX]; @@ -187,11 +191,11 @@ int _fcmbget(short *len) switch(*len = mbsize(_Fcin.fcptr)) { case -1: - if(_Fcin._fcfile && (n=(_Fcin.fclast-_Fcin.fcptr)) < MB_LEN_MAX) + if(_Fcin._fcfile && (n=(_Fcin.fclast-_Fcin.fcptr)) < CUSTOM_MB_LEN_MAX) { memcpy(extra.buff, _Fcin.fcptr, n); _Fcin.fcptr = _Fcin.fclast; - for(i=n; i < MB_LEN_MAX+n; i++) + for(i=n; i < CUSTOM_MB_LEN_MAX+n; i++) { if((extra.buff[i] = fcgetc(c))==0) break; -- 2.9.3
iso_and_utf_sh.tar
Description: Unix tar archive
_______________________________________________ ast-developers mailing list ast-developers@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-developers