ups 3.35 compilation woes

From: Terry R. Friedrichsen (terry_at_venus.sunquest.com)
Date: Wed Jan 03 2001 - 15:11:25 GMT


ups/menudata.c initializes a whole boatload of MENU structures, a la:

static MENU blockmen_MM1 = {
        0x60,
        0,
        "Expand",
        101,
        -1,
        -1,
        107,
        41,
        0,
        0,
        0,
        0,
        0,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
};

Note that 18 values are supplied in the initializer.

However, MENU is:

typedef struct mnode {
        unsigned short me_flags;
        short me_pos;   /*  The position at which the field is divided */
        const char *me_cap;     /*  Caption to be displayed in the field */
        short me_rv;            /* result to be returned */
        short me_xstart;        /* The window area of this node */
        short me_ystart;
        short me_xend;
        short me_yend;
        short me_xcurs;         /* cursor coordinates for cursor */
        short me_ycurs;         /* relative popup menus */
        short me_colour;
        long me_fg_colour;
        long me_bg_colour;
        long me_save;           /* For saving popup backgrounds */
        struct mnode * me_topleft; /* pointer to top or left sub-menu */
        struct mnode * me_botrite; /* pointer to b. or r. sub_menu */
        struct mnode * me_parent;  /* pointer to parent */
        struct omenst *me_omen;    /* pointer to open menu structure */
        int*   me_toggle;       /* For toggle items */
        int    me_select_val;   /* if >= 0, select value for exclusive group */
} MENU;

Note that there are 20 elements in the structure.

The terminating 5 NULL values in the initializer are evidently to correspond
to the 5 pointers near the end of the structure.  However, there is an addi-
tional value (int me_select_val) at the end of the structure which is unini-
tialized.  It looks, from the comment, as though initializing it to 0 might
be correct.

But that only accounts for one of the two missing values.  Note that the NULL
values begin at position 14 in the initializers, but begin at position 15 in
the actual structure.  This has the potential for being more serious, since
the initializers don't all specify all NULL values for these pointers.


Notice that, except for "const char *me_cap", which the initializers set cor-
rectly, everything else before the NULLs is a numeric type.  Taking a flyer
here, I've assumed that the unaccounted-for initializer value (whichever ele-
ment it belongs to) is supposed to be 0.

Accordingly, every menu (all 338 of 'em!) requires an additional initializer
value of 0 to be inserted after the 13th position, and an additional 0 ini-
tializer at the end.

Fortunately, this was easy to accomplish with Emacs - I'll save the bandwidth
and not reproduce the context diff here (including the entire file would be
shorter!).

These changes made the C compiler happy, at any rate ...

Terry R. Friedrichsen

terry_at_venus.sunquest.com


This archive was generated by hypermail 2.1.4 : Wed Feb 13 2002 - 21:51:33 GMT