diff options
Diffstat (limited to 'geometry.c')
-rw-r--r-- | geometry.c | 96 |
1 files changed, 39 insertions, 57 deletions
@@ -397,14 +397,13 @@ static void FreeRows(RowInfo * row, SectionInfo * section, GeometryInfo * info) { RowInfo *next; - RowInfo *tmp; if (row == section->rows) { section->nRows = 0; section->rows = NULL; } - for (tmp = row; tmp != NULL; tmp = next) + for (RowInfo *tmp = row; tmp != NULL; tmp = next) { ClearRowInfo(tmp, info); next = (RowInfo *) tmp->defs.next; @@ -1095,9 +1094,7 @@ NextSection(GeometryInfo * info) static SectionInfo * FindMatchingSection(GeometryInfo * info, SectionInfo * new) { - SectionInfo *old; - - for (old = info->sections; old != NULL; + for (SectionInfo *old = info->sections; old != NULL; old = (SectionInfo *) old->defs.next) { if (new->name == old->name) @@ -2550,8 +2547,6 @@ static int HandleOverlayDef(OverlayDef * def, unsigned merge, SectionInfo * si, GeometryInfo * info) { - OverlayKeyDef *keyDef; - OverlayKeyInfo *key; OverlayInfo ol; if ((def->nKeys < 1) && (warningLevel > 3)) @@ -2565,10 +2560,10 @@ HandleOverlayDef(OverlayDef * def, bzero(&ol, sizeof(OverlayInfo)); ol.name = XkbInternAtom(info->dpy, XkbAtomGetString(NULL, def->name), False); - for (keyDef = def->keys; keyDef; + for (OverlayKeyDef *keyDef = def->keys; keyDef; keyDef = (OverlayKeyDef *) keyDef->common.next) { - key = uTypedCalloc(1, OverlayKeyInfo); + OverlayKeyInfo *key = uTypedCalloc(1, OverlayKeyInfo); if (!key) { if (warningLevel > 0) @@ -2599,11 +2594,10 @@ HandleOverlayDef(OverlayDef * def, static Bool HandleComplexKey(KeyDef * def, KeyInfo * key, GeometryInfo * info) { - RowInfo *row; - ExprDef *expr; + RowInfo *row = key->row; - row = key->row; - for (expr = def->expr; expr != NULL; expr = (ExprDef *) expr->common.next) + for (ExprDef *expr = def->expr; expr != NULL; + expr = (ExprDef *) expr->common.next) { if (expr->op == OpAssign) { @@ -2657,15 +2651,13 @@ static Bool HandleRowBody(RowDef * def, RowInfo * row, unsigned merge, GeometryInfo * info) { - KeyDef *keyDef; - if ((def->nKeys < 1) && (warningLevel > 3)) { ERROR("Row in section %s has no keys\n", rowText(info->dpy, row)); ACTION("Section ignored\n"); return True; } - for (keyDef = def->keys; keyDef != NULL; + for (KeyDef *keyDef = def->keys; keyDef != NULL; keyDef = (KeyDef *) keyDef->common.next) { if (keyDef->common.stmtType == StmtVarDef) @@ -2729,10 +2721,7 @@ static Bool HandleSectionBody(SectionDef * def, SectionInfo * si, unsigned merge, GeometryInfo * info) { - RowDef *rowDef; - DoodadInfo *di; - - for (rowDef = def->rows; rowDef != NULL; + for (RowDef *rowDef = def->rows; rowDef != NULL; rowDef = (RowDef *) rowDef->common.next) { if (rowDef->common.stmtType == StmtVarDef) @@ -2740,6 +2729,8 @@ HandleSectionBody(SectionDef * def, VarDef *var = (VarDef *) rowDef; ExprResult elem, field; ExprDef *ndx; + DoodadInfo *di; + if (ExprResolveLhs(var->name, &elem, &field, &ndx) == 0) return 0; /* internal error, already reported */ if ((elem.str == NULL) || (uStrCaseCmp(elem.str, "section") == 0)) @@ -2843,7 +2834,6 @@ HandleGeometryFile(XkbFile * file, XkbDescPtr xkb, unsigned merge, GeometryInfo * info) { ParseCommon *stmt; - const char *failWhat; if (merge == MergeDefault) merge = MergeAugment; @@ -2851,7 +2841,8 @@ HandleGeometryFile(XkbFile * file, stmt = file->defs; while (stmt) { - failWhat = NULL; + const char *failWhat = NULL; + switch (stmt->stmtType) { case StmtInclude: @@ -2923,9 +2914,9 @@ HandleGeometryFile(XkbFile * file, static Bool CopyShapeDef(Display * dpy, XkbGeometryPtr geom, ShapeInfo * si) { - int i, n; + int n; XkbShapePtr shape; - XkbOutlinePtr old_outline, outline; + XkbOutlinePtr old_outline; Atom name; si->index = geom->num_shapes; @@ -2938,9 +2929,11 @@ CopyShapeDef(Display * dpy, XkbGeometryPtr geom, ShapeInfo * si) return False; } old_outline = si->outlines; - for (i = 0; i < si->nOutlines; i++, old_outline++) + for (int i = 0; i < si->nOutlines; i++, old_outline++) { - outline = XkbAddGeomOutline(shape, old_outline->num_points); + XkbOutlinePtr outline = + XkbAddGeomOutline(shape, old_outline->num_points); + if (!outline) { WSGO("Couldn't allocate outline in shape\n"); @@ -3406,7 +3399,6 @@ VerifyOverlayInfo(XkbGeometryPtr geom, GeometryInfo * info, short rowMap[256], short rowSize[256]) { OverlayKeyInfo *ki, *next; - unsigned long oKey, uKey, sKey; XkbRowPtr row; XkbKeyPtr key; int r, k; @@ -3414,15 +3406,16 @@ VerifyOverlayInfo(XkbGeometryPtr geom, /* find out which row each key is in */ for (ki = oi->keys; ki != NULL; ki = (OverlayKeyInfo *) ki->defs.next) { - oKey = KeyNameToLong(ki->over); - uKey = KeyNameToLong(ki->under); + unsigned long oKey = KeyNameToLong(ki->over); + unsigned long uKey = KeyNameToLong(ki->under); + for (r = 0, row = section->rows; (r < section->num_rows) && oKey; r++, row++) { for (k = 0, key = row->keys; (k < row->num_keys) && oKey; k++, key++) { - sKey = KeyNameToLong(key->name.name); + unsigned long sKey = KeyNameToLong(key->name.name); if (sKey == oKey) { if (warningLevel > 0) @@ -3505,11 +3498,7 @@ CopyOverlayDef(XkbGeometryPtr geom, { Atom name; XkbOverlayPtr ol; - XkbOverlayRowPtr row; - XkbOverlayKeyPtr key; - OverlayKeyInfo *ki; short rowMap[256], rowSize[256]; - int i; if (!VerifyOverlayInfo(geom, section, oi, info, rowMap, rowSize)) return False; @@ -3522,7 +3511,7 @@ CopyOverlayDef(XkbGeometryPtr geom, XkbAtomText(info->dpy, section->name, XkbMessage)); return False; } - for (i = 0; i < oi->nRows; i++) + for (int i = 0; i < oi->nRows; i++) { int tmp, row_under; for (tmp = 0, row_under = -1; @@ -3540,10 +3529,11 @@ CopyOverlayDef(XkbGeometryPtr geom, return False; } } - for (ki = oi->keys; ki != NULL; ki = (OverlayKeyInfo *) ki->defs.next) + for (OverlayKeyInfo *ki = oi->keys; ki != NULL; + ki = (OverlayKeyInfo *) ki->defs.next) { - row = &ol->rows[ki->overlayRow]; - key = &row->keys[row->num_keys++]; + XkbOverlayRowPtr row = &ol->rows[ki->overlayRow]; + XkbOverlayKeyPtr key = &row->keys[row->num_keys++]; bzero(key, sizeof(XkbOverlayKeyRec)); strncpy(key->over.name, ki->over, XkbKeyNameLength); strncpy(key->under.name, ki->under, XkbKeyNameLength); @@ -3557,10 +3547,6 @@ static Bool CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info) { XkbSectionPtr section; - XkbRowPtr row; - XkbKeyPtr key; - KeyInfo *ki; - RowInfo *ri; Atom name; name = XkbInternAtom(NULL, XkbAtomGetString(NULL, si->name), False); @@ -3578,9 +3564,9 @@ CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info) section->height = si->height; section->angle = si->angle; section->priority = si->priority; - for (ri = si->rows; ri != NULL; ri = (RowInfo *) ri->defs.next) + for (RowInfo *ri = si->rows; ri != NULL; ri = (RowInfo *) ri->defs.next) { - row = XkbAddGeomRow(section, ri->nKeys); + XkbRowPtr row = XkbAddGeomRow(section, ri->nKeys); if (row == NULL) { WSGO("Couldn't allocate row in section\n"); @@ -3590,8 +3576,9 @@ CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info) row->top = ri->top; row->left = ri->left; row->vertical = ri->vertical; - for (ki = ri->keys; ki != NULL; ki = (KeyInfo *) ki->defs.next) + for (KeyInfo *ki = ri->keys; ki != NULL; ki = (KeyInfo *) ki->defs.next) { + XkbKeyPtr key; XkbColorPtr color; if ((ki->defs.defined & _GK_Name) == 0) { @@ -3632,16 +3619,15 @@ CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info) } if (si->doodads != NULL) { - DoodadInfo *di; - for (di = si->doodads; di != NULL; di = (DoodadInfo *) di->defs.next) + for (DoodadInfo *di = si->doodads; di != NULL; + di = (DoodadInfo *) di->defs.next) { CopyDoodadDef(geom, section, di, info); } } if (si->overlays != NULL) { - OverlayInfo *oi; - for (oi = si->overlays; oi != NULL; + for (OverlayInfo *oi = si->overlays; oi != NULL; oi = (OverlayInfo *) oi->defs.next) { CopyOverlayDef(geom, section, oi, info); @@ -3724,8 +3710,7 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge) if (info.props) { - PropertyInfo *pi; - for (pi = info.props; pi != NULL; + for (PropertyInfo *pi = info.props; pi != NULL; pi = (PropertyInfo *) pi->defs.next) { if (!XkbAddGeomProperty(geom, pi->name, pi->value)) @@ -3734,8 +3719,7 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge) } if (info.shapes) { - ShapeInfo *si; - for (si = info.shapes; si != NULL; + for (ShapeInfo *si = info.shapes; si != NULL; si = (ShapeInfo *) si->defs.next) { if (!CopyShapeDef(xkb->dpy, geom, si)) @@ -3744,8 +3728,7 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge) } if (info.sections) { - SectionInfo *si; - for (si = info.sections; si != NULL; + for (SectionInfo *si = info.sections; si != NULL; si = (SectionInfo *) si->defs.next) { if (!CopySectionDef(geom, si, &info)) @@ -3754,8 +3737,7 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge) } if (info.doodads) { - DoodadInfo *di; - for (di = info.doodads; di != NULL; + for (DoodadInfo *di = info.doodads; di != NULL; di = (DoodadInfo *) di->defs.next) { if (!CopyDoodadDef(geom, NULL, di, &info)) |