This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: port-line bug details & patch question.



I've really got to stop talking to myself ;) This is a better patch
for fgets & generic_fgets, based on the cvs repository (I've also sent
it along to jb.

1998-10-09  Greg Harvey  <Greg.Harvey@thezone.net>

	* fports.c (scm_fgets): added port line incrementing

	* ports.c (scm_generic_fgets): added port line incrementing 


*** guile-core/libguile/fports.c	Fri Oct  9 18:04:02 1998
--- guile-core.dev/libguile/fports.c	Fri Oct  9 18:47:11 1998
*************** local_fgets (SCM port, int *len)
*** 431,436 ****
--- 431,437 ----
        SCM_CLRDY (port);
        if (buf[(*len)++] == '\n')
  	{
+           SCM_INCLINE(port);
  	  buf[*len] = '\0';
  	  return buf;
  	}
*************** local_fgets (SCM port, int *len)
*** 458,466 ****
        numread = ftell (f) - pos;
        *len += numread;
  
!       if (numread < chunk_size - 1 || buf[limit-2] == '\n')
! 	return buf;
! 
        buf = (char *) realloc (buf, sizeof(char) * limit * 2);
        limit *= 2;
      }
--- 459,468 ----
        numread = ftell (f) - pos;
        *len += numread;
  
!       if (numread < chunk_size - 1 || buf[limit-2] == '\n') {
! 	if (buf[*len-1] == '\n') SCM_INCLINE(port); 
!         return buf;
!       }
        buf = (char *) realloc (buf, sizeof(char) * limit * 2);
        limit *= 2;
      }
*** guile-core/libguile/ports.c	Fri Oct  9 18:04:07 1998
--- guile-core.dev/libguile/ports.c	Fri Oct  9 19:04:18 1998
*************** scm_generic_fgets (port, len)
*** 624,629 ****
--- 624,630 ----
        SCM_CLRDY (port);
        if (buf[(*len)++] == '\n')
  	{
+ 	  SCM_INCLINE(port);
  	  buf[*len] = '\0';
  	  return buf;
  	}
*************** scm_generic_fgets (port, len)
*** 644,649 ****
--- 645,651 ----
        {
  	if (*len)
  	  {
+ 	    if (c == '\n' ) SCM_INCLINE(port);
  	    buf[*len] = '\0';
  	    return buf;
  	  }





-- 
Greg