Problems with CURSES on Vax11/780
Chris Torek
chris at mimsy.umd.edu
Thu Nov 30 16:22:42 AEST 1989
In article <678 at dgis.dtic.dla.mil> sdussin at 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 at cs.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.questions
mailing list