wampler@unmvax.UUCP (01/30/86)
Fixes/notes to tvx (version 1/10/86, first release to USENET): This makes new version 1/29/86: **** Change 1: ============================================================= In file tvx_io.c, the routine fopenx(argc,argv): Change original: --- old old old --- .... /* now see if we can make an output file */ if (!rdonly) { temp_name(work_file,TRUE); /* make into a temporary name 1st time */ unlink(work_file); /* get rid if already there */ .... --- old old old --- To this: --- new new new --- /* now see if we can make an output file */ if (!rdonly) { temp_name(work_file,TRUE); /* make into a temporary name 1st time */ /* new code added here for version 1/29/86 */ if ((outfile = fopen(work_file,FILEREAD))) { /* this code is needed when the temp_name might not be unique - which happens when you push (^O) and try to edit a file with the same main name but perhaps a different extension - the temp file will be the same, and the child version of tvx will then delete the temprorary file created by the parent. This can happen again if fbeg, but let's assume the 'y' applies forever. */ fclose(outfile); /* close up the file */ prompt("Work file already exists: "); remark(work_file); prompt("Erase it and continue with editing? (y/n) "); ureply(rply,1); if (*rply != 'Y') { reset(); exit(100); /* abnormal exit */ } } /* end of new code added here for version 1/29/86 */ unlink(work_file); /* get rid if already there */ --- new new new --- **** Change 2: ================================================================ In file tvx_lex.c, replace ENTIRE memory() function with the following code. The old code works on most machines, but this code is better and avoids some problems on the Atari 520ST version with the use of stcopy instead of strcopy. The whole problem has been caused by trying to deal with long file names. --- new new new --- /* =============================>>> MEMORY <<<============================= */ memory() { /* memory - print memory left */ SLOW int nxt; SLOW unsigned int tmp; char value[10],msg[85],*cp; nxt=0; /* where message goes */ cp = (*dest_file ? dest_file : orig_file); strcopy(cp,max(strlen(cp)-42,0),msg,&nxt); /* the file name */ if (nxt <= 14) { strcopy(VERSION,0,msg,&nxt); /* TVX */ strcopy(cversn,0,msg,&nxt); /* terminal type */ } strcopy(" Chrs left:",0,msg,&nxt); /* add ' Chars: ' */ #ifdef LASL tmp = max(nxtsav - nxtchr - BUFFLIMIT,0); #else tmp = nxtsav - nxtchr; #endif #ifdef INT16 if (tmp > 30000) /* handle "neg" size */ { msg[nxt++] = '+'; tmp -= 30000; } #endif itoa(tmp,value); strcopy(value,0,msg,&nxt); /* the value */ strcopy(" Last line:",0,msg,&nxt); /* add ' Lines: ' */ itoa(nxtlin-1,value); strcopy(value,0,msg,&nxt); /* add the count */ #ifdef STATCURLINE strcopy(" Cur line:",0,msg,&nxt); /* add ' Cur line: ' */ itoa(curlin,value); #endif #ifdef STATREPEAT strcopy(" Rpt:",0,msg,&nxt); /* add ' Rpt: ' */ itoa(rptuse+1,value); strcopy(value,0,msg,&nxt); /* the count */ strcopy("/",0,msg,&nxt); /* add '/' */ itoa(REPEATBUFS,value); #endif strcopy(value,0,msg,&nxt); tverr(msg); /* display line on screen */ } --- new new new --- **** Change 3: ============================================================== In tvx_lib.c, delete the line: #define BACKSPACE 8 **** Change 4: ============================================================== In tvx_defs.ic, change the #define's for BEGLINE and GARBAGE to be: #define BEGLINE (char)(0xf6) #define GARBAGE (char)(0xf2) These definitions avoid problems in some compilers with char sign extension. **** Change 5: ============================================================= In tvx_unix.c, in the routine gettermcap, change the code after the FORCETTY: label to be: FORCETTY: reset(); remark(""); remark("Unable to set up for video terminal, try again with -t switch."); exit(999); --- It is possible that the original intent of the code could be fixed, but as it stands, it doesn't work right, and royally hangs the terminal. The intent was to but tvx into tty mode automatically if the termcap entry was missing or didn't have the required screen controls. **** Change 6: ============================================================= In tvx_unix.c, in the functions "gettermcap" and "ttosinit", delete the two lines using the "is" termcap entry: DELETE THESE LINES in two places: gettcap("is",entry); /* initialization string */ tcapcs(entry); /* send the intialization string */ --- This initialization procedure is normally handled by the user's .login or .profile file. Vi doesn't use "is", and tvx shouldn't either. **** Change 7: ============================================================= In file tvx_1.c, in the function findx, change original 8 to tabspc: --- old old old --- if (*(buff+i-1)==TAB) /* handle tabs */ for (++pos ; ((pos-1) % 8)!=0; ++pos) ; --- old old old --- To this: --- new new new --- if (*(buff+i-1)==TAB) /* handle tabs */ for (++pos ; ((pos-1) % tabspc)!=0; ++pos) ; --- new new new --- **** Change 8: ============================================================= The function rindex conflicts with some standard C libraries. Either change the name throughout, or add the following define to tvx_defs.ic: #define rindex rndex /* avoid conflict with C library */ **** Change 9: CP/M-80 only ======================================================= It had been some time since I had actually compiled the version for CP/M, and some problems have crept in. First, for CP/M, you will probably want to undefine the options for ULBD, config file, log file, and FULLHELP. Then, in addition: a. in tvx_2.c, the #ifdef CPM should be #ifdef OSCPM. b. in tvx_io.c, the 3 #ifdef CPM's should read #ifdef OSCPM. The third #ifdef defines dispch. It should also define user_1 and user_2 as dummy functions. The definition of getchr is also needed for CP/M, and can be the same code as the MS-DOS version already there. c. in tvx_lib.c, the routine printc is missing the code for CP/M. Again, use the MSDOS code. d. be careful with the definition of MAXBUFF and the use in the call to malloc - Aztec C, for one, needs you to leave some heap space to malloc for the I/O package. You may need to look at the link map to pick a size. **** Change 10: ============================================================== In tvx_1.c, in function insert, change the following line: --- old old old --- /* # to here, ready to insert the new character at the end of the line */ if (chr==' ' && wraplm > 1 && (tvx >= wraplm || leftmg > 1)) /* auto wrap? */ chr = CR; --- old old old --- To this: --- new new new --- /* # to here, ready to insert the new character at the end of the line */ /* bug 1/29/86 - found by rf, fixed by bew - wraplm > screenwidth */ if (chr==' ' && wraplm > 1 && tvx+leftmg > wraplm) /* auto wrap? */ chr = CR; --- new new new --- **** Note 1: ================================================================== Point of confusion: There is no logical difference between using #undef and commenting out #define's -- the #undef method seems a bit nicer looking is all. Sorry - I should have been consistent on these. **** Note 2: (IBM-PC) ====================================================== The IBM-PC version was compiled using CII-86. There are 3 non-standard routines used: coreleft, bdos, and sysint. Coreleft is a "feature" of cii-86, and can probably be left out for most other C's. Its intent is to leave some memory left over for malloc to give to the I/O routines. Ugly, but if your compiler has the same problem but no equivalent to coreleft, you may have to Bdos and sysint are used to access DOS and the ROM bios. Bdos is used to read charcters from the keyboard and sysint is used to access the rom bios screen handling code. The bdos function takes the bdos number and the value for the dx register. The sysint routine takes an int number, and a register in structure, and a register out structure. Not all registers are used, and significant increases in screen write time can be had by hand optomizing the assembly of this code. It would be possible to modify tvx_term.ic to build the definitions for ANSI.SYS, but to get any decent speed, it is necessary to access the screen directly. It is likely that whatever C you use will either let you call the bios, or will have its own screen handling code. One more note: Microsoft C Version 3 has a brain damaged rename function with the order of the arguments reversed. Sigh. -- Dr. Bruce E. Wampler University of New Mexico Department of Computer Science Albuquerque, NM 87131 ..{ucbvax | seismo!gatech | ihnp4!lanl}!unmvax!wampler