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

Diff for /mandoc/term_ascii.c between version 1.30 and 1.36

version 1.30, 2014/08/14 22:33:10 version 1.36, 2014/10/26 18:12:28
Line 19 
Line 19 
   
 #include <sys/types.h>  #include <sys/types.h>
   
 #ifdef USE_WCHAR  #if HAVE_WCHAR
 #include <locale.h>  #include <locale.h>
 #endif  #endif
 #include <stdint.h>  #include <stdint.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <unistd.h>  #include <unistd.h>
 #ifdef USE_WCHAR  #if HAVE_WCHAR
 #include <wchar.h>  #include <wchar.h>
 #endif  #endif
   
Line 36 
Line 36 
 #include "term.h"  #include "term.h"
 #include "main.h"  #include "main.h"
   
 /*  
  * Sadly, this doesn't seem to be defined on systems even when they  
  * support it.  For the time being, remove it and let those compiling  
  * the software decide for themselves what to use.  
  */  
 #if 0  
 #if ! defined(__STDC_ISO_10646__)  
 # undef USE_WCHAR  
 #endif  
 #endif  
   
 static  struct termp     *ascii_init(enum termenc, char *);  static  struct termp     *ascii_init(enum termenc, char *);
 static  double            ascii_hspan(const struct termp *,  static  double            ascii_hspan(const struct termp *,
                                 const struct roffsu *);                                  const struct roffsu *);
Line 58  static void    ascii_endline(struct termp *);
Line 47  static void    ascii_endline(struct termp *);
 static  void              ascii_letter(struct termp *, int);  static  void              ascii_letter(struct termp *, int);
 static  void              ascii_setwidth(struct termp *, int, size_t);  static  void              ascii_setwidth(struct termp *, int, size_t);
   
 #ifdef  USE_WCHAR  #if HAVE_WCHAR
 static  void              locale_advance(struct termp *, size_t);  static  void              locale_advance(struct termp *, size_t);
 static  void              locale_endline(struct termp *);  static  void              locale_endline(struct termp *);
 static  void              locale_letter(struct termp *, int);  static  void              locale_letter(struct termp *, int);
