source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: texi2mdoc: Allow for @sc{} to properly uppercase as requested by
Date: Mon, 2 Mar 2015 13:13:23 -0500 (EST)	[thread overview]
Message-ID: <3679786250748624993.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
Allow for @sc{} to properly uppercase as requested by Baptiste Daroussin--thanks!

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

Revision Data
-------------
Index: extern.h
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/extern.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -Lextern.h -Lextern.h -u -p -r1.23 -r1.24
--- extern.h
+++ extern.h
@@ -404,6 +404,7 @@ struct	texi {
 	int		  seenvs; /* newline has been Pp'd */
 	int		  ign; /* if >0, don't print anything */
 	int		  literal; /* if >0, literal context */
+	int		  uppercase; /* if >0, uppercase */
 };
 
 #define	BUF(_p) ((_p)->files[(_p)->filepos - 1].map)
Index: util.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/util.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -Lutil.c -Lutil.c -u -p -r1.22 -r1.23
--- util.c
+++ util.c
@@ -184,7 +184,10 @@ texiputchar(struct texi *p, char c)
 	if ('\'' == c && 0 == p->outcol)
 		fputs("\\&", p->outfile);
 
-	fputc(c, p->outfile);
+	if (p->uppercase)
+		fputc(toupper((unsigned int)c), p->outfile);
+	else
+		fputc(c, p->outfile);
 	if ('\\' == c)
 		fputc('e', p->outfile);
 	p->seenvs = 0;
@@ -210,7 +213,12 @@ texiputchars(struct texi *p, const char 
 		fputs("\\&", p->outfile);
 	if ('\'' == *s && 0 == p->outcol)
 		fputs("\\&", p->outfile);
-	p->outcol += fputs(s, p->outfile);
+	if (p->uppercase) 
+		for ( ; '\0' != *s; s++)
+			p->outcol += fputc(toupper
+				((unsigned int)*s), p->outfile);
+	else
+		p->outcol += fputs(s, p->outfile);
 	p->seenvs = 0;
 }
 
@@ -616,7 +624,7 @@ texicmd(const struct texi *p, size_t pos
 		return(TEXICMD__MAX);
 
 	/* Alphabetic commands are special. */
-	if ( ! isalpha((unsigned char)BUF(p)[pos])) {
+	if ( ! isalpha((unsigned int)BUF(p)[pos])) {
 		if ((*end = pos + 1) == BUFSZ(p))
 			return(TEXICMD__MAX);
 		for (i = 0; i < TEXICMD__MAX; i++) {
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -Lmain.c -Lmain.c -u -p -r1.57 -r1.58
--- main.c
+++ main.c
@@ -268,7 +268,7 @@ static	const struct texitok __texitoks[T
 	{ doaccent, "ringaccent", 10 }, /* TEXICMD_RINGACCENT */
 	{ doinline, "samp", 4 }, /* TEXICMD_SAMP */
 	{ doinline, "sansserif", 9 }, /* TEXICMD_SANSSERIF */
-	{ dobracket, "sc", 2 }, /* TEXICMD_SC */
+	{ doinline, "sc", 2 }, /* TEXICMD_SC */
 	{ dosection, "section", 7 }, /* TEXICMD_SECTION */
 	{ dovalue, "set", 3 }, /* TEXICMD_SET */
 	{ doignline, "setchapternewpage", 17 }, /* TEXICMD_SETCHAPNEWPAGE */
@@ -725,13 +725,21 @@ doinline(struct texi *p, enum texicmd cm
 	}
 
 	if (NULL == macro || p->literal || TEXILIST_TABLE == p->list) {
+		if (TEXICMD_SC == cmd)
+			p->uppercase++;
 		parsebracket(p, pos, 0);
+		if (TEXICMD_SC == cmd)
+			p->uppercase--;
 		return;
 	}
 
 	teximacroopen(p, macro);
 	p->seenws = 0;
+	if (TEXICMD_SC == cmd)
+		p->uppercase++;
 	parsebracket(p, pos, 0);
+	if (TEXICMD_SC == cmd)
+		p->uppercase--;
 	texipunctuate(p, pos);
 	teximacroclose(p);
 }
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2015-03-02 18:13 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=3679786250748624993.enqueue@fantadrom.bsd.lv \
    --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).