lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev Re: [dev.15] fixup patch: edit TEXTAREA


From: dickey
Subject: Re: lynx-dev Re: [dev.15] fixup patch: edit TEXTAREA
Date: Fri, 29 Jan 1999 20:36:10 -0500 (EST)

> 
> On Fri, Jan 29, 1999, address@hidden (address@hidden) said: 
> | 
> | > The attached patch fixes a couple bugs that crept into the edit 
> | > TEXTAREA feature. 
> | ... 
> | mostly ok, but 
> | 
> | why do you expect fread will return something with trailing nulls? 
> | 
> | >-   while ((size != 0) && isspace(ebuf[size-1])) 
> | >+  while ((size != 0) && (isspace(ebuf[size-1]) || (ebuf[size-1] == 
> '\0'))) 
> | >   ebuf[--size] = '\0'; 
>  
> Far as I know, fread() can return one or more nulls at the end of the file 
> (implementation dependent).  I was just making sure I was backing up thru 
> any extra nulls that might be there.  If there aren't any, it's a near nop. 

I've not seen that (the stat call, on the other hand I know in VAX C will
return the filesize rounded up to the next block).
  
>  
> | or embedded nulls? 
> | 
> | > -         *p = '\0'; 
> | > + for (size = MAX_LINE, p = line + (size - 1); size != 0; p--, size--) { 
> | > +     if ((isspace(*p)) || (*p == '\0')) 
> | > +        *p = '\0'; 
>  
> Heh ... not embedded nulls.  We are scanning from the tail end of the buffer 

but the test for null is redundant then (why would the buffer be full of 
nulls?).

> (line + (MAX_LINE - 1), and the buffer is full of nulls.  I suppose I could 
> optimize that to work backwards from (line + strlen(line) - 1) instead, but 
> it's probably a wash, cycle-wise, given a decent compiler, and good string 
> handling machine ops. 
>  
> As it stands, NO whitespace will ever get reached without that test for \0. 
>  
>  
> | and (I didn't change this because it's not used), your substitution for 
> | the "X" isn't ANSI (won't work except for pre-ANSI compilers). 
> | 
> | >  /* usage: DUMPSTRUCT_ANCHOR(anchor_ptr, "message"); */ 
> | >  #define   DUMPSTRUCT_ANCHOR(A,X) \ 
> | >  CTRACE(tfp, "\n" \ 
> | ... 
> | > +            "KED:   anchor_ptr=0x%08x  sizeof=%d  ["X"]\n" \ 
>  
> Works fine with gcc (using whatever the default switches your config sets). 

oops - sorry (friday/long week).  your usage is correct (X has to be a quoted
string, and an ANSI compiler will indeed concatenate them when adjacent).

> /kim 


-- 
Thomas E. Dickey
address@hidden
http://www.clark.net/pub/dickey

reply via email to

[Prev in Thread] Current Thread [Next in Thread]