Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: input.c and here documents bugfixes
- X-seq: zsh-workers 397
 
- From: schaefer@xxxxxxxxxx (Barton E. Schaefer)
 
- To: Zoltan Hidvegi  <hzoli@xxxxxxxxxx>,        zsh-workers@xxxxxxxxxxxxxxx (zsh-workers)
 
- Subject: Re: input.c and here documents bugfixes
 
- Date: Thu, 21 Sep 1995 11:09:02 -0700
 
- In-reply-to: schaefer@xxxxxxxxxxxxxxxxx (Barton E. Schaefer)        "Re: input.c and here documents bugfixes" (Sep 21,  9:22am)
 
- References: <199509211119.NAA20683@xxxxxxxxxxxxxxxxx> 	<950921092241.ZM8730@xxxxxxxxxxxxxxxxx>
 
- Reply-to: schaefer@xxxxxxxxxx
 
I think Zoltan's input.c patch was incorrect.  The exec.c part of the
patch is OK.  Here's the relevant bit:
--- Forwarded mail from Zoltan Hidvegi  <hzoli@xxxxxxxxxx>
*** 1.2	1995/09/19 17:57:52
--- Src/input.c	1995/09/20 11:04:22
***************
*** 274,283 ****
  {
      int l;
  
!     for (l = 0; l < n - 1; l++)
! 	if ((buf[l] = ingetc()) == '\n' || lexstop)
! 	    break;
!     buf[l + (lexstop ? 0 : 1)] = 0;
  
      return (!lexstop || l) ? buf : NULL;
  }
--- 274,283 ----
  {
      int l;
  
!     for (l = 0; l < n - 1 && (buf[l++] = ingetc()) != '\n' && !lexstop;)
!     if (lexstop)
! 	l--;
!     buf[l] = '\0';
  
      return (!lexstop || l) ? buf : NULL;
  }
--- End of forwarded mail from Zoltan Hidvegi  <hzoli@xxxxxxxxxx>
I don't know whether that's supposed to be "for (... && !lexstop;);" or
whether the "if (lexstop)" is intended to be part of the loop (as it is
as it stands), but either way it's wrong -- if it's not part of the loop,
it can decrement `l' to less than zero when n <= 1, and if it *is* part
of the loop, it fails to decrement `l' at all.
Zoltan, why did you change this code in the first place?
-- 
Bart Schaefer                     Vice President, Technology, Z-Code Software
schaefer@xxxxxxxxxx                  Division of NCD Software Corporation
http://www.well.com/www/barts
Messages sorted by:
Reverse Date,
Date,
Thread,
Author