aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-05-14 17:54:42 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-05-14 17:54:42 +0000
commit46b6fb73529e79de5452e9d25e26a7c8b83bd79f (patch)
tree9fdb49fd81c23696e74be71a6af9c0ad9db52d88
parente3ef897e17cf74a686ec213e362a869d4a9b77f0 (diff)
downloadmandoc-46b6fb73529e79de5452e9d25e26a7c8b83bd79f.tar.gz
mandoc-46b6fb73529e79de5452e9d25e26a7c8b83bd79f.tar.zst
mandoc-46b6fb73529e79de5452e9d25e26a7c8b83bd79f.zip
Make character engine (-Tascii, -Tpdf, -Tps) ready for Unicode: make buffer
consist of type "int". This will take more work (especially in encode and friends), but this is a strong start. This commit also consists of some harmless lint fixes.
-rw-r--r--chars.c5
-rw-r--r--mandoc.c4
-rw-r--r--term.c8
-rw-r--r--term.h8
-rw-r--r--term_ascii.c10
-rw-r--r--term_ps.c17
6 files changed, 28 insertions, 24 deletions
diff --git a/chars.c b/chars.c
index c33dedcf..6d9cf9d3 100644
--- a/chars.c
+++ b/chars.c
@@ -1,4 +1,4 @@
-/* $Id: chars.c,v 1.40 2011/05/01 08:38:56 kristaps Exp $ */
+/* $Id: chars.c,v 1.41 2011/05/14 17:54:42 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -151,7 +151,8 @@ mchars_num2char(const char *p, size_t sz)
return('\0');
i = atoi(p);
- return(isprint(i) ? (char)i : '\0');
+ /* LINTED */
+ return(isprint(i) ? i : '\0');
}
/*
diff --git a/mandoc.c b/mandoc.c
index 249a0dea..671f059a 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.50 2011/05/14 16:06:09 kristaps Exp $ */
+/* $Id: mandoc.c,v 1.51 2011/05/14 17:54:42 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -704,7 +704,7 @@ mandoc_strntou(const char *p, size_t sz, int base)
return(-1);
memcpy(buf, p, sz);
- buf[sz] = '\0';
+ buf[(int)sz] = '\0';
errno = 0;
v = strtol(buf, &ep, base);
diff --git a/term.c b/term.c
index 9b158e54..2810d620 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.186 2011/04/30 22:24:31 kristaps Exp $ */
+/* $Id: term.c,v 1.187 2011/05/14 17:54:42 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -532,7 +532,7 @@ adjbuf(struct termp *p, size_t sz)
while (sz >= p->maxcols)
p->maxcols <<= 2;
- p->buf = mandoc_realloc(p->buf, p->maxcols);
+ p->buf = mandoc_realloc(p->buf, sizeof(int) * p->maxcols);
}
@@ -562,8 +562,8 @@ encode(struct termp *p, const char *word, size_t sz)
if (TERMFONT_NONE == (f = term_fonttop(p))) {
if (p->col + sz >= p->maxcols)
adjbuf(p, p->col + sz);
- memcpy(&p->buf[(int)p->col], word, sz);
- p->col += sz;
+ for (i = 0; i < (int)sz; i++)
+ p->buf[(int)p->col++] = word[i];
return;
}
diff --git a/term.h b/term.h
index c1c9c457..f2b3db3d 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.80 2011/04/29 22:18:12 kristaps Exp $ */
+/* $Id: term.h,v 1.81 2011/05/14 17:54:42 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -103,7 +103,7 @@ struct termp {
#define TERMP_ANPREC (1 << 13) /* See termp_an_pre(). */
#define TERMP_KEEP (1 << 14) /* Keep words together. */
#define TERMP_PREKEEP (1 << 15) /* ...starting with the next one. */
- char *buf; /* Output buffer. */
+ int *buf; /* Output buffer. */
enum termenc enc; /* Type of encoding. */
struct mchars *symtab; /* Encoded-symbol table. */
enum termfont fontl; /* Last font set. */
@@ -111,12 +111,12 @@ struct termp {
int fonti; /* Index of font stack. */
term_margin headf; /* invoked to print head */
term_margin footf; /* invoked to print foot */
- void (*letter)(struct termp *, char);
+ void (*letter)(struct termp *, int);
void (*begin)(struct termp *);
void (*end)(struct termp *);
void (*endline)(struct termp *);
void (*advance)(struct termp *, size_t);
- size_t (*width)(const struct termp *, char);
+ size_t (*width)(const struct termp *, int);
double (*hspan)(const struct termp *,
const struct roffsu *);
const void *argf; /* arg for headf/footf */
diff --git a/term_ascii.c b/term_ascii.c
index 374a2a02..fd7005f0 100644
--- a/term_ascii.c
+++ b/term_ascii.c
@@ -1,4 +1,4 @@
-/* $Id: term_ascii.c,v 1.12 2011/01/25 17:32:04 kristaps Exp $ */
+/* $Id: term_ascii.c,v 1.13 2011/05/14 17:54:42 kristaps Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -33,12 +33,12 @@
static double ascii_hspan(const struct termp *,
const struct roffsu *);
-static size_t ascii_width(const struct termp *, char);
+static size_t ascii_width(const struct termp *, int);
static void ascii_advance(struct termp *, size_t);
static void ascii_begin(struct termp *);
static void ascii_end(struct termp *);
static void ascii_endline(struct termp *);
-static void ascii_letter(struct termp *, char);
+static void ascii_letter(struct termp *, int);
void *
@@ -84,7 +84,7 @@ ascii_alloc(char *outopts)
/* ARGSUSED */
static size_t
-ascii_width(const struct termp *p, char c)
+ascii_width(const struct termp *p, int c)
{
return(1);
@@ -101,7 +101,7 @@ ascii_free(void *arg)
/* ARGSUSED */
static void
-ascii_letter(struct termp *p, char c)
+ascii_letter(struct termp *p, int c)
{
/* LINTED */
diff --git a/term_ps.c b/term_ps.c
index 233118b8..c505d90a 100644
--- a/term_ps.c
+++ b/term_ps.c
@@ -1,4 +1,4 @@
-/* $Id: term_ps.c,v 1.48 2011/03/17 08:49:34 kristaps Exp $ */
+/* $Id: term_ps.c,v 1.49 2011/05/14 17:54:42 kristaps Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -373,14 +373,14 @@ ps_growbuf(struct termp *p, size_t sz)
static double ps_hspan(const struct termp *,
const struct roffsu *);
-static size_t ps_width(const struct termp *, char);
+static size_t ps_width(const struct termp *, int);
static void ps_advance(struct termp *, size_t);
static void ps_begin(struct termp *);
static void ps_closepage(struct termp *);
static void ps_end(struct termp *);
static void ps_endline(struct termp *);
static void ps_fclose(struct termp *);
-static void ps_letter(struct termp *, char);
+static void ps_letter(struct termp *, int);
static void ps_pclose(struct termp *);
static void ps_pletter(struct termp *, int);
static void ps_printf(struct termp *, const char *, ...);
@@ -963,9 +963,12 @@ ps_fclose(struct termp *p)
static void
-ps_letter(struct termp *p, char c)
+ps_letter(struct termp *p, int arg)
{
- char cc;
+ char cc, c;
+
+ /* LINTED */
+ c = arg >= 128 || arg <= 0 ? '?' : arg;
/*
* State machine dictates whether to buffer the last character
@@ -1095,14 +1098,14 @@ ps_setfont(struct termp *p, enum termfont f)
/* ARGSUSED */
static size_t
-ps_width(const struct termp *p, char c)
+ps_width(const struct termp *p, int c)
{
if (c <= 32 || c - 32 >= MAXCHAR)
return((size_t)fonts[(int)TERMFONT_NONE].gly[0].wx);
c -= 32;
- return((size_t)fonts[(int)TERMFONT_NONE].gly[(int)c].wx);
+ return((size_t)fonts[(int)TERMFONT_NONE].gly[c].wx);
}