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

Diff for /mandoc/chars.c between version 1.38 and 1.44

version 1.38, 2011/04/30 22:14:42 version 1.44, 2011/05/17 11:50:20
Line 20 
Line 20 
 #endif  #endif
   
 #include <assert.h>  #include <assert.h>
   #include <ctype.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   
 #include "mandoc.h"  #include "mandoc.h"
   #include "libmandoc.h"
   
 #define PRINT_HI         126  #define PRINT_HI         126
 #define PRINT_LO         32  #define PRINT_LO         32
Line 135  mchars_res2cp(struct mchars *arg, const char *p, size_
Line 137  mchars_res2cp(struct mchars *arg, const char *p, size_
         return(ln->unicode);          return(ln->unicode);
 }  }
   
   
 /*  /*
  * Numbered character to literal character,   * Numbered character string to ASCII codepoint.
  * represented as a null-terminated string for additional safety.   * This can only be a printable character (i.e., alnum, punct, space) so
    * prevent the character from ruining our state (backspace, newline, and
    * so on).
    * If the character is illegal, returns '\0'.
  */   */
 const char *  char
 mchars_num2char(const char *p, size_t sz)  mchars_num2char(const char *p, size_t sz)
 {  {
         int               i;          int               i;
         static char       c[2];  
   
         if (sz > 3)          if ((i = mandoc_strntou(p, sz, 10)) < 0)
                 return(NULL);                  return('\0');
         i = atoi(p);          return(isprint(i) ? i : '\0');
         if (i < 0 || i > 255)  
                 return(NULL);  
         c[0] = (char)i;  
         c[1] = '\0';  
         return(c);  
 }  }
   
   /*
    * Hex character string to Unicode codepoint.
    * If the character is illegal, returns '\0'.
    */
   int
   mchars_num2uc(const char *p, size_t sz)
   {
           int               i;
   
           if ((i = mandoc_strntou(p, sz, 16)) < 0)
                   return('\0');
           /* FIXME: make sure we're not in a bogus range. */
           return(i > 0x80 && i <= 0x10FFFF ? i : '\0');
   }
   
 /*  /*
  * Special character to string array.   * Special character to string array.
  */   */
Line 172  mchars_spec2str(struct mchars *arg, const char *p, siz
Line 184  mchars_spec2str(struct mchars *arg, const char *p, siz
         *rsz = strlen(ln->ascii);          *rsz = strlen(ln->ascii);
         return(ln->ascii);          return(ln->ascii);
 }  }
   
   
 /*  /*
  * Reserved word to string array.   * Reserved word to string array.

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.44

CVSweb