Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!aplcen!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: Problems with CURSES on Vax11/780 Keywords: Vax unix curses programming c Message-ID: <21018@mimsy.umd.edu> Date: 30 Nov 89 05:22:42 GMT References: <678@dgis.dtic.dla.mil> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 63 In article <678@dgis.dtic.dla.mil> sdussin@dgis.dtic.dla.mil (Steve Dussinger) writes: >... to print a string of _exactly_ 600 characters, using: > wprintw(window,"%s",buffer); >... When I attempt to print this 600-char string, I get a Segmentation >Violation. Do you suppose it might have something to do with this? _sprintw(win, fmt, args) WINDOW *win; char *fmt; int *args; { FILE junk; char buf[512]; junk._flag = _IOWRT + _IOSTRG; junk._ptr = buf; junk._cnt = 32767; _doprnt(fmt, args, &junk); putc('\0', &junk); return waddstr(win, buf); } 600 characters should fit comfortably in a 512 character buffer, right? :-( (One wonders why Ken Arnold set _cnt to 32767 when he could tell that the buffer size was only 512. Had he tried 512, he would have discovered the next bug, this one in _doprnt/fflush....) This is why I changed it to: static int _winwrite(cookie, buf, n) void *cookie; reg char *buf; int n; { reg WINDOW *win = cookie; reg int c = n; while (--c >= 0) { if (waddch(win, *buf++) == ERR) return (-1); } return n; } _sprintw(win, fmt, args) WINDOW *win; char *fmt; int *args; { /* XXX */ FILE *f; if ((f = fwopen((void *)win, _winwrite)) == NULL) return ERR; (void) vfprintf(f, fmt, args); /* XXX */ return fclose(f) ? ERR : OK; } Alas, this will not work anywhere else. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris