[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.59 and 1.61

version 1.59, 2017/08/23 10:50:15 version 1.61, 2018/05/20 21:37:34
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@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 above   * purpose with or without fee is hereby granted, provided that the above
Line 21 
Line 21 
   
 #include <assert.h>  #include <assert.h>
 #if HAVE_WCHAR  #if HAVE_WCHAR
   #include <langinfo.h>
 #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 <string.h>
 #include <unistd.h>  #include <unistd.h>
 #if HAVE_WCHAR  #if HAVE_WCHAR
 #include <wchar.h>  #include <wchar.h>
Line 100  ascii_init(enum termenc enc, const struct manoutput *o
Line 102  ascii_init(enum termenc enc, const struct manoutput *o
                 v = TERMENC_LOCALE == enc ?                  v = TERMENC_LOCALE == enc ?
                     setlocale(LC_CTYPE, "") :                      setlocale(LC_CTYPE, "") :
                     setlocale(LC_CTYPE, UTF8_LOCALE);                      setlocale(LC_CTYPE, UTF8_LOCALE);
                 if (NULL != v && MB_CUR_MAX > 1) {  
                   /*
                    * We only support UTF-8,
                    * so revert to ASCII for anything else.
                    */
   
                   if (v != NULL &&
                       strcmp(nl_langinfo(CODESET), "UTF-8") != 0)
                           v = setlocale(LC_CTYPE, "C");
   
                   if (v != NULL && MB_CUR_MAX > 1) {
                         p->enc = enc;                          p->enc = enc;
                         p->advance = locale_advance;                          p->advance = locale_advance;
                         p->endline = locale_endline;                          p->endline = locale_endline;
Line 121  ascii_init(enum termenc enc, const struct manoutput *o
Line 133  ascii_init(enum termenc enc, const struct manoutput *o
         if (outopts->synopsisonly)          if (outopts->synopsisonly)
                 p->synopsisonly = 1;                  p->synopsisonly = 1;
   
           assert(p->defindent < UINT16_MAX);
           assert(p->defrmargin < UINT16_MAX);
         return p;          return p;
 }  }
   
Line 159  ascii_setwidth(struct termp *p, int iop, int width)
Line 173  ascii_setwidth(struct termp *p, int iop, int width)
                 p->defrmargin -= width;                  p->defrmargin -= width;
         else          else
                 p->defrmargin = 0;                  p->defrmargin = 0;
           if (p->defrmargin > 1000)
                   p->defrmargin = 1000;
         p->lastrmargin = p->tcol->rmargin;          p->lastrmargin = p->tcol->rmargin;
         p->tcol->rmargin = p->maxrmargin = p->defrmargin;          p->tcol->rmargin = p->maxrmargin = p->defrmargin;
 }  }
Line 227  ascii_advance(struct termp *p, size_t len)
Line 243  ascii_advance(struct termp *p, size_t len)
 {  {
         size_t          i;          size_t          i;
   
           assert(len < UINT16_MAX);
         for (i = 0; i < len; i++)          for (i = 0; i < len; i++)
                 putchar(' ');                  putchar(' ');
 }  }
Line 364  locale_advance(struct termp *p, size_t len)
Line 381  locale_advance(struct termp *p, size_t len)
 {  {
         size_t          i;          size_t          i;
   
           assert(len < UINT16_MAX);
         for (i = 0; i < len; i++)          for (i = 0; i < len; i++)
                 putwchar(L' ');                  putwchar(L' ');
 }  }

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

CVSweb