HangulKorean

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ HangulKorean ] in KIDS
글 쓴 이(By): pkp (~~~pkp~~~)
날 짜 (Date): 1994년05월28일(토) 02시54분29초 KDT
제 목(Title): hanterm patch -Daeshik Kim-



 안녕하세요.. 키즈의 아저씨 pkp 입니다.

 HellCat, 일명 앙마님이 NETNEWS에 올리신 글을 이곳에 올립니다.

 이용에 도움이 되시기를 바랍니다. :)

>>>>> 여기서부터 >>>>>

From: dkim@sprintf.merit.edu (Daeshik Kim)
Newsgroups: han.hangul
Subject: hanterm patch
Date: 19 May 1994 14:25:52 GMT


What's fixed:
1) This patch fixes some memory leak inherited from xterm code.
   - VisualBell() does not do XtReleaseGC() after XtGetGC().
     so are we keep losing memory whenever it beeps?

   - VTRealize() keeps adding new fonts w/o freeing the previously
     loaded ones.

2) 'cat some-large-hangul-file' will crash hanterm since
   'fillgc' in hangul.c was being used uninitialized.

3) DGUX XServer does not handle XDrawImageString16() correctly -
   leaving ASCENT area blank for the johab hangul fonts; but
   XDrawString16() is being handled correctly.

   In order to get around this problem, added XDrawString16() so
   that this - 'XDrawString16()' - fills the foreground parts
   again - well .. ugly but the life sucks anyway.

To apply this:
1) cd to hanterm302 dir
2) patch -p1 < this_patch_file

=============================== CUT HERE ======================================
diff -c hanterm302/DGUX.note hanterm302+/DGUX.note
*** hanterm302/DGUX.noteMon Sep 27 13:20:53 1993
--- hanterm302+/DGUX.noteTue May 10 09:41:03 1994
***************
*** 1,36 ****
  Notes on DGUX port.
  
! For DATA GENERAL Aviion Series.
  
! Currently, johab style font only works on DGUX 5.4.2 version of X11R5
! server.
  
! Right now, I've set up font server on one server class machine
! and using this hanterm on my local DGUX 5.4.2.R2.01 with
! older version of X11R5 X server (DGUX 5.4.2) instead of the one
! came with the current OS.
  
! On DGUX 5.4.1 and DGUX 5.4.2.R2.01, you cannot combine multiple fonts
! which is required on the implementation of hanterm font handling.
  
! For example, let's say you are trying to combine 3 hangul characters.
  
! Then when you type each one it will show up on hanterm; however,
! as soon as hanterm took it as one combined hangul and try to combine
! 3 different hangul johab fonts, the last fonts will clear the
! other 2 previously loaded fonts.
  
! So in result, you'll always see the last character of one whole hangul
! character.
  
! So, if you have earlier version of X11 Server than DGUX 5.4.2,
! give it up. It does not work simply.
  
! If you have DGUX 5.4.2.R2.01 (the most rescent one),
! save the X11R5 server from DGUX 5.4.2 and use it insted of
! the one from DGUX 5.4.2.R2.01.
  
! DGUX 5.4.2 supposed to be System 5.4.2; however, tty related stuff
  is heavily relying on BSD implementation, so use BSD flavor of tty.
  
  Use __using_BSD and __using_DGUX together.
--- 1,35 ----
  Notes on DGUX port.
  
! What's new:
  
! Couple of possible mem. leaks are fixed.
  
! I've found out why johab fonts on X11R5 X Server ever since
! since DGUX 5.4.R2.01 (so far the most rescent version is
! DGUX 5.4.3 - yes, with those good stuff posix thread).
  
! DGUX XServer does not handle XDrawImageString16() correctly-
! i.e. XServer does now show any johab hangul fonts
! of ASCENT Area of the font box.
  
! However, I found XDrawString16() is handled correctly by
! DGUX Xserver.
  
! Using this XDrawString16() in addition to the
! XDrwaImageString16(), we can fill up the missing
! ASCENT Area of the fonts.
  
! I know I know it's an overhead; but it works :)
  
! Now the problem is that whoever uses DGUX XServer but uses
! remote hanterm on other platform than DGUX also should use
! this changes since it is the XServer that cannot handle
! XDrawImageString16() with johab fonts.
  
