From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Use proper infix expressions and provide a default.
Date: Wed, 9 Nov 2011 18:31:37 -0500 (EST) [thread overview]
Message-ID: <201111092331.pA9NVbmf001758@krisdoz.my.domain> (raw)
Log Message:
-----------
Use proper infix expressions and provide a default. (Exact match.)
Modified Files:
--------------
mdocml:
db.c
Revision Data
-------------
Index: db.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/db.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -Ldb.c -Ldb.c -u -p -r1.2 -r1.3
--- db.c
+++ db.c
@@ -462,30 +462,43 @@ exprcomp(int cs, char *argv[], int argc)
{
struct expr *p;
struct expr e;
- int i, ch;
+ int i, pos, ch;
- if (3 != argc)
+ pos = 0;
+
+ if (pos > argc)
+ return(NULL);
+
+ for (i = 0; 0 != types[i].mask; i++)
+ if (0 == strcmp(types[i].name, argv[pos]))
+ break;
+
+ if (0 == (e.mask = types[i].mask))
return(NULL);
- if (0 == strcmp("-eq", argv[0]))
+ if (++pos > argc--)
+ return(NULL);
+
+ if ('-' != *argv[pos])
+ e.match = cs ? MATCH_STRCASE : MATCH_STR;
+ else if (0 == strcmp("-eq", argv[pos]))
e.match = cs ? MATCH_STRCASE : MATCH_STR;
- else if (0 == strcmp("-ieq", argv[0]))
+ else if (0 == strcmp("-ieq", argv[pos]))
e.match = MATCH_STRCASE;
- else if (0 == strcmp("-re", argv[0]))
+ else if (0 == strcmp("-re", argv[pos]))
e.match = cs ? MATCH_REGEXCASE : MATCH_REGEX;
- else if (0 == strcmp("-ire", argv[0]))
+ else if (0 == strcmp("-ire", argv[pos]))
e.match = MATCH_REGEXCASE;
else
return(NULL);
- for (i = 0; 0 != types[i].mask; i++)
- if (0 == strcmp(types[i].name, argv[1]))
- break;
+ if ('-' == *argv[pos])
+ pos++;
- if (0 == (e.mask = types[i].mask))
+ if (pos > argc--)
return(NULL);
- e.v = mandoc_strdup(argv[2]);
+ e.v = mandoc_strdup(argv[pos]);
if (MATCH_REGEX == e.match || MATCH_REGEXCASE == e.match) {
ch = REG_EXTENDED | REG_NOSUB;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2011-11-09 23:31 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=201111092331.pA9NVbmf001758@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).