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

Diff for /mandoc/chars.c between version 1.53 and 1.59

version 1.53, 2013/05/18 16:40:15 version 1.59, 2014/08/10 23:54:41
Line 15 
Line 15 
  * 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"  #include "config.h"
 #endif  
   
   #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  #include <ctype.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   
 #include "mandoc.h"  #include "mandoc.h"
   #include "mandoc_aux.h"
 #include "libmandoc.h"  #include "libmandoc.h"
   
 #define PRINT_HI         126  #define PRINT_HI         126
Line 37  struct ln {
Line 38  struct ln {
         int               unicode;          int               unicode;
 };  };
   
 #define LINES_MAX         328  #define LINES_MAX         330
   
 #define CHAR(in, ch, code) \  #define CHAR(in, ch, code) \
         { NULL, (in), (ch), (code) },          { NULL, (in), (ch), (code) },
Line 51  struct mchars {
Line 52  struct mchars {
         struct ln       **htab;          struct ln       **htab;
 };  };
   
 static  const struct ln  *find(const struct mchars *,  static  const struct ln  *find(const struct mchars *,
                                 const char *, size_t);                                  const char *, size_t);
   
   
 void  void
 mchars_free(struct mchars *arg)  mchars_free(struct mchars *arg)
 {  {
Line 110  mchars_spec2cp(const struct mchars *arg, const char *p
Line 112  mchars_spec2cp(const struct mchars *arg, const char *p
 char  char
 mchars_num2char(const char *p, size_t sz)  mchars_num2char(const char *p, size_t sz)
 {  {
         int               i;          int       i;
   
         if ((i = mandoc_strntoi(p, sz, 10)) < 0)          if ((i = mandoc_strntoi(p, sz, 10)) < 0)
                 return('\0');                  return('\0');
         return(i > 0 && i < 256 && isprint(i) ?  
                         /* LINTED */ i : '\0');          return(i > 0 && i < 256 && isprint(i) ? i : '\0');
 }  }
   
 int  int
 mchars_num2uc(const char *p, size_t sz)  mchars_num2uc(const char *p, size_t sz)
 {  {
         int               i;          int      i;
   
         if ((i = mandoc_strntoi(p, sz, 16)) < 0)          if ((i = mandoc_strntoi(p, sz, 16)) < 0)
                 return('\0');                  return('\0');
         /* FIXME: make sure we're not in a bogus range. */  
           /*
            * Security warning:
            * Never extend the range of accepted characters
            * to overlap with the ASCII range, 0x00-0x7F
            * without re-auditing the callers of this function.
            * Some callers might relay on the fact that we never
            * return ASCII characters for their escaping decisions.
            *
            * XXX Code is missing here to exclude bogus ranges.
            */
   
         return(i > 0x80 && i <= 0x10FFFF ? i : '\0');          return(i > 0x80 && i <= 0x10FFFF ? i : '\0');
 }  }
   
 const char *  const char *
 mchars_spec2str(const struct mchars *arg,  mchars_spec2str(const struct mchars *arg,
                 const char *p, size_t sz, size_t *rsz)                  const char *p, size_t sz, size_t *rsz)
 {  {
         const struct ln *ln;          const struct ln *ln;
Line 159  find(const struct mchars *tab, const char *p, size_t s
Line 172  find(const struct mchars *tab, const char *p, size_t s
         hash = (int)p[0] - PRINT_LO;          hash = (int)p[0] - PRINT_LO;
   
         for (pp = tab->htab[hash]; pp; pp = pp->next)          for (pp = tab->htab[hash]; pp; pp = pp->next)
                 if (0 == strncmp(pp->code, p, sz) &&                  if (0 == strncmp(pp->code, p, sz) &&
                                 '\0' == pp->code[(int)sz])                      '\0' == pp->code[(int)sz])
                         return(pp);                          return(pp);
   
         return(NULL);          return(NULL);

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.59

CVSweb