! In this case, you will have to add -DDGUX_XSERVER to CFLAGS 
! in the Makefile or add "#define DGUX_XSERVER" to hangul.h
  
! DGUX 5.4.* supposed to be USL System 5.4.*; however, tty related stuff
  is heavily relying on BSD implementation, so use BSD flavor of tty.
  
  Use __using_BSD and __using_DGUX together.
***************
*** 51,55 ****
--- 50,55 ----
  
  P.S. 2:  If someone can provide hanterm that do not use johab-style
           fonts, it would be very portable.

           As a matter of fact, I've seen the same problem on one version of 
SGI.
   Most version of X server on SGI can handle it.
diff -c hanterm302/Makefile.dgux hanterm302+/Makefile.dgux
*** hanterm302/Makefile.dguxMon Sep 27 13:24:52 1993
--- hanterm302+/Makefile.dguxTue May 10 09:24:36 1994
***************
*** 4,10 ****
  OBJS = $(SRCS:.c=.o)
  TERMCAPLIB = -ltermcap
  
! CFLAGS = -DUSE_SYSV_UTMP -DUSE_TTY_GROUP -DUTMP \
  -D_BSD_TTY_FLAVOR -D__using_BSD -D__using_DGUX
  
  hanterm: $(OBJS)
--- 4,10 ----
  OBJS = $(SRCS:.c=.o)
  TERMCAPLIB = -ltermcap
  
! CFLAGS = -O2 -DUSE_SYSV_UTMP -DUSE_TTY_GROUP -DUTMP \
  -D_BSD_TTY_FLAVOR -D__using_BSD -D__using_DGUX
  
  hanterm: $(OBJS)
Common subdirectories: hanterm302/X11 and hanterm302+/X11
diff -c hanterm302/charproc.c hanterm302+/charproc.c
*** hanterm302/charproc.cWed Nov 17 07:46:18 1993
--- hanterm302+/charproc.cWed May 18 17:57:00 1994
***************
*** 86,92 ****
  static void bitset(), bitclr();
      
  #defineDEFAULT-1
- #defineTEXT_BUF_SIZE256
  #define TRACKTIMESEC4L
  #define TRACKTIMEUSEC0L
  #define BELLSUPPRESSMSEC 200
--- 86,91 ----
***************
*** 2397,2402 ****
--- 2396,2413 ----
  TabReset (term->tabs);
  
  screen->menu_font_names[fontMenu_fontdefault] = term->misc.f_n;

+ /*
+  * mem. leak?
+  * Daeshik Kim (dkim@sprint.com) - DKIM
+  */
+ if (screen->fnt_norm)
+   XFreeFont (screen->display, screen->fnt_norm);
+ if (screen->fnt_bold)
+   XFreeFont (screen->display, screen->fnt_bold);
+ if (screen->fnt_hangul)
+   XFreeFont (screen->display, screen->fnt_hangul);

  screen->fnt_norm = screen->fnt_bold = screen->fnt_hangul = NULL;
  if (!LoadNewFont(screen, term->misc.f_n, term->misc.f_b,
   term->misc.f_h, False, 0)) {
diff -c hanterm302/hangul.c hanterm302+/hangul.c
*** hanterm302/hangul.cTue Sep  7 17:05:22 1993
--- hanterm302+/hangul.cTue May 10 09:37:35 1994
***************
*** 152,159 ****
--- 152,165 ----
  show_chat_buf();
  }
  
+ /*
  GC fillgc;
  
+  This can be used as unintialized; in result, it can crash hanterm
+   - Daeshik Kim (dkim@sprint.com) - DKIM
+ */
+ GC fillgc = NULL;

  /* str 은 2 byte 조합형 */
  
  HDrawImageString(d, w, gc, hgc, x, y, str, len)
