Re: Abbrv

From: Bejhan Jetha (nhlstar6@yahoo.com)
Date: 03/08/02


>handler.c: In function `isname':
>handler.c:87: warning: implicit declaration of function `single_isname'

I also noticed this bug. D Tyler Barnes kindly rewrote the code. I'll
post it here for anyone who wants it:

Do all that the old improved isname snippet says accept instead of
adding the improved isname before the original isname, replace the
entire isname function with this:

/* isname with abbreviations by D Tyler Barnes */
int isname(const char *str, const char *namelist) {

   const char *curname = namelist;

   for (;;) {
      if (is_abbrev(str, curname))
         return(1);

      for (; isalpha(*curname); curname++);

      if (!*curname)
         return(0);
      curname++;
   }
}

/* Old stock isname, no abbreviations */
int isname_noabbrev(const char *str, const char *namelist)
{
  const char *curname, *curstr;

  curname = namelist;
  for (;;) {
    for (curstr = str;; curstr++, curname++) {
      if (!*curstr && !isalpha(*curname))
   return (1);

      if (!*curname)
   return (0);

      if (!*curstr || *curname == ' ')
   break;

      if (LOWER(*curstr) != LOWER(*curname))
   break;
    }

    /* skip to next name */

    for (; isalpha(*curname); curname++);
    if (!*curname)
      return (0);
    curname++;       /* first char of new name */
  }
}



and instead of replacing get_number with what they have replace it with:

// beginning of new get_number function
int get_number(char **name)
{
  int i;
  char number[MAX_INPUT_LENGTH], *ppos;

  /*
   * These lines was added to make possible the dot sign to be used as a
magic
   * char on isname() function.
   */
  if (!isdigit(**name))
    return (1);

  if ((ppos = strchr(*name, '.')) != NULL) {
    *ppos++ = '\0';
    strcpy(number, *name);
    strcpy(*name, ppos);

    for (i = 0; *(number + i); i++)
      if (!isdigit(*(number + i)))
        return (0);

    return (atoi(number));
  }
  return (1);
} // thought to be an error
  // end of new get_number function


Hope this helps,
Bejhan Jetha


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

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