Re: [OLC] A problem with hedit

From: Artovil (artovil@arcanerealms.org)
Date: 06/07/02


At 21:55 2002-06-06 -0700, Jason Yarber wrote:
>Ok, I've been having a problem with another mud I work on, that deals with
>the help files.
>It seems that extra lines are being added to the beginning and end of
>every help file entry.
>I've narrowed it down to either when it saves, or when it loads, which it
>does both everytime
>I do a copyover to update my code.  This bug has been persistant for a
>very long time, and
>as you can probably imagine, we're having to cycle through about 5 blank
>screens before we
>get to the actual help file.  I do know that the blank lines are being
>saved to disk.  But whether
>they are being added when the file is loaded or when it's saved, is beyond
>me.  I've looked at
>the code for both the saving and the loading, but can't see any apparent
>problems myself.
>So I'm reluctantly asking you for help.  I've placed a copy of each
>suspect function below.
>Please look through those functions and tell me what you think is
>wrong.  As usual, your
>help is greatly appreciated.

For one, the following code adds an \r\n to the end of each key line in
load_help:

>     /* read in the corresponding help entry */
>     strcpy(entry, strcat(key, "\r\n"));

If you remove those two lines it might work better.  I placed this entry at
the top of my help file, I can't remember exactly why, but it had something
to do with the count or something, it doesn't work well without I remember
at least:
-----------------------------------------------
~UNDEFINED!
Implementors don't need help, eh?!
#106
-----------------------------------------------

Here's both my functions:
-----------------------------------------------
void hedit_save_to_disk(struct descriptor_data *d)
{
   int i;
   FILE *fp;

   sprintf(buf, "%s/%s", HLP_PREFIX, HELP_FILE);
   if (!(fp = fopen(buf, "w+"))) {
     mudlog("SYSERR: OLC: Cannot open help file!", BRF, LVL_BUILDER, TRUE);
     return;
   }
   for (i = 0; i < top_of_helpt; i++) {
     strcpy(buf1, help_table[i].entry ? help_table[i].entry : "Empty");
     strip_cr(buf1);
     sprintf(buf, "%s\n%s#%d\n",
       ALLCAP(help_table[i].keywords),
       buf1,
       help_table[i].min_level);
     fputs(buf, fp);
   }

   /*
    * Write final line and close.
    */
   fprintf(fp, "$\n");
   fclose(fp);

}


void load_help(FILE *fl)
{
   char key[READ_SIZE+1], entry[32384];
   char line[READ_SIZE+1];
   struct help_index_element el;

   /* get the first keyword line */
   get_one_line(fl, key);
   while (*key != '$') {
     get_one_line(fl, line);
     *entry = '\0';
     while (*line != '#') {
       strcat(entry, strcat(line, "\r\n"));
       get_one_line(fl, line);
     }

     el.min_level = 0;
     if ((*line == '#') && (*(line + 1) != 0))
       el.min_level = atoi((line + 1));

     el.min_level = MAX(0, MIN(el.min_level, LVL_IMPL));

     /* now, add the entry to the index with each keyword on the keyword
line */
     el.entry = str_dup(entry);
     el.keywords = str_dup(key);

     help_table[top_of_helpt] = el;
     top_of_helpt++;

     /* get next keyword line (or $) */
     get_one_line(fl, key);
   }
}


char *ALLCAP(char *txt)
{
   char *ptr;

   for (ptr = txt; *ptr; ptr++)
     *ptr = UPPER(*ptr);

   return (txt);
}

-----------------------------------------------

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT