From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p4EHsgLD004348 for ; Sat, 14 May 2011 13:54:43 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id p4EHsgXc010396; Sat, 14 May 2011 13:54:42 -0400 (EDT) Date: Sat, 14 May 2011 13:54:42 -0400 (EDT) Message-Id: <201105141754.p4EHsgXc010396@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Make character engine (-Tascii, -Tpdf, -Tps) ready for Unicode: X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- 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. Modified Files: -------------- mdocml: chars.c mandoc.c term.c term.h term_ascii.c term_ps.c Revision Data ------------- Index: term.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v retrieving revision 1.186 retrieving revision 1.187 diff -Lterm.c -Lterm.c -u -p -r1.186 -r1.187 --- term.c +++ term.c @@ -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 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; } Index: mandoc.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.c,v retrieving revision 1.50 retrieving revision 1.51 diff -Lmandoc.c -Lmandoc.c -u -p -r1.50 -r1.51 --- mandoc.c +++ mandoc.c @@ -704,7 +704,7 @@ mandoc_strntou(const char *p, size_t sz, return(-1); memcpy(buf, p, sz); - buf[sz] = '\0'; + buf[(int)sz] = '\0'; errno = 0; v = strtol(buf, &ep, base); Index: chars.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.c,v retrieving revision 1.40 retrieving revision 1.41 diff -Lchars.c -Lchars.c -u -p -r1.40 -r1.41 --- chars.c +++ chars.c @@ -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'); } /* Index: term.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.h,v retrieving revision 1.80 retrieving revision 1.81 diff -Lterm.h -Lterm.h -u -p -r1.80 -r1.81 --- term.h +++ term.h @@ -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 */ Index: term_ascii.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ascii.c,v retrieving revision 1.12 retrieving revision 1.13 diff -Lterm_ascii.c -Lterm_ascii.c -u -p -r1.12 -r1.13 --- term_ascii.c +++ term_ascii.c @@ -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 */ Index: term_ps.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v retrieving revision 1.48 retrieving revision 1.49 diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.48 -r1.49 --- term_ps.c +++ term_ps.c @@ -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 termfon /* 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); } -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv