lynx-dev
[Top][All Lists]
Advanced

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

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


From: Kim DeVaughn
Subject: lynx-dev Re: [dev.15] fixup patch: edit TEXTAREA
Date: Fri, 29 Jan 1999 16:00:45 -0800

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.


| 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
(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).

Doesn't work if X is replaced with any reasonable form of (X) that I could
come up with.  Damned documentation on MACRO writing, is sorely inadequate.

How would *you* write it ...?

/kim

reply via email to

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