[comp.windows.x] XV10R4 on Apollo SR9.X systems - Bugs in X/Porting problems

nazgul@EDDIE.MIT.EDU@apollo.UUCP (02/18/87)

In doing the port to the Apollo I came across a number of problems
in the non-libapollo code which I broke into two categories - bugs,
and porting problems.  You may argue with where to draw the line, but
the changes are small enough, so here they are.  If you want context
diffs send me mail, if enough people want them I'll post them.

One comment -
    The number one porting problem I come across when porting to
Apollo's (and the hardest to catch, although our compiler tries
real hard) is the assumption that stack variables are intialized
to zero.  Not even in the main procedure can you make this assumption.
Time and time again I run across things like:
    char    *filename;
    
    if (argc > 1) filename = argv[1];

    if (filename) ...

If you want your code to be portable you have to initialize 'filename'
to NULL!  Sigh.

Oh, yes.  One other thing - malloc(strlen(foo)+1)
                                              ^^
Some machines will politely give you one byte of leeway, but you can't
count on it.

Anyway.  Here they are.

****
Log.bugs
****
showimg/Makefile
    Changed CONFDIR from /usr/users/wyatte/bin to /usr/new

xcolors/xcolors.c
    Initialized option, border_color, back_color, fore_color and border_width
    to NULL and 0.  STACK VARIABLES ARE NOT GUARANTEED TO BE ZEROED!!!!!

xfd/xfd.c
    Ditto for border_width and geometry.

xterm/button.c
    The code wasn't checking to see if XFetchBytes returned NULL, and
    was thus dying horribly later on if it did.

xterm/resize.c
    Increased the buffer size of termcap and newtc.
    Added Apollo #ifdefs to get around some problems with /dev/tty which
    will go away in a release or two.
    Fixed some arithmetic problem with the strncpy's which was causing
    failure if the string had not been previously nulled (by chance).

xtrek/input.c
    atan2(0, 0) is undefined (from one side it approaches pi, the other 0).
    I added a test and returned 0 if they both were zero (I haven't the
    slightest what they *should* return, but 0 sounded better than pi.

xtrek/orbit.c
    Declared atan2.

xtrek/rmove.c
    Same problem as input.c

xtrek/stats.c
    Occasionally you would die if you came up with stats on.  As far as I
    can figure this was due to the program trying to print stats before
    the window was created, or something silly like that.  In any case
    a test to see if 'rp' is null seemed to get rid of the problem.

****
Log.port
****
Makefile
    Added an option to allow the global changing of the CFLAGS in subsidiary
    makefiles.
	newflags:
		for i in ${OTHERDIR}; do \
		    (cd $$i; echo "fixing $$i/Makefile";\
		     (echo 'g/^CFLAGS/s/${OLDF}/${NEWF}/p'; echo w; echo q) | ed Makefile;\
		     cd ..);\
		done

hacks/bee/def.h
    Included <sys/types.h>

hacks/bitrot/bitrot.c
    Changed 'display' size.
    Changed strncpy to a strcpy.

showimg/shopt.h
    Added include of <sys/types.h>

showimg/shzoom.c
    Ditto, also took out declaration of malloc as unsigned char and
    added a cast.  (Otherwise it gives warnings on type mismatches
    elsewhere.

uwm/Iconify.c
    Got rid of illicit register variable declarations (the code later
    took the address of the variable).  Note:  Due to a bug in the
    Apollo compiler this was flagged as an error where it should have
    just been a warning (actually it should only have told me if I asked,
    but we'll ignore the ongoing fight over that).

uwm/Move.c
    Ditto.


uwm/NewIconify.c
    Ditto.


uwm/Resize.c
    Ditto.


ximpv/impv.h
    Changed declarations of diameter and pages to be externs.


xterm/Makefile
    Changed resize to use CFLAGS instead of cflags

xterm/main.c
    Added include of <sys/types.h>

xwm/Change.c
    More registers where they're shouldn't be.

xwm/LowerIconify.c
    Ditto.

xwm/Move.c
    Ditto.
-------