XmacII color name lookup problems

Kieron Drake kieron at root.co.uk
Thu Oct 11 02:22:16 AEST 1990


                     [being sent to both xbugs and comp.unix.aux]

			  X Window System Bug Report
			    xbugs at expo.lcs.mit.edu


VERSION:
    R4

CLIENT MACHINE and OPERATING SYSTEM:
    MacIIfx, A/UX 2.0 Beta 15

DISPLAY TYPE:
    N/A

WINDOW MANAGER:
    N/A

AREA:
    Server: OsLookupColor()

SYNOPSIS:
    XmacII produced garbage results from XLookupColor and XAllocNamedColor
    calls. Erroneous results were returned and non-existent color names
    were not detected. All due to a an unexpected indirection in the
    result returned from A/UX 2.0 beta 15 version of the fetch() dbm routine.

DESCRIPTION:

    As above for symptoms. The problem was that under this version of A/UX
    the documentation, and implementation, of the dbm routines differ
    from almost everybody else's. The normal (non-NDBM) version has fetch
    defined as:
	datum fetch(datum key);
    but A/UX has it as:
	datum *fetch(datum key);

    Note that the man page and the implementation agree on the latter
    interpretation but the declaration of fetch() in /usr/include/dbm.h
    is in the former style!

    The subsequent accesses to datum fields produce junk as they are
    effectively the contents of whatever happened to be pointed to
    by a0 (cc) or whatever is in d0/d1 (gcc). The only other affected
    part of the X Window System is the showrgb utility for dumping
    the color database.

REPEAT BY:
    Run the showrgb utility on your rgb database. It uses fetch() and
    hence prints out rubbish results (normally many lines of:
	"0   0   0   <lots of nulls or other junk instead of a color name>"
    ).

SAMPLE FIX:

    First fix /usr/include/dbm,h:
	44c44,45
	< datum fetch();
	---
	> datum *fetch(); /* was datum rather than datum *, but is datum * in docs!
	>                       kieron - UniSoft Ltd, 9th October 1990 */


    The following diffs will fix mit/server/os/4.2bsd/ocolor.c:
	74,75d78
	> #ifdef macII
	>     /* A/UX has a brain damaged view of fetch as datum *fetch(), kieron */
	>     dbent = *fetch (dbent);
	> #else
	75a80
	> #endif macII

    and the following will deal with mit/rgb/showrgb.c:
	32,32c37
	< #define dbm_fetch(db,key) (fetch(key))
	---
	> /* A/UX has fetch returning a datum * rather than a datum !!! - kieron */
	> #ifdef macII
	> #     define dbm_fetch(db,key) (*fetch(key))
	> #else
	> #     define dbm_fetch(db,key) (fetch(key))
	> #endif macII

-- 
	Kieron Drake
MAIL:	kieron at root.co.uk
SNAIL:	UniSoft Ltd, Saunderson House, Hayne Street, London EC1A 9HH
PHONE:	+44 71 315 6637 (direct) +44 71 315 6600 (switchboard)



More information about the Comp.unix.aux mailing list