Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!island!argv From: argv@island.uu.net (Dan Heller) Newsgroups: comp.sources.x Subject: v05i005: xwps3, Patch1 Message-ID: <1090@island.uu.net> Date: 24 Sep 89 17:54:28 GMT Organization: Island Graphics, Marin County, California Lines: 52 Approved: island!argv@sun.com Submitted-by: uunet!cs.buffalo.edu!sigmast!planck!meyer Posting-number: Volume 5, Issue 5 Archive-name: xwps3/patch1 Patch-To: xwps3: Volume 5, Issue 2 [ From the Author: ] I have been informed of a major problem with my 'xwps' program (which has been dubbed 'xwps3' by our moderator) which will cause it to fill filesystems with NULLs on little endian machines (i.e. VAXEN and VAXStations). It seems that a little piece of code left over from the translation from 'xwd' causes major problems. The original code (xwd) had to translate to big endian form on little endian machines in order to generate a common bitmap format file. It doesn't even get invoked on big endian machines so I never questioned it. Here's the context diff. *** xwps.old Fri Sep 22 17:17:07 1989 --- xwps.c Fri Sep 22 17:17:25 1989 *************** *** 144,150 **** Window window; FILE *out; { - unsigned long swaptest = 1; XColor *colors; unsigned buffer_size; int win_name_size; --- 144,149 ---- *************** *** 257,270 **** header.window_y = (xwdval) win_info.y; } header.window_bdrwidth = (xwdval) win_info.border_width; - - if (*(char *) &swaptest) { - _swaplong((char *) &header, sizeof(header)); - for (i = 0; i < ncolors; i++) { - _swaplong((char *) &colors[i].pixel, sizeof(long)); - _swapshort((char *) &colors[i].red, 3 * sizeof(short)); - } - } openImage(out, header.pixmap_width, header.pixmap_height); writeImage(out,image,header.pixmap_width, header.pixmap_height,colors,ncolors); --- 256,261 ---- -- Thinking quickly, the IBM System Jock # Bob Meyer uttered an incantation in EBCDIC and made # Calspan Advanced Tech. Center the sign of the Terminated Fork. # ...!sunybcs!planck!meyer The UNIX Guru only smiled and trapped him in a recursive SED script.