Index: kit/CHANGELOG
diff -u kit/CHANGELOG:1.9 kit/CHANGELOG:removed
--- kit/CHANGELOG:1.9	Sat Sep  5 00:11:21 1998
+++ kit/CHANGELOG	Mon Mar 12 05:10:01 2001
@@ -1,51 +0,0 @@
-CHANGELOG for magicpoint
-$Id: CHANGELOG,v 1.9 1998/09/04 15:11:21 onoe Exp $
-
-Fri Sep  5 1998  onoe@sm.sony.co.jp
-	* handle key inputs from invoked terminal as pressed on Xserver,
-	  even if the Xserver is running on a remote host.
-
-Mon Aug 26 1998  itojun@iijlab.net
-	* new copyright. (BSDish copyright without clause 3)
-
-Mon Aug 25 1998  itojun@iijlab.net
-	* print.c: better x11/freetype/vflib -> postscript font mapping.
-
-Mon Aug 23 1998  kato@wide.ad.jp
-	* embedded image support (added mgpembed.pl and embed.c)
-
-Mon Aug 22 1998  itojun@iijlab.net
-	* added contrib/xmindpath, MindPath PocketPoint user-level driver.
-
-Fri Jul 10 11:57:59 JST 1998  itojun@iijlab.net
-	* cache gs-generated image file.
-	  Suggested by: luigi@FreeBSD.org
-
-Mon Jul  6 11:38:32 JST 1998  itojun@iijlab.net
-	* capable of handling GB2312 and KSC5601 encoding.
-	  they must be encoded by using iso-2022 like escape sequences.
-	  EUC-cn or EUC-kr does not work.
-	* -x option is added.
-
-Thu Jul  2 18:04:16 JST 1998  itojun@iijlab.net
-	* eliminate gsview.
-	* revamp "xfont" directive. (see SYNTAX for detail)
-
-Thu Jun 25 13:10:28 JST 1998  itojun@iijlab.net
-	* print.c: color postscript support by "mgp2ps -c".
-
-changes between 1.02a and 1.03a:
-	* To allow color name that has space inbetween ("dark blue"), 
-	  color name after directives SHOULD come with doublequote.
-	  Therefore,
-		%fore blue
-	  should be
-		%fore "blue"
-	  At this moment, doublequote can be ommitted for backward
-	  compatibility.  We may require to have doublequote in the future.
-	  Font names and other string parameter obeys the same rule.
-	* %image is now capable of rendering encapsulated postscript files
-	  (*.eps).
-		%image foo.eps
-	  should work fine.
-	  By using -X option, you can specify device name for ghostscript.
Index: kit/ctlwords.pl
diff -u kit/ctlwords.pl:1.2 kit/ctlwords.pl:removed
--- kit/ctlwords.pl:1.2	Sat Sep  5 06:05:08 1998
+++ kit/ctlwords.pl	Mon Mar 12 05:10:01 2001
@@ -1,12 +0,0 @@
-#! /usr/bin/perl
-$counter = 0;	# 0 origin
-print "/* generated by ctlwords.awk. do not edit by hand. */\n";
-
-while (<>) {
-	next if (!/^\/\*CTL\*\//);
-	next if ($_ !~ /(CTL_[A-Z0-9]+)/);
-
-	$word = $1;
-	print "#define $word\t$counter\n";
-	$counter++;
-}
Index: kit/draw.c
diff -u kit/draw.c:1.181 kit/draw.c:1.184
--- kit/draw.c:1.181	Thu Feb  8 17:54:13 2001
+++ kit/draw.c	Wed Mar  7 00:41:41 2001
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: draw.c,v 1.181 2001/02/08 08:54:13 nishida Exp $
+ * $Id: draw.c,v 1.184 2001/03/06 15:41:41 nishida Exp $
  */
 
 #include "mgp.h"
@@ -75,7 +75,7 @@
 #endif
 
 static void draw_string __P((struct render_state *, char *));
-static void draw_fragment __P((struct render_state *, u_char *, u_int, char *, int));
+static char *draw_fragment __P((struct render_state *, u_char *, u_int, char *, int));
 static int iskinsokuchar __P((u_int));
 static struct render_object *obj_alloc __P((struct render_state *state));
 static void obj_free __P((struct render_state *, struct render_object *));
@@ -1114,13 +1114,13 @@
 			}
 		}
 
-		draw_fragment(state, p, q - p, registry, charset16);
+		q = draw_fragment(state, p, q - p, registry, charset16);
 
 		p = q;
 	}
 }
 
-static void
+static char *
 draw_fragment(state, p, len, registry, charset16)
 	struct render_state *state;
 	u_char *p;
@@ -1285,6 +1285,10 @@
 		len -= (charset16 ? 2 : 1);
 
 		state->linewidth += HORIZ_STEP(char_size[caching], char_len);
+		/* ukai */
+		if (state->linewidth + HORIZ_STEP(char_size[caching], char_len)
+		    > state->width)
+		    break;
 	}
 
 	if (state->width - state->leftfillpos / 2 < state->linewidth
@@ -1333,6 +1337,7 @@
 			draw_line_itemsize(state, tail->ascent, tail->descent);
 		}
 	}
+	return p;
 }
 
 static int
@@ -3468,7 +3473,7 @@
 {
 	/* invalidate the background image cache */
 
-	bg_ctl_last = NULL;
+	bg_ctl_last = bg_ctl_cache = NULL;
 	x_registerseed(state, NULL, NULL);
 }
 
@@ -3655,7 +3660,7 @@
 	fprintf(fp, "(%s) run\n", epsfile);
 	fprintf(fp, "showpage\n");
 	fprintf(fp, "quit\n");
-	fsync(fd);
+	fflush(fp);
 	fclose(fp);
 	signal(SIGPIPE, sigpipe_handler);
 
@@ -3930,6 +3935,9 @@
 	struct render_state *state;
 	int page;
 {
+	struct ctrl *tmp_bg_ctl;
+	int tmp_bgindex;
+
 	/* we don't need caching */
 	if (cached_page == page || page > maxpage || page <= 0)
 		return;
@@ -3943,6 +3951,8 @@
 	state->height = window_height;
 	state->page = page;
 	caching = 1;
+	tmp_bg_ctl = bg_ctl;
+	tmp_bgindex = bgindex;
 	if (verbose){
 		printf("now caching %d page ...\n", page);
 		fflush(stdout);
@@ -3953,6 +3963,8 @@
 	}
 	caching = 0;
 	cached_page = page;
+	bg_ctl = tmp_bg_ctl;
+	bgindex = tmp_bgindex;
 }
 
 static void
@@ -3975,7 +3987,13 @@
 	XSetForeground(display, gcfore, fore_color[0]);
 	XSetBackground(display, gcfore, back_color[0]);
 	bg_ctl = bg_ctl_last = bg_ctl_cache;
-	set_background_pixmap(bg_ctl);
+	if (bg_ctl){
+		for (i = 0; i < MAXBGPIXMAP; i ++){
+			if (bgpixmap[i].ctl && ctlcmp(bg_ctl, bgpixmap[i].ctl) == 0)
+				bgindex = i;
+		}
+		set_background_pixmap(bg_ctl);
+	}
 
 	switch(cache_effect){
 		case 1:
@@ -3998,6 +4016,7 @@
 	int	i = 0;
 
 	bg_ctl_last = NULL;
+	bg_ctl_cache = NULL;
 
 	for (i = 0; i < MAXBGPIXMAP; i ++) {
 		if (bgpixmap[i].image){
@@ -4123,7 +4142,7 @@
 		case CTL_BACK:
 			break;
 		default:
-			fprintf(stderr, "fatal error in get_background_image()\n");
+			fprintf(stderr, "fatal error in get_background_pixmap()\n");
 			cleanup(-1);
 			break;
 		}
@@ -4156,6 +4175,7 @@
 			bgpixmap[j +1].image = bgpixmap[j].image;
 			bgpixmap[j +1].ximageinfo = bgpixmap[j].ximageinfo;
 		}
+		bg_ctl_last = NULL;
 		i = 0;
 	}
 
@@ -4182,7 +4202,7 @@
 				break;	
 		}
 		if (i == MAXBGPIXMAP){
-			fprintf(stderr, "fatal error in set_background_image()\n");
+			fprintf(stderr, "fatal error in set_background_pixmap()\n");
 			cleanup(-1);
 		}
 		XSetWindowBackgroundPixmap(display, window, bgpixmap[i].pixmap);
@@ -4191,7 +4211,7 @@
 		XSetWindowBackground(display, window, ctl->ctl_value);
 		break;
 	default:
-		fprintf(stderr, "fatal error in set_background_image() %d\n", 
+		fprintf(stderr, "fatal error in set_background_pixmap() op=%d\n", 
 			ctl->ct_op);
 		cleanup(-1);
 		break;
@@ -4218,7 +4238,7 @@
 				break;	
 		}
 		if (i == MAXBGPIXMAP){
-			fprintf(stderr, "fatal error in set_background_image()\n");
+			fprintf(stderr, "fatal error in XClearPixmap()\n");
 			cleanup(-1);
 		}
 
@@ -4235,7 +4255,7 @@
 			gc_cache, 0, 0, window_width, window_height);
 		break;
 	default:
-		fprintf(stderr, "fatal error in set_background_image()\n");
+		fprintf(stderr, "fatal error in XClearPixmap()\n");
 		cleanup(-1);
 		break;
 	}
Index: kit/print.c
diff -u kit/print.c:1.93 kit/print.c:1.94
--- kit/print.c:1.93	Thu Feb  8 17:54:13 2001
+++ kit/print.c	Mon Mar  5 22:16:14 2001
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: print.c,v 1.93 2001/02/08 08:54:13 nishida Exp $
+ * $Id: print.c,v 1.94 2001/03/05 13:16:14 nishida Exp $
  */
 /*
  * Paper size selection code is based on psutil.c by Angus J. C. Duggan
@@ -913,7 +913,10 @@
 		} else
 			fprintf(fp, "%d ", textpool[i].xsiz);
 		fprintf(fp, "updatetotlen ");
-		fprintf(fp, "%snewlinecheck ", alignstr);
+		if (textpool[i].text) 
+			fprintf(fp, "%snewlinecheck ", alignstr);
+		else
+			fprintf(fp, "pop ");
 
 		if (colorps
 		 && (i == 0
Index: kit/image/gif.h
diff -u kit/image/gif.h:1.2 kit/image/gif.h:removed
--- kit/image/gif.h:1.2	Mon Dec 28 17:23:03 1998
+++ kit/image/gif.h	Mon Mar 12 05:10:02 2001
@@ -1,72 +0,0 @@
-/* gif.h:
- *
- * gifin.h
- * kirk johnson
- * november 1989
- * external interface to gifin.c
- *
- * Copyright 1989 Kirk L. Johnson (see the included file
- * "kljcpyrght.h" for complete copyright information)
- */
-
-/*
- * gifin return codes
- */
-#define GIFIN_SUCCESS       0   /* success */
-#define GIFIN_DONE          1   /* no more images */
-
-#define GIFIN_ERR_BAD_SD   -1   /* bad screen descriptor */
-#define GIFIN_ERR_BAD_SEP  -2   /* bad image separator */
-#define GIFIN_ERR_BAD_SIG  -3   /* bad signature */
-#define GIFIN_ERR_EOD      -4   /* unexpected end of raster data */
-#define GIFIN_ERR_EOF      -5   /* unexpected end of input stream */
-#define GIFIN_ERR_FAO      -6   /* file already open */
-#define GIFIN_ERR_IAO      -7   /* image already open */
-#define GIFIN_ERR_NFO      -8   /* no file open */
-#define GIFIN_ERR_NIO      -9   /* no image open */
-
-/*
- * colormap indices 
- */
-
-#define GIF_RED  0
-#define GIF_GRN  1
-#define GIF_BLU  2
-
-/*
- * typedef BYTE for convenience
- */
-
-typedef unsigned char BYTE;
-
-static int gifin_open_file();
-static int gifin_open_image();
-static int gifin_get_pixel();
-#if 0
-static int gifin_close_image();
-#endif
-static int gifin_close_file();
-static int gifin_load_cmap();
-static int gifin_skip_extension();
-static int gifin_read_data_block();
-static int gifin_push_string();
-static void gifin_add_string();
-static void gifin_fatal();
-
-/* #defines, typedefs, and such
- */
-
-#define GIF_SIG      "GIF87a"
-#define GIF_SIG_89   "GIF89a"
-#define GIF_SIG_LEN  6          /* GIF signature length */
-#define GIF_SD_SIZE  7          /* GIF screen descriptor size */
-#define GIF_ID_SIZE  9          /* GIF image descriptor size */
-
-#define GIF_SEPARATOR   ','     /* GIF image separator */
-#define GIF_EXTENSION   '!'     /* GIF extension block marker */
-#define GIF_TERMINATOR  ';'     /* GIF terminator */
-
-#define STAB_SIZE  4096         /* string table size */
-#define PSTK_SIZE  4096         /* pixel stack size */
-
-#define NULL_CODE  -1           /* string table null code */
Index: kit/sample/cloud.gif
Index: kit/sample/dad.gif
Index: kit/sample/mgp-old1.gif
Index: kit/sample/mgp-old2.gif
Index: kit/sample/mgp-old3.gif
Index: kit/sample/mgp1.gif
Index: kit/sample/mgp2.gif
Index: kit/sample/mgp3.gif
Index: kit/sample/v6header.gif
