Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: input.c and here documents bugfixes



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