127ea55
--- mgp-1.11b.orig/contrib/mgp2html.pl.in
127ea55
+++ mgp-1.11b/contrib/mgp2html.pl.in
127ea55
@@ -79,10 +79,18 @@
127ea55
 
127ea55
 &prologue;
127ea55
 while (<>) {
127ea55
-	s/\n$//;
127ea55
+	s/[\n\r]*$//; # trim CR and LF
127ea55
+	s/</</g; # escape < as <
127ea55
 
127ea55
 	$_ = '' if (/^#/o);
127ea55
 
127ea55
+	# multiline processing (lines ending with '\')
127ea55
+	while ((/\\$/) && (not eof())) {
127ea55
+		$_=substr($_,0,-1); # cuts last char (should be '\')
127ea55
+		$_=$_.<>; # concatenate next line
127ea55
+		s/[\n\r]*$//; # trim CR and LF
127ea55
+	}
127ea55
+
127ea55
 	if ($_ eq '' || $_ =~ /^[^%]/) {
127ea55
 		$line++;
127ea55
 		$cont = 0 if ($cont == 2);
127ea55
@@ -103,6 +111,8 @@
127ea55
 		next;
127ea55
 	}
127ea55
 
127ea55
+        $cont = 0 if ($cont == 2);
127ea55
+        $cont = 2 if ($cont == 1);
127ea55
 	&cmds($_);
127ea55
 }
127ea55
 &pageepilogue;
127ea55
@@ -152,14 +162,15 @@
127ea55
 			if (!$doimage) {
127ea55
 				# don't use images
127ea55
 			} elsif (scalar(@dir) == 2 || scalar(@dir) == 3) {
127ea55
-				print "\"$dir[1]\"\n";
127ea55
+				&output("\"$dir[1]\"\n");
127ea55
 			} elsif (scalar(@dir) == 4) {
127ea55
 				# interpretation wrong
127ea55
-				print "\"$dir[1]\"\n";
127ea55
+				&output("\"$dir[1]\"\n");
127ea55
 			} elsif (scalar(@dir) >= 5) {
127ea55
 				# interpretation wrong
127ea55
-				print "\"$dir[1]\"\n";
127ea55
+				&output("\"$dir[1]\"\n");
127ea55
 			}
127ea55
+			$endline = "
\n";
127ea55
 		} elsif ($dir[0] eq 'nodefault') {
127ea55
 			$nodefault++;
127ea55
 		} elsif ($dir[0] =~ /^(left|leftfill|right|center)$/) {
127ea55
--- mgp-1.11b.orig/contrib/mgpnet.in
127ea55
+++ mgp-1.11b/contrib/mgpnet.in
127ea55
@@ -32,7 +32,7 @@
127ea55
 
127ea55
 # configurations
127ea55
 $tmpdir = '/tmp';
127ea55
-$httpdatestr = "date '+\%a, \%d \%b \%Y \%H:\%M:\%S \%Z'";
127ea55
+$httpdatestr = "env LC_ALL=C date '+\%a, \%d \%b \%Y \%H:\%M:\%S \%Z'";
127ea55
 $seltimeout = 1;
127ea55
 $refreshtimeout = 10;
127ea55
 $debug = 0;
127ea55
@@ -53,6 +53,7 @@
127ea55
 		} while ($hostname =~ /^127\./);
127ea55
 		close(IN);
127ea55
 	};
127ea55
+	$hostname =~ s/^addr://; # for GNU/Linux, by ukai
127ea55
 	print "http://$hostname:$port/\n";
127ea55
 	exit 0;
127ea55
 }
127ea55
@@ -150,19 +151,19 @@
127ea55
 	vec($rin, fileno(S), 1) = 1;
127ea55
 	vec($win, fileno(S), 1) = 1;
127ea55
 	$ewin = $rin | $win;
127ea55
-	print STDERR "waiting for connetion...\n" if ($debug);
127ea55
+	print STDERR "waiting for connection...\n" if ($debug);
127ea55
 	($nfound, $timeleft) = 
127ea55
 		select($rout = $rin, $wout = $win, $eout = $ein, $seltimeout);
127ea55
 	next if ($nfound <= 0);
127ea55
 	if (vec($rout, fileno(S), 1)) {
127ea55
-		print STDERR "accepting connetion...\n" if ($debug);
127ea55
+		print STDERR "accepting connection...\n" if ($debug);
127ea55
 		accept(NS, S) || do {
127ea55
 			print STDERR "server: accept fail\n" if ($debug);
127ea55
 			next;
127ea55
 		};
127ea55
 
127ea55
 		$acceptstat++;
127ea55
-		print STDERR "connetion accepted...\n" if ($debug);
127ea55
+		print STDERR "connection accepted...\n" if ($debug);
127ea55
 
127ea55
 		$pid = fork;
127ea55
 		if ($pid < 0) {
127ea55
@@ -185,7 +186,7 @@
127ea55
 	}
127ea55
 }
