* mdocml: Following clue-stick applied by schwarze@, back out const-ness
@ 2010-06-27 16:18 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-06-27 16:18 UTC (permalink / raw)
To: source
Log Message:
-----------
Following clue-stick applied by schwarze@, back out const-ness of regset
passed in to libmdoc and libman.
Fix mdoc.3 and man.3 EXAMPLE sections to include regset.
Add MDOC_SYNPRETTY flag cueing front-end to nicely format certain values
as if SEC_SYNOPSIS were the current section.
Modified Files:
--------------
mdocml:
libman.h
libmdoc.h
man.3
man.c
man.h
man_html.c
mdoc.3
mdoc.c
mdoc.h
mdoc_html.c
mdoc_term.c
Revision Data
-------------
Index: man_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_html.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -Lman_html.c -Lman_html.c -u -p -r1.39 -r1.40
--- man_html.c
+++ man_html.c
@@ -252,6 +252,7 @@ a2width(const struct man_node *n, struct
}
+/* ARGSUSED */
static int
man_root_pre(MAN_ARGS)
{
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.86 -r1.87
--- mdoc_html.c
+++ mdoc_html.c
@@ -304,7 +304,7 @@ synopsis_pre(struct html *h, const struc
struct roffsu su;
struct htmlpair tag;
- if (NULL == n->prev || SEC_SYNOPSIS != n->sec)
+ if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
return;
SCALE_VS_INIT(&su, 1);
@@ -1614,7 +1614,7 @@ mdoc_fn_pre(MDOC_ARGS)
*/
#if 0
- if (SEC_SYNOPSIS == n->sec) {
+ if (MDOC_SYNPRETTY & n->flags) {
nbuf[0] = '\0';
html_idcat(nbuf, sp, BUFSIZ);
PAIR_ID_INIT(&tag[1], nbuf);
@@ -1644,7 +1644,7 @@ mdoc_fn_pre(MDOC_ARGS)
for (nn = n->child->next; nn; nn = nn->next) {
i = 1;
- if (SEC_SYNOPSIS == n->sec)
+ if (MDOC_SYNPRETTY & n->flags)
i = 2;
t = print_otag(h, TAG_SPAN, i, tag);
print_text(h, nn->string);
@@ -1654,7 +1654,7 @@ mdoc_fn_pre(MDOC_ARGS)
}
print_text(h, ")");
- if (SEC_SYNOPSIS == n->sec)
+ if (MDOC_SYNPRETTY & n->flags)
print_text(h, ";");
return(0);
@@ -1824,7 +1824,7 @@ mdoc_in_pre(MDOC_ARGS)
PAIR_CLASS_INIT(&tag[0], "includes");
print_otag(h, TAG_SPAN, 1, tag);
- if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
+ if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags)
print_text(h, "#include");
print_text(h, "<");
Index: libmdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libmdoc.h,v
retrieving revision 1.56
retrieving revision 1.57
diff -Llibmdoc.h -Llibmdoc.h -u -p -r1.56 -r1.57
--- libmdoc.h
+++ libmdoc.h
@@ -43,7 +43,7 @@ struct mdoc {
struct mdoc_meta meta; /* document meta-data */
enum mdoc_sec lastnamed;
enum mdoc_sec lastsec;
- const struct regset *regs; /* readonly registers */
+ struct regset *regs; /* registers */
};
#define MACRO_PROT_ARGS struct mdoc *m, \
Index: man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -Lman.c -Lman.c -u -p -r1.79 -r1.80
--- man.c
+++ man.c
@@ -95,8 +95,8 @@ man_free(struct man *man)
struct man *
-man_alloc(const struct regset *regs,
- void *data, int pflags, mandocmsg msg)
+man_alloc(struct regset *regs, void *data,
+ int pflags, mandocmsg msg)
{
struct man *p;
Index: mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v
retrieving revision 1.149
retrieving revision 1.150
diff -Lmdoc.c -Lmdoc.c -u -p -r1.149 -r1.150
--- mdoc.c
+++ mdoc.c
@@ -192,8 +192,8 @@ mdoc_free(struct mdoc *mdoc)
* Allocate volatile and non-volatile parse resources.
*/
struct mdoc *
-mdoc_alloc(const struct regset *regs,
- void *data, int pflags, mandocmsg msg)
+mdoc_alloc(struct regset *regs, void *data,
+ int pflags, mandocmsg msg)
{
struct mdoc *p;
@@ -368,9 +368,18 @@ node_alloc(struct mdoc *m, int line, int
p->pos = pos;
p->tok = tok;
p->type = type;
+
+ /* Flag analysis. */
+
if (MDOC_NEWLINE & m->flags)
p->flags |= MDOC_LINE;
m->flags &= ~MDOC_NEWLINE;
+
+ /* Section analysis. */
+
+ if (SEC_SYNOPSIS == p->sec)
+ p->flags |= MDOC_SYNPRETTY;
+
return(p);
}
Index: libman.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libman.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -Llibman.h -Llibman.h -u -p -r1.39 -r1.40
--- libman.h
+++ libman.h
@@ -40,7 +40,7 @@ struct man {
struct man_node *last; /* the last parsed node */
struct man_node *first; /* the first parsed node */
struct man_meta meta; /* document meta-data */
- const struct regset *regs; /* readonly registers */
+ struct regset *regs; /* registers */
};
#define MACRO_PROT_ARGS struct man *m, \
Index: man.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -Lman.h -Lman.h -u -p -r1.39 -r1.40
--- man.h
+++ man.h
@@ -106,7 +106,7 @@ __BEGIN_DECLS
struct man;
void man_free(struct man *);
-struct man *man_alloc(const struct regset *, void *, int, mandocmsg);
+struct man *man_alloc(struct regset *, void *, int, mandocmsg);
void man_reset(struct man *);
int man_parseln(struct man *, int, char *, int);
int man_endparse(struct man *);
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.159
retrieving revision 1.160
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.159 -r1.160
--- mdoc_term.c
+++ mdoc_term.c
@@ -1278,7 +1278,7 @@ synopsis_pre(struct termp *p, const stru
* Obviously, if we're not in a SYNOPSIS or no prior macros
* exist, do nothing.
*/
- if (NULL == n->prev || SEC_SYNOPSIS != n->sec)
+ if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
return;
/*
@@ -1543,7 +1543,7 @@ termp_fn_pre(DECL_ARGS)
term_word(p, ")");
- if (SEC_SYNOPSIS == n->sec)
+ if (MDOC_SYNPRETTY & n->flags)
term_word(p, ";");
return(0);
@@ -1820,7 +1820,7 @@ termp_in_pre(DECL_ARGS)
synopsis_pre(p, n);
- if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
+ if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags) {
term_fontpush(p, TERMFONT_BOLD);
term_word(p, "#include");
term_word(p, "<");
@@ -1839,13 +1839,13 @@ static void
termp_in_post(DECL_ARGS)
{
- if (SEC_SYNOPSIS == n->sec)
+ if (MDOC_SYNPRETTY & n->flags)
term_fontpush(p, TERMFONT_BOLD);
p->flags |= TERMP_NOSPACE;
term_word(p, ">");
- if (SEC_SYNOPSIS == n->sec)
+ if (MDOC_SYNPRETTY & n->flags)
term_fontpop(p);
}
@@ -1987,7 +1987,7 @@ termp_fo_post(DECL_ARGS)
p->flags |= TERMP_NOSPACE;
term_word(p, ")");
- if (SEC_SYNOPSIS == n->sec) {
+ if (MDOC_SYNPRETTY & n->flags) {
p->flags |= TERMP_NOSPACE;
term_word(p, ";");
}
Index: mdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.h,v
retrieving revision 1.93
retrieving revision 1.94
diff -Lmdoc.h -Lmdoc.h -u -p -r1.93 -r1.94
--- mdoc.h
+++ mdoc.h
@@ -301,6 +301,7 @@ struct mdoc_node {
#define MDOC_ACTED (1 << 1) /* has been acted upon */
#define MDOC_EOS (1 << 2) /* at sentence boundary */
#define MDOC_LINE (1 << 3) /* first macro/text on line */
+#define MDOC_SYNPRETTY (1 << 4) /* SYNOPSIS-style formatting */
enum mdoc_type type; /* AST node type */
enum mdoc_sec sec; /* current named section */
/* FIXME: these can be union'd to shave a few bytes. */
@@ -333,7 +334,7 @@ struct mdoc;
/* See mdoc.3 for documentation. */
void mdoc_free(struct mdoc *);
-struct mdoc *mdoc_alloc(const struct regset *, void *, int, mandocmsg);
+struct mdoc *mdoc_alloc(struct regset *, void *, int, mandocmsg);
void mdoc_reset(struct mdoc *);
int mdoc_parseln(struct mdoc *, int, char *, int);
const struct mdoc_node *mdoc_node(const struct mdoc *);
Index: mdoc.3
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.3,v
retrieving revision 1.43
retrieving revision 1.44
diff -Lmdoc.3 -Lmdoc.3 -u -p -r1.43 -r1.44
--- mdoc.3
+++ mdoc.3
@@ -35,7 +35,7 @@
.Vt extern const char * const * mdoc_argnames;
.Ft "struct mdoc *"
.Fo mdoc_alloc
-.Fa "const struct regset *regs"
+.Fa "struct regset *regs"
.Fa "void *data"
.Fa "int pflags"
.Fa "mandocmsg msgs"
@@ -259,14 +259,16 @@ on the finished parse tree with
.Fn parsed .
This example does not error-check nor free memory upon failure.
.Bd -literal -offset indent
+struct regset regs;
struct mdoc *mdoc;
const struct mdoc_node *node;
char *buf;
size_t len;
int line;
+bzero(®s, sizeof(struct regset));
line = 1;
-mdoc = mdoc_alloc(NULL, 0, NULL);
+mdoc = mdoc_alloc(®s, NULL, 0, NULL);
buf = NULL;
alloc_len = 0;
Index: man.3
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.3,v
retrieving revision 1.20
retrieving revision 1.21
diff -Lman.3 -Lman.3 -u -p -r1.20 -r1.21
--- man.3
+++ man.3
@@ -34,7 +34,7 @@
.Vt extern const char * const * man_macronames;
.Ft "struct man *"
.Fo man_alloc
-.Fa "const struct regset *regs"
+.Fa "struct regset *regs"
.Fa "void *data"
.Fa "int pflags"
.Fa "mandocmsg msgs"
@@ -291,14 +291,16 @@ on the finished parse tree with
.Fn parsed .
This example does not error-check nor free memory upon failure.
.Bd -literal -offset indent
+struct regset regs;
struct man *man;
struct man_node *node;
char *buf;
size_t len;
int line;
+bzero(®s, sizeof(struct regset));
line = 1;
-man = man_alloc(NULL, 0, NULL);
+man = man_alloc(®s, NULL, 0, NULL);
buf = NULL;
alloc_len = 0;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-06-27 16:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-27 16:18 mdocml: Following clue-stick applied by schwarze@, back out const-ness kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).