source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* texi2mdoc: Implement macro-invocation workarounds found in real-life
@ 2015-02-23 15:09 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2015-02-23 15:09 UTC (permalink / raw)
  To: source

Log Message:
-----------
Implement macro-invocation workarounds found in real-life manuals.
Add some random macros found in real-life manuals.

Modified Files:
--------------
    texi2mdoc:
        extern.h
        main.c
        util.c

Revision Data
-------------
Index: util.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/util.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -Lutil.c -Lutil.c -u -p -r1.9 -r1.10
--- util.c
+++ util.c
@@ -170,6 +170,8 @@ texiputchar(struct texi *p, char c)
 
 	if ('.' == c && 0 == p->outcol)
 		fputs("\\&", stdout);
+	if ('\'' == c && 0 == p->outcol)
+		fputs("\\&", stdout);
 
 	putchar(c);
 	p->seenvs = 0;
@@ -542,6 +544,9 @@ texiword(struct texi *p, const char *buf
 			 '\'' == buf[*pos + 1]) {
 			texiputchars(p, "\\(rq");
 			advance(p, buf, pos);
+		} else if ('\\' == buf[*pos]) {
+			texiputchar(p, buf[*pos]);
+			texiputchar(p, 'e');
 		} else
 			texiputchar(p, buf[*pos]);
 		advance(p, buf, pos);