127ea55
 print STDERR "leaving MagicPoint Netserver...\n";
127ea55
-print STDERR "accepted $acceptstat connetions so far.\n";
127ea55
+print STDERR "accepted $acceptstat connections so far.\n";
127ea55
 close(NS);
127ea55
 close(S);
127ea55
 unlink($imagefile);
127ea55
@@ -256,7 +257,7 @@
127ea55
 	$httpmethod = $httppath = $httpver = '';
127ea55
 	($httpmethod, $httppath, $httpver) = split(/\s+/, $httpreq);
127ea55
 	$httppath =~ s/http:\/\/[^:\/]+(:\d+)\//\//;
127ea55
-	if ($httpver eq '' || $httpver eq 'HTTP/1.0') {
127ea55
+	if ($httpver eq '' || $httpver =~ m'HTTP/1.[01]') {
127ea55
 		;	# ok
127ea55
 	} else {
127ea55
 		&httpheader(501, $cthtml) if ($httpver);
127ea55
@@ -350,7 +351,7 @@
127ea55
 <HEAD><TITLE>File Not found</TITLE></HEAD>
127ea55
 <BODY>

File Not found

127ea55
 The requested URL $httppath was not found on this server.

127ea55
-Looks like a mitake in configuration.
127ea55
+Looks like a mistake in configuration.
127ea55
 Contact the administrator.

127ea55
 </BODY>
127ea55
 EOF
127ea55
@@ -415,7 +416,7 @@
127ea55
 'XXX4', 'SO_REUSEPORT',	'XXX5', 'SOCK_STREAM',	'XXX6', 'WNOHANG',
127ea55
 );
127ea55
 	$tmpnam = &tmpname;
127ea55
-	open(CPP, "| @CPP@ >$tmpnam") || return;
127ea55
+	open(CPP, "| @CPP@ - >$tmpnam") || return;
127ea55
 	print CPP "#include <sys/socket.h>\n";
127ea55
 	print CPP "#include <sys/wait.h>\n";
127ea55
 	foreach $tmp (keys %varnames) {
127ea55
@@ -439,12 +440,19 @@
127ea55
 		$havesinlen = 0; $sockaddr = 'S n a4 x8';
127ea55
 	}
127ea55
 
127ea55
+	use Socket;
127ea55
 	foreach $i (keys %varnames) {
127ea55
 		if (@tmp2 = grep($_ =~ /^$i/, @tmp1)) {
127ea55
 			$tmp = (split(/\s+/, @tmp2[0]))[1];
127ea55
 			$tmp = oct($tmp) if ($tmp =~ /^0/);
127ea55
-			next if ($tmp !~ /^[0-9]+$/);
127ea55
-			eval "\$$varnames{$i} = \$tmp;";
127ea55
+			if ($tmp =~ /^[0-9]+$/) {
127ea55
+			    eval "\$$varnames{$i} = \$tmp;";
127ea55
+			} else {
127ea55
+			    # some constant defined by enum, so we can not
127ea55
+			    # always use cpp as above. I believe use Socket
127ea55
+			    # is more reliable in these days.
127ea55
+			    eval "\$$varnames{$i} = &$varnames{$i};";
127ea55
+			}
127ea55
 		}
127ea55
 	}
127ea55
 }
127ea55
--- mgp-1.11b.orig/README.lang
127ea55
+++ mgp-1.11b/README.lang
127ea55
@@ -16,6 +16,9 @@
127ea55
 
127ea55
 	%charset "iso8859-1"
127ea55
 
127ea55
+Note that this directive can be used after %page directive, that is,
127ea55
+you can't use %charset directive in preamble.
127ea55
+
127ea55
 In the future, we will add more encodings to charset directive, like
127ea55
 "iso2022-jp", or "euc-jp"
127ea55
 
127ea55
--- mgp-1.11b.orig/mgpembed.pl.in
127ea55
+++ mgp-1.11b/mgpembed.pl.in
127ea55
@@ -85,12 +85,20 @@
127ea55
 			print OUT;
127ea55
 			next;
127ea55
 		}
127ea55
-		if (/^%(.*)image\s+/i) {
127ea55
-			$prefix = $1; $postfix = $';
127ea55
-			if ($postfix =~ /\"([^"]*)\"/) { 
127ea55
-                # "]*)\"/) { # (workaround for bug in Emacs Perl-syntax)
127ea55
+		if (/^%(.*)image\s+([^,]+)/i) {
127ea55
+			$a = $1; $fname0 = $fname = $2; $b = $';
127ea55
+			if ($a =~ /new$/) {
127ea55
+			    if ($fname =~ /\"([^"]*)\"$/) {
127ea55
 				$fname = $1;
127ea55
-			} elsif ($b =~ /^(\S+)/) {
127ea55
+			    }
127ea55
+			} else {
127ea55
+			    if ($fname =~ /\s.*/) {
127ea55
+				$b = $' . $b;
127ea55
+			    }
127ea55
+			}
127ea55
+			if ($fname =~ /^\"([^"]*)\"/) {
127ea55
+				$fname = $1;
127ea55
+			} elsif ($fname =~ /^(\S+)/) {
127ea55
 				$fname = $1;
127ea55
 			}