Line 69  static size_t    locale_width(const struct termp *, in
Line 58  static size_t    locale_width(const struct termp *, in
 static struct termp *  static struct termp *
 ascii_init(enum termenc enc, char *outopts)  ascii_init(enum termenc enc, char *outopts)
 {  {
         const char      *toks[4];          const char      *toks[5];
         char            *v;          char            *v;
         struct termp    *p;          struct termp    *p;
   
Line 90  ascii_init(enum termenc enc, char *outopts)
Line 79  ascii_init(enum termenc enc, char *outopts)
         p->setwidth = ascii_setwidth;          p->setwidth = ascii_setwidth;
         p->width = ascii_width;          p->width = ascii_width;
   
 #ifdef  USE_WCHAR  #if HAVE_WCHAR
         if (TERMENC_ASCII != enc) {          if (TERMENC_ASCII != enc) {
                 v = TERMENC_LOCALE == enc ?                  v = TERMENC_LOCALE == enc ?
                     setlocale(LC_ALL, "") :                      setlocale(LC_ALL, "") :
Line 108  ascii_init(enum termenc enc, char *outopts)
Line 97  ascii_init(enum termenc enc, char *outopts)
         toks[0] = "indent";          toks[0] = "indent";
         toks[1] = "width";          toks[1] = "width";
         toks[2] = "mdoc";          toks[2] = "mdoc";
         toks[3] = NULL;          toks[3] = "synopsis";
           toks[4] = NULL;
   
         while (outopts && *outopts)          while (outopts && *outopts)
                 switch (getsubopt(&outopts, UNCONST(toks), &v)) {                  switch (getsubopt(&outopts, UNCONST(toks), &v)) {
Line 126  ascii_init(enum termenc enc, char *outopts)
Line 116  ascii_init(enum termenc enc, char *outopts)
                         p->mdocstyle = 1;                          p->mdocstyle = 1;
                         p->defindent = 5;                          p->defindent = 5;
                         break;                          break;
                   case 3:
                           p->synopsisonly = 1;
                           break;
                 default:                  default:
                         break;                          break;
                 }                  }
Line 264  ascii_hspan(const struct termp *p, const struct roffsu
Line 257  ascii_hspan(const struct termp *p, const struct roffsu
         case SCALE_EM:          case SCALE_EM:
                 r = su->scale;                  r = su->scale;
                 break;                  break;
         case SCALE_MAX:          default:
                 abort();                  abort();
                 /* NOTREACHED */                  /* NOTREACHED */
         }          }
Line 272  ascii_hspan(const struct termp *p, const struct roffsu
Line 265  ascii_hspan(const struct termp *p, const struct roffsu
         return(r);          return(r);
 }  }
   
 #ifdef USE_WCHAR  const char *
   ascii_uc2str(int uc)
   {
           static const char nbrsp[2] = { ASCII_NBRSP, '\0' };
           static const char *tab[] = {
           "<NUL>","<SOH>","<STX>","<ETX>","<EOT>","<ENQ>","<ACK>","<BEL>",
           "<BS>", "\t",   "<LF>", "<VT>", "<FF>", "<CR>", "<SO>", "<SI>",
           "<DLE>","<DC1>","<DC2>","<DC3>","<DC4>","<NAK>","<SYN>","<ETB>",
           "<CAN>","<EM>", "<SUB>","<ESC>","<FS>", "<GS>", "<RS>", "<US>",
           " ",    "!",    "\"",   "#",    "$",    "%",    "&",    "'",
           "(",    ")",    "*",    "+",    ",",    "-",    ".",    "/",
           "0",    "1",    "2",    "3",    "4",    "5",    "6",    "7",
           "8",    "9",    ":",    ";",    "<",    "=",    ">",    "?",
           "@",    "A",    "B",    "C",    "D",    "E",    "F",    "G",
           "H",    "I",    "J",    "K",    "L",    "M",    "N",    "O",
           "P",    "Q",    "R",    "S",    "T",    "U",    "V",    "W",
           "X",    "Y",    "Z",    "[",    "\\",   "]",    "^",    "_",
           "`",    "a",    "b",    "c",    "d",    "e",    "f",    "g",
           "h",    "i",    "j",    "k",    "l",    "m",    "n",    "o",
           "p",    "q",    "r",    "s",    "t",    "u",    "v",    "w",
           "x",    "y",    "z",    "{",    "|",    "}",    "~",    "<DEL>",
           "<80>", "<81>", "<82>", "<83>", "<84>", "<85>", "<86>", "<87>",
           "<88>", "<89>", "<8A>", "<8B>", "<8C>", "<8D>", "<8E>", "<8F>",
           "<90>", "<91>", "<92>", "<93>", "<94>", "<95>", "<96>", "<97>",
           "<99>", "<99>", "<9A>", "<9B>", "<9C>", "<9D>", "<9E>", "<9F>",
           nbrsp,  "!",    "c",    "GBP",  "$?",   "Y=",   "|",    "<sec>",
           "\"",   "(C)",  "a.",   "<<",   "<not>","",     "(R)",  "-",
           "<deg>","+-",   "^2",   "^3",   "'",    "<my>", "<par>","*",
           ",",    "^1",   "o.",   ">>",   "1/4",  "1/2",  "3/4",  "?",
           "A",    "A",    "A",    "A",    "Ae",   "Aa",   "AE",   "C",
           "E",    "E",    "E",    "E",    "I",    "I",    "I",    "I",
           "D",    "N",    "O",    "O",    "O",    "O",    "Oe",   "*",
           "Oe",   "U",    "U",    "U",    "Ue",   "Y",    "Th",   "ss",
           "a",    "a",    "a",    "a",    "ae",   "aa",   "ae",   "c",
           "e",    "e",    "e",    "e",    "i",    "i",    "i",    "i",
           "d",    "n",    "o",    "o",    "o",    "o",    "oe",   "/",
           "oe",   "u",    "u",    "u",    "ue",   "y",    "th",   "y",
           "A",    "a",    "A",    "a",    "A",    "a",    "C",    "c",
           "C",    "c",    "C",    "c",    "C",    "c",    "D",    "d",
           "D",    "d",    "E",    "e",    "E",    "e",    "E",    "e",
           "E",    "e",    "E",    "e",    "G",    "g",    "G",    "g",
           "G",    "g",    "G",    "g",    "H",    "h",    "H",    "h",
           "I",    "i",    "I",    "i",    "I",    "i",    "I",    "i",
           "I",    "i",    "IJ",   "ij",   "J",    "j",    "K",    "k",
           "q",    "L",    "l",    "L",    "l",    "L",    "l",    "L",
           "l",    "L",    "l",    "N",    "n",    "N",    "n",    "N",
           "n",    "'n",   "Ng",   "ng",   "O",    "o",    "O",    "o",
           "O",    "o",    "OE",   "oe",   "R",    "r",    "R",    "r",
           "R",    "r",    "S",    "s",    "S",    "s",    "S",    "s",
           "S",    "s",    "T",    "t",    "T",    "t",    "T",    "t",
           "U",    "u",    "U",    "u",    "U",    "u",    "U",    "u",
           "U",    "u",    "U",    "u",    "W",    "w",    "Y",    "y",
           "Y",    "Z",    "z",    "Z",    "z",    "Z",    "z",    "s",
           "b",    "B",    "B",    "b",    "6",    "6",    "O",    "C",
           "c",    "D",    "D",    "D",    "d",    "d",    "3",    "@",
           "E",    "F",    "f",    "G",    "G",    "hv",   "I",    "I",
           "K",    "k",    "l",    "l",    "W",    "N",    "n",    "O",
           "O",    "o",    "OI",   "oi",   "P",    "p",    "YR",   "2",
           "2",    "SH",   "sh",   "t",    "T",    "t",    "T",    "U",
           "u",    "Y",    "V",    "Y",    "y",    "Z",    "z",    "ZH",
           "ZH",   "zh",   "zh",   "2",    "5",    "5",    "ts",   "w",
           "|",    "||",   "|=",   "!",    "DZ",   "Dz",   "dz",   "LJ",
           "Lj",   "lj",   "NJ",   "Nj",   "nj",   "A",    "a",    "I",
           "i",    "O",    "o",    "U",    "u",    "U",    "u",    "U",
           "u",    "U",    "u",    "U",    "u",    "@",    "A",    "a",
           "A",    "a",    "AE",   "ae",   "G",    "g",    "G",    "g",
           "K",    "k",    "O",    "o",    "O",    "o",    "ZH",   "zh",
           "j",    "DZ",   "D",    "dz",   "G",    "g",    "HV",   "W",
           "N",    "n",    "A",    "a",    "AE",   "ae",   "O",    "o"};
   
           if (uc < 0)
                   return("<?>");
           if ((size_t)uc < sizeof(tab)/sizeof(tab[0]))
                   return(tab[uc]);
           return(mchars_uc2str(uc));
   }
   
   #if HAVE_WCHAR
 static size_t  static size_t
 locale_width(const struct termp *p, int c)  locale_width(const struct termp *p, int c)
 {  {

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.36

CVSweb