Fix parsing of iso8859 characters

Resolves: #1417886
This commit is contained in:
Siteshwar Vashisht 2017-04-25 16:20:49 +02:00
parent 10cab94743
commit 75c67d3437
2 changed files with 83 additions and 1 deletions

View File

@ -0,0 +1,74 @@
diff --git a/src/cmd/ksh93/sh/fcin.c b/src/cmd/ksh93/sh/fcin.c
index ea6ea6b..08c1f2a 100644
--- a/src/cmd/ksh93/sh/fcin.c
+++ b/src/cmd/ksh93/sh/fcin.c
@@ -150,63 +150,19 @@ extern void fcrestore(Fcin_t *fp)
_Fcin = *fp;
}
-/* for testing purposes with small buffers */
-#if defined(IOBSIZE) && (IOBSIZE < 2*MB_LEN_MAX)
-# undef MB_LEN_MAX
-# define MB_LEN_MAX (IOBSIZE/2)
-#endif
-
-struct Extra
-{
- unsigned char buff[2*MB_LEN_MAX];
- unsigned char *next;
-};
-
int _fcmbget(short *len)
{
- static struct Extra extra;
- register int i, c, n;
- if(_Fcin.fcleft)
- {
- if((c = mbsize(extra.next)) < 0)
- c = 1;
- if((_Fcin.fcleft -= c) <=0)
- {
- _Fcin.fcptr = (unsigned char*)fcfirst() - _Fcin.fcleft;
- _Fcin.fcleft = 0;
- }
- *len = c;
- if(c==1)
- c = *extra.next++;
- else if(c==0)
- _Fcin.fcleft = 0;
- else
- c = mbchar(extra.next);
- return(c);
- }
- switch(*len = mbsize(_Fcin.fcptr))
+ register int c;
+ switch (*len = mbsize(_Fcin.fcptr))
{
- case -1:
- if(_Fcin._fcfile && (n=(_Fcin.fclast-_Fcin.fcptr)) < MB_LEN_MAX)
- {
- memcpy(extra.buff, _Fcin.fcptr, n);
- _Fcin.fcptr = _Fcin.fclast;
- for(i=n; i < MB_LEN_MAX+n; i++)
- {
- if((extra.buff[i] = fcgetc(c))==0)
- break;
- }
- _Fcin.fcleft = n;
- extra.next = extra.buff;
- return(fcmbget(len));
- }
+ case -1:
*len = 1;
/* fall through */
- case 0:
- case 1:
+ case 0:
+ case 1:
c=fcget();
break;
- default:
+ default:
c = mbchar(_Fcin.fcptr);
}
return(c);

View File

@ -8,7 +8,7 @@ URL: http://www.kornshell.com/
#CPL everywhere else (for KSH itself)
License: CPL
Version: %{releasedate}
Release: 33%{?dist}
Release: 34%{?dist}
Source0: http://www.research.att.com/~gsf/download/tgz/ast-ksh.%{release_date}.tgz
Source1: http://www.research.att.com/~gsf/download/tgz/INIT.%{release_date}.tgz
Source2: kshcomp.conf
@ -181,6 +181,9 @@ Patch75: ksh-20120801-F_dupfd_cloexec.patch
# rhbz#1441142
Patch76: ksh-20120801-kia.patch
# rhbz#1417886
Patch77: ksh-20120801-iso8859.patch
Conflicts: pdksh
Requires: coreutils, diffutils, chkconfig
BuildRequires: bison
@ -256,6 +259,7 @@ with "sh" (the Bourne Shell).
%patch74 -p1 -b .mb-after-argvar
%patch75 -p1 -b .F_dupfd_cloexec
%patch76 -p1 -b .kia
%patch77 -p1 -b .iso8859
#/dev/fd test does not work because of mock
sed -i 's|ls /dev/fd|ls /proc/self/fd|' src/cmd/ksh93/features/options
@ -361,6 +365,10 @@ fi
%config(noreplace) %{_sysconfdir}/binfmt.d/kshcomp.conf
%changelog
* Tue Apr 25 2017 Siteshwar Vashisht <svashisht@redhat.com> - 20120801-34
- Fix parsing of iso8859 characters
Resolves: #1417886
* Tue Apr 11 2017 Siteshwar Vashisht <svashisht@redhat.com> - 20120801-33
- Avoid spurrious output in kia file creation
Resolves: #1441142