From 2a471242a55265a27ff69ccd737cf228e102ac65 Mon Sep 17 00:00:00 2001 From: frese Date: Mon, 16 Jul 2001 11:52:01 +0000 Subject: [PATCH] Fixed wrong string comparison. --- c/xlib/gcontext.c | 46 +++++++++++------------ c/xlib/window.c | 96 +++++++++++++++++++++-------------------------- 2 files changed, 65 insertions(+), 77 deletions(-) diff --git a/c/xlib/gcontext.c b/c/xlib/gcontext.c index 2076b87..6558601 100644 --- a/c/xlib/gcontext.c +++ b/c/xlib/gcontext.c @@ -12,73 +12,73 @@ unsigned long AList_To_GCValues(s48_value alist, XGCValues* GCV) { value = S48_CDR(l); cname = s48_extract_string(S48_SYMBOL_TO_STRING(name)); - if (cname == "function") { + if (strcmp(cname, "function") == 0) { GCV->function = Symbols_To_Bits(value, 0, Func_Syms); mask |= GCFunction; - } else if (cname == "plane-mask") { + } else if (strcmp(cname, "plane-mask") == 0) { GCV->plane_mask = EXTRACT_PIXEL(value); mask |= GCPlaneMask; - } else if (cname == "foreground") { + } else if (strcmp(cname, "foreground") == 0) { GCV->foreground = EXTRACT_PIXEL(value); mask |= GCForeground; - } else if (cname == "background") { + } else if (strcmp(cname, "background") == 0) { GCV->background = EXTRACT_PIXEL(value); mask |= GCBackground; - } else if (cname == "line-width") { + } else if (strcmp(cname, "line-width") == 0) { GCV->line_width = s48_extract_integer(value); mask |= GCLineWidth; - } else if (cname == "line-style") { + } else if (strcmp(cname, "line-style") == 0) { GCV->line_style = Symbol_To_Bit(value,Line_Style_Syms); mask |= GCLineStyle; - } else if (cname == "cap-style") { + } else if (strcmp(cname, "cap-style") == 0) { GCV->cap_style = Symbol_To_Bit(value, Cap_Style_Syms); mask |= GCCapStyle; - } else if (cname == "join-style") { + } else if (strcmp(cname, "join-style") == 0) { GCV->join_style = Symbol_To_Bit(value, Join_Style_Syms); mask |= GCJoinStyle; - } else if (cname == "fill-style") { + } else if (strcmp(cname, "fill-style") == 0) { GCV->fill_style = Symbol_To_Bit(value, Fill_Style_Syms); mask |= GCFillStyle; - } else if (cname == "fill-rule") { + } else if (strcmp(cname, "fill-rule") == 0) { GCV->fill_rule = Symbol_To_Bit(value, Fill_Rule_Syms); mask |= GCFillRule; - } else if (cname == "arc-mode") { + } else if (strcmp(cname, "arc-mode") == 0) { GCV->arc_mode = Symbol_To_Bit(value, Arc_Mode_Syms); mask |= GCArcMode; - } else if (cname == "tile") { + } else if (strcmp(cname, "tile") == 0) { GCV->tile = EXTRACT_PIXMAP(value); mask |= GCTile; - } else if (cname == "stipple") { + } else if (strcmp(cname, "stipple") == 0) { GCV->stipple = EXTRACT_PIXMAP(value); mask |= GCStipple; - } else if (cname == "ts-x") { + } else if (strcmp(cname, "ts-x") == 0) { GCV->ts_x_origin = s48_extract_integer(value); mask |= GCTileStipXOrigin; - } else if (cname == "ts-y") { + } else if (strcmp(cname, "ts-y") == 0) { GCV->ts_y_origin = s48_extract_integer(value); mask |= GCTileStipYOrigin; - } else if (cname == "font") { + } else if (strcmp(cname, "font") == 0) { GCV->font = EXTRACT_FONT(value); mask |= GCFont; - } else if (cname == "subwindow-mode") { + } else if (strcmp(cname, "subwindow-mode") == 0) { GCV->subwindow_mode = Symbol_To_Bit(value, Subwin_Mode_Syms); mask |= GCSubwindowMode; - } else if (cname == "exposures") { + } else if (strcmp(cname, "exposures") == 0) { GCV->graphics_exposures = !S48_FALSE_P(value); mask |= GCGraphicsExposures; - } else if (cname == "clip-x") { + } else if (strcmp(cname, "clip-x") == 0) { GCV->clip_x_origin = s48_extract_integer(value); mask |= GCClipXOrigin; - } else if (cname == "clip-y") { + } else if (strcmp(cname, "clip-y") == 0) { GCV->clip_y_origin = s48_extract_integer(value); mask |= GCClipYOrigin; - } else if (cname == "clip-mask") { + } else if (strcmp(cname, "clip-mask") == 0) { GCV->clip_mask = EXTRACT_PIXMAP(value); mask |= GCClipMask; - } else if (cname == "dash-offset") { + } else if (strcmp(cname, "dash-offset") == 0) { GCV->dash_offset = s48_extract_integer(value); mask |= GCDashOffset; - } else if (cname == "dashes") { + } else if (strcmp(cname, "dashes") == 0) { GCV->dashes = (char)s48_extract_integer(value); mask |= GCDashList; } diff --git a/c/xlib/window.c b/c/xlib/window.c index 69fbd7a..e7cb74e 100644 --- a/c/xlib/window.c +++ b/c/xlib/window.c @@ -5,60 +5,62 @@ unsigned long AList_To_XSetWindowAttributes(s48_value attrAlist, XSetWindowAttributes* Xattrs) { unsigned long mask = 0; s48_value l; + s48_value p; char* cname; s48_value name, value; for (l = attrAlist; !S48_NULL_P(l); l = S48_CDR(l)) { - name = S48_CAR(l); - value = S48_CDR(l); - cname = s48_extract_string(S48_SYMBOL_TO_STRING(name)); - - if (cname == "background-pixmap") { + p = S48_CAR(l); + name = S48_CAR(p); + value = S48_CDR(p); + cname = s48_extract_symbol(name); + + if (strcmp(cname, "background-pixmap") == 0) { Xattrs->background_pixmap = extract_background(value); mask |= CWBackPixmap; - } else if (cname == "background-pixel") { + } else if (strcmp(cname, "background-pixel") == 0) { Xattrs->background_pixel = s48_extract_integer(value); mask |= CWBackPixel; - } else if (cname == "border-pixmap") { + } else if (strcmp(cname, "border-pixmap") == 0) { Xattrs->border_pixmap = extract_border(value); mask |= CWBorderPixmap; - } else if (cname == "border-pixel") { + } else if (strcmp(cname, "border-pixel") == 0) { Xattrs->border_pixel = s48_extract_integer(value); mask |= CWBorderPixel; - } else if (cname == "bit-gravity") { + } else if (strcmp(cname, "bit-gravity") == 0) { Xattrs->bit_gravity = Symbol_To_Bit(value, Bit_Grav_Syms); mask |= CWBitGravity; - } else if (cname == "gravity") { + } else if (strcmp(cname, "gravity") == 0) { Xattrs->win_gravity = Symbol_To_Bit(value, Grav_Syms); mask |= CWWinGravity; - } else if (cname == "backing-store") { + } else if (strcmp(cname, "backing-store") == 0) { Xattrs->backing_store = Symbol_To_Bit(value, Backing_Store_Syms); mask |= CWBackingStore; - } else if (cname == "backing-planes") { + } else if (strcmp(cname, "backing-planes") == 0) { Xattrs->backing_planes = s48_extract_integer(value); mask |= CWBackingPlanes; - } else if (cname == "backing-pixel") { + } else if (strcmp(cname, "backing-pixel") == 0) { Xattrs->backing_pixel = s48_extract_integer(value); mask |= CWBackingPixel; - } else if (cname == "save-under") { + } else if (strcmp(cname, "save-under") == 0) { Xattrs->save_under = !S48_FALSE_P(value); mask |= CWSaveUnder; - } else if (cname == "event-mask") { - Xattrs->event_mask = Symbols_To_Bits(value, Event_Syms); + } else if (strcmp(cname, "event-mask") == 0) { + Xattrs->event_mask = Symbols_To_Bits(value, Event_Mask_Syms); mask |= CWEventMask; - } else if (cname == "do-not-propagate-mask") { - Xattrs->do_not_propagate_mask = Symbols_To_Bits(value, Event_Syms); + } else if (strcmp(cname, "do-not-propagate-mask") == 0) { + Xattrs->do_not_propagate_mask = Symbols_To_Bits(value, Event_Mask_Syms); mask |= CWDontPropagate; - } else if (cname == "override-redirect") { + } else if (strcmp(cname, "override-redirect") == 0) { Xattrs->override_redirect = !S48_FALSE_P(value); mask |= CWOverrideRedirect; - } else if (cname == "colormap") { + } else if (strcmp(cname, "colormap") == 0) { Xattrs->colormap = s48_extract_integer(value); mask |= CWColormap; - } else if (cname == "cursor") { + } else if (strcmp(cname, "cursor") == 0) { Xattrs->cursor = s48_extract_integer(value); mask |= CWCursor; - } // else error + } // else error ?? } /* for */ return mask; } @@ -66,9 +68,9 @@ unsigned long AList_To_XSetWindowAttributes(s48_value attrAlist, int extract_background(s48_value value) { if (S48_SYMBOL_P(value)) { char* v = s48_extract_string(S48_SYMBOL_TO_STRING(value)); - if (v == "none") + if (strcmp(v, "none") == 0) return None; - else if (v == "parent-relative") + else if (strcmp(v, "parent-relative") == 0) return ParentRelative; //else // error ... } @@ -78,7 +80,7 @@ int extract_background(s48_value value) { int extract_border(s48_value value) { if (S48_SYMBOL_P(value)) { char* v = s48_extract_string(S48_SYMBOL_TO_STRING(value)); - if (v == "copy-from-parent") + if (strcmp(v, "copy-from-parent") == 0) return CopyFromParent; // else error } else @@ -116,9 +118,7 @@ s48_value Change_Window_Attributes(s48_value Xwindow, s48_value Xdisplay, s48_value attrAlist) { XSetWindowAttributes Xattrs; - unsigned long mask = 0; - - mask = AList_To_XSetWindowAttributes( attrAlist, &Xattrs ); + unsigned long mask = AList_To_XSetWindowAttributes( attrAlist, &Xattrs ); XChangeWindowAttributes(EXTRACT_DISPLAY(Xdisplay), EXTRACT_WINDOW(Xwindow), mask, &Xattrs); @@ -159,12 +159,15 @@ s48_value Get_Window_Attributes(s48_value Xdisplay, s48_value Xwindow) { S48_VECTOR_SET(res, 15, ENTER_COLORMAP( WA.colormap )); S48_VECTOR_SET(res, 16, WA.map_installed ? S48_TRUE : S48_FALSE); S48_VECTOR_SET(res, 17, Bit_To_Symbol( WA.map_state, Map_State_Syms)); - S48_VECTOR_SET(res, 18, ENTER_MASK( WA.all_event_masks )); //?? MASKS? - S48_VECTOR_SET(res, 19, ENTER_MASK( WA.your_event_mask )); - S48_VECTOR_SET(res, 20, ENTER_MASK( WA.do_not_propagate_mask )); + S48_VECTOR_SET(res, 18, Bits_To_Symbols( WA.all_event_masks, + Event_Mask_Syms )); + S48_VECTOR_SET(res, 19, Bits_To_Symbols( WA.your_event_mask, + Event_Mask_Syms )); + S48_VECTOR_SET(res, 20, Bits_To_Symbols( WA.do_not_propagate_mask, + Event_Mask_Syms )); S48_VECTOR_SET(res, 21, WA.override_redirect ? S48_TRUE : S48_FALSE); S48_VECTOR_SET(res, 22, s48_enter_integer((long)WA.screen)); //?? - // WA.screen - ignored in Elk + // WA.screen - ignored/not supported in Elk } S48_GC_UNPROTECT(); @@ -186,25 +189,25 @@ s48_value Configure_Window (s48_value Xwindow, s48_value Xdisplay, cname = s48_extract_string(S48_SYMBOL_TO_STRING(name)); cvalue = (int)s48_extract_integer(value); // only ints here - if (cname == "x") { + if (strcmp(cname, "x") == 0) { WC.x = cvalue; mask |= CWX; - } else if (cname == "y") { + } else if (strcmp(cname, "y") == 0) { WC.y = cvalue; mask |= CWY; - } else if (cname == "width") { + } else if (strcmp(cname, "width") == 0) { WC.width = cvalue; mask |= CWWidth; - } else if (cname == "height") { + } else if (strcmp(cname, "height") == 0) { WC.height = cvalue; mask |= CWHeight; - } else if (cname == "border-width") { + } else if (strcmp(cname, "border-width") == 0) { WC.border_width = cvalue; mask |= CWBorderWidth; - } else if (cname == "sibling") { + } else if (strcmp(cname, "sibling") == 0) { WC.sibling = (Window)s48_extract_integer(value); mask |= CWSibling; - } else if (cname == "stack-mode") { + } else if (strcmp(cname, "stack-mode") == 0) { WC.stack_mode = cvalue; mask |= CWStackMode; } @@ -247,23 +250,8 @@ s48_value Circulate_Subwindows(s48_value Xwindow, s48_value Xdisplay, return S48_UNSPECIFIC; } - - - /* -Drawable Get_Drawable (d, dpyp) s48_value d; Display **dpyp; { - if (TYPE(d) == T_Window) { - *dpyp = WINDOW(d)->dpy; - return (Drawable)WINDOW(d)->win; - } else if (TYPE(d) == T_Pixmap) { - *dpyp = PIXMAP(d)->dpy; - return (Drawable)PIXMAP(d)->pm; - } - Wrong_Type_Combination (d, "drawable"); - //NOTREACHED -} - static s48_value P_Get_Geometry (d) s48_value d; { Display *dpy; Drawable dr = Get_Drawable (d, &dpy);