Those wretched ^M's!

From: George (greerga@DRAGON.HAM.MUOHIO.EDU)
Date: 11/12/97


You all may be relieved to know that I have determined the cause of the
^M's which pop up in world files.

They are caused by a small bug in fread_string() right by this comment:
/* If there is a '~', end the string; else put an "\r\n" over the '\n'. */

It appears that when it overwrites the \n with a \r\n, there was already a
\r there to begin with!

Example:
$1 = 0xe85f8 "  The main hang out of the Gods, the Immortal Board Room is
the place to\r\r\nbe.  Gods exchange messages here most every day.  The
mortal board room is\r\r\nto the east and the meeting room for the gods i".

After applying my fix:
$1 = 0xe8568 "  The main hang out of the Gods, the Immortal Board Room is
the place to\r\nbe.  Gods exchange m essages here most every day.  The
mortal board room is\r\nto the east and the meeting room for the gods is"

The fix:
    /* If there is a '~', end the string; else put an "\r\n" over the '\n'. */
    if ((point = strchr(tmp, '~')) != NULL) {
      *point = '\0';
      done = 1;
    } else {
-      point = tmp + strlen(tmp) - 1;
+      point = tmp + strlen(tmp) + 1;
-      *(point++) = '\r';
-      *(point++) = '\n';
      *point = '\0';
    }

That is not a patch. :)  I've only tested it by booting, setting a
breakpoint in copy_room, and then copying the room description.

Maybe in bpl13 we can throw away all those string strippers. :)

--
George Greer  -  Me@Null.net   | Genius may have its limitations, but stupidity
http://www.van.ml.org/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST