Re: An olc question

From: Sammy (
Date: 04/16/96

On Tue, 16 Apr 1996, Hades wrote:

> Ok, when the olc saves the file (I use iedit/redit) it leaves those damn
> annoying M's at the end of any line with a CR in it. ANyone know a way to
> take those damn things out? Or a function they made to lose the CR's?

Well after several attempts over the past several months I think I've 
finally found the answer.  Other people have posted code to fix this, but 
it's been a personal goal to figure it out for myself since strings give 
me such a hard time :)

This is actual working (and probably inefficient, but hey) code from the 
upcoming release of obuild:

void kill_ems(char *str)
  char *ptr1, *ptr2, *tmp;

  tmp = str;
  ptr1 = str;
  ptr2 = str;

  while(*ptr1) {
    if((*(ptr2++) = *(ptr1++)) == '\r')
      if(*ptr1 == '\r')
  *ptr2 = '\0';

In actual use, what I do is something like this:

#define CHECK_NULL(string) ((string) ? (string) : "")

void save_rooms(int zone)
  char *temp;

/* snip */

  temp = str_dup(CHECK_NULL(world[rnum].description));
  fprintf(outfile, "%s\n", temp);


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