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

Diff for /mandoc/chars.c between version 1.3 and 1.18

version 1.3, 2009/09/22 10:07:01 version 1.18, 2010/05/25 12:37:20
Line 14 
Line 14 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
   #ifdef HAVE_CONFIG_H
   #include "config.h"
   #endif
   
 #include <assert.h>  #include <assert.h>
 #include <err.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   
   #include "mandoc.h"
 #include "chars.h"  #include "chars.h"
   
 #define PRINT_HI         126  #define PRINT_HI         126
Line 35  struct ln {
Line 40  struct ln {
         int               type;          int               type;
 #define CHARS_CHAR       (1 << 0)  #define CHARS_CHAR       (1 << 0)
 #define CHARS_STRING     (1 << 1)  #define CHARS_STRING     (1 << 1)
 #define CHARS_BOTH       (0x03)  #define CHARS_BOTH       (CHARS_CHAR | CHARS_STRING)
 };  };
   
 #define LINES_MAX         267  #define LINES_MAX         369
   
 #define CHAR(w, x, y, z, a, b) \  #define CHAR(w, x, y, z, a, b) \
         { NULL, (w), (y), (a), (x), (z), (b), CHARS_CHAR },          { NULL, (w), (y), (a), (x), (z), (b), CHARS_CHAR },
Line 47  struct ln {
Line 52  struct ln {
 #define BOTH(w, x, y, z, a, b) \  #define BOTH(w, x, y, z, a, b) \
         { NULL, (w), (y), (a), (x), (z), (b), CHARS_BOTH },          { NULL, (w), (y), (a), (x), (z), (b), CHARS_BOTH },
   
 static  struct ln lines[LINES_MAX] = {  #define CHAR_TBL_START    static struct ln lines[LINES_MAX] = {
   #define CHAR_TBL_END      };
   
 #include "chars.in"  #include "chars.in"
 };  
   
 struct  tbl {  struct  tbl {
         enum chars        type;          enum chars        type;
Line 89  chars_init(enum chars type)
Line 95  chars_init(enum chars type)
          * (they're in-line re-ordered during lookup).           * (they're in-line re-ordered during lookup).
          */           */
   
         if (NULL == (tab = malloc(sizeof(struct tbl))))          tab = malloc(sizeof(struct tbl));
                 err(1, "malloc");          if (NULL == tab) {
         tab->type = type;                  perror(NULL);
                   exit(EXIT_FAILURE);
           }
   
         htab = calloc(PRINT_HI - PRINT_LO + 1, sizeof(struct ln **));          htab = calloc(PRINT_HI - PRINT_LO + 1, sizeof(struct ln **));
         if (NULL == htab)          if (NULL == htab) {
                 err(1, "malloc");                  perror(NULL);
                   exit(EXIT_FAILURE);
           }
   
         for (i = 0; i < LINES_MAX; i++) {          for (i = 0; i < LINES_MAX; i++) {
                 hash = (int)lines[i].code[0] - PRINT_LO;                  hash = (int)lines[i].code[0] - PRINT_LO;
Line 111  chars_init(enum chars type)
Line 121  chars_init(enum chars type)
         }          }
   
         tab->htab = htab;          tab->htab = htab;
           tab->type = type;
         return(tab);          return(tab);
 }  }
   
Line 155  find(struct tbl *tab, const char *p, size_t sz, size_t
Line 166  find(struct tbl *tab, const char *p, size_t sz, size_t
   
         if (NULL == (pp = htab[hash]))          if (NULL == (pp = htab[hash]))
                 return(NULL);                  return(NULL);
   
         if (NULL == pp->next) {  
                 if ( ! match(pp, p, sz, type))  
                         return(NULL);  
   
                 if (CHARS_HTML == tab->type) {  
                         *rsz = pp->htmlsz;  
                         return(pp->html);  
                 }  
                 *rsz = pp->asciisz;  
                 return(pp->ascii);  
         }  
   
         for (prev = NULL; pp; pp = pp->next) {          for (prev = NULL; pp; pp = pp->next) {
                 if ( ! match(pp, p, sz, type)) {                  if ( ! match(pp, p, sz, type)) {

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.18

CVSweb