[OLC] A problem with hedit

From: Jason Yarber (JasonYarber@hotmail.com)
Date: 06/07/02


I thank Torgny for this.  I've been working on my problem with the help
files for about three months before I posted here.
The problem was that everytime the help files were being loaded, an extra
line was being added to the beginning and end of the
entries.  Torgny suggested that I remove the line under /* get the first
keyword line */, so I did, and I noticed that extra lines
were no longer being added to the beginning of the entry.  That got me on
the right path, because I was unsure if my problem
was in the loading or saving.  His advice proved to me that it was in the
loading.  So I worked for a few hours after that, to
solve the problem.  Below is a copy of the original load_help function:

 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);
    }
 }

Below is a copy of my new load_help function.  I've done this so that anyone
else who has this problem, now has a cure.

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

  /* get the keyword line */
  get_one_line(fl, key);
  while (*key != '$') {
    END_ENTRY = FALSE;
    /* read in the corresponding help entry */
    get_one_line(fl, line);
    get_one_line(fl, line2);
    *entry = '\0';

    while(!END_ENTRY) {
      if(*line2 == '#') {
        strcat(entry, line);
        strcpy(line, line2);
        END_ENTRY = TRUE;
      }
      else {
        strcat(entry, strcat(line, "\r\n"));
        strcpy(line, line2);
        get_one_line(fl, line2);
      }
    }

    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);
  }
}

--
   +---------------------------------------------------------------+
   | 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