82 lines
2.0 KiB
Plaintext
82 lines
2.0 KiB
Plaintext
|
|Subject: here doc bug with locales
|
||
|
--- src/cmd/ksh93/include/fcin.h Tue Aug 3 11:43:29 2010
|
||
|
+++ src/cmd/ksh93/include/fcin.h Wed Jul 20 14:52:54 2011
|
||
|
@@ -35,6 +35,8 @@
|
||
|
#define fcpeek(n) ((int)_Fcin.fcptr[n])
|
||
|
#define fcseek(n) ((char*)(_Fcin.fcptr+=(n)))
|
||
|
#define fcfirst() ((char*)_Fcin.fcbuff)
|
||
|
+#define fclast() ((char*)_Fcin.fclast)
|
||
|
+#define fcleft() (_Fcin.fclast-_Fcin.fcptr)
|
||
|
#define fcsopen(s) (_Fcin._fcfile=(Sfio_t*)0,_Fcin.fclen=1,_Fcin.fcbuff=_Fcin.fcptr=(unsigned char*)(s))
|
||
|
#define fctell() (_Fcin.fcoff + (_Fcin.fcptr-_Fcin.fcbuff))
|
||
|
#define fcsave(x) (*(x) = _Fcin)
|
||
|
--- src/cmd/ksh93/sh/lex.c Wed Apr 6 12:05:19 2011
|
||
|
+++ src/cmd/ksh93/sh/lex.c Wed Jul 20 14:59:04 2011
|
||
|
@@ -1564,7 +1564,10 @@ static int comsub(register Lex_t *lp, in
|
||
|
{
|
||
|
|
||
|
if(first==lp->lexd.first)
|
||
|
- fcseek(cp+1-fcseek(0));
|
||
|
+ {
|
||
|
+ const char *tp = fcseek(0);
|
||
|
+ fcseek(cp+1-tp);
|
||
|
+ }
|
||
|
count++;
|
||
|
lp->lexd.paren = 0;
|
||
|
fcgetc(c);
|
||
|
@@ -1817,18 +1820,41 @@ static int here_copy(Lex_t *lp,register
|
||
|
if(n!=S_NL)
|
||
|
{
|
||
|
/* skip over regular characters */
|
||
|
+#if SHOPT_MULTIBYTE
|
||
|
+ do
|
||
|
+ {
|
||
|
+ if(fcleft()< MB_LEN_MAX && mbsize(fcseek(0))<0)
|
||
|
+ {
|
||
|
+ n = S_EOF;
|
||
|
+ LEN = -fcleft();
|
||
|
+ break;
|
||
|
+ }
|
||
|
+ }
|
||
|
+#endif /* SHOPT_MULTIBYTE */
|
||
|
while((n=STATE(state,c))==0);
|
||
|
}
|
||
|
if(n==S_EOF || !(c=fcget()))
|
||
|
{
|
||
|
- if(!lp->lexd.dolparen && (c=(fcseek(0)-1)-bufp))
|
||
|
+ if(LEN < 0)
|
||
|
+ c = fclast()-bufp;
|
||
|
+ else
|
||
|
+ c= (fcseek(0)-1)-bufp;
|
||
|
+ if(!lp->lexd.dolparen && c)
|
||
|
{
|
||
|
if(n==S_ESC)
|
||
|
c--;
|
||
|
if(!lp->lexd.dolparen && (c=sfwrite(sp,bufp,c))>0)
|
||
|
iop->iosize += c;
|
||
|
}
|
||
|
- if((c=lexfill(lp))<=0)
|
||
|
+ if(LEN < 0)
|
||
|
+ {
|
||
|
+ n = LEN;
|
||
|
+ c = fcmbget(&LEN);
|
||
|
+ LEN += n;
|
||
|
+ }
|
||
|
+ else
|
||
|
+ c = lexfill(lp);
|
||
|
+ if(c<0)
|
||
|
break;
|
||
|
if(n==S_ESC)
|
||
|
{
|
||
|
@@ -1844,7 +1870,9 @@ static int here_copy(Lex_t *lp,register
|
||
|
sfputc(sp,'\\');
|
||
|
}
|
||
|
}
|
||
|
- bufp = fcseek(-1);
|
||
|
+ if (LEN < 1)
|
||
|
+ LEN = 1;
|
||
|
+ bufp = fcseek(-LEN);
|
||
|
}
|
||
|
else
|
||
|
fcseek(-LEN);
|