***************
*** 164,171 ****
      char* str;
      int len;
  {
!     register TScreen *screen = &term->screen;
!     XChar2b buf[200];
      int n, width;
      char *p;
      XGCValues values;
--- 170,177 ----
      char* str;
      int len;
  {
!     TScreen *screen = &term->screen;
!     static XChar2b buf[TEXT_BUF_SIZE];
      int n, width;
      char *p;
      XGCValues values;
***************
*** 176,181 ****
--- 182,203 ----
  ;
      n = convert_johab_to_display(str, buf, p - str);
      XDrawImageString16(d, w, hgc, x, y, buf, n);
+ #if defined(DGUX_XSERVER) || defined(DGUX)
+     /*
+      * In DGUX XServer, XDrawImageString16() with hangul johab fonts which
+      * uses ASCENT area does not work.
+      *
+      * Beware, it's the DG XServer so even when you use remote
+      * hanterm from Sun4 machines; you sill get the same result.
+      *
+      * However, fortunately, XDrawString16() works - so
+      * let XDrawImageString16() draw whatever needs to be done; then
+      * add the broken ASCENT area with XDrawString16().
+      *
+      * Daeshik Kim - DKIM
+      */
+     XDrawString16(d, w, hgc, x, y, buf, n);
+ #endif
      width = (p - str) * FontWidth(screen);
      if (screen->ascent > screen->fnt_hangul->ascent) {
  XGetGCValues(d, hgc, GCBackground, &values);
***************
*** 1174,1180 ****
  
  int convert_3_to_johab( f , m , l , buf )
      int f, m, l;
!     char *buf;
  {
      if (f == 0xff) {
  if (m >= 0xa1 && m <= 0xac) {
--- 1196,1202 ----
  
  int convert_3_to_johab( f , m , l , buf )
      int f, m, l;
!     unsigned char *buf;
  {
      if (f == 0xff) {
  if (m >= 0xa1 && m <= 0xac) {
diff -c hanterm302/hangul.h hanterm302+/hangul.h
*** hanterm302/hangul.hMon Sep  6 00:02:30 1993
--- hanterm302+/hangul.hWed May 18 16:48:45 1994
***************
*** 21,23 ****
--- 21,27 ----
  #define ST_CODE_LEN6
  #define ST_KBD_X12
  #define ST_KBD_LEN7

+ #ifndef TEXT_BUF_SIZE
+ #defineTEXT_BUF_SIZE256
+ #endif
diff -c hanterm302/main.c hanterm302+/main.c
*** hanterm302/main.cFri Nov 12 02:30:29 1993
--- hanterm302+/main.cWed May 18 17:42:58 1994
***************
*** 994,999 ****
--- 994,1005 ----
  
          screen = &term->screen;
  
+ /*
+  * Need to initialize for later garbage collection
+  * Daeshik Kim (dkim@sprint.com) - DKIM
+  */
+ screen->fnt_norm = screen->fnt_bold = screen->fnt_hangul = NULL;

  if (screen->savelines < 0) screen->savelines = 0;
  
  term->flags = 0;
diff -c hanterm302/main.h hanterm302+/main.h
*** hanterm302/main.hWed Sep  8 01:05:09 1993
--- hanterm302+/main.hWed May 18 16:36:58 1994
***************
*** 30,32 ****
--- 30,33 ----
  #defineDEFBOLDFONTNULL /* no bold font uses overstriking */
  #defineDEFBORDER2
  #defineDEFBORDERWIDTH2
+ #defineTEXT_BUF_SIZE256
diff -c hanterm302/misc.c hanterm302+/misc.c
*** hanterm302/misc.cWed Sep  8 02:21:45 1993
--- hanterm302+/misc.cWed May 18 17:43:34 1994
***************
*** 358,363 ****
--- 358,369 ----
     0, 0,
     (unsigned) FullWidth(screen),
     (unsigned) FullHeight(screen));

+     /*
+      * This is a memory leak if it's not released
+      * Daeshik Kim (dkim@sprint.com) - DKIM
+      */
+     XtReleaseGC ((Widget)term, visualGC);
  }
  
  /* ARGSUSED */
Common subdirectories: hanterm302/tmp and hanterm302+/tmp
-- 
            Daeshik Kim (angma at IRC) \ O: (703) 689-5878

             dkim@sprint.com dskim@{Glue,eng}.umd.edu
              DAESHIK.KIM@sprintintl.sprint.com

<<<<< 여기까지 <<<<<

 :)

 
~~~~~~~~pkp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~pkp~~~~~~~~~~~~
   ^_^             키즈의  아저씨    pkp    palindrome             ^L^

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.