--- ./util/wmsetbg.c.orig-wsnum Thu Jun 7 18:39:51 2001 +++ ./util/wmsetbg.c Sun Aug 12 23:44:24 2001 @@ -1214,13 +1214,17 @@ void -changeTextureForWorkspace(char *domain, char *texture, int workspace) +changeTextureForWorkspace(char *domain, char *texture, unsigned int workspace) { proplist_t array; proplist_t val; char *value; - int j; + unsigned int j; + if (0 == workspace) { + return; + } + val = PLGetProplistWithDescription(texture); if (!val) { wwarning("could not parse texture %s", texture); @@ -1234,18 +1238,24 @@ } j = PLGetNumberOfElements(array); - if (workspace >= j) { - proplist_t empty; + if (j < workspace) { + if (++j < workspace) { + proplist_t empty; - empty = PLMakeArrayFromElements(NULL, NULL); + empty = PLMakeArrayFromElements(NULL, NULL); - while (j++ < workspace-1) { - PLAppendArrayElement(array, empty); + for (; j < workspace; ++j) { + PLAppendArrayElement(array, empty); + } } PLAppendArrayElement(array, val); } else { - PLRemoveArrayElement(array, workspace); - PLInsertArrayElement(array, val, workspace); + /* Workspace number is 1-origin. + * PL array manipulation functions are 0-origin. + */ + j = workspace - 1; + PLInsertArrayElement(array, val, j); + PLRemoveArrayElement(array, j+1); } value = PLGetDescription(array); @@ -1266,7 +1276,7 @@ char *domain = "WindowMaker"; int update=0, cpc=4, render_mode=RDitheredRendering, obey_user=0; char *texture = NULL; - int workspace = -1; + unsigned int workspace = 0; /* Workspace number is 1-origin. */ signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); @@ -1360,7 +1370,7 @@ wfatal("too few arguments for %s\n", argv[i-1]); exit(1); } - if (sscanf(argv[i], "%i", &workspace)!=1) { + if ((sscanf(argv[i], "%u", &workspace)!=1) || (0 == workspace)) { wfatal("bad value for workspace number: \"%s\"", argv[i]); exit(1); @@ -1458,7 +1468,7 @@ texture = (char*)buffer; } - if (update && workspace < 0) { + if (update && (0 == workspace)) { updateDomain(domain, "WorkspaceBack", texture); } @@ -1466,7 +1476,7 @@ if (!tex) exit(1); - if (workspace<0) + if (0 == workspace) changeTexture(tex); else { /* always update domain */