"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "preconv.c" between
mdocml-1.14.1rc1.tar.gz and mdocml-1.14.1rc2.tar.gz

About: mdocml is a suite of tools compiling "-mdoc", the roff macro package of choice for BSD manual pages, and "-man", the predominant historical package for UNIX manuals. Hint: The installed binary name is "mandoc". Release candidate.

preconv.c  (mdocml-1.14.1rc1):preconv.c  (mdocml-1.14.1rc2)
/* $Id: preconv.c,v 1.15 2015/10/06 18:32:19 schwarze Exp $ */ /* $Id: preconv.c,v 1.16 2017/02/18 13:43:52 schwarze Exp $ */
/* /*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2014 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
* copyright notice and this permission notice appear in all copies. * copyright notice and this permission notice appear in all copies.
* *
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
skipping to change at line 29 skipping to change at line 29
#include <sys/types.h> #include <sys/types.h>
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "mandoc.h" #include "mandoc.h"
#include "libmandoc.h" #include "libmandoc.h"
int int
preconv_encode(struct buf *ib, size_t *ii, struct buf *ob, size_t *oi, preconv_encode(const struct buf *ib, size_t *ii, struct buf *ob, size_t *oi,
int *filenc) int *filenc)
{ {
unsigned char *cu; const unsigned char *cu;
int nby; int nby;
unsigned int accum; unsigned int accum;
cu = (unsigned char *)ib->buf + *ii; cu = (const unsigned char *)ib->buf + *ii;
assert(*cu & 0x80); assert(*cu & 0x80);
if ( ! (*filenc & MPARSE_UTF8)) if ( ! (*filenc & MPARSE_UTF8))
goto latin; goto latin;
nby = 1; nby = 1;
while (nby < 5 && *cu & (1 << (7 - nby))) while (nby < 5 && *cu & (1 << (7 - nby)))
nby++; nby++;
switch (nby) { switch (nby) {
skipping to change at line 93 skipping to change at line 93
accum <<= 6; accum <<= 6;
accum += *cu & 0x3f; accum += *cu & 0x3f;
cu++; cu++;
} }
assert(accum > 0x7f); assert(accum > 0x7f);
assert(accum < 0x110000); assert(accum < 0x110000);
assert(accum < 0xd800 || accum > 0xdfff); assert(accum < 0xd800 || accum > 0xdfff);
*oi += snprintf(ob->buf + *oi, 11, "\\[u%.4X]", accum); *oi += snprintf(ob->buf + *oi, 11, "\\[u%.4X]", accum);
*ii = (char *)cu - ib->buf; *ii = (const char *)cu - ib->buf;
*filenc &= ~MPARSE_LATIN1; *filenc &= ~MPARSE_LATIN1;
return 1; return 1;
latin: latin:
if ( ! (*filenc & MPARSE_LATIN1)) if ( ! (*filenc & MPARSE_LATIN1))
return 0; return 0;
*oi += snprintf(ob->buf + *oi, 11, *oi += snprintf(ob->buf + *oi, 11,
"\\[u%.4X]", (unsigned char)ib->buf[(*ii)++]); "\\[u%.4X]", (unsigned char)ib->buf[(*ii)++]);
 End of changes. 5 change blocks. 
7 lines changed or deleted 7 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS