On Sun, Sep 25, 2005 at 07:50:54PM +0000, Gerrit Pape wrote:
> 
> > --- dash-0.5.2.ORIG/src/input.c     2003-03-08 03:43:47.000000000 +0100
> > +++ dash-0.5.2/src/input.c  2005-09-03 14:22:23.000000000 +0200
> > @@ -266,6 +266,7 @@
> >     int something;
> >  #endif
> >     char savec;
> > +   static size_t skipped_characters = 0;
> >  
> >     while (parsefile->strpush) {
> >             if (
> > @@ -285,6 +286,9 @@
> >     flushout(&errout);
> >  #endif
> >  
> > +   parsenextc += skipped_characters;
> > +   skipped_characters = 0;
> > +
> >  again:
> >     if (parselleft <= 0) {
> >             if ((parselleft = preadfd()) <= 0) {
> > @@ -303,6 +307,7 @@
> >             switch (*p) {
> >             case '\0':
> >                     p++;    /* Skip nul */
> > +                   skipped_characters++;
> >                     goto check;
> >  
> >  #ifndef SMALL

Thanks for the patch.  The idea is right but you need to handle the
case of nested input streams by saving skipped_characters whenever
the input stream is pushed.

Anyway, I've fixed in a different way with the following patch.

BTW, the dash source is now available in git format at

http://gondor.apana.org.au/~herbert/dash/dash.git/

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
diff --git a/src/input.c b/src/input.c
--- a/src/input.c
+++ b/src/input.c
@@ -300,9 +300,9 @@ again:
        something = 0;
 #endif
        for (more = 1; more;) {
-               switch (*p) {
+               switch (*p++) {
                case '\0':
-                       p++;    /* Skip nul */
+                       p = memmove(q, p, parselleft);
                        goto check;
 
 #ifndef SMALL
@@ -323,7 +323,7 @@ again:
 #endif
                }
 
-               *q++ = *p++;
+               q++;
 check:
                if (--parselleft <= 0 && more) {
                        parsenleft = q - parsenextc - 1;

Reply via email to