@@ -1158,8 +1163,30 @@ argparse(struct texi *p, const char *buf
 	args = NULL;
 	*argsz = 0;
 
-	/* Check for no arguments. */
-	if ('{' != buf[*pos])
+	if ('{' != buf[*pos] && hint) {
+		/*
+		 * Special case: if we encounter an unbracketed argument
+		 * and we're being invoked with non-zero arguments
+		 * (versus being set, i.e., hint>0), then parse until
+		 * the end of line.
+		 */
+		*argsz = 1;
+		args = calloc(1, sizeof(char *));
+		if (NULL == args)
+			texiabort(p, NULL);
+		start = *pos;
+		while (*pos < sz) {
+			if ('\n' == buf[*pos])
+				break;
+			advance(p, buf, pos);
+		}
+		args[0] = malloc(*pos - start + 1);
+		memcpy(args[0], &buf[start], *pos - start);
+		args[0][*pos - start] = '\0';
+		if (*pos < sz && '\n' == buf[*pos])
+			advance(p, buf, pos);
+		return(args);
+	} else if ('{' != buf[*pos])
 		return(args);
 
 	/* Parse til the closing '}', putting into the array. */
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -Lmain.c -Lmain.c -u -p -r1.34 -r1.35
--- main.c
+++ main.c
@@ -106,6 +106,7 @@ static	const struct texitok __texitoks[T
 	{ doinline, "code", 4 }, /* TEXICMD_CODE */
 	{ dosymbol, ":", 1 }, /* TEXICMD_COLON */
 	{ NULL, "columnfractions", 15 }, /* TEXICMD_COLUMNFRACTIONS */
+	{ dosymbol, "comma", 5 }, /* TEXICMD_COMMA */
 	{ doinline, "command", 7 }, /* TEXICMD_COMMAND */
 	{ doignline, "c", 1 }, /* TEXICMD_COMMENT */
 	{ doignline, "comment", 7 }, /* TEXICMD_COMMENT_LONG */
@@ -225,6 +226,7 @@ static	const struct texitok __texitoks[T
 	{ dosection, "section", 7 }, /* TEXICMD_SECTION */
 	{ dovalue, "set", 3 }, /* TEXICMD_SET */
 	{ doignline, "setchapternewpage", 17 }, /* TEXICMD_SETCHAPNEWPAGE */
+	{ doignline, "setcontentsaftertitlepage", 25 }, /* TEXICMD_SETCONTENTSAFTER */
 	{ doignline, "setfilename", 11 }, /* TEXICMD_SETFILENAME */
 	{ dotitle, "settitle", 8 }, /* TEXICMD_SETTITLE */
 	{ doignline, "shortcontents", 13 }, /* TEXICMD_SHORTCONTENTS */
@@ -239,6 +241,7 @@ static	const struct texitok __texitoks[T
 	{ dodisplay, "smallindentblock", 16 }, /* TEXICMD_SMALLINDENTBLOCK */
 	{ dosymbol, "{", 1 }, /* TEXICMD_SQUIGGLE_LEFT */
 	{ dosymbol, "}", 1 }, /* TEXICMD_SQUIGGLE_RIGHT */
+	{ dosymbol, "ss", 2 }, /* TEXICMD_SS */
 	{ doinline, "strong", 6 }, /* TEXICMD_STRONG */
 	{ dosubsection, "subheading", 10 }, /* TEXICMD_SUBHEADING */
 	{ dosubsection, "subsection", 10 }, /* TEXICMD_SUBSECTION */
@@ -254,6 +257,7 @@ static	const struct texitok __texitoks[T
 	{ dotable, "table", 5 }, /* TEXICMD_TABLE */
 	{ doignblock, "tex", 3 }, /* TEXICMD_TEX */
 	{ dosymbol, "TeX", 3 }, /* TEXICMD_TEXSYM */
+	{ dosymbol, "tie", 3 }, /* TEXICMD_TIE */
 	{ doaccent, "~", 1 }, /* TEXICMD_TILDE */
 	{ doignline, "tindex", 6 }, /* TEXICMD_TINDEX */
 	{ doignline, "title", 5 }, /* TEXICMD_TITLE */
@@ -323,6 +327,7 @@ dodefn(struct texi *p, enum texicmd cmd,
 	blk = NULL;
 	switch (cmd) {
 	case (TEXICMD_DEFFN):
+	case (TEXICMD_DEFMAC):
 	case (TEXICMD_DEFTP):
 	case (TEXICMD_DEFTYPEFN):
 	case (TEXICMD_DEFTYPEFUN):
@@ -1010,6 +1015,9 @@ dosymbol(struct texi *p, enum texicmd cm
 	case (TEXICMD_BULLET):
 		texiputchars(p, "\\(bu");
 		break;
+	case (TEXICMD_COMMA):
+		texiputchar(p, ',');
+		break;
 	case (TEXICMD_COPYRIGHT):
 		texiputchars(p, "\\(co");
 		break;
@@ -1044,14 +1052,20 @@ dosymbol(struct texi *p, enum texicmd cm
 	case (TEXICMD_SLASH):
 		texiputchar(p, '/');
 		break;
+	case (TEXICMD_SS):
+		texiputchars(p, "\\(ss");
+		break;
 	case (TEXICMD_SQUIGGLE_LEFT):
 		texiputchars(p, "{");
 		break;
 	case (TEXICMD_SQUIGGLE_RIGHT):
 		texiputchars(p, "}");
 		break;
-	case (TEXICMD_TEXSYM):
+	case (TEXICMD_TIE):
 		texiputchars(p, "TeX");
+		break;
+	case (TEXICMD_TEXSYM):
+		texiputchars(p, "\\ ");
 		break;
 	case (TEXICMD_COLON):
 	case (TEXICMD_HYPHEN):
Index: extern.h
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/extern.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -Lextern.h -Lextern.h -u -p -r1.9 -r1.10
--- extern.h
+++ extern.h
@@ -50,6 +50,7 @@ enum	texicmd {
 	TEXICMD_CODE,
 	TEXICMD_COLON,
 	TEXICMD_COLUMNFRACTIONS,
+	TEXICMD_COMMA,
 	TEXICMD_COMMAND,
 	TEXICMD_COMMENT,
 	TEXICMD_COMMENT_LONG,
@@ -169,6 +170,7 @@ enum	texicmd {
 	TEXICMD_SECTION,
 	TEXICMD_SET,
 	TEXICMD_SETCHAPNEWPAGE,
+	TEXICMD_SETCONTENTSAFTER,
 	TEXICMD_SETFILENAME,
 	TEXICMD_SETTITLE,
 	TEXICMD_SHORTCONTENTS,
@@ -183,6 +185,7 @@ enum	texicmd {
 	TEXICMD_SMALLINDENTBLOCK,
 	TEXICMD_SQUIGGLE_LEFT,
 	TEXICMD_SQUIGGLE_RIGHT,
+	TEXICMD_SS,
 	TEXICMD_STRONG,
 	TEXICMD_SUBHEADING,
 	TEXICMD_SUBSECTION,
@@ -198,6 +201,7 @@ enum	texicmd {
 	TEXICMD_TABLE,
 	TEXICMD_TEX,
 	TEXICMD_TEXSYM,
+	TEXICMD_TIE,
 	TEXICMD_TILDE,
 	TEXICMD_TINDEX,
 	TEXICMD_TITLE,
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-02-23 15:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-23 15:09 texi2mdoc: Implement macro-invocation workarounds found in real-life kristaps

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).