bradley@grip.cis.upenn.edu (John Bradley) (10/19/90)
Submitted-by: bradley@grip.cis.upenn.edu (John Bradley) Posting-number: Volume 9, Issue 100 Archive-name: xv/patch1 Patch-To: xv: Volume 9, Issue 76-83 Minor patches to XV: * modifications for SYSV systems and Convex systems * a 'vprintf' module has been added to allow it to run on machines that don't have 'vprintf' in the standard library (BSD 4.3 machines), * problems with 'olwm' fixed * an Imakefile has been added * quieter compilation on paranoid compilers * an icon has been added * and, of course, some bugs have been fixed John Bradley - University of Pennsylvania - GRASP Lab (bradley@cis.upenn.edu) (apply with 'patch -p <filename') ---------------------------(cut here)----------------------------- *** ../xv1/README Wed Oct 17 23:26:22 1990 --- ./README Wed Oct 17 15:03:31 1990 *************** *** 1,8 **** Installation ------------ ! Check the Makefile for the configuration option(s). 'make'. Enjoy. Caveats ------- --- 1,13 ---- Installation ------------ ! If you don't plan to use Imake, copy 'Makefile.std' (a regular old-style ! minimalist makefile, not one created by Imake) to 'Makefile'. + Check the Makefile for the configuration option(s). Make it. + Otherwise, check the Imakefile, and make the program however you normally + would. + Caveats ------- *************** *** 26,34 **** Provided you don't have some odd-ball 5-bit StaticColor display, it should work for you. ! One note: on some machines, the function 'vsprintf' (a VARARGS sprintf()) ! doesn't exist. You won't be able to compile on these machines. They are ! wrong. Bizarrities --- 31,38 ---- Provided you don't have some odd-ball 5-bit StaticColor display, it should work for you. ! 'vsprintf.c' has been included for the benefit of those on machines that ! don't have it. (IBM RT AOS 4.3 and BSD 4.3 on VAX) Bizarrities *** ../xv1/bggen.c Wed Oct 17 23:26:01 1990 --- ./bggen.c Wed Oct 17 18:39:27 1990 *************** *** 5,10 **** --- 5,11 ---- * (bradley@cis.upenn.edu) * * Rev: 8/31/90 + * Rev: 10/17/90 - added '-w' option */ /* *************** *** 39,52 **** { int i,j,cnt,numcols; int high = DEFSIZE; int bits = 8; int r, g, b; - int bandsize; cnt = 0; numcols = 0; for (i=1; i<argc; i++) { if (!strcmp(argv[i],"-s")) high = atoi(argv[++i]); else if (!strcmp(argv[i],"-b")) bits = atoi(argv[++i]); else if (argv[i][0]=='-') break; /* any other '-' option is unknown */ --- 40,55 ---- { int i,j,cnt,numcols; int high = DEFSIZE; + int wide = 1; int bits = 8; int r, g, b; cnt = 0; numcols = 0; for (i=1; i<argc; i++) { if (!strcmp(argv[i],"-s")) high = atoi(argv[++i]); + else if (!strcmp(argv[i],"-w")) wide = atoi(argv[++i]); + else if (!strcmp(argv[i],"-b")) bits = atoi(argv[++i]); else if (argv[i][0]=='-') break; /* any other '-' option is unknown */ *************** *** 68,78 **** if (cnt || numcols==0 || high<1 || bits<1 || bits>8) { ! fprintf(stderr,"usage: %s [-s size] [-b bits] r1 g1 b1 [r2 g2 b2 ...]\n\n" ! ,argv[0]); ! fprintf(stderr,"\tThis will generate a 1xSIZE vertical color band.\n"); ! fprintf(stderr,"\t(SIZE defaults to %d.) To set your background\n", ! DEFSIZE); fprintf(stderr,"\t'bits' is the number of significant bits in the\n"); fprintf(stderr,"\tcolor specifications. (1-8)\n"); fprintf(stderr,"\tpipe the resulting output into this cmd:\n"); --- 71,80 ---- if (cnt || numcols==0 || high<1 || bits<1 || bits>8) { ! fprintf(stderr,"usage: %s [-s size] [-w width] [-b bits] %s\n\n", ! argv[0], "r1 g1 b1 [r2 g2 b2 ...]"); ! fprintf(stderr,"\tThis will generate a WIDTHxSIZE vertical color band.\n"); ! fprintf(stderr,"\t(Default: 1x%d) To set your background\n",DEFSIZE); fprintf(stderr,"\t'bits' is the number of significant bits in the\n"); fprintf(stderr,"\tcolor specifications. (1-8)\n"); fprintf(stderr,"\tpipe the resulting output into this cmd:\n"); *************** *** 80,91 **** exit(1); } ! printf("P3 1 %d 255\n",high); /* special case code for numcols==1 */ if (numcols==1) { ! for (i=0; i<high; i++) printf("%d %d %d\n",cols[0].r,cols[0].g,cols[0].b); } else { --- 82,95 ---- exit(1); } ! printf("P3 %d %d 255\n",wide,high); /* special case code for numcols==1 */ if (numcols==1) { ! for (i=0; i<high; i++) ! for (j=0; j<wide; j++) ! printf("%d %d %d\n",cols[0].r,cols[0].g,cols[0].b); } else { *************** *** 107,115 **** g = g & bmask[bits-1]; b = b & bmask[bits-1]; ! printf("%d %d %d\n",r,g,b); } } } --- 111,122 ---- g = g & bmask[bits-1]; b = b & bmask[bits-1]; ! for (j=0; j<wide; j++) ! printf("%d %d %d\n",r,g,b); } } } + + *** ../xv1/xv.c Wed Oct 17 23:25:56 1990 --- ./xv.c Wed Oct 17 19:35:52 1990 *************** *** 26,31 **** --- 26,32 ---- #define NEEDSDIR /* for value of MAXPATHLEN */ #include "xv.h" + #include "bitmaps.h" #include <X11/Xatom.h> *************** *** 87,94 **** static void TrackPicValues(); static void MakeDispNames(); static int Rect(); ! static int CheckForConfig(); ! static Bool IsConfig(); static void SaveRootInfo(); static void KillOldRootInfo(); static int rd_int(); --- 88,95 ---- static void TrackPicValues(); static void MakeDispNames(); static int Rect(); ! /* static int CheckForConfig(); ! static Bool IsConfig(); */ static void SaveRootInfo(); static void KillOldRootInfo(); static int rd_int(); *************** *** 114,120 **** --- 115,125 ---- /*** Variable Initialization ***/ /*****************************************************/ + #ifdef SYSV + getcwd(initpath, sizeof(initpath)); + #else getwd(initpath); + #endif /* init internal variables */ display = fname = whitestr = blackstr = NULL; *************** *** 450,455 **** --- 455,462 ---- mono = 1; } + iconPix = XCreatePixmapFromBitmapData(theDisp, rootW, icon_bits, + icon_width, icon_height, 1, 0, 1); /* try to load fonts */ if ( (mfinfo = XLoadQueryFont(theDisp,FONT1))==NULL && *************** *** 480,485 **** --- 487,493 ---- if (dispDEEP>1) ncols = 1<<dispDEEP; else ncols = 0; } + else if (ncols>256) ncols = 256; /* so program doesn't blow up */ if (numnames==0) { /* no filenames. build one-name (stdio) list */ namelist[0] = STDINSTR; *************** *** 534,539 **** --- 542,548 ---- /* Do The Thing... */ MainLoop(); Quit(0); + return(0); } *************** *** 1059,1068 **** i=ClickCtrl(but_event->x, but_event->y); if (i>=0) { switch (i) { ! case BNEXT: retval=NEXTPIC; done=1; break; ! case BPREV: retval=PREVPIC; done=1; break; case BSAVE: DirBox(1); break; ! case BQUIT: retval=QUIT; done=1; break; case BCROP: DoCrop(); break; case BUNCROP: UnCrop(); break; --- 1068,1077 ---- i=ClickCtrl(but_event->x, but_event->y); if (i>=0) { switch (i) { ! case BNEXT: retval= NEXTPIC; done=1; break; ! case BPREV: retval= PREVPIC; done=1; break; case BSAVE: DirBox(1); break; ! case BQUIT: retval= QUIT; done=1; break; case BCROP: DoCrop(); break; case BUNCROP: UnCrop(); break; *************** *** 1106,1112 **** if (i==S_BOPEN) SelectDir(dList.selected); else if (i==S_BCANC) DirBox(0); else if (i==S_BSAVE) DoSave(); ! else if (i==S_BQUIT) { retval=QUIT; done=1; } } else if (but_event->window == dList.win) { --- 1115,1121 ---- if (i==S_BOPEN) SelectDir(dList.selected); else if (i==S_BCANC) DirBox(0); else if (i==S_BSAVE) DoSave(); ! else if (i==S_BQUIT) { retval = QUIT; done=1; } } else if (but_event->window == dList.win) { *************** *** 1270,1275 **** --- 1279,1285 ---- XSetWindowAttributes xswa; unsigned int xswamask; XWindowAttributes xwa; + XWMHints xwmh; XSizeHints hints; int i,x,y; unsigned int w,h; *************** *** 1291,1296 **** --- 1301,1308 ---- eWIDE = eWIDE / normFact; eHIGH = eHIGH / normFact; } + if (eWIDE < 1) eWIDE = 1; + if (eHIGH < 1) eHIGH = 1; if (fixedaspect && i&WidthValue && i&HeightValue) FixAspect(0,&eWIDE,&eHIGH); else if (i&WidthValue && i&HeightValue) *************** *** 1308,1313 **** --- 1320,1328 ---- if (x+eWIDE > dispWIDE) x = dispWIDE - eWIDE; /* keep on screen */ if (y+eHIGH > dispHIGH) y = dispHIGH - eHIGH; + if (eWIDE < 1) eWIDE = 1; + if (eHIGH < 1) eHIGH = 1; + hints.x = x; hints.y = y; hints.width = eWIDE; hints.height = eHIGH; hints.max_width = dispWIDE; hints.max_height = dispHIGH; *************** *** 1325,1331 **** } if (!mainW) ! mainW = XCreateWindow(theDisp,rootW,x,y,eWIDE,eHIGH,bwidth,0, CopyFromParent, CopyFromParent, xswamask, &xswa); sprintf(winname,"xv %s",name); --- 1340,1346 ---- } if (!mainW) ! mainW = XCreateWindow(theDisp,rootW,x,y,eWIDE,eHIGH,bwidth,CopyFromParent, CopyFromParent, CopyFromParent, xswamask, &xswa); sprintf(winname,"xv %s",name); *************** *** 1333,1338 **** --- 1348,1358 ---- XSetStandardProperties(theDisp,mainW,winname,iconname,None, NULL,0,&hints); + xwmh.input = True; + xwmh.flags = InputHint; + if (iconPix) { xwmh.icon_pixmap = iconPix; xwmh.flags |= IconPixmapHint; } + XSetWMHints(theDisp, mainW, &xwmh); + if (!mainW) FatalError("can't create window!"); } *************** *** 1383,1388 **** --- 1403,1411 ---- *h = dispHIGH; *w = (int) (*w / a + .5); } + + if (*w < 1) *w = 1; + if (*h < 1) *h = 1; } *************** *** 1547,1553 **** XWindowAttributes *xwa; { /* sets window x,y,w,h values */ ! XSizeHints xsh; Window root, parent, *children, child; unsigned int nchildren; XWindowAttributes pxwa; --- 1570,1576 ---- XWindowAttributes *xwa; { /* sets window x,y,w,h values */ ! /* XSizeHints xsh; */ Window root, parent, *children, child; unsigned int nchildren; XWindowAttributes pxwa; *************** *** 1727,1733 **** int mx,my; { Window rW,cW; ! int rx,ry,ox,oy,x,y,active; unsigned int mask; int ty, w; char foo[40]; --- 1750,1756 ---- int mx,my; { Window rW,cW; ! int rx,ry,ox,oy,x,y; unsigned int mask; int ty, w; char foo[40]; *************** *** 1835,1841 **** } ! /***********************************/ static int CheckForConfig() { --- 1858,1864 ---- } ! #ifdef FOOBAR /***********************************/ static int CheckForConfig() { *************** *** 1864,1870 **** } return False; } ! /***********************************/ void MakeRootPic() --- 1887,1893 ---- } return False; } ! #endif /***********************************/ void MakeRootPic() *** ../xv1/xv.h Wed Oct 17 23:25:56 1990 --- ./xv.h Wed Oct 17 14:57:57 1990 *************** *** 16,34 **** * This software is provided "as is" without any express or implied warranty. */ ! #define REVDATE "Rev: 10/9/90" /* include files */ #include <stdio.h> #include <math.h> #include <ctype.h> #include <string.h> - #include <memory.h> /* for 'memset()' prototype */ extern int errno; /* this SHOULD be in errno.h */ extern char *sys_errlist[]; /* this SHOULD be in errno.h */ #include <X11/Xos.h> #include <X11/Xlib.h> #include <X11/Xutil.h> --- 16,47 ---- * This software is provided "as is" without any express or implied warranty. */ ! #define REVDATE "Rev: 10/17/90" + #ifdef SVR4 + #define DIRENT /* SysV release 4 uses dirent */ + #endif + /* include files */ #include <stdio.h> #include <math.h> #include <ctype.h> #include <string.h> extern int errno; /* this SHOULD be in errno.h */ extern char *sys_errlist[]; /* this SHOULD be in errno.h */ + #ifndef __convexc__ /* Convex doesn't have <memory.h> */ + #include <memory.h> /* for 'memset()' prototype */ + #endif + /* neither IBM AOS 4.3, Convex, nor BSD 4.3 on VAX have <malloc.h> */ + #if !defined(ibm032) && !defined(__convexc__) && \ + !(defined(vax) && !defined(ultrix)) + #include <malloc.h> + #endif + + #include <X11/Xos.h> #include <X11/Xlib.h> #include <X11/Xutil.h> *************** *** 35,46 **** #include <X11/cursorfont.h> #include <X11/keysym.h> ! #ifndef ibm032 /* IBM RT 4.3 doesn't have malloc.h */ ! #include <malloc.h> #endif #ifdef NEEDSTIME - #include <sys/types.h> #include <sys/timeb.h> #include <signal.h> #ifndef sigmask --- 48,59 ---- #include <X11/cursorfont.h> #include <X11/keysym.h> ! ! #if defined(NEEDSTIME) || defined(NEEDSDIR) ! #include <sys/types.h> /* only include <sys/types.h> once */ #endif #ifdef NEEDSTIME #include <sys/timeb.h> #include <signal.h> #ifndef sigmask *************** *** 49,55 **** #endif #ifdef NEEDSDIR - #include <sys/types.h> #include <sys/dir.h> #include <sys/param.h> #include <sys/stat.h> --- 62,67 ---- *************** *** 259,264 **** --- 271,277 ---- WHERE XFontStruct *mfinfo, *monofinfo; WHERE Visual *theVisual; WHERE Cursor arrow, cross; + WHERE Pixmap iconPix; /* global vars used by LOAD routines */ WHERE byte *pic; /* ptr to loaded picture */ *** ../xv1/xv24to8.c Wed Oct 17 23:25:57 1990 --- ./xv24to8.c Wed Oct 17 18:22:37 1990 *************** *** 912,924 **** indicies (in pic) */ unsigned long colors[256],col; ! int i, nc, low, high, mid, k; byte *p, *pix; if (maxcol>256) maxcol = 256; /* put the first color in the table by hand */ ! nc = 0; for (i=w*h,p=pic24; i; i--) { col = (*p++ << 16); --- 912,924 ---- indicies (in pic) */ unsigned long colors[256],col; ! int i, nc, low, high, mid; byte *p, *pix; if (maxcol>256) maxcol = 256; /* put the first color in the table by hand */ ! nc = 0; mid = 0; for (i=w*h,p=pic24; i; i--) { col = (*p++ << 16); *************** *** 937,946 **** if (high < low) { /* didn't find color in list, add it. */ /* WARNING: this is an overlapped memory copy. memcpy doesn't do it correctly, hence 'bcopy', which claims to */ bcopy(&colors[low], &colors[low+1], (nc - low) * sizeof(unsigned long)); colors[low] = col; nc++; - if (nc>maxcol) return 0; } } --- 937,946 ---- if (high < low) { /* didn't find color in list, add it. */ /* WARNING: this is an overlapped memory copy. memcpy doesn't do it correctly, hence 'bcopy', which claims to */ + if (nc>=maxcol) return 0; bcopy(&colors[low], &colors[low+1], (nc - low) * sizeof(unsigned long)); colors[low] = col; nc++; } } *** ../xv1/xvdir.c Wed Oct 17 23:25:59 1990 --- ./xvdir.c Wed Oct 17 18:25:46 1990 *************** *** 336,342 **** --- 336,346 ---- numdirnames = 0; + #ifdef SYSV + getcwd(path, sizeof(path)); + #else getwd(path); + #endif if (path[strlen(path)-1] != '/') strcat(path,"/"); /* tack on a trailing '/' to make path consistent */ *************** *** 365,371 **** --- 369,379 ---- /* skip over '.' and '..' */ } else { + #ifdef DIRENT + dirnames[i] = (char *) malloc(strlen(dp->d_name) + 3); + #else dirnames[i] = (char *) malloc(dp->d_namlen + 2); /* +2=filetype + '\0'*/ + #endif if (!dirnames[i]) FatalError("malloc error while reading directory"); strcpy(dirnames[i]+1, dp->d_name); *************** *** 374,382 **** if (lstat(dirnames[i]+1, &st)==0) { ftype = st.st_mode & S_IFMT; /* mask off uninteresting bits */ ! if (ftype == S_IFIFO) dirnames[i][0] = C_FIFO; else if (ftype == S_IFCHR) dirnames[i][0] = C_CHR; - else if (ftype == S_IFDIR) dirnames[i][0] = C_DIR; else if (ftype == S_IFBLK) dirnames[i][0] = C_BLK; else if (ftype == S_IFLNK) dirnames[i][0] = C_LNK; else if (ftype == S_IFSOCK) dirnames[i][0] = C_SOCK; --- 382,392 ---- if (lstat(dirnames[i]+1, &st)==0) { ftype = st.st_mode & S_IFMT; /* mask off uninteresting bits */ ! if (ftype == S_IFDIR) dirnames[i][0] = C_DIR; ! #ifdef S_IFIFO ! else if (ftype == S_IFIFO) dirnames[i][0] = C_FIFO; ! #endif else if (ftype == S_IFCHR) dirnames[i][0] = C_CHR; else if (ftype == S_IFBLK) dirnames[i][0] = C_BLK; else if (ftype == S_IFLNK) dirnames[i][0] = C_LNK; else if (ftype == S_IFSOCK) dirnames[i][0] = C_SOCK; *************** *** 534,540 **** GammifyColors(); } ! i = RBWhich(formatRB); switch (i) { case 0: rv = WriteGIF(fp,thepic,w, h, r, g, b, numcols, RBWhich(colorRB)); --- 544,550 ---- GammifyColors(); } ! rv = 0; i = RBWhich(formatRB); switch (i) { case 0: rv = WriteGIF(fp,thepic,w, h, r, g, b, numcols, RBWhich(colorRB)); *** ../xv1/xvfish.c Wed Oct 17 23:26:22 1990 --- ./xvfish.c Wed Oct 17 14:26:35 1990 *************** *** 102,108 **** --- 102,112 ---- if (!fish) return; if (!fishrunning) return; + #ifdef SVR4 + sighold(SIGALRM); + #else sigblock(sigmask(SIGALRM)); + #endif bzero(&it, sizeof(it)); it.it_interval.tv_usec = 0L; it.it_value.tv_usec = 0L; *************** *** 109,115 **** --- 113,123 ---- setitimer(ITIMER_REAL, &it, (struct itimerval *)0); signal(SIGALRM,SIG_DFL); + #ifdef SVR4 + sigrelse(SIGALRM); + #else sigblock(0); + #endif fishrunning = 0; } *************** *** 159,165 **** --- 167,177 ---- it.it_value.tv_usec = DELAY; signal(SIGALRM,dofish); + #ifdef SVR4 + sigrelse(SIGALRM); + #else sigsetmask(0); + #endif setitimer(ITIMER_REAL, &it, (struct itimerval *)0); } *** ../xv1/xvgam.c Wed Oct 17 23:25:59 1990 --- ./xvgam.c Wed Oct 17 18:39:01 1990 *************** *** 254,260 **** /* called when we've gotten a click inside graph window */ Window rW, cW; ! int x, y, rx, ry, rval; unsigned int mask; int h, vertonly, offx, offy; --- 254,260 ---- /* called when we've gotten a click inside graph window */ Window rW, cW; ! int x, y, rx, ry; unsigned int mask; int h, vertonly, offx, offy; *************** *** 377,383 **** to map to white (255) (roughly). Values between 50 and 200 will cover the output range 0-255. The reponse curve will be slightly 's' shaped. */ ! int i,j,k; static int x[4] = {0,32,224,255}; static int y[4] = {0, 0,255,255}; float yf[4]; --- 377,383 ---- to map to white (255) (roughly). Values between 50 and 200 will cover the output range 0-255. The reponse curve will be slightly 's' shaped. */ ! int i,j; static int x[4] = {0,32,224,255}; static int y[4] = {0, 0,255,255}; float yf[4]; *************** *** 455,461 **** { int i,p, app; ! app = 1; switch (cmd) { case G_BAPPLY: DoGammaApply(1); app = 0; break; --- 455,461 ---- { int i,p, app; ! app = 1; p=0; switch (cmd) { case G_BAPPLY: DoGammaApply(1); app = 0; break; *************** *** 696,703 **** if (max != 0.0) s = (del) / max; else s = 0.0; ! if (s == 0.0) h = NOHUE; ! else { rc = (max - rd) / del; gc = (max - gd) / del; bc = (max - bd) / del; --- 696,703 ---- if (max != 0.0) s = (del) / max; else s = 0.0; ! h = NOHUE; ! if (s != 0.0) { rc = (max - rd) / del; gc = (max - gd) / del; bc = (max - bd) / del; *** ../xv1/xvmisc.c Wed Oct 17 23:25:58 1990 --- ./xvmisc.c Wed Oct 17 18:19:15 1990 *************** *** 62,67 **** --- 62,68 ---- Window win; XSetWindowAttributes xswa; unsigned int xswamask; + XWMHints xwmh; XSizeHints hints; int i,x,y; *************** *** 88,98 **** xswamask = CWBackPixel | CWBorderPixel; win = XCreateWindow(theDisp, rootW, x, y, w, h, ! bwidth, 0, CopyFromParent, CopyFromParent, xswamask, &xswa); if (!win) return(win); /* leave immediately if couldn't create */ XSetStandardProperties(theDisp, win, name, name, None, NULL, 0, &hints); return(win); } --- 89,105 ---- xswamask = CWBackPixel | CWBorderPixel; win = XCreateWindow(theDisp, rootW, x, y, w, h, ! bwidth, CopyFromParent, CopyFromParent, CopyFromParent, xswamask, &xswa); if (!win) return(win); /* leave immediately if couldn't create */ XSetStandardProperties(theDisp, win, name, name, None, NULL, 0, &hints); + + xwmh.input = True; + xwmh.flags = InputHint; + if (iconPix) { xwmh.icon_pixmap = iconPix; xwmh.flags |= IconPixmapHint; } + XSetWMHints(theDisp, win, &xwmh); + return(win); } *************** *** 1377,1382 **** --- 1384,1390 ---- { Cursor c; + c = cross; /* if n < 0 sets normal cursor in all windows n = 0..6 cycles through fish cursors */ *************** *** 1450,1461 **** --- 1458,1477 ---- signal(SIGALRM,onalarm); setitimer(ITIMER_REAL, &it, (struct itimerval *)0); while (1) { + #ifdef SVR4 + sighold(SIGALRM); + #else sigblock(sigmask(SIGALRM)); /* note: have to block, so that ALRM */ + #endif if (timerdone) break; /* doesn't occur between 'if (timerdone)' */ else sigpause(0); /* and calling sigpause(0) */ } + #ifdef SVR4 + sigrelse(SIGALRM); + #else sigblock(0); /* turn ALRM blocking off */ + #endif signal(SIGALRM,SIG_DFL); } *** ../xv1/xvpbm.c Wed Oct 17 23:26:22 1990 --- ./xvpbm.c Wed Oct 17 20:29:09 1990 *************** *** 54,60 **** int c, c1; int w, h, maxv, rv; ! garbage = 0; /* open the stream, if necesary */ fp=fopen(fname,"r"); --- 54,60 ---- int c, c1; int w, h, maxv, rv; ! garbage = maxv = 0; /* open the stream, if necesary */ fp=fopen(fname,"r"); *************** *** 107,113 **** int w,h,raw; { byte *pix; ! int i,j,k,bit; SetISTR(ISTR_FORMAT,"PBM, %s format. (%ld bytes)", --- 107,113 ---- int w,h,raw; { byte *pix; ! int i,j,bit; SetISTR(ISTR_FORMAT,"PBM, %s format. (%ld bytes)", *************** *** 138,144 **** else { /* read raw bits */ ! int trunc = 0; for (i=0, pix=pic; i<h; i++) for (j=0,bit=0; j<w; j++, pix++, bit++) { --- 138,144 ---- else { /* read raw bits */ ! int trunc = 0, k = 0; for (i=0, pix=pic; i<h; i++) for (j=0,bit=0; j<w; j++, pix++, bit++) { *** ../xv1/xvxbm.c Wed Oct 17 23:26:21 1990 --- ./xvxbm.c Wed Oct 17 18:34:33 1990 *************** *** 56,61 **** --- 56,62 ---- char line[256]; byte hex[256]; + k = 0; fp=fopen(fname,"r"); if (!fp) return 1; *** ../xv1/docs/bggen.man Wed Oct 17 23:26:26 1990 --- ./docs/bggen.man Wed Oct 17 16:44:18 1990 *************** *** 2,10 **** .SH NAME bggen \- generates colored backgrounds on X11 displays .SH SYNTAX ! \fBbggen\fP [-s size] [-b bits] r1 g1 b1 [r2 g2 b2 ... rn gn bn] .SH DESCRIPTION ! \fBbggen\fP is a program that generates a 1-pixel wide by size-pixels high vertical stripe. The top of the stripe is in color (r1,g1,b1), and the bottom of the stripe is in color (rn,gn,bn). Intermediate colors are interpolated between these colors. If you specify more than 2 colors, the --- 2,10 ---- .SH NAME bggen \- generates colored backgrounds on X11 displays .SH SYNTAX ! \fBbggen\fP [-w width] [-s size] [-b bits] r1 g1 b1 [r2 g2 b2 ... rn gn bn] .SH DESCRIPTION ! \fBbggen\fP is a program that generates a width-pixel wide by size-pixels high vertical stripe. The top of the stripe is in color (r1,g1,b1), and the bottom of the stripe is in color (rn,gn,bn). Intermediate colors are interpolated between these colors. If you specify more than 2 colors, the *************** *** 30,35 **** --- 30,39 ---- otherwise you will get a bizarre repeating effect, that you probably didn't want. Note: If you specify small values of '-s', you can get some neat effects. + .PP + The '-w' argument has been added to improve the performance of various + stippling algorithms (as in XV). More information to work with, and such. + Try using '-w 16' on these command lines to see what is meant. .SH TRY THESE .nf Light Blue to Dark Blue *************** *** 52,54 **** --- 56,59 ---- and also by hexadecimal value. .SH AUTHOR John Bradley - bradley@cis.upenn.edu + *** /dev/null Thu Oct 18 00:00:14 1990 --- ./Imakefile Wed Oct 17 15:11:26 1990 *************** *** 0 **** --- 1,69 ---- + /* + * optimization/debugging options for your C compiler + * Note: If you are running on a POSIX-compatible machine, such as an + * IBM RS6000, you MAY need to add '-DDIRENT' to DEFINES. To determine + * if this is the case, do a 'man readdir' on your machine. If + * readdir() returns a pointer to 'struct direct', you will not have + * to change anything. If, however, readdir() returns a pointer to + * 'struct dirent', you will have to add the '-DDIRENT' to DEFINES + */ + + /* + * Vax BSD and IBM AOS don't have vprintf or vsprintf. + * Note that our local library versions of sprintf have been updated + * to return int, the number of characters in the formatted string, + * whereas the versions in stock 4.3BSD do not so return. You may + * have to remove the "-DINTSPRINTF" below if you're compiling for + * stock 4.3BSD or for some other Vax or RT library package where + * sprintf returns char *. + * + * Also, I define NOVOID on the Vax because I'm using pcc to compile. + * If you use gcc or some other better compiler, this should not be + * necessary. I define NOSTDHDRS on the RT because we don't have + * standard ANSI header files installed for the RT, even though the RT + * compiler claims to be ANSI-compliant. + */ + #if defined(VaxArchitecture) && !defined(UltrixArchitecture) + DEFINES= -DNEED_VPRINTF -DINTSPRINTF -DLONGINT -DNOVOID + #else + # if defined(RtArchitecture) && !defined(AIXArchitecture) + DEFINES= -DNEED_VPRINTF -DINTSPRINTF -DLONGINT -DNOSTDHDRS + # endif + #endif + + SYS_LIBRARIES= -lX11 -lm + + BITMAPS = bitmaps/grasp bitmaps/penn bitmaps/down bitmaps/down1 \ + bitmaps/up bitmaps/up1 bitmaps/scrlgray bitmaps/gray50 \ + bitmaps/gray25 bitmaps/i_fifo bitmaps/i_chr bitmaps/i_dir \ + bitmaps/i_blk bitmaps/i_lnk bitmaps/i_sock bitmaps/i_reg \ + bitmaps/rb_off bitmaps/rb_on bitmaps/rb_off1 bitmaps/rb_on1 \ + bitmaps/fc_left bitmaps/fc_leftm bitmaps/fc_mid bitmaps/fc_midm \ + bitmaps/fc_right bitmaps/fc_rightm bitmaps/fc_left1 \ + bitmaps/fc_left1m bitmaps/fc_right1 bitmaps/fc_right1m \ + bitmaps/icon + + SRCS1 = xv.c xv24to8.c xvbutt.c xvctrl.c xvdir.c xvfish.c xvgam.c\ + xvgif.c xvgifwr.c xvinfo.c xvmisc.c xvpbm.c xvpm.c xvscrl.c\ + xvxbm.c vprintf.c + + OBJS1 = xv.o xv24to8.o xvbutt.o xvctrl.o xvdir.o xvfish.o xvgam.o\ + xvgif.o xvgifwr.o xvinfo.o xvmisc.o xvpbm.o xvpm.o xvscrl.o \ + xvxbm.o vprintf.o + + SRCS2= bggen.c + OBJS2= bggen.o + + PROGRAMS= xv bggen + + ComplexProgramTarget_1(xv,,) + ComplexProgramTarget_2(bggen,,) + + tar: + tar cf xv.tar Makefile *.c *.h bitmaps docs $(MISC) + + bitmaps.h: $(BITMAPS) + cat $(BITMAPS) > bitmaps.h + + depend:: bitmaps.h + *** /dev/null Thu Oct 18 00:00:14 1990 --- ./Makefile.std Wed Oct 17 22:54:52 1990 *************** *** 0 **** --- 1,86 ---- + # Makefile for xv + # + + # your C compiler of choice + CC = cc + + # optimization/debugging options for your C compiler + # Note: If you are running on a POSIX-compatible machine, such as an + # IBM RS6000, you MAY need to add '-DDIRENT' to CFLAGS. To determine + # if this is the case, do a 'man readdir' on your machine. If + # readdir() returns a pointer to 'struct direct', you will not have + # to change anything. If, however, readdir() returns a pointer to + # 'struct dirent', you will have to add the '-DDIRENT' to CFLAGS + + # IF YOUR MACHINE DOESN'T HAVE 'vprintf()' OR 'vsprintf()' + # + # Vax BSD and IBM AOS don't have vprintf or vsprintf. + # Note that our local library versions of sprintf have been updated + # to return int, the number of characters in the formatted string, + # whereas the versions in stock 4.3BSD do not so return. You may + # have to remove the "-DINTSPRINTF" below if you're compiling for + # stock 4.3BSD or for some other Vax or RT library package where + # sprintf returns char *. + # + # Also, I define NOVOID on the Vax because I'm using pcc to compile. + # If you use gcc or some other better compiler, this should not be + # necessary. I define NOSTDHDRS on the RT because we don't have + # standard ANSI header files installed for the RT, even though the RT + # compiler claims to be ANSI-compliant. + # + # (for BSD 4.3 VAX, add the following to CFLAGS) + # -DNEED_VPRINTF -DINTSPRINTF -DLONGINT -DNOVOID + # (for (stock) IBM RT AOS 4.3, add the following to CFLAGS) + # -DNEED_VPRINTF -DLONGINT -DNOSTDHDRS + + CFLAGS = -O + + + LIBS = -lX11 -lm + + BITMAPS = bitmaps/grasp bitmaps/penn bitmaps/down bitmaps/down1 \ + bitmaps/up bitmaps/up1 bitmaps/scrlgray bitmaps/gray50 \ + bitmaps/gray25 bitmaps/i_fifo bitmaps/i_chr bitmaps/i_dir \ + bitmaps/i_blk bitmaps/i_lnk bitmaps/i_sock bitmaps/i_reg \ + bitmaps/rb_off bitmaps/rb_on bitmaps/rb_off1 bitmaps/rb_on1 \ + bitmaps/fc_left bitmaps/fc_leftm bitmaps/fc_mid bitmaps/fc_midm \ + bitmaps/fc_right bitmaps/fc_rightm bitmaps/fc_left1 \ + bitmaps/fc_left1m bitmaps/fc_right1 bitmaps/fc_right1m \ + bitmaps/icon + + OBJS = xv.o xvmisc.o xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o \ + xvgifwr.o xvdir.o xvbutt.o xvpbm.o xvxbm.o xvgam.o xvfish.o \ + vprintf.o + + MISC = README PATCHLEVEL + + .c.o: ; $(CC) -c $(CFLAGS) -o $@ $*.c + + all: xv bggen + + xv: $(OBJS) + $(CC) $(CFLAGS) -o xv $(OBJS) $(LIBS) + + bggen: bggen.c + $(CC) $(CFLAGS) -o bggen bggen.c + + clean: + rm -f $(OBJS) + + tar: + tar cf xv.tar Makefile* Imakefile *.c *.h bitmaps docs $(MISC) + + xv.3100: bitmaps.h + cc -O3 *.c -o xv $(XLIB) + + $(OBJS): xv.h + xv.o: bitmaps.h + xvmisc.o: bitmaps.h + xvinfo.o: bitmaps.h + xvctrl.o: bitmaps.h + xvscrl.o: bitmaps.h + xvbutt.o: bitmaps.h + + bitmaps.h: $(BITMAPS) + cat $(BITMAPS) > bitmaps.h + *** /dev/null Thu Oct 18 00:00:14 1990 --- ./PATCHLEVEL Wed Oct 17 23:38:43 1990 *************** *** 0 **** --- 1,16 ---- + Current patchlevel: 1 + + Rev: 10/9/90 (patchlevel 0 - initial release) + + Rev: 10/17/90 (patchlevel 1) + ------------------------------ + Imakefile added (David Elliot (dce@smsc.sony.com)) + System V release 4 mods (David Elliot (dce@smsc.sony.com)) + Bug in 'quick check' fixed (Arthur Olson (ado@elsie.nci.nih.gov)) + Mods for Convex machines (Anthony Datri (datri@convex.com)) + 'vprintf' module added (Jonathan Kamens (jik@pit-manager.mit.edu)) + window creation bug fixed + added icon + fixed 'Input Focus' probs + added '-w' flag to bggen + various cleanups to shut up 'noisy' compilers *** /dev/null Thu Oct 18 00:00:14 1990 --- ./vprintf.c Wed Oct 17 22:36:26 1990 *************** *** 0 **** --- 1,306 ---- + #ifdef NEED_VPRINTF + + #include <stdio.h> + + /* Portable vsprintf by Robert A. Larson <blarson@skat.usc.edu> */ + /* Portable vfprintf by Robert A. Larson <blarson@skat.usc.edu> */ + + /* Copyright 1989 Robert A. Larson. + * Distribution in any form is allowed as long as the author + * retains credit, changes are noted by their author and the + * copyright message remains intact. This program comes as-is + * with no warentee of fitness for any purpouse. + * + * Thanks to Doug Gwen, Chris Torek, and others who helped clarify + * the ansi printf specs. + * + * Please send any bug fixes and improvments to blarson@skat.usc.edu . + * The use of goto is NOT a bug. + */ + + /* Feb 7, 1989 blarson First usenet release */ + + /* This code implements the vsprintf function, without relying on + * the existance of _doprint or other system specific code. + * + * Define NOVOID if void * is not a supported type. + * + * Two compile options are available for efficency: + * INTSPRINTF should be defined if sprintf is int and returns + * the number of chacters formated. + * LONGINT should be defined if sizeof(long) == sizeof(int) + * + * They only make the code smaller and faster, they need not be + * defined. + * + * UNSIGNEDSPECIAL should be defined if unsigned is treated differently + * than int in argument passing. If this is definded, and LONGINT is not, + * the compiler must support the type unsingned long. + * + * Most quirks and bugs of the available sprintf fuction are duplicated, + * however * in the width and precision fields will work correctly + * even if sprintf does not support this, as will the n format. + * + * Bad format strings, or those with very long width and precision + * fields (including expanded * fields) will cause undesired results. + */ + + #ifdef OSK /* os9/68k can take advantage of both */ + #define LONGINT + #define INTSPRINTF + #endif + + /* This must be a typedef not a #define! */ + #ifdef NOVOID + typedef char *pointer; + #else + typedef void *pointer; + #endif + + #ifdef INTSPRINTF + #define Sprintf(string,format,arg) (sprintf((string),(format),(arg))) + #else + #define Sprintf(string,format,arg) (\ + sprintf((string),(format),(arg)),\ + strlen(string)\ + ) + #endif + + #if defined(__STDC__) && !defined(NOSTDHDRS) + #include <stdarg.h> + #else + #include <varargs.h> + #endif + + typedef int *intp; + + int vsprintf(dest, format, args) + char *dest; + register char *format; + va_list args; + { + register char *dp = dest; + register char c; + register char *tp; + char tempfmt[64]; + #ifndef LONGINT + int longflag; + #endif + + tempfmt[0] = '%'; + while( (c = *format++) != 0) { + if(c=='%') { + tp = &tempfmt[1]; + #ifndef LONGINT + longflag = 0; + #endif + continue_format: + switch(c = *format++) { + case 's': + *tp++ = c; + *tp = '\0'; + dp += Sprintf(dp, tempfmt, va_arg(args, char *)); + break; + case 'u': + case 'x': + case 'o': + case 'X': + #ifdef UNSIGNEDSPECIAL + *tp++ = c; + *tp = '\0'; + #ifndef LONGINT + if(longflag) + dp += Sprintf(dp, tempfmt, va_arg(args, unsigned long)); + else + #endif + dp += Sprintf(dp, tempfmt, va_arg(args, unsigned)); + break; + #endif + case 'd': + case 'c': + case 'i': + *tp++ = c; + *tp = '\0'; + #ifndef LONGINT + if(longflag) + dp += Sprintf(dp, tempfmt, va_arg(args, long)); + else + #endif + dp += Sprintf(dp, tempfmt, va_arg(args, int)); + break; + case 'f': + case 'e': + case 'E': + case 'g': + case 'G': + *tp++ = c; + *tp = '\0'; + dp += Sprintf(dp, tempfmt, va_arg(args, double)); + break; + case 'p': + *tp++ = c; + *tp = '\0'; + dp += Sprintf(dp, tempfmt, va_arg(args, pointer)); + break; + case '-': + case '+': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '.': + case ' ': + case '#': + case 'h': + *tp++ = c; + goto continue_format; + case 'l': + #ifndef LONGINT + longflag = 1; + *tp++ = c; + #endif + goto continue_format; + case '*': + tp += Sprintf(tp, "%d", va_arg(args, int)); + goto continue_format; + case 'n': + *va_arg(args, intp) = dp - dest; + break; + case '%': + default: + *dp++ = c; + break; + } + } else *dp++ = c; + } + *dp = '\0'; + return dp - dest; + } + + + int vfprintf(dest, format, args) + FILE *dest; + register char *format; + va_list args; + { + register char c; + register char *tp; + register int count = 0; + char tempfmt[64]; + #ifndef LONGINT + int longflag; + #endif + + tempfmt[0] = '%'; + while(c = *format++) { + if(c=='%') { + tp = &tempfmt[1]; + #ifndef LONGINT + longflag = 0; + #endif + continue_format: + switch(c = *format++) { + case 's': + *tp++ = c; + *tp = '\0'; + count += fprintf(dest, tempfmt, va_arg(args, char *)); + break; + case 'u': + case 'x': + case 'o': + case 'X': + #ifdef UNSIGNEDSPECIAL + *tp++ = c; + *tp = '\0'; + #ifndef LONGINT + if(longflag) + count += fprintf(dest, tempfmt, va_arg(args, unsigned long)); + else + #endif + count += fprintf(dest, tempfmt, va_arg(args, unsigned)); + break; + #endif + case 'd': + case 'c': + case 'i': + *tp++ = c; + *tp = '\0'; + #ifndef LONGINT + if(longflag) + count += fprintf(dest, tempfmt, va_arg(args, long)); + else + #endif + count += fprintf(dest, tempfmt, va_arg(args, int)); + break; + case 'f': + case 'e': + case 'E': + case 'g': + case 'G': + *tp++ = c; + *tp = '\0'; + count += fprintf(dest, tempfmt, va_arg(args, double)); + break; + case 'p': + *tp++ = c; + *tp = '\0'; + count += fprintf(dest, tempfmt, va_arg(args, pointer)); + break; + case '-': + case '+': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '.': + case ' ': + case '#': + case 'h': + *tp++ = c; + goto continue_format; + case 'l': + #ifndef LONGINT + longflag = 1; + *tp++ = c; + #endif + goto continue_format; + case '*': + tp += Sprintf(tp, "%d", va_arg(args, int)); + goto continue_format; + case 'n': + *va_arg(args, intp) = count; + break; + case '%': + default: + putc(c, dest); + count++; + break; + } + } else { + putc(c, dest); + count++; + } + } + return count; + } + + vprintf(format, args) + char *format; + va_list args; + { + return vfprintf(stdout, format, args); + } + + #endif *** /dev/null Thu Oct 18 00:00:14 1990 --- ./bitmaps/icon Wed Oct 17 14:13:05 1990 *************** *** 0 **** --- 1,18 ---- + #define icon_width 48 + #define icon_height 29 + static char icon_bits[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x7c, 0x7c, 0x00, 0x7c, 0x5c, 0x00, 0x2e, 0x5c, 0x00, 0x5c, + 0xb8, 0x00, 0x17, 0xb8, 0x00, 0x2e, 0x70, 0x81, 0x0b, 0xb8, 0x00, 0x2e, + 0x70, 0x81, 0x0b, 0x70, 0x01, 0x17, 0xe0, 0xc2, 0x05, 0x70, 0x01, 0x17, + 0xc0, 0xe5, 0x02, 0xe0, 0x82, 0x0b, 0x80, 0x7b, 0x01, 0xe0, 0x82, 0x0b, + 0x00, 0xb7, 0x00, 0xc0, 0xc5, 0x05, 0x00, 0x56, 0x00, 0xc0, 0xc5, 0x05, + 0x00, 0x2e, 0x00, 0x80, 0xeb, 0x02, 0x00, 0x56, 0x00, 0x80, 0xeb, 0x02, + 0x00, 0xb7, 0x00, 0x00, 0x77, 0x01, 0x80, 0x7b, 0x01, 0x00, 0x77, 0x01, + 0xc0, 0xe5, 0x02, 0x00, 0xae, 0x00, 0xe0, 0xc2, 0x05, 0x00, 0xae, 0x00, + 0x70, 0x81, 0x0b, 0x00, 0x5c, 0x00, 0x70, 0x81, 0x0b, 0x00, 0x5c, 0x00, + 0xb8, 0x00, 0x17, 0x00, 0x38, 0x00, 0x5c, 0x00, 0x2e, 0x00, 0x38, 0x00, + 0x3e, 0x00, 0x7c, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.