summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/mplibdir/mpxout.w
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/mplibdir/mpxout.w')
-rw-r--r--Build/source/texk/web2c/mplibdir/mpxout.w19
1 files changed, 15 insertions, 4 deletions
diff --git a/Build/source/texk/web2c/mplibdir/mpxout.w b/Build/source/texk/web2c/mplibdir/mpxout.w
index d0cfeddf33c..0cd99d7409b 100644
--- a/Build/source/texk/web2c/mplibdir/mpxout.w
+++ b/Build/source/texk/web2c/mplibdir/mpxout.w
@@ -1,4 +1,4 @@
-% $Id: mpxout.w 1219 2010-04-01 09:05:51Z taco $
+% $Id: mpxout.w 1330 2010-07-27 16:53:56Z taco $
%
% Copyright 2008-2009 Taco Hoekwater.
%
@@ -456,6 +456,7 @@ whitespace corrections applied).
@d VERBATIM_TEX 1
@d B_TEX 2
+@d FIRST_VERBATIM_TEX 3
@c
static int mpx_getbta(MPX mpx, char *s) {
@@ -515,6 +516,7 @@ static void mpx_copy_mpto (MPX mpx, FILE *outfile, int textype) {
char *t; /* for finding start of last line */
char c;
char *res = NULL;
+ t = NULL;
do {
if (mpx->aa == NULL || *mpx->aa == 0) {
if ((mpx->aa = mpx_getline(mpx,mpx->mpfile)) == NULL) {
@@ -551,12 +553,16 @@ static void mpx_copy_mpto (MPX mpx, FILE *outfile, int textype) {
*s = c;
} while (*(mpx->tt) != 'e');
s = res;
- if (textype != VERBATIM_TEX) {
+ if (textype == B_TEX) {
/* whitespace at the end */
for (s = res + strlen(res) - 1;
s >= res && (*s == ' ' || *s == '\t' || *s == '\r' || *s == '\n'); s--);
t = s;
*(++s) = '\0';
+ } else {
+ t =s;
+ }
+ if (textype == B_TEX || textype == FIRST_VERBATIM_TEX) {
/* whitespace at the start */
for (s = res;
s < (res + strlen(res)) && (*s == ' ' || *s == '\t' || *s == '\r'
@@ -564,7 +570,7 @@ static void mpx_copy_mpto (MPX mpx, FILE *outfile, int textype) {
for (; *t != '\n' && t > s; t--);
}
fprintf(outfile,"%s", s);
- if (textype != VERBATIM_TEX) {
+ if (textype == B_TEX) {
/* put no |%| at end if it's only 1 line total, starting with |%|;
* this covers the special case |%&format| in a single line. */
if (t != s || *t != '%')
@@ -601,6 +607,7 @@ static const char *mpx_postverb[] = { "\n", "\n" } ;
@ @c
static void mpx_mpto(MPX mpx, char *tmpname, char *mptexpre) {
FILE *outfile;
+ int verbatim_written = 0;
int mode = mpx->mode;
char *mpname = mpx->mpname;
if (mode==mpx_tex_mode) {
@@ -654,11 +661,15 @@ static void mpx_mpto(MPX mpx, char *tmpname, char *mptexpre) {
fprintf(outfile,mpx_preverb1[mode], mpx->lnno, mpname);
else
fprintf(outfile,mpx_preverb[mode], mpx->lnno, mpname);
- mpx_copy_mpto(mpx, outfile, VERBATIM_TEX);
+ if (!verbatim_written)
+ mpx_copy_mpto(mpx, outfile, FIRST_VERBATIM_TEX);
+ else
+ mpx_copy_mpto(mpx, outfile, VERBATIM_TEX);
fprintf(outfile,"%s", mpx_postverb[mode]);
} else {
mpx_error(mpx,"unmatched etex");
}
+ verbatim_written = 1;
}
}