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 o58DMcH9002635 for ; Tue, 8 Jun 2010 09:22:38 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id o58DMbHO018956; Tue, 8 Jun 2010 09:22:37 -0400 (EDT) Date: Tue, 8 Jun 2010 09:22:37 -0400 (EDT) Message-Id: <201006081322.o58DMbHO018956@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: No functionality changes: just restructuring. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- No functionality changes: just restructuring. Deprecated terminal_free() in favour of ps_free() and ascii_free(). Moved ps_*() functions into term_ps.c so that they don't clutter up term.c. Modified Files: -------------- mdocml: Makefile main.c main.h term.c term.h Added Files: ----------- mdocml: term_ps.c Revision Data ------------- Index: term.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v retrieving revision 1.144 retrieving revision 1.145 diff -Lterm.c -Lterm.c -u -p -r1.144 -r1.145 --- term.c +++ term.c @@ -45,8 +45,6 @@ #define PS_CHAR_BOTMARG 24 #define PS_CHAR_BOT (PS_CHAR_BOTMARG + 36) -static struct termp *alloc(char *, enum termenc, enum termtype); -static void term_free(struct termp *); static void spec(struct termp *, const char *, size_t); static void res(struct termp *, const char *, size_t); static void buffera(struct termp *, const char *, size_t); @@ -62,28 +60,44 @@ static void pageopen(struct termp *); void * ascii_alloc(char *outopts) { + struct termp *p; + const char *toks[2]; + char *v; - return(alloc(outopts, TERMENC_ASCII, TERMTYPE_CHAR)); -} + if (NULL == (p = term_alloc(TERMENC_ASCII))) + return(NULL); + p->type = TERMTYPE_CHAR; -void * -ps_alloc(void) -{ + toks[0] = "width"; + toks[1] = NULL; + + while (outopts && *outopts) + switch (getsubopt(&outopts, UNCONST(toks), &v)) { + case (0): + p->defrmargin = (size_t)atoi(v); + break; + default: + break; + } - return(alloc(NULL, TERMENC_ASCII, TERMTYPE_PS)); + /* Enforce a lower boundary. */ + if (p->defrmargin < 58) + p->defrmargin = 58; + + return(p); } void -terminal_free(void *arg) +ascii_free(void *arg) { term_free((struct termp *)arg); } -static void +void term_free(struct termp *p) { @@ -91,6 +105,7 @@ term_free(struct termp *p) free(p->buf); if (p->symtab) chars_free(p->symtab); + free(p); } @@ -290,16 +305,10 @@ advance(struct termp *p, size_t len) } -static struct termp * -alloc(char *outopts, enum termenc enc, enum termtype type) +struct termp * +term_alloc(enum termenc enc) { struct termp *p; - const char *toks[2]; - char *v; - size_t width; - - toks[0] = "width"; - toks[1] = NULL; p = calloc(1, sizeof(struct termp)); if (NULL == p) { @@ -307,25 +316,9 @@ alloc(char *outopts, enum termenc enc, e exit(EXIT_FAILURE); } - p->type = type; p->tabwidth = 5; p->enc = enc; - - width = 80; - - while (outopts && *outopts) - switch (getsubopt(&outopts, UNCONST(toks), &v)) { - case (0): - width = (size_t)atoi(v); - break; - default: - break; - } - - /* Enforce some lower boundary. */ - if (width < 60) - width = 60; - p->defrmargin = width - 2; + p->defrmargin = 78; return(p); } Index: term.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.h,v retrieving revision 1.58 retrieving revision 1.59 diff -Lterm.h -Lterm.h -u -p -r1.58 -r1.59 --- term.h +++ term.h @@ -81,6 +81,8 @@ struct termp { size_t pspage; /* -Tps: current page */ }; +struct termp *term_alloc(enum termenc); +void term_free(struct termp *); void term_newln(struct termp *); void term_vspace(struct termp *); void term_word(struct termp *, const char *); --- /dev/null +++ term_ps.c @@ -0,0 +1,45 @@ +/* $Id: term_ps.c,v 1.1 2010/06/08 13:22:37 kristaps Exp $ */ +/* + * Copyright (c) 2008, 2009 Kristaps Dzonsons + * + * 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. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "out.h" +#include "main.h" +#include "term.h" + +void * +ps_alloc(void) +{ + struct termp *p; + + if (NULL == (p = term_alloc(TERMENC_ASCII))) + return(NULL); + + p->type = TERMTYPE_PS; + return(p); +} + + +void +ps_free(void *arg) +{ + + term_free((struct termp *)arg); +} Index: main.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.h,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmain.h -Lmain.h -u -p -r1.5 -r1.6 --- main.h +++ main.h @@ -42,10 +42,13 @@ void tree_mdoc(void *, const struct m void tree_man(void *, const struct man *); void *ascii_alloc(char *); +void ascii_free(void *); + void *ps_alloc(void); +void ps_free(void *); + void terminal_mdoc(void *, const struct mdoc *); void terminal_man(void *, const struct man *); -void terminal_free(void *); __END_DECLS Index: Makefile =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/Makefile,v retrieving revision 1.277 retrieving revision 1.278 diff -LMakefile -LMakefile -u -p -r1.277 -r1.278 --- Makefile +++ Makefile @@ -69,13 +69,15 @@ MANSRCS = man_macro.c man.c man_hash. MAINLNS = main.ln mdoc_term.ln chars.ln term.ln tree.ln \ compat.ln man_term.ln html.ln mdoc_html.ln \ - man_html.ln out.ln + man_html.ln out.ln term_ps.ln MAINOBJS = main.o mdoc_term.o chars.o term.o tree.o compat.o \ - man_term.o html.o mdoc_html.o man_html.o out.o + man_term.o html.o mdoc_html.o man_html.o out.o \ + term_ps.o MAINSRCS = main.c mdoc_term.c chars.c term.c tree.c compat.c \ - man_term.c html.c mdoc_html.c man_html.c out.c + man_term.c html.c mdoc_html.c man_html.c out.c \ + term_ps.c LLNS = llib-llibmdoc.ln llib-llibman.ln llib-lmandoc.ln \ llib-llibmandoc.ln llib-llibroff.ln @@ -222,6 +224,8 @@ main.ln main.o: main.c mdoc.h man.h roff compat.ln compat.o: compat.c term.ln term.o: term.c term.h man.h mdoc.h chars.h + +term_ps.ln term_ps.o: term_ps.c term.h main.h html.ln html.o: html.c html.h chars.h Index: main.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v retrieving revision 1.85 retrieving revision 1.86 diff -Lmain.c -Lmain.c -u -p -r1.85 -r1.86 --- main.c +++ main.c @@ -591,9 +591,11 @@ fdesc(struct curparse *curp) break; case (OUTT_ASCII): curp->outdata = ascii_alloc(curp->outopts); + curp->outfree = ascii_free; break; case (OUTT_PS): curp->outdata = ps_alloc(); + curp->outfree = ps_free; break; default: break; @@ -616,7 +618,6 @@ fdesc(struct curparse *curp) case (OUTT_PS): curp->outman = terminal_man; curp->outmdoc = terminal_mdoc; - curp->outfree = terminal_free; break; default: break; -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv