Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!cwi.UUCP!uunet!golem!david From: uunet!golem!david@cwi.UUCP ("David J. Fiander") Newsgroups: comp.mail.mh Subject: Re: HELP with vmh problem, please Message-ID: <8338.672627414@golem> Date: 26 Apr 91 00:56:54 GMT References: Sender: usenet@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 335 Include below, as promised, are my patches to uip/vmh.c so that it will work with System V curses. Unfortunately, I don't have a BSD system to try them on, so I don't know whether I broke anything or not. I have also included a patch to uip/vmhsbr.c which fixes an off-by-one allocation error which was walking on the heap. After this patch has been applied, you have to rebuild both vmh _and_ msh, since the both use it. - David --------- Cut here ---8<-------- *** vmh.orig.c Thu Apr 25 20:45:47 1991 --- vmh.c Sun Mar 10 13:34:44 1991 *************** *** 346,352 **** (void) sprintf (bp, "%d %d", RC_VRSN, numwins); bp += strlen (bp); for (w = windows; *w; w++) { ! (void) sprintf (bp, " %d", (*w) -> _maxy); bp += strlen (bp); } --- 347,355 ---- (void) sprintf (bp, "%d %d", RC_VRSN, numwins); bp += strlen (bp); for (w = windows; *w; w++) { ! int x, y; ! getmaxyx(*w, y, x); ! (void) sprintf (bp, " %d", y); bp += strlen (bp); } *************** *** 694,699 **** --- 697,703 ---- { register int c; register char *bp; + int x, y; bp = buffer; *bp = NULL; *************** *** 712,718 **** *bp = NULL; if (bp > buffer) { leaveok (curscr, FALSE); ! wmove (w, 0, w -> _curx - (bp - buffer)); wrefresh (w); leaveok (curscr, TRUE); } --- 716,723 ---- *bp = NULL; if (bp > buffer) { leaveok (curscr, FALSE); ! getyx(w, y, x); ! wmove (w, 0, x - (bp - buffer)); wrefresh (w); leaveok (curscr, TRUE); } *************** *** 736,742 **** if (c == ERASE) { if (bp <= buffer) continue; ! bp--, w -> _curx--; wclrtoeol (w); break; } --- 741,749 ---- if (c == ERASE) { if (bp <= buffer) continue; ! getyx(w, y, x); ! bp--, x--; ! wmove(w, y, x); wclrtoeol (w); break; } *************** *** 743,749 **** if (c == KILL) { if (bp <= buffer) continue; ! w -> _curx -= bp - buffer; bp = buffer; wclrtoeol (w); break; --- 750,757 ---- if (c == KILL) { if (bp <= buffer) continue; ! getyx(w, y, x); ! x -= bp - buffer; wmove(w, y, x); bp = buffer; wclrtoeol (w); break; *************** *** 751,767 **** if (c == WERASC) { if (bp <= buffer) continue; do { ! bp--, w -> _curx--; } while (isspace (*bp) && bp > buffer); if (bp > buffer) { do { ! bp--, w -> _curx--; } while (!isspace (*bp) && bp > buffer); if (isspace (*bp)) ! bp++, w -> _curx++; } wclrtoeol (w); break; } --- 759,777 ---- if (c == WERASC) { if (bp <= buffer) continue; + getyx(w, y, x); do { ! bp--, x--; } while (isspace (*bp) && bp > buffer); if (bp > buffer) { do { ! bp--, x--; } while (!isspace (*bp) && bp > buffer); if (isspace (*bp)) ! bp++, x++; } + wmove(w, y, x); wclrtoeol (w); break; } *************** *** 830,835 **** --- 840,846 ---- nwait; char *cp; register struct line *lbottom; + int x, y; did_less++; *************** *** 843,848 **** --- 854,860 ---- nwait = 0; wrefresh (w); + getmaxyx(w, y, x); for (;;) { if (nfresh || nwait) { nfresh = 0; *************** *** 856,862 **** if (ltop == NULL) if (fin) { ! (void) lgo (ltail -> l_no - w -> _maxy + 1); if (ltop == NULL) ltop = lhead; } --- 868,874 ---- if (ltop == NULL) if (fin) { ! (void) lgo (ltail -> l_no - y + 1); if (ltop == NULL) ltop = lhead; } *************** *** 961,967 **** break; case 'G': ! if (lgo (n ? n : ltail -> l_no - w -> _maxy + 1)) nfresh++; break; --- 973,979 ---- break; case 'G': ! if (lgo (n ? n : ltail -> l_no - y + 1)) nfresh++; break; *************** *** 1027,1032 **** --- 1039,1048 ---- register int x, y; + register int maxx, + maxy; + + getmaxyx(w, maxy, maxx); switch (c) { default: if (!isascii (c)) { *************** *** 1050,1057 **** if (w != Scan) return waddch (w, c); ! if ((x = w -> _curx) < 0 || x >= w -> _maxx ! || (y = w -> _cury) < 0 || y >= w -> _maxy) return DONE; switch (c) { --- 1066,1073 ---- if (w != Scan) return waddch (w, c); ! getyx(w, y, x); ! if (x < 0 || x >= maxx || y < 0 || y >= maxy) return DONE; switch (c) { *************** *** 1062,1068 **** break; case '\n': ! if (++y < w -> _maxy) (void) waddch (w, c); else wclrtoeol (w); --- 1078,1084 ---- break; case '\n': ! if (++y < maxy) (void) waddch (w, c); else wclrtoeol (w); *************** *** 1069,1075 **** break; default: ! if (++x < w -> _maxx) (void) waddch (w, c); break; } --- 1085,1091 ---- break; default: ! if (++x < maxx) (void) waddch (w, c); break; } *************** *** 1095,1100 **** --- 1111,1118 ---- static linsert (w) WINDOW *w; { + int origx, origy, maxx, maxy; /* origy and maxy are ignored */ + register int x; register char *cp; register struct line *lp; *************** *** 1101,1108 **** if ((lp = (struct line *) calloc ((unsigned) 1, sizeof *lp)) == NULL) adios (NULLCP, "unable to allocate line storage"); lp -> l_no = (ltail ? ltail -> l_no : 0) + 1; ! lp -> l_buf = getcpy (w -> _y[w -> _cury]); for (cp = lp -> l_buf + strlen (lp -> l_buf) - 1; cp >= lp -> l_buf; cp--) if (isspace (*cp)) *cp = NULL; --- 1119,1134 ---- if ((lp = (struct line *) calloc ((unsigned) 1, sizeof *lp)) == NULL) adios (NULLCP, "unable to allocate line storage"); + getmaxyx(w, maxy, maxx); + getyx(w, origy, origx); lp -> l_no = (ltail ? ltail -> l_no : 0) + 1; ! lp -> l_buf = malloc(maxx + 1); ! if (lp -> l_buf == 0) ! adios(NULLCP, "unable to allocate string storage"); ! for (x = 0; x < maxx; ++x) ! lp -> l_buf[x] = mvwinch(w, origy, x); ! lp -> l_buf[maxx] = '\0'; ! wmove(w, origy, origx); for (cp = lp -> l_buf + strlen (lp -> l_buf) - 1; cp >= lp -> l_buf; cp--) if (isspace (*cp)) *cp = NULL; *** vmhsbr.orig.c Thu Apr 25 20:47:46 1991 --- vmhsbr.c Sun Mar 10 13:34:44 1991 *************** *** 44,50 **** if ((cp = getenv ("MHVDEBUG")) && *cp ! && (fp = fopen (sprintf (buffer, "%s.out", invo_name), "w"))) { (void) fseek (fp, 0L, 2); fprintf (fp, "%d: rcinit (%d, %d)\n", getpid (), rfd, wfd); (void) fflush (fp); --- 45,52 ---- if ((cp = getenv ("MHVDEBUG")) && *cp ! && sprintf (buffer, "%s.out", invo_name) > 0 ! && (fp = fopen (buffer, "w"))) { (void) fseek (fp, 0L, 2); fprintf (fp, "%d: rcinit (%d, %d)\n", getpid (), rfd, wfd); (void) fflush (fp); *************** *** 101,107 **** if (read (PEERrfd, (char *) rc_head (rc), RHSIZE (rc)) != RHSIZE (rc)) return rclose (rc, "read from peer lost(1)"); if (rc -> rc_len) { ! if ((rc -> rc_data = malloc ((unsigned) rc -> rc_len)) == NULL) return rclose (rc, "malloc of %d lost", rc -> rc_len); if (read (PEERrfd, rc -> rc_data, rc -> rc_len) != rc -> rc_len) return rclose (rc, "read from peer lost(2)"); --- 103,109 ---- if (read (PEERrfd, (char *) rc_head (rc), RHSIZE (rc)) != RHSIZE (rc)) return rclose (rc, "read from peer lost(1)"); if (rc -> rc_len) { ! if ((rc -> rc_data = malloc ((unsigned) rc -> rc_len + 1)) == NULL) return rclose (rc, "malloc of %d lost", rc -> rc_len); if (read (PEERrfd, rc -> rc_data, rc -> rc_len) != rc -> rc_len) return rclose (rc, "read from peer lost(2)"); ---------- End of patches