From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout.scc.kit.edu (mailout.scc.kit.edu [129.13.185.202]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id q3FAlsUm016199 for ; Sun, 15 Apr 2012 06:47:55 -0400 (EDT) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by scc-mailout-02.scc.kit.edu with esmtp (Exim 4.72 #1) id 1SJMzp-0002GE-Ip; Sun, 15 Apr 2012 12:47:53 +0200 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.77) (envelope-from ) id 1SJMzp-0003Tu-Hy for tech@mdocml.bsd.lv; Sun, 15 Apr 2012 12:47:53 +0200 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1SJMzp-0001Fb-Gc for tech@mdocml.bsd.lv; Sun, 15 Apr 2012 12:47:53 +0200 Received: from schwarze by usta.de with local (Exim 4.77) (envelope-from ) id 1SJMzp-0001C5-3I for tech@mdocml.bsd.lv; Sun, 15 Apr 2012 12:47:53 +0200 Date: Sun, 15 Apr 2012 12:47:52 +0200 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: Re: Make the `-width' field to `Bl' not puke Message-ID: <20120415104752.GA28604@iris.usta.de> References: <201203230550.q2N5oPkb028753@krisdoz.my.domain> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201203230550.q2N5oPkb028753@krisdoz.my.domain> User-Agent: Mutt/1.5.21 (2010-09-15) Hi Kristaps, kristaps@mdocml.bsd.lv wrote on Fri, Mar 23, 2012 at 01:50:25AM -0400: > Log Message: > ----------- > Make the `-width' field to `Bl' not puke if it doesn't have an argument. > This makes mandoc work much, much nicer with Mac OSX manpages. > > Modified Files: > -------------- > mdocml: > mdoc_argv.c > mdoc_validate.c This patch caused a regression in the following case, seen e.g. in fs(1): .Bl -tag -width -Fl -compact Correct behaviour is that -width and -offset consume the next argument even if it starts with a dash. By changing -width to OPT_SINGLE, the above case became "-width without argument", breaking the indentation. While merging your patch to OpenBSD, i fixed this by removing the dash check. Besides, ARGV_SINGLE turned out to be completely unused - .Bd -file errors out, anyway. Thus, i simply renamed opt_single to single and was able to delete a couple of lines of code. OK to commit to bsd.lv as well? Yours, Ingo Index: mdoc_argv.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_argv.c,v retrieving revision 1.82 diff -u -p -r1.82 mdoc_argv.c --- mdoc_argv.c 23 Mar 2012 05:50:24 -0000 1.82 +++ mdoc_argv.c 15 Apr 2012 10:35:26 -0000 @@ -42,8 +42,7 @@ enum argsflag { enum argvflag { ARGV_NONE, /* no args to flag (e.g., -split) */ ARGV_SINGLE, /* one arg to flag (e.g., -file xxx) */ - ARGV_MULTI, /* multiple args (e.g., -column xxx yyy) */ - ARGV_OPT_SINGLE /* optional arg (e.g., -offset [xxx]) */ + ARGV_MULTI /* multiple args (e.g., -column xxx yyy) */ }; struct mdocarg { @@ -57,8 +56,6 @@ static enum margserr args(struct mdoc * static int args_checkpunct(const char *, int); static int argv_multi(struct mdoc *, int, struct mdoc_argv *, int *, char *); -static int argv_opt_single(struct mdoc *, int, - struct mdoc_argv *, int *, char *); static int argv_single(struct mdoc *, int, struct mdoc_argv *, int *, char *); @@ -69,7 +66,7 @@ static const enum argvflag argvflags[MDO ARGV_NONE, /* MDOC_Unfilled */ ARGV_NONE, /* MDOC_Literal */ ARGV_SINGLE, /* MDOC_File */ - ARGV_OPT_SINGLE, /* MDOC_Offset */ + ARGV_SINGLE, /* MDOC_Offset */ ARGV_NONE, /* MDOC_Bullet */ ARGV_NONE, /* MDOC_Dash */ ARGV_NONE, /* MDOC_Hyphen */ @@ -81,7 +78,7 @@ static const enum argvflag argvflags[MDO ARGV_NONE, /* MDOC_Ohang */ ARGV_NONE, /* MDOC_Inset */ ARGV_MULTI, /* MDOC_Column */ - ARGV_OPT_SINGLE, /* MDOC_Width */ + ARGV_SINGLE, /* MDOC_Width */ ARGV_NONE, /* MDOC_Compact */ ARGV_NONE, /* MDOC_Std */ ARGV_NONE, /* MDOC_Filled */ @@ -351,10 +348,6 @@ mdoc_argv(struct mdoc *m, int line, enum if ( ! argv_multi(m, line, &tmp, pos, buf)) return(ARGV_ERROR); break; - case (ARGV_OPT_SINGLE): - if ( ! argv_opt_single(m, line, &tmp, pos, buf)) - return(ARGV_ERROR); - break; case (ARGV_NONE): break; } @@ -669,44 +662,17 @@ argv_multi(struct mdoc *m, int line, } static int -argv_opt_single(struct mdoc *m, int line, +argv_single(struct mdoc *m, int line, struct mdoc_argv *v, int *pos, char *buf) { enum margserr ac; char *p; - if ('-' == buf[*pos]) - return(1); - ac = args(m, line, pos, buf, ARGSFL_NONE, &p); if (ARGS_ERROR == ac) return(0); if (ARGS_EOLN == ac) return(1); - - v->sz = 1; - v->value = mandoc_malloc(sizeof(char *)); - v->value[0] = mandoc_strdup(p); - - return(1); -} - -static int -argv_single(struct mdoc *m, int line, - struct mdoc_argv *v, int *pos, char *buf) -{ - int ppos; - enum margserr ac; - char *p; - - ppos = *pos; - - ac = args(m, line, pos, buf, ARGSFL_NONE, &p); - if (ARGS_EOLN == ac) { - mdoc_pmsg(m, line, ppos, MANDOCERR_SYNTARGVCOUNT); - return(0); - } else if (ARGS_ERROR == ac) - return(0); v->sz = 1; v->value = mandoc_malloc(sizeof(char *)); -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv