--- ./files.c.org 1994-05-19 11:01:06.000000000 +0900 +++ ./files.c 2005-08-01 06:44:27.000000000 +0900 @@ -90,10 +90,14 @@ bytes = read (fd, (void *) buffer, 1024); (void) close (fd); +#ifdef I18N + return 1; +#else for (i = 0; i < bytes; i++) if (!isascii (buffer[i])) return (0); return (1); +#endif } /* --- ./Imakefile.org 1994-05-19 11:01:00.000000000 +0900 +++ ./Imakefile 2005-08-01 07:11:36.000000000 +0900 @@ -5,10 +5,14 @@ XCOMM Imakefile,v 2.0 1994/05/19 02:01:00 dan Exp XMLIB = -lXm -XCOMM -XCOMM for Dell SVR4 -XCOMM -EXTRA_LIBRARIES = -lc -lucb + +#if defined(sun) +DEFINES = -DI18N -I/usr/ucbinclude +EXTRA_LIBRARIES = -lc -L/usr/ucblib -lucb -lsocket -lnsl +#else +DEFINES = -DI18N -I/opt/local/include +EXTRA_LIBRARIES = -L/opt/local/lib +#endif SRCS = mgdiff.c rundiff.c misc.c files.c spawn.c manual.c modal.c legend.c OBJS = mgdiff.o rundiff.o misc.o files.o spawn.o manual.o modal.o legend.o --- ./Imakefile~ 2005-08-01 06:44:27.000000000 +0900 +++ ./Imakefile 2005-08-01 07:11:36.000000000 +0900 @@ -10,7 +10,8 @@ DEFINES = -DI18N -I/usr/ucbinclude EXTRA_LIBRARIES = -lc -L/usr/ucblib -lucb -lsocket -lnsl #else -DEFINES = -DI18N +DEFINES = -DI18N -I/opt/local/include +EXTRA_LIBRARIES = -L/opt/local/lib #endif SRCS = mgdiff.c rundiff.c misc.c files.c spawn.c manual.c modal.c legend.c --- ./mgdiff.c.org 1994-09-29 10:56:53.000000000 +0900 +++ ./mgdiff.c 2005-08-01 06:44:27.000000000 +0900 @@ -146,6 +146,9 @@ static char *diffcmd; static char *diffargs; +#ifdef I18N +static XFontSet fs = NULL; +#endif static int font_height = 10; static int font_width; static int font_descent; @@ -307,11 +310,37 @@ XtGetApplicationResources (toplevel, &gc_values, resources, XtNumber (resources), NULL, 0); xfs = XQueryFont (XtDisplay (w), gc_values.font); +#ifdef I18N + { + char **miss, *def; + int n_miss; + + fs = XCreateFontSet(XtDisplay(w), "-*-fixed-medium-r-normal--14-*", + &miss, &n_miss, &def); + if (!fs) + XCreateFontSet(XtDisplay(w), XtDefaultFontSet, + &miss, &n_miss, &def); + } + { + XRectangle ink, log; + + XmbTextExtents(fs, "W", strlen("W"), &ink, &log); + + font_descent = 2; + font_width = log.width; + font_height = log.height + 1; + font_mono = 0; + + XmbTextExtents(fs, di->longline, strlen(di->longline), &ink, &log); + font_widestline = log.width; + } +#else font_descent = xfs->descent; font_height = xfs->ascent + xfs->descent; font_width = xfs->max_bounds.width; font_mono = ((xfs->per_char == NULL) || (xfs->min_bounds.width == xfs->max_bounds.width)); font_widestline = XTextWidth (xfs, di->longline, strlen (di->longline)); +#endif XFreeFontInfo (NULL, xfs, 1); XtVaGetValues (w, XmNbackground, &gc_values.background, NULL); @@ -462,34 +491,60 @@ if (ths->text != NULL) { if (XRectInRegion (region, 0, stemp - font_height, width, font_height) != RectangleOut) { if (font_mono) { +#ifdef I18N + XmbDrawString(XtDisplay(w), XtWindow(w), fs, fore, + 0, stemp - font_descent, + &ths->text[j][newss.leftcol], + min(ths->tlen[j] - newss.leftcol, columns)); +#else XDrawString (XtDisplay (w), XtWindow (w), fore, 0, stemp - font_descent, &ths->text[j][newss.leftcol], min (ths->tlen[j] - newss.leftcol, columns)); +#endif } else { +#ifdef I18N + XmbDrawString(XtDisplay(w), XtWindow(w), fs, fore, + -newss.leftcol, stemp - font_descent, + ths->text[j], ths->tlen[j]); +#else XDrawString (XtDisplay (w), XtWindow (w), fore, -newss.leftcol, stemp - font_descent, ths->text[j], ths->tlen[j]); +#endif } } } else if (oth->text != NULL) { if (XRectInRegion (region, 0, stemp - font_height, width, font_height) != RectangleOut) { if (font_mono) { +#ifdef I18N + XmbDrawString(XtDisplay(w), XtWindow(w), fs, fore, + 0, stemp - font_descent, + &oth->text[j][newss.leftcol], + min(oth->tlen[j] - newss.leftcol, columns)); +#else XDrawString (XtDisplay (w), XtWindow (w), fore, 0, stemp - font_descent, &oth->text[j][newss.leftcol], min (oth->tlen[j] - newss.leftcol, columns)); +#endif } else { +#ifdef I18N + XmbDrawString(XtDisplay(w), XtWindow(w), fs, fore, + -newss.leftcol, stemp - font_descent, + oth->text[j], oth->tlen[j]); +#else XDrawString (XtDisplay (w), XtWindow (w), fore, -newss.leftcol, stemp - font_descent, oth->text[j], oth->tlen[j]); +#endif } } } @@ -1020,6 +1075,10 @@ progname = basename (argv[0]); +#ifdef I18N + XtSetLanguageProc( NULL, NULL, NULL ); +#endif + toplevel = XtVaAppInitialize (&app, "Mgdiff", option_table, XtNumber (option_table), #if X11R5 &argc, @@ -1087,7 +1146,7 @@ else XtAppSetWarningHandler (app, xt_warning_handler); -#if sun +#ifdef NO_ATEXIT (void) on_exit (cleanup_at_exit, NULL); #else (void) atexit (cleanup_at_exit); --- ./rundiff.c.org 1994-05-19 11:01:22.000000000 +0900 +++ ./rundiff.c 2005-08-01 06:44:27.000000000 +0900 @@ -524,6 +524,45 @@ { int len, i, tabs, ctrls; +#ifdef I18N + /* + * compute length of new string, taking tabs + */ + for (i = 0, len = 0, ctrls = tabs = 0; s[i] != '\0'; i++) { + if (isascii (s[i])) { + if (s[i] == '\t') { + tabs++; + len += 8; + len /= 8; + len *= 8; + } else + len++; + } else + len++; + } + + if (tabs) { + char *ret = (char *) calloc (1, len + 1); + int j; + + for (i = 0, j = 0; s[i] != '\0'; i++) { + if (isascii (s[i])) { + if (s[i] == '\t') { + ret[j++] = ' '; + while ((j % 8) != 0) + ret[j++] = ' '; + } else + ret[j++] = s[i]; + } else + ret[j++] = s[i]; + } + *flag = True; + return ret; + } else { + *flag = False; + return strdup(s); + } +#else /* * compute length of new string, taking tabs and control * characters into account @@ -587,6 +626,7 @@ *flag = False; return (strdup (s)); } +#endif } /*