From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Cached `An' arguments in struct mdoc_an.
Date: Fri, 2 Jul 2010 11:03:14 -0400 (EDT) [thread overview]
Message-ID: <201007021503.o62F3Exe024026@krisdoz.my.domain> (raw)
Log Message:
-----------
Cached `An' arguments in struct mdoc_an. Note that this isn't a
pointer like the other data members, as there's no need to copy it around.
Modified Files:
--------------
mdocml:
mdoc.h
mdoc_term.c
mdoc_validate.c
Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.106 -r1.107
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -849,13 +849,20 @@ static int
pre_an(PRE_ARGS)
{
- if (NULL == n->args || 1 == n->args->argc)
+ if (NULL == n->args)
return(1);
- mdoc_vmsg(mdoc, MANDOCERR_SYNTARGCOUNT,
- n->line, n->pos,
- "line arguments == 1 (have %d)",
- n->args->argc);
- return(0);
+ if (n->args->argc > 1)
+ if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_ARGCOUNT))
+ return(0);
+
+ if (MDOC_Split == n->args->argv[0].arg)
+ n->data.An.auth = AUTH_split;
+ else if (MDOC_Nosplit == n->args->argv[0].arg)
+ n->data.An.auth = AUTH_nosplit;
+ else
+ abort();
+
+ return(1);
}
@@ -1076,16 +1083,14 @@ post_at(POST_ARGS)
static int
post_an(POST_ARGS)
{
+ struct mdoc_node *np;
- if (mdoc->last->args) {
- if (NULL == mdoc->last->child)
- return(1);
- return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGCOUNT));
- }
-
- if (mdoc->last->child)
+ np = mdoc->last;
+ if (AUTH__NONE != np->data.An.auth && np->child)
+ return(mdoc_nmsg(mdoc, np, MANDOCERR_ARGCOUNT));
+ if (AUTH__NONE != np->data.An.auth || np->child)
return(1);
- return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS));
+ return(mdoc_nmsg(mdoc, np, MANDOCERR_NOARGS));
}
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.167
retrieving revision 1.168
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.167 -r1.168
--- mdoc_term.c
+++ mdoc_term.c
@@ -57,7 +57,6 @@ static size_t a2width(const struct ter
static size_t a2height(const struct termp *, const char *);
static size_t a2offs(const struct termp *, const char *);
-static int arg_hasattr(int, const struct mdoc_node *);
static int arg_getattr(int, const struct mdoc_node *);
static void print_bvspace(struct termp *,
const struct mdoc_node *,
@@ -528,18 +527,6 @@ a2offs(const struct termp *p, const char
/*
- * Return 1 if an argument has a particular argument value or 0 if it
- * does not. See arg_getattr().
- */
-static int
-arg_hasattr(int arg, const struct mdoc_node *n)
-{
-
- return(-1 != arg_getattr(arg, n));
-}
-
-
-/*
* Get the index of an argument in a node's argument list or -1 if it
* does not exist.
*/
@@ -1141,10 +1128,10 @@ termp_an_post(DECL_ARGS)
return;
}
- if (arg_hasattr(MDOC_Split, n)) {
+ if (AUTH_split == n->data.An.auth) {
p->flags &= ~TERMP_NOSPLIT;
p->flags |= TERMP_SPLIT;
- } else {
+ } else if (AUTH_nosplit == n->data.An.auth) {
p->flags &= ~TERMP_SPLIT;
p->flags |= TERMP_NOSPLIT;
}
Index: mdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.h,v
retrieving revision 1.98
retrieving revision 1.99
diff -Lmdoc.h -Lmdoc.h -u -p -r1.98 -r1.99
--- mdoc.h
+++ mdoc.h
@@ -279,6 +279,12 @@ enum mdoc_disp {
DISP_literal
};
+enum mdoc_auth {
+ AUTH__NONE = 0,
+ AUTH_split,
+ AUTH_nosplit
+};
+
enum mdoc_font {
FONT__NONE = 0,
FONT_Em,
@@ -303,6 +309,10 @@ struct mdoc_bf {
enum mdoc_font font; /* font */
};
+struct mdoc_an {
+ enum mdoc_auth auth; /* -split, etc. */
+};
+
/* Node in AST. */
struct mdoc_node {
struct mdoc_node *parent; /* parent AST node */
@@ -332,6 +342,7 @@ struct mdoc_node {
enum mdoc_endbody end; /* BODY */
union {
+ struct mdoc_an An;
struct mdoc_bd *Bd;
struct mdoc_bf *Bf;
struct mdoc_bl *Bl;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2010-07-02 15:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201007021503.o62F3Exe024026@krisdoz.my.domain \
--to=kristaps@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).