From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: be more careful about argc == 0
Date: Sat, 7 Feb 2015 01:28:39 -0500 (EST) [thread overview]
Message-ID: <10375499602436286411.enqueue@fantadrom.bsd.lv> (raw)
Log Message:
-----------
be more careful about argc == 0
Modified Files:
--------------
mdocml:
demandoc.c
main.c
Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.218
retrieving revision 1.219
diff -Lmain.c -Lmain.c -u -p -r1.218 -r1.219
--- main.c
+++ main.c
@@ -134,8 +134,9 @@ main(int argc, char *argv[])
int options;
int c;
- progname = strrchr(argv[0], '/');
- if (progname == NULL)
+ if (argc < 1)
+ progname = "mandoc";
+ else if ((progname = strrchr(argv[0], '/')) == NULL)
progname = argv[0];
else
++progname;
@@ -287,8 +288,10 @@ main(int argc, char *argv[])
/* Parse arguments. */
- argc -= optind;
- argv += optind;
+ if (argc > 0) {
+ argc -= optind;
+ argv += optind;
+ }
resp = NULL;
/*
@@ -414,13 +417,13 @@ main(int argc, char *argv[])
if (OUTT_MAN == curp.outtype)
mparse_keep(curp.mp);
- if (argc == 0) {
+ if (argc < 1) {
if (use_pager && isatty(STDOUT_FILENO))
spawn_pager();
parse(&curp, STDIN_FILENO, "<stdin>", &rc);
}
- while (argc) {
+ while (argc > 0) {
rctmp = mparse_open(curp.mp, &fd,
resp != NULL ? resp->file : *argv);
if (rc < rctmp)
Index: demandoc.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/demandoc.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -Ldemandoc.c -Ldemandoc.c -u -p -r1.13 -r1.14
--- demandoc.c
+++ demandoc.c
@@ -47,8 +47,9 @@ main(int argc, char *argv[])
int ch, fd, i, list;
extern int optind;
- progname = strrchr(argv[0], '/');
- if (progname == NULL)
+ if (argc < 1)
+ progname = "demandoc";
+ else if ((progname = strrchr(argv[0], '/')) == NULL)
progname = argv[0];
else
++progname;
@@ -81,7 +82,7 @@ main(int argc, char *argv[])
mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_BADARG, NULL, mchars, NULL);
assert(mp);
- if (0 == argc)
+ if (argc < 1)
pmandoc(mp, STDIN_FILENO, "<stdin>", list);
for (i = 0; i < argc; i++) {
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2015-02-07 6:28 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=10375499602436286411.enqueue@fantadrom.bsd.lv \
--to=schwarze@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).