From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Move check for closing punctuation into its own function.
Date: Wed, 16 Mar 2011 20:58:14 -0400 (EDT) [thread overview]
Message-ID: <201103170058.p2H0wEk2005231@krisdoz.my.domain> (raw)
Log Message:
-----------
Move check for closing punctuation into its own function. This will
later be modified to remove the need for iscdelim(), which will be used
to unify delimiter checks, which will then allow for the simple removal
of a TODO regarding escaped periods.
Modified Files:
--------------
mdocml:
mdoc_argv.c
Revision Data
-------------
Index: mdoc_argv.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_argv.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -Lmdoc_argv.c -Lmdoc_argv.c -u -p -r1.63 -r1.64
--- mdoc_argv.c
+++ mdoc_argv.c
@@ -48,6 +48,7 @@
static enum mdocargt argv_a2arg(enum mdoct, const char *);
static enum margserr args(struct mdoc *, int, int *,
char *, int, char **);
+static int args_checkpunct(const char *);
static int argv(struct mdoc *, int,
struct mdoc_argv *, int *, char *);
static int argv_single(struct mdoc *, int,
@@ -377,7 +378,6 @@ args(struct mdoc *m, int line, int *pos,
int i;
char *p, *pp;
enum margserr rc;
- enum mdelim d;
/*
* Parse out the terms (like `val' in `.Xx -arg val' or simply
@@ -419,33 +419,20 @@ args(struct mdoc *m, int line, int *pos,
* we ONLY care about closing delimiters.
*/
- if ((fl & ARGS_DELIM) && DELIM_CLOSE == mdoc_iscdelim(buf[*pos])) {
- for (i = *pos; buf[i]; ) {
- d = mdoc_iscdelim(buf[i]);
- if (DELIM_NONE == d || DELIM_OPEN == d)
- break;
- i++;
- if ('\0' == buf[i] || ' ' != buf[i])
- break;
- i++;
- while (buf[i] && ' ' == buf[i])
- i++;
- }
+ *v = &buf[*pos];
- if ('\0' == buf[i]) {
- *v = &buf[*pos];
- if (i && ' ' != buf[i - 1])
- return(ARGS_PUNCT);
- if (ARGS_NOWARN & fl)
- return(ARGS_PUNCT);
- if ( ! mdoc_pmsg(m, line, *pos, MANDOCERR_EOLNSPACE))
- return(ARGS_ERROR);
+ if (ARGS_DELIM & fl && args_checkpunct(&buf[*pos])) {
+ i = strlen(&buf[*pos]) + *pos;
+ if (i && ' ' != buf[i - 1])
return(ARGS_PUNCT);
- }
+ if (ARGS_NOWARN & fl)
+ return(ARGS_PUNCT);
+ /* FIXME: remove conditional messages... */
+ if ( ! mdoc_pmsg(m, line, *pos, MANDOCERR_EOLNSPACE))
+ return(ARGS_ERROR);
+ return(ARGS_PUNCT);
}
- *v = &buf[*pos];
-
/*
* First handle TABSEP items, restricted to `Bl -column'. This
* ignores conventional token parsing and instead uses tabs or
@@ -581,6 +568,36 @@ args(struct mdoc *m, int line, int *pos,
return(ARGS_ERROR);
return(ARGS_WORD);
+}
+
+/*
+ * Check if the string consists only of space-separated closing
+ * delimiters.
+ */
+static int
+args_checkpunct(const char *p)
+{
+ int i;
+ enum mdelim d;
+
+ i = 0;
+
+ if (DELIM_CLOSE != mdoc_iscdelim(p[i]))
+ return(0);
+
+ while ('\0' != p[i]) {
+ d = mdoc_iscdelim(p[i]);
+ if (DELIM_NONE == d || DELIM_OPEN == d)
+ break;
+ i++;
+ if ('\0' == p[i] || ' ' != p[i])
+ break;
+ i++;
+ while (p[i] && ' ' == p[i])
+ i++;
+ }
+
+ return('\0' == p[i]);
}
/*
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2011-03-17 0:58 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=201103170058.p2H0wEk2005231@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).