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

Diff for /mandoc/preconv.c between version 1.10 and 1.11

version 1.10, 2014/10/26 18:22:51 version 1.11, 2014/11/01 04:08:43
Line 25 
Line 25 
 #include "libmandoc.h"  #include "libmandoc.h"
   
 int  int
 preconv_encode(struct buf *ib, struct buf *ob, int *filenc)  preconv_encode(struct buf *ib, size_t *ii, struct buf *ob, size_t *oi,
       int *filenc)
 {  {
         size_t           i;          size_t           i;
         const long       one = 1L;          const long       one = 1L;
Line 45  preconv_encode(struct buf *ib, struct buf *ob, int *fi
Line 46  preconv_encode(struct buf *ib, struct buf *ob, int *fi
         if ( ! (*((const char *)(&one))))          if ( ! (*((const char *)(&one))))
                 be = 1;                  be = 1;
   
         for (i = ib->offs; i < ib->sz; i++) {          for (i = *ii; i < ib->sz; i++) {
                 cu = ib->buf[i];                  cu = ib->buf[i];
                 if (state) {                  if (state) {
                         if ( ! (cu & 128) || (cu & 64)) {                          if ( ! (cu & 128) || (cu & 64)) {
Line 79  preconv_encode(struct buf *ib, struct buf *ob, int *fi
Line 80  preconv_encode(struct buf *ib, struct buf *ob, int *fi
                                         (accum << 24);                                          (accum << 24);
   
                         if (accum < 0x80)                          if (accum < 0x80)
                                 ob->buf[ob->offs++] = accum;                                  ob->buf[(*oi)++] = accum;
                         else                          else
                                 ob->offs += snprintf(ob->buf + ob->offs,                                  *oi += snprintf(ob->buf + *oi,
                                     11, "\\[u%.4X]", accum);                                      11, "\\[u%.4X]", accum);
                         ib->offs = i + 1;                          *ii = i + 1;
                         *filenc &= ~MPARSE_LATIN1;                          *filenc &= ~MPARSE_LATIN1;
                         return(1);                          return(1);
                 } else {                  } else {
Line 134  latin:
Line 135  latin:
         if ( ! (*filenc & MPARSE_LATIN1))          if ( ! (*filenc & MPARSE_LATIN1))
                 return(0);                  return(0);
   
         ob->offs += snprintf(ob->buf + ob->offs, 11,          *oi += snprintf(ob->buf + *oi, 11,
             "\\[u%.4X]", (unsigned char)ib->buf[ib->offs++]);              "\\[u%.4X]", (unsigned char)ib->buf[(*ii)++]);
   
         *filenc &= ~MPARSE_UTF8;          *filenc &= ~MPARSE_UTF8;
         return(1);          return(1);
 }  }
   
 int  int
 preconv_cue(const struct buf *b)  preconv_cue(const struct buf *b, size_t offset)
 {  {
         const char      *ln, *eoln, *eoph;          const char      *ln, *eoln, *eoph;
         size_t           sz, phsz;          size_t           sz, phsz;
   
         ln = b->buf + b->offs;          ln = b->buf + offset;
         sz = b->sz - b->offs;          sz = b->sz - offset;
   
         /* Look for the end-of-line. */          /* Look for the end-of-line. */
   

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

CVSweb