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: Sat, 30 Jan 1999 02:49:12 -0800

On Fri, Jan 29, 1999, address@hidden (address@hidden) said:
|
| > which is a quick'n'dirty way of making sure you have a null on the end
| > of the strncpy()'d data, without thinking about char counts, lengths,
| > and pointers.  Remember that strncpy() doesn't tack on a null if the
| > strlen(src) is greater than the count.
|
| but you've overlaid it with a string that you have the right length
| (assuming that fread did not lie ;-)

Yeah .. that's how it ended up, alright.  It is not necessarily how it
started out though ... :-) ...

Anyway, here is a patchlet to apply on top of my earlier posted "fixup"
patch, which does it "the right way", I do believe.  I didn't change the
other chopper, on the fread() data, since I'm not convinced that you
can't get multiple nulls at the end of the returned data on some systems.


| oh, I usually get a good night's sleep on Friday night and then work all
| weekend on these projects.  But Fridays are worst since I've been juggling
| this & day-work all week.

Not to mention "ncurses", I'll bet ...!

/kim


diff -uNr lynx-2.8.2-dev.15+kd.orig/src/GridText.c 
lynx-2.8.2-dev.15+kd/src/GridText.c
--- lynx-2.8.2-dev.15+kd.orig/src/GridText.c    Fri Jan 29 09:47:46 1999
+++ lynx-2.8.2-dev.15+kd/src/GridText.c Sat Jan 30 02:02:27 1999
@@ -8846,14 +8846,14 @@
        else
           len = strlen (lp);
 
-       strncpy (line, "\0", MAX_LINE);
        strncpy (line, lp, len);
+       *(line + len) = '\0';
 
        /*
         *  Whack off trailing whitespace from the line.
         */
-       for (size = MAX_LINE, p = line + (size - 1); size != 0; p--, size--) {
-           if ((isspace(*p)) || (*p == '\0'))
+       for (i = len, p = line + (len - 1); i != 0; p--, i--) {
+           if (isspace(*p))
               *p = '\0';
            else
               break;
@@ -8872,7 +8872,7 @@
           s = tbuf;
 
           while (*p) {
-              if (cp = strchr (p, '\t')) {
+              if ((cp = strchr (p, '\t')) != 0) {
                  i  = cp - p;
                  s  = (strncpy (s, p, i))      + i;
                  n  = TABSTOP - (i % TABSTOP);
diff -uNr lynx-2.8.2-dev.15+kd.orig/src/LYKeymap.c 
lynx-2.8.2-dev.15+kd/src/LYKeymap.c
--- lynx-2.8.2-dev.15+kd.orig/src/LYKeymap.c    Fri Jan 29 09:47:46 1999
+++ lynx-2.8.2-dev.15+kd/src/LYKeymap.c Sat Jan 30 01:45:19 1999
@@ -577,7 +577,7 @@
 { "WHEREIS",           "search within the current document" },
 { "NEXT",              "search for the next occurence" },
 { "COMMENT",           "send a comment to the author of the current document" 
},
-{ "EDIT",              "edit the current document" },
+{ "EDIT",              "edit the current document or a form's textarea" },
 { "INFO",              "display information on the current document and link" 
},
 { "PRINT",             "display choices for printing the current document" },
 { "ADD_BOOKMARK",      "add to your personal bookmark list" },
##--eof--##

reply via email to

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