[BACK]Return to man_hash.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/Attic/man_hash.c between version 1.7 and 1.11

version 1.7, 2009/04/12 19:45:26 version 1.11, 2009/08/19 09:14:50
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>   * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 37  man_hash_alloc(void)
Line 37  man_hash_alloc(void)
         int             *htab;          int             *htab;
         int              i, j, x;          int              i, j, x;
   
         htab = calloc(26 * 5, sizeof(int));          /* Initialised to -1. */
   
           htab = malloc(26 * 6 * sizeof(int));
         if (NULL == htab)          if (NULL == htab)
                 return(NULL);                  return(NULL);
           for (i = 0; i < 26 * 6; i++)
                   htab[i] = -1;
   
         for (i = 1; i < MAN_MAX; i++) {          for (i = 0; i < MAN_MAX; i++) {
                 x = man_macronames[i][0];                  x = man_macronames[i][0];
   
                 assert((x >= 65 && x <= 90) ||                  assert((x >= 65 && x <= 90) ||
                                 (x >= 97 && x <= 122));                                  (x >= 97 && x <= 122));
   
                 x -= (x <= 90) ? 65 : 97;                  x -= (x <= 90) ? 65 : 97;
                 x *= 5;                  x *= 6;
   
                 for (j = 0; j < 5; j++)                  for (j = 0; j < 6; j++)
                         if (0 == htab[x + j]) {                          if (-1 == htab[x + j]) {
                                 htab[x + j] = i;                                  htab[x + j] = i;
                                 break;                                  break;
                         }                          }
   
                 assert(j < 5);                  assert(j < 6);
         }          }
   
         return((void *)htab);          return((void *)htab);
Line 77  man_hash_find(const void *arg, const char *tmp)
Line 81  man_hash_find(const void *arg, const char *tmp)
                 return(MAN_MAX);                  return(MAN_MAX);
   
         x -= (x <= 90) ? 65 : 97;          x -= (x <= 90) ? 65 : 97;
         x *= 5;          x *= 6;
   
         for (i = 0; i < 5; i++) {          for (i = 0; i < 6; i++) {
                 if (0 == (tok = htab[x + i]))                  if (-1 == (tok = htab[x + i]))
                         return(MAN_MAX);                          return(MAN_MAX);
                 if (0 == strcmp(tmp, man_macronames[tok]))                  if (0 == strcmp(tmp, man_macronames[tok]))
                         return(tok);                          return(tok);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.11

CVSweb