127ea55
 			$base = $fname;
127ea55
@@ -106,10 +114,11 @@
127ea55
 			}
127ea55
 			$files{$base} = $fname;
127ea55
 			$embfn = "EMBEDDIR/" . $base;
127ea55
-			$postfix =~ s/\"$fname\"/\"$embfn\"/;
127ea55
+			$fname0 =~ s/$fname/$embfn/;
127ea55
 			print OUT '%';
127ea55
-			print OUT "$prefix";
127ea55
-			print OUT "image $postfix";
127ea55
+			print OUT "$a";
127ea55
+			print OUT "image $fname0";
127ea55
+			print OUT "$b";
127ea55
 		} elsif (/^%(.*)include\s+(\S+)(.*)$/i) {
127ea55
 			$incfname = $2;
127ea55
 			if ($incfname =~ /^\"(.+)\"$/) {
127ea55
--- mgp-1.11b.orig/parse.c
127ea55
+++ mgp-1.11b/parse.c
127ea55
@@ -782,6 +782,10 @@
127ea55
 				}
127ea55
 			}
127ea55
 		} else {
127ea55
+#if 1 /* escape % by backslash */
127ea55
+			if (buf[0] == 0x5c)
127ea55
+				memcpy(&buf[0], &buf[1], strlen(buf));
127ea55
+#endif
127ea55
 			/* this is data */
127ea55
 
127ea55
 			/*
127ea55
@@ -1091,6 +1099,7 @@
127ea55
 				case CTL_TMFONT: tmpstr[4] = cp; break;
127ea55
 #endif
127ea55
 				case CTL_XFONT2:
127ea55
+					define_font (cp);
127ea55
 					if (strcmp(cp->ctc2_value2,
127ea55
 							"iso8859-1") == 0) {
127ea55
 						tmpstr[2] = cp;
127ea55
@@ -1913,7 +1922,7 @@
127ea55
 	int i;
127ea55
 
127ea55
 	/* find duplicated def */
127ea55
-	for (i = 0; i < MAXFONTDEF; i++) {
127ea55
+	for (i = 0; cp->ct_op != CTL_XFONT2 && i < MAXFONTDEF; i++) {
127ea55
 		if (!fontdef_control[i])
127ea55
 			continue;
127ea55
 		if (strcmp(fontdef_control[i]->ctc_value,
127ea55
@@ -1949,8 +1958,10 @@
127ea55
 	for (i = 0; i < MAXFONTDEF; i++) {
127ea55
 		if (!fontdef_control[i])
127ea55
 			continue;
127ea55
-		if (strcmp(fontdef_control[i]->ctc_value, font) == 0)
127ea55
+		if (fontdef_control[i]->ct_op != CTL_XFONT2
127ea55
+		    && strcmp(fontdef_control[i]->ctc_value, font) == 0) {
127ea55
 			return fontdef_control[i];
127ea55
+		}
127ea55
 	}
127ea55
 	return NULL;
127ea55
 }
127ea55
--- mgp-1.11b.orig/sample/sample-fr.mgp
127ea55
+++ mgp-1.11b/sample/sample-fr.mgp
127ea55
@@ -182,6 +182,8 @@
127ea55
 this is test
127ea55
 %endfilter
127ea55
 
127ea55
+	Pour voir cette feature (et les 2 slides prochains) il faut utiliser -U parce que c'est dangereux.
127ea55
+
127ea55
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127ea55
 %PAGE
127ea55
 
127ea55
--- mgp-1.11b.orig/sample/sample-jp.mgp
127ea55
+++ mgp-1.11b/sample/sample-jp.mgp
127ea55
@@ -312,6 +312,9 @@
127ea55
 %filter "rev"
127ea55
 this is test
127ea55
 %endfilter
127ea55
+
127ea55
+	このフィーチャーは危いですから -U が必要です(次の2スライドも)
127ea55
+
127ea55
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127ea55
 %PAGE
127ea55
 
127ea55
--- mgp-1.11b.orig/sample/sample.mgp
127ea55
+++ mgp-1.11b/sample/sample.mgp
127ea55
@@ -229,6 +229,8 @@
127ea55
 this is test
127ea55
 %endfilter
127ea55
 
127ea55
+	Note the -U command line option is required to make this (un-secure) feature and the next two slides work.
127ea55
+
127ea55
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127ea55
 %PAGE
127ea55
 %bgrad 0 0 256 0 0 "white" "blue"