From mi@misha.cisco.com Tue Oct 12 12:21:00 1999
Return-Path: <mi@misha.cisco.com>
Received: from misha.cisco.com (misha.cisco.com [171.69.206.50])
	by hub.freebsd.org (Postfix) with ESMTP
	id EA0B314C1E; Tue, 12 Oct 1999 12:20:56 -0700 (PDT)
	(envelope-from mi@misha.cisco.com)
Received: (from mi@localhost)
	by misha.cisco.com (8.9.3/8.9.1) id PAA52138;
	Tue, 12 Oct 1999 15:20:55 -0400 (EDT)
	(envelope-from mi)
Message-Id: <199910121920.PAA52138@misha.cisco.com>
Date: Tue, 12 Oct 1999 15:20:55 -0400 (EDT)
From: Mikhail Teterin <mi@misha.cisco.com>
Reply-To: mi@aldan.algebra.com
To: FreeBSD-gnats-submit@freebsd.org
Cc: brett@peloton.runet.edu, billf@freebsd.org
Subject: tkfont does not work with XiG X-server
X-Send-Pr-Version: 3.2

>Number:         14292
>Category:       ports
>Synopsis:       tkfont does not work with XiG X-server
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 12 12:30:01 PDT 1999
>Closed-Date:    Fri Nov 26 10:31:07 PST 1999
>Last-Modified:  Fri Nov 26 10:33:03 PST 1999
>Originator:     Mikhail Teterin
>Release:        FreeBSD 3.3-STABLE i386
>Organization:
Virtual Estates, Inc.
>Environment:

	An X-server from XiG.

>Description:

	An X-server without an XFree86-MISC extension (or ANY other
	X-server on which `xset -q' writes ANYTHING to stderr) will
	prevent tkfont from starting up. This is because TCL's exec
	treats non-empty stderr as an indication of error. A script
	is supposed to catch it and analize errorCode to avoid it.

	Also, the  tkfont relies  on the presense  of awk  (not too
	dangerous),  and on  the  fact  that at  least  one of  the
	font-dirs  will have  the the  "fonts" component  in it  --
	quite dangerous.

	Also, the current port does not make sure the references to
	/usr/local are replaced with ${LOCALBASE}.

>How-To-Repeat:

	See description.
>Fix:

	The patch below  fixes the crash by  replacing the original
	(very silly) GetFontDirs-procedure  with a more intelligent
	one. This one  only execs xset and does the  parsing of the
	output  inside TCL,  which also  happens to  be faster.  It
	detects the fontpath  component of `xset -q'  output by the
	words "Font Dirs:". The  auxiliary shell script GetFontDirs
	is no longer installed.
	
diff -r -P -U1 /lan/bummer/home/mi/ports/x11-fonts/tkfont/Makefile ./Makefile
--- /lan/bummer/home/mi/ports/x11-fonts/tkfont/Makefile	Thu Sep 16 11:31:19 1999
+++ ./Makefile	Tue Oct 12 14:48:32 1999
@@ -20,3 +20,5 @@
 post-patch:
-	${SED} -e "s,#!/usr/X11/bin/wish,#!$(LOCALBASE)/bin/wish8.0," < ${WRKSRC}/tkfont > ${WRKSRC}/tkfont.new
+	${SED} -e "s,/usr/local,${LOCALBASE}," \
+		-e "s,#!/usr/X11/bin/wish,#!$(LOCALBASE)/bin/wish8.0," \
+		 < ${WRKSRC}/tkfont > ${WRKSRC}/tkfont.new
 	${MV} ${WRKSRC}/tkfont.new ${WRKSRC}/tkfont
@@ -26,3 +28,2 @@
 	@${MKDIR} ${PREFIX}/lib/tkfont
-	@${INSTALL_SCRIPT} ${WRKSRC}/GetFontDirs ${PREFIX}/lib/tkfont
 	@for file in COPYING Bugs.txt FileMenu.txt FindFont FontDirs.txt FontTypes.txt HelpText.txt README WhatsNew.txt; do \
@@ -30,2 +31,3 @@
 	done
+
 .include <bsd.port.mk>
diff -r -P -U1 /lan/bummer/home/mi/ports/x11-fonts/tkfont/patches/patch-aa ./patches/patch-aa
--- /lan/bummer/home/mi/ports/x11-fonts/tkfont/patches/patch-aa	Wed Dec 31 19:00:00 1969
+++ ./patches/patch-aa	Tue Oct 12 14:35:52 1999
@@ -0,0 +1,32 @@
+--- /usr/local/bin/tkfont	Tue Oct 12 13:37:45 1999
++++ tkfont	Tue Oct 12 14:27:43 1999
+@@ -33,11 +33,4 @@
+-proc GetFontDirs { } {
+-	global FontDirList
+-	set TempFileName "/tmp/dirs.list.[pid]"
+-	exec /usr/local/lib/tkfont/GetFontDirs > $TempFileName
+-	list FontDirList_a
+-
+-	set Chan [open $TempFileName r]
+-	set chars 1
+-	while {$chars > 0} {
+-		set chars [gets $Chan onedirname]
+-		lappend FontDirList_a $onedirname
++proc GetFontDirs {} {
++	global FontDirList errorCode
++	if {[catch {exec xset -q} result] && $errorCode != "NONE"} {
++		error $result
+@@ -45,5 +38,8 @@
+-	close $Chan
+-	exec rm $TempFileName
+-	set FontDirList [lreplace $FontDirList_a 0 0 \
+-		[string trim [lindex $FontDirList_a 0]]]
+-	set FontDirList [lreplace $FontDirList end end]
++	set lines [split $result \n]
++	set i [lsearch -exact $lines "Font Path:"]
++	if {$i == -1} {
++		error "Output of `xset -q' did not contain\
++			`Font Path:'\n$result"
++	}
++	set dirLine [string trim [lindex $lines [incr i]]]
++	set FontDirList [split $dirLine ,]
diff -r -P -U1 /lan/bummer/home/mi/ports/x11-fonts/tkfont/pkg/PLIST ./pkg/PLIST
--- /lan/bummer/home/mi/ports/x11-fonts/tkfont/pkg/PLIST	Sun Jan  3 13:25:22 1999
+++ ./pkg/PLIST	Tue Oct 12 14:48:38 1999
@@ -8,3 +8,2 @@
 lib/tkfont/Bugs.txt
-lib/tkfont/GetFontDirs
 lib/tkfont/FindFont

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: steve 
State-Changed-When: Fri Nov 26 10:31:07 PST 1999 
State-Changed-Why:  
Committed, thanks! 
>Unformatted:
