From 532d9835a773f3953bb24769ee0baf08e2a388fc Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Tue, 22 Mar 2011 10:13:01 +0000 Subject: Step 4: merge chars.h into out.h. The functions in this file are necessary to all [real] front-ends, so stop pretending it's special. While here, add some documentation to the variable types. --- Makefile | 8 +++---- chars.c | 4 ++-- chars.h | 38 ------------------------------ html.c | 3 +-- man_term.c | 3 +-- mdoc_term.c | 3 +-- out.h | 77 ++++++++++++++++++++++++++++++++++++------------------------- term.c | 3 +-- 8 files changed, 55 insertions(+), 84 deletions(-) delete mode 100644 chars.h diff --git a/Makefile b/Makefile index 376de4b2..282cabf4 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ DATAS = arch.in att.in lib.in msec.in st.in \ vol.in chars.in HEADS = mdoc.h libmdoc.h man.h libman.h term.h \ - libmandoc.h html.h chars.h out.h main.h \ + libmandoc.h html.h out.h main.h \ mandoc.h libroff.h GSGMLS = mandoc.1.sgml mdoc.7.sgml \ @@ -207,7 +207,7 @@ arch.ln arch.o: arch.c arch.in libmdoc.h vol.ln vol.o: vol.c vol.in libmdoc.h -chars.ln chars.o: chars.c chars.in chars.h +chars.ln chars.o: chars.c chars.in msec.ln msec.o: msec.c msec.in libmdoc.h @@ -229,13 +229,13 @@ main.ln main.o: main.c mdoc.h man.h compat.ln compat.o: compat.c -term.ln term.o: term.c term.h man.h mdoc.h chars.h +term.ln term.o: term.c term.h man.h mdoc.h term_ps.ln term_ps.o: term_ps.c term.h main.h term_ascii.ln term_ascii.o: term_ascii.c term.h main.h -html.ln html.o: html.c html.h chars.h +html.ln html.o: html.c html.h mdoc_html.ln mdoc_html.o: mdoc_html.c html.h mdoc.h diff --git a/chars.c b/chars.c index ba4de8da..03e44910 100644 --- a/chars.c +++ b/chars.c @@ -1,4 +1,4 @@ -/* $Id: chars.c,v 1.33 2011/03/17 08:49:34 kristaps Exp $ */ +/* $Id: chars.c,v 1.34 2011/03/22 10:13:01 kristaps Exp $ */ /* * Copyright (c) 2009, 2010 Kristaps Dzonsons * Copyright (c) 2011 Ingo Schwarze @@ -25,7 +25,7 @@ #include #include "mandoc.h" -#include "chars.h" +#include "out.h" #define PRINT_HI 126 #define PRINT_LO 32 diff --git a/chars.h b/chars.h deleted file mode 100644 index 28f48b33..00000000 --- a/chars.h +++ /dev/null @@ -1,38 +0,0 @@ -/* $Id: chars.h,v 1.7 2011/01/30 16:05:37 schwarze Exp $ */ -/* - * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons - * Copyright (c) 2011 Ingo Schwarze - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#ifndef CHARS_H -#define CHARS_H - -__BEGIN_DECLS - -enum chars { - CHARS_ASCII, - CHARS_HTML -}; - -void *chars_init(enum chars); -const char *chars_num2char(const char *, size_t); -const char *chars_spec2str(void *, const char *, size_t, size_t *); -int chars_spec2cp(void *, const char *, size_t); -const char *chars_res2str(void *, const char *, size_t, size_t *); -int chars_res2cp(void *, const char *, size_t); -void chars_free(void *); - -__END_DECLS - -#endif /*!CHARS_H*/ diff --git a/html.c b/html.c index 8e333ecb..31cc8117 100644 --- a/html.c +++ b/html.c @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.129 2011/03/17 09:16:38 kristaps Exp $ */ +/* $Id: html.c,v 1.130 2011/03/22 10:13:01 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011 Ingo Schwarze @@ -32,7 +32,6 @@ #include "mandoc.h" #include "out.h" -#include "chars.h" #include "html.h" #include "main.h" diff --git a/man_term.c b/man_term.c index bb526aac..cb0b08d7 100644 --- a/man_term.c +++ b/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.104 2011/03/07 01:35:51 schwarze Exp $ */ +/* $Id: man_term.c,v 1.105 2011/03/22 10:13:01 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -31,7 +31,6 @@ #include "out.h" #include "man.h" #include "term.h" -#include "chars.h" #include "main.h" #define INDENT 7 diff --git a/mdoc_term.c b/mdoc_term.c index 8d7a331a..5319e4f8 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.220 2011/03/07 01:35:51 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.221 2011/03/22 10:13:01 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -32,7 +32,6 @@ #include "out.h" #include "term.h" #include "mdoc.h" -#include "chars.h" #include "main.h" #define INDENT 5 diff --git a/out.h b/out.h index 425c727b..9bf5357b 100644 --- a/out.h +++ b/out.h @@ -1,4 +1,4 @@ -/* $Id: out.h,v 1.17 2011/03/07 01:35:51 schwarze Exp $ */ +/* $Id: out.h,v 1.18 2011/03/22 10:13:01 kristaps Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * @@ -17,34 +17,17 @@ #ifndef OUT_H #define OUT_H -__BEGIN_DECLS - -struct roffcol { - size_t width; /* width of cell */ - size_t decimal; /* decimal position in cell */ -}; - -typedef size_t (*tbl_strlen)(const char *, void *); -typedef size_t (*tbl_len)(size_t, void *); - -struct rofftbl { - tbl_strlen slen; /* calculate string length */ - tbl_len len; /* produce width of empty space */ - struct roffcol *cols; /* master column specifiers */ - void *arg; /* passed to slen and len */ -}; - enum roffscale { - SCALE_CM, - SCALE_IN, - SCALE_PC, - SCALE_PT, - SCALE_EM, - SCALE_MM, - SCALE_EN, - SCALE_BU, - SCALE_VS, - SCALE_FS, + SCALE_CM, /* centimeters (c) */ + SCALE_IN, /* inches (i) */ + SCALE_PC, /* pica (P) */ + SCALE_PT, /* points (p) */ + SCALE_EM, /* ems (m) */ + SCALE_MM, /* mini-ems (M) */ + SCALE_EN, /* ens (n) */ + SCALE_BU, /* default horizontal (u) */ + SCALE_VS, /* default vertical (v) */ + SCALE_FS, /* syn. for u (f) */ SCALE_MAX }; @@ -64,11 +47,33 @@ enum roffdeco { DECO_MAX }; +enum chars { + CHARS_ASCII, /* 7-bit ascii representation */ + CHARS_HTML /* unicode values */ +}; + +struct roffcol { + size_t width; /* width of cell */ + size_t decimal; /* decimal position in cell */ +}; + struct roffsu { enum roffscale unit; double scale; }; +typedef size_t (*tbl_strlen)(const char *, void *); +typedef size_t (*tbl_len)(size_t, void *); + +struct rofftbl { + tbl_strlen slen; /* calculate string length */ + tbl_len len; /* produce width of empty space */ + struct roffcol *cols; /* master column specifiers */ + void *arg; /* passed to slen and len */ +}; + +__BEGIN_DECLS + #define SCALE_VS_INIT(p, v) \ do { (p)->unit = SCALE_VS; \ (p)->scale = (v); } \ @@ -79,10 +84,18 @@ struct roffsu { (p)->scale = (v); } \ while (/* CONSTCOND */ 0) -int a2roffsu(const char *, struct roffsu *, enum roffscale); -int a2roffdeco(enum roffdeco *, const char **, size_t *); -void time2a(time_t, char *, size_t); -void tblcalc(struct rofftbl *tbl, const struct tbl_span *); +int a2roffsu(const char *, struct roffsu *, enum roffscale); +int a2roffdeco(enum roffdeco *, const char **, size_t *); +void time2a(time_t, char *, size_t); +void tblcalc(struct rofftbl *tbl, const struct tbl_span *); + +void *chars_init(enum chars); +const char *chars_num2char(const char *, size_t); +const char *chars_spec2str(void *, const char *, size_t, size_t *); +int chars_spec2cp(void *, const char *, size_t); +const char *chars_res2str(void *, const char *, size_t, size_t *); +int chars_res2cp(void *, const char *, size_t); +void chars_free(void *); __END_DECLS diff --git a/term.c b/term.c index 3d1f4edd..caa4a83a 100644 --- a/term.c +++ b/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.180 2011/03/17 09:16:38 kristaps Exp $ */ +/* $Id: term.c,v 1.181 2011/03/22 10:13:01 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -29,7 +29,6 @@ #include #include "mandoc.h" -#include "chars.h" #include "out.h" #include "term.h" #include "main.h" -- cgit v1.2.3-56-ge451