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

Diff for /mandoc/Attic/ascii.c between version 1.2 and 1.7

version 1.2, 2009/03/17 13:35:46 version 1.7, 2009/04/12 19:45:26
Line 1 
Line 1 
 /* $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>   * Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
  *   *
  * 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   * purpose with or without fee is hereby granted, provided that the above
  * above copyright notice and this permission notice appear in all   * copyright notice and this permission notice appear in all copies.
  * copies.  
  *   *
  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED   * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE   * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL   * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR   * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  * PERFORMANCE OF THIS SOFTWARE.  
  */   */
 #include <assert.h>  #include <assert.h>
 #include <err.h>  #include <err.h>
Line 26 
Line 24 
 #define ASCII_PRINT_HI   126  #define ASCII_PRINT_HI   126
 #define ASCII_PRINT_LO   32  #define ASCII_PRINT_LO   32
   
 /*  
  * Lookup and hashing routines for constructing the ASCII symbol table,  
  * which should contain a significant portion of mdoc(7)'s special  
  * symbols.  
  */  
   
 struct  line {  struct  line {
         const char       *code;          const char       *code;
         const char       *out;          const char       *out;
Line 62  static inline int   match(const struct line *,
Line 54  static inline int   match(const struct line *,
   
   
 void  void
 asciifree(void *arg)  term_asciifree(void *arg)
 {  {
         struct asciitab *tab;          struct asciitab *tab;
   
Line 75  asciifree(void *arg)
Line 67  asciifree(void *arg)
   
   
 void *  void *
 ascii2htab(void)  term_ascii2htab(void)
 {  {
         struct asciitab  *tab;          struct asciitab  *tab;
         void            **htab;          void            **htab;
Line 92  ascii2htab(void)
Line 84  ascii2htab(void)
         if (NULL == (tab = malloc(sizeof(struct asciitab))))          if (NULL == (tab = malloc(sizeof(struct asciitab))))
                 err(1, "malloc");                  err(1, "malloc");
   
         assert(0 == sizeof(lines) % sizeof(struct line));  
         len = sizeof(lines) / sizeof(struct line);          len = sizeof(lines) / sizeof(struct line);
   
         if (NULL == (p = calloc((size_t)len, sizeof(struct linep))))          if (NULL == (p = calloc((size_t)len, sizeof(struct linep))))
Line 132  ascii2htab(void)
Line 123  ascii2htab(void)
   
   
 const char *  const char *
 a2ascii(void *arg, const char *p, size_t sz, size_t *rsz)  term_a2ascii(void *arg, const char *p, size_t sz, size_t *rsz)
 {  {
         struct asciitab  *tab;          struct asciitab  *tab;
         struct linep     *pp, *prev;          struct linep     *pp, *prev;
Line 144  a2ascii(void *arg, const char *p, size_t sz, size_t *r
Line 135  a2ascii(void *arg, const char *p, size_t sz, size_t *r
   
         assert(p);          assert(p);
         assert(sz > 0);          assert(sz > 0);
         assert(p[0] >= ASCII_PRINT_LO && p[0] <= ASCII_PRINT_HI);  
           if (p[0] < ASCII_PRINT_LO || p[0] > ASCII_PRINT_HI)
                   return(NULL);
   
   
         /*          /*
          * Lookup the symbol in the symbol hash.  See ascii2htab for the           * Lookup the symbol in the symbol hash.  See ascii2htab for the

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

CVSweb