diff options
-rw-r--r-- | tecbuf.c | 72 | ||||
-rw-r--r-- | teccmd.c | 34 | ||||
-rw-r--r-- | tecexec.c | 50 | ||||
-rw-r--r-- | tecmem.c | 42 | ||||
-rw-r--r-- | teco.h | 536 | ||||
-rw-r--r-- | tecparse.c | 30 | ||||
-rw-r--r-- | tecparse.h | 28 | ||||
-rw-r--r-- | tecundo.c | 2 |
8 files changed, 402 insertions, 392 deletions
@@ -413,10 +413,10 @@ register struct buff_line *lbp; * the buffer position resides on. */ struct buff_line * -buff_find_line( struct buff_header *hbp, int position ) +buff_find_line( struct buff_header *hbp, unsigned long position ) { register struct buff_line *lbp; -register int i; +register unsigned long i; PREAMBLE(); @@ -479,10 +479,10 @@ register int i; if(lbp->next_line == NULL){ char panic_string[LINE_BUFFER_SIZE]; sprintf(panic_string, - "buff_find_line: position %d specified in buffer %s, z=%d", + "buff_find_line: position %lu specified in buffer %s, z=%lu", position,hbp->name,hbp->zee); tec_panic(panic_string); - printf("NULL ptr %d bytes still to go\n",i); + printf("NULL ptr %lu bytes still to go\n",i); }/* End IF */ lbp = lbp->next_line; }/* End While */ @@ -514,7 +514,7 @@ register int i; */ int buff_find_offset( struct buff_header *hbp, - struct buff_line *lbp, int position ) + struct buff_line *lbp, long position ) { PREAMBLE(); @@ -546,7 +546,7 @@ buff_find_offset( struct buff_header *hbp, * of characters at any one time. */ int -buff_contents( struct buff_header *hbp, int position ) +buff_contents( struct buff_header *hbp, long position ) { register struct buff_line *lbp; register int i; @@ -558,7 +558,7 @@ register int i; if(position > hbp->zee || position < 0){ char panic_string[LINE_BUFFER_SIZE]; sprintf(panic_string, - "buff_contents: illegal position %d specified in buffer %s", + "buff_contents: illegal position %ld specified in buffer %s", position,hbp->name); tec_panic(panic_string); }/* End IF */ @@ -585,7 +585,7 @@ register int i; */ int buff_cached_contents( struct buff_header *hbp, - int position, struct position_cache *cache ) + unsigned long position, struct position_cache *cache ) { register struct buff_line *lbp; register int i; @@ -596,7 +596,7 @@ register int i; */ if(position > hbp->zee || position < 0){ char tmp_message[LINE_BUFFER_SIZE]; - sprintf(tmp_message,"buff_contents: illegal position %d %s Z = %d\n", + sprintf(tmp_message,"buff_contents: illegal position %lu %s Z = %lu\n", position,hbp->name,hbp->zee); tec_panic(tmp_message); }/* End IF */ @@ -968,7 +968,7 @@ buff_readfd( struct buff_header *hbp, char *name, int iochan ) * wishes to write out the contents of the buffer. */ int -buff_write( struct buff_header *hbp, int chan, int start, int end ) +buff_write( struct buff_header *hbp, int chan, unsigned long start, unsigned long end ) { register int bcount; register struct buff_line *lbp; @@ -1097,7 +1097,7 @@ int max_length; for(hbp = buffer_headers; hbp != NULL ; hbp = hbp->next_header){ if(hbp->buffer_number <= 0) continue; i = max_length - strlen(hbp->name); - snprintf(tmp_buffer,sizeof(tmp_buffer),"<Buffer %-4d> %s%s %s %6d bytes\n", + snprintf(tmp_buffer,sizeof(tmp_buffer),"<Buffer %-4d> %s%s %s %6lu bytes\n", hbp->buffer_number,hbp->name,&padd_buffer[sizeof(padd_buffer)-1-i], hbp->ismodified ? "(modified)" : " ",hbp->zee); i = strlen(tmp_buffer); @@ -1109,7 +1109,7 @@ int max_length; for(hbp = buffer_headers; hbp != NULL ; hbp = hbp->next_header){ if(hbp->buffer_number >= 0) continue; i = max_length - strlen(hbp->name); - snprintf(tmp_buffer,sizeof(tmp_buffer),"<Buffer %-4d> %s%s %s %6d bytes\n", + snprintf(tmp_buffer,sizeof(tmp_buffer),"<Buffer %-4d> %s%s %s %6lu bytes\n", hbp->buffer_number,hbp->name,&padd_buffer[sizeof(padd_buffer)-1-i], hbp->ismodified ? "(modified)" : " ",hbp->zee); i = strlen(tmp_buffer); @@ -1222,7 +1222,7 @@ int max_length; * at the buffer's current location. */ int -buff_insert( struct buff_header *hbp, int position, char *buffer, int length ) +buff_insert( struct buff_header *hbp, unsigned long position, char *buffer, unsigned long length ) { struct buff_header fake_header; struct buff_line *fake_line; @@ -1296,10 +1296,10 @@ register char *cp; int buff_insert_from_buffer_with_undo( struct cmd_token *ct, struct buff_header *dbp, - int dest_position, + unsigned long dest_position, struct buff_header *sbp, - int src_position, - int length ) + unsigned long src_position, + size_t length ) { register int i; struct undo_token *ut = 0; @@ -1323,21 +1323,21 @@ char outbuf[1024]; /* * Insure that the specified position is legal */ - if(src_position < 0 || src_position > sbp->zee){ + if(src_position > sbp->zee){ char tmp_message[LINE_BUFFER_SIZE]; sprintf( tmp_message, - "buff_insert_from_buffer_with_undo: bad src pos %d %s Z = %d\n", + "buff_insert_from_buffer_with_undo: bad src pos %lu %s Z = %lu\n", src_position, sbp->name,sbp->zee ); tec_panic(tmp_message); }/* End IF */ - if(dest_position < 0 || dest_position > dbp->zee){ + if(dest_position > dbp->zee){ char tmp_message[LINE_BUFFER_SIZE]; sprintf( tmp_message, - "buff_insert_from_buffer_with_undo: bad dest pos %d %s Z = %d\n", + "buff_insert_from_buffer_with_undo: bad dest pos %lu %s Z = %lu\n", dest_position, dbp->name,dbp->zee ); @@ -1734,9 +1734,9 @@ char outbuf[1024]; int buff_insert_with_undo( struct cmd_token *ct, struct buff_header *hbp, - int position, + unsigned long position, char *buffer, - int length ) + unsigned long length ) { struct undo_token *ut; @@ -1771,7 +1771,7 @@ struct undo_token *ut; */ int buff_insert_char( struct buff_header *hbp, - int position, + unsigned long position, char data ) { register struct buff_line *lbp; @@ -1786,7 +1786,7 @@ register int i,j; */ if(position > hbp->zee){ char tmp_message[LINE_BUFFER_SIZE]; - sprintf(tmp_message,"buff_insert_char: bad position %d %s Z = %d\n", + sprintf(tmp_message,"buff_insert_char: bad position %lu %s Z = %lu\n", position,hbp->name,hbp->zee); tec_panic(tmp_message); }/* End IF */ @@ -1913,7 +1913,7 @@ register int i,j; int buff_insert_char_with_undo( struct cmd_token *ct, struct buff_header *hbp, - int position, + unsigned long position, char data ) { struct undo_token *ut; @@ -1946,8 +1946,8 @@ struct undo_token *ut; */ void buff_delete( struct buff_header *hbp, - int position, - int count ) + unsigned long position, + unsigned long count ) { PREAMBLE(); @@ -1957,7 +1957,7 @@ buff_delete( struct buff_header *hbp, */ if((position + count) > hbp->zee){ char tmp_message[LINE_BUFFER_SIZE]; - sprintf(tmp_message,"buff_delete: illegal range %d-%d %s Z = %d\n", + sprintf(tmp_message,"buff_delete: illegal range %lu-%lu %s Z = %lu\n", position,position+count,hbp->name,hbp->zee); tec_panic(tmp_message); }/* End IF */ @@ -1983,7 +1983,7 @@ buff_delete( struct buff_header *hbp, */ int buff_delete_char( struct buff_header *hbp, - int position ) + unsigned long position ) { register struct buff_line *lbp; struct buff_line *nlbp; @@ -1996,7 +1996,7 @@ register int i,j; */ if(position >= hbp->zee){ char tmp_message[LINE_BUFFER_SIZE]; - sprintf(tmp_message,"buff_delete_char: bad position %d %s Z = %d\n", + sprintf(tmp_message,"buff_delete_char: bad position %lu %s Z = %lu\n", position,hbp->name,hbp->zee); tec_panic(tmp_message); }/* End IF */ @@ -2133,15 +2133,15 @@ register int i,j; int buff_delete_with_undo( struct cmd_token *ct, struct buff_header *hbp, - int position, - int count ) + unsigned long position, + long count ) { register char *cp; struct undo_token *ut; register struct buff_line *lbp; struct buff_line *top_lbp; -int top_offset,local_count,bulk_position; -int bytes_deleted_so_far = 0; +unsigned long top_offset,local_count,bulk_position; +unsigned long bytes_deleted_so_far = 0; PREAMBLE(); @@ -2332,8 +2332,8 @@ int bytes_deleted_so_far = 0; */ void buff_bulk_insert( struct buff_header *hbp, - int position, - int count, + unsigned long position, + long count, struct buff_line *lbp ) { register struct buff_line *olbp; @@ -47,8 +47,8 @@ char *teccmd_c_version = "teccmd.c: $Revision: 1.3 $"; /* * Globals */ - int last_search_pos1; - int last_search_pos2; + unsigned long last_search_pos1; + unsigned long last_search_pos2; int last_search_status; struct tags *current_tags; @@ -102,16 +102,16 @@ char *teccmd_c_version = "teccmd.c: $Revision: 1.3 $"; */ int cmd_search( - int arg1, - int arg2, + long arg1, + long arg2, struct search_buff *search_tbl ) { int count; char forwards; int status; -int pos1; -int pos2; -int original_dot; +unsigned long pos1; +unsigned long pos2; +unsigned long original_dot; PREAMBLE(); @@ -191,8 +191,8 @@ int original_dot; */ int cmd_forward_search( - int pos1, - int pos2, + unsigned long pos1, + unsigned long pos2, struct search_buff *search_tbl ) { register struct search_element *ep; @@ -210,7 +210,7 @@ struct position_cache running_position; /* * Insure the search string is non-null */ - if(search_tbl->length <= 0){ + if(!search_tbl->length){ error_message("?Null Search String"); search_tbl->error_message_given = YES; return(FAIL); @@ -351,7 +351,7 @@ struct position_cache running_position; /* * Insure the search string is non-null */ - if(search_tbl->length <= 0){ + if(!search_tbl->length){ error_message("?Null Search String"); search_tbl->error_message_given = YES; return(FAIL); @@ -576,7 +576,7 @@ int new_length; int compile_search_string( struct search_buff *search_tbl ) { -register int position; +register unsigned long position; register char c; register char *cp; register struct buff_header *qbp; @@ -1282,7 +1282,7 @@ register int status; * number of words. */ int -cmd_wordmove( int count ) +cmd_wordmove( long count ) { register int c; @@ -1744,7 +1744,7 @@ register int length; * \retval FAIL Command failed. Error message has been displayed. */ int -cmd_oscmd(struct cmd_token *uct, int arg_count, int arg1, int arg2, char *cp) +cmd_oscmd(struct cmd_token *uct, int arg_count, unsigned long arg1, unsigned long arg2, char *cp) { int last_intr_flag; int line_cnt,w; @@ -1960,7 +1960,7 @@ failreap: * user to execute operating system commands from within the editor. */ int -cmd_oscmd(struct cmd_token *uct, int arg_count, int arg1, int arg2, char *cp) +cmd_oscmd(struct cmd_token *uct, int arg_count, unsigned long arg1, unsigned long arg2, char *cp) { PREAMBLE(); @@ -2053,8 +2053,8 @@ int length; */ int cmd_setoptions( - int arg1, - int arg2, + long arg1, + long arg2, struct undo_token *uct ) { struct undo_token fake_token; @@ -42,9 +42,9 @@ char *tecexec_c_version = "tecexec.c: $Revision: 1.3 $"; extern struct window *window_list; extern struct buff_header *curbuf,*buffer_headers; extern struct buff_header *qregister_push_down_list; - extern int last_search_pos1,last_search_pos2; + extern unsigned long last_search_pos1,last_search_pos2; extern int last_search_status; - extern int remembered_dot; + extern unsigned long remembered_dot; extern char intr_flag; extern char immediate_execute_flag; extern struct window *curwin; @@ -355,8 +355,8 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; register struct buff_header *hbp; register struct buff_header *qbp; register struct buff_line *lbp; - register int i,j; - int pos1,pos2; + register long i,j; + long pos1,pos2; hbp = curbuf; /* @@ -647,17 +647,17 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; return(FAIL); }/* End IF */ - sprintf(tmp_buffer,"value = %d",ct->ctx.iarg1); + sprintf(tmp_buffer,"value = %ld",ct->ctx.iarg1); screen_message(tmp_buffer); return(SUCCESS); case EXEC_C_TWO_EQUALS: - sprintf(tmp_buffer,"value = 0%o",ct->ctx.iarg1); + sprintf(tmp_buffer,"value = 0%lo",ct->ctx.iarg1); screen_message(tmp_buffer); return(SUCCESS); case EXEC_C_THREE_EQUALS: - sprintf(tmp_buffer,"value = 0x%X",ct->ctx.iarg1); + sprintf(tmp_buffer,"value = 0x%lX",ct->ctx.iarg1); screen_message(tmp_buffer); return(SUCCESS); /* @@ -666,7 +666,7 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; */ case EXEC_C_BACKSLASH: {/* Local Block */ - register int i,j; + register long i,j; char *cp; int length = 0; @@ -774,7 +774,7 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; */ case EXEC_C_CHAR: {/* Local Block */ - register int i; + register long i; i = curbuf->dot + 1; @@ -798,7 +798,7 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; */ case EXEC_C_RCHAR: {/* Local Block */ - register int i; + register long i; i = curbuf->dot - 1; if(ct->ctx.iarg1_flag == YES){ @@ -821,7 +821,7 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; */ case EXEC_C_DELETE: {/* Local Block */ - register int i; + register long i; i = 1; if(ct->ctx.iarg1_flag == YES) i = ct->ctx.iarg1; @@ -856,7 +856,7 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; */ case EXEC_C_WORD: {/* Local Block */ - register int count; + register long count; ut = allocate_undo_token(uct); if(ut == NULL) return(FAIL); @@ -878,9 +878,9 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; */ case EXEC_C_DELWORD: {/* Local Block */ - register int count; - int original_position; - int pos; + register long count; + unsigned long original_position; + unsigned long pos; ut = allocate_undo_token(uct); if(ut == NULL) return(FAIL); @@ -912,9 +912,9 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; */ case EXEC_C_RDELWORD: {/* Local Block */ - register int count; - int original_position; - int pos; + register long count; + unsigned long original_position; + unsigned long pos; ut = allocate_undo_token(uct); if(ut == NULL) return(FAIL); @@ -1047,8 +1047,8 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; {/* Local Block */ register struct buff_header *hbp; register struct buff_line *lbp; - register int i,j; - int pos1,pos2; + register long i,j; + long pos1,pos2; hbp = curbuf; /* @@ -1227,7 +1227,7 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; */ case EXEC_C_SEARCH: {/* Local Block */ - int arg1,arg2; + long arg1,arg2; #if 0 struct buff_header *qbp; #endif @@ -1253,13 +1253,13 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; if(ct->ctx.iarg1_flag && ct->ctx.iarg2_flag){ if(arg1 < 0 || arg1 > curbuf->zee){ sprintf(tmp_message, - "?Illegal buffer position %d in search command",arg1); + "?Illegal buffer position %ld in search command",arg1); error_message(tmp_message); return(FAIL); }/* End IF */ if(arg2 < 0 || arg2 > curbuf->zee){ sprintf(tmp_message, - "?Illegal buffer position %d in search command",arg2); + "?Illegal buffer position %ld in search command",arg2); error_message(tmp_message); return(FAIL); }/* End IF */ @@ -1299,7 +1299,7 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; case EXEC_C_FRREPLACE: {/* Local Block */ register struct buff_header *qbp; - register int j; + register unsigned long j; if(last_search_status == 0){ if(ct->ctx.flags & CTOK_M_COLON_SEEN){ @@ -1359,7 +1359,7 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; */ case EXEC_C_FSREPLACE1: {/* Local Block */ - register int j; + register unsigned long j; register struct buff_header *qbp; ct->ctx.tmpval = 0; @@ -37,7 +37,7 @@ char *tecmem_c_version = "tecmem.c: $Revision: 1.3 $"; #endif #endif - char *starting_break; + static char *starting_break; #if !defined(HAVE_UNISTD_H) && !defined(HAVE_STDLIB_H) char *malloc(); @@ -58,14 +58,15 @@ struct memlist { struct memlist *next_block; }; -char *malloc_leftover; -int malloc_leftover_size; -struct memlist *lookaside_lists[LOOKASIDE_COUNT]; -int lookaside_stat_allocated[LOOKASIDE_COUNT]; -int lookaside_stat_available[LOOKASIDE_COUNT]; -int malloc_stat_call_count,malloc_stat_inuse; +static char *malloc_leftover; +static size_t malloc_leftover_size; +static struct memlist *lookaside_lists[LOOKASIDE_COUNT]; +static unsigned int lookaside_stat_allocated[LOOKASIDE_COUNT]; +static unsigned int lookaside_stat_available[LOOKASIDE_COUNT]; +static unsigned int malloc_stat_call_count; +static unsigned long malloc_stat_inuse; -int memstat_by_type[TYPE_C_MAXTYPE-TYPE_C_MINTYPE+1]; +static unsigned int memstat_by_type[TYPE_C_MAXTYPE-TYPE_C_MINTYPE+1]; void tecmem_verify(unsigned char,char *,char *); @@ -75,9 +76,9 @@ void tecmem_verify(unsigned char,char *,char *); * This routine is called to request memory */ char * -tec_alloc( int type, int size ) +tec_alloc( int type, size_t size ) { -int actual_size; +size_t actual_size; register int i; register char *cp; register struct memblock *mp; @@ -332,18 +333,20 @@ tecmem_stats() { char tmp_buffer[LINE_BUFFER_SIZE]; register int i; -register int size; -int total_memory_in_use; +register size_t size; +unsigned long total_memory_in_use; char *current_break; -int bss_in_use; +unsigned long bss_in_use; PREAMBLE(); total_memory_in_use = malloc_stat_inuse; +#if LOOKASIDE_COUNT > 1 + sprintf( tmp_buffer, - "\n\n%d non-lookaside allocations, %d bytes outstanding\n\n", + "\n\n%u non-lookaside allocations, %lu bytes outstanding\n\n", malloc_stat_call_count, malloc_stat_inuse ); @@ -357,7 +360,7 @@ int bss_in_use; sprintf( tmp_buffer, - "LA%2d, size %4d, bytes in use %6d, bytes available %6d\n", + "LA%2u, size %4lu, bytes in use %6lu, bytes available %6lu\n", i, size, lookaside_stat_allocated[i] * size, @@ -370,7 +373,7 @@ int bss_in_use; sprintf( tmp_buffer, - "Malloc Leftover %d bytes\n", + "Malloc Leftover %lu bytes\n", malloc_leftover_size ); buff_insert(curbuf,curbuf->dot,tmp_buffer,strlen(tmp_buffer)); @@ -421,6 +424,8 @@ int bss_in_use; }/* End FOR */ +#endif /* LOOKASIDE_COUNT > 1 */ + #if HAVE_SBRK current_break = (char *)sbrk(0); if(current_break != sbrk(0)){ @@ -434,13 +439,12 @@ int bss_in_use; if( bss_in_use ){ sprintf( tmp_buffer, - "\nTotal memory in use %d, Total allocated bss %d\n", + "\nTotal memory in use %lu, Total allocated bss %lu\n", total_memory_in_use, bss_in_use ); } else { - sprintf(tmp_buffer,"\nTotal memory in use %d\n",total_memory_in_use); + sprintf(tmp_buffer,"\nTotal memory in use %lu\n",total_memory_in_use); } buff_insert(curbuf,curbuf->dot,tmp_buffer,strlen(tmp_buffer)); - }/* End Routine */ @@ -45,16 +45,257 @@ #define VMINOR 0 #define AUTO_DATE "$Date: 2007/12/10 22:13:07 $" +/* + * Immediately start insertion after the first escape in FS. + */ +#define INTERACTIVE_FS + +/** + * We define unix except for the really different operating systems, like + * vms. It lets us write our own version of functions which simply do not + * exist outside of unix. + */ +#if !defined(VMS) && !defined(MSDOS) +#define UNIX +#define JOB_CONTROL +#endif + +/* + * Include Files From GNU Autoconf/Autoheader + * + * FIXME: The Autoconf build system does not pass down -DHAVE_CONFIG_H. + * This should be fixed by rewriting it as the original sources + * are missing. + */ +//#ifdef HAVE_CONFIG_H +#ifndef __WATCOMC__ +#include "config.h" +#endif + +#ifdef HAVE_SYS_IOCTL_H +#include <sys/ioctl.h> +#endif + +/* + * sys/filio.h has the FIONREAD definition + */ +#ifdef HAVE_SYS_FILIO_H +#include <sys/filio.h> +#endif +#ifdef FIONREAD +#define HAS_FIONREAD +#endif + +#if HAVE_SYS_TYPES_H +#include <sys/types.h> +#if HAVE_SYS_WAIT_H +# include <sys/wait.h> +#endif +#ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif +#ifndef WIFEXITED +# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif +#endif + +#if HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + +#if STDC_HEADERS +#include <stdlib.h> +#include <stddef.h> +#else +#if HAVE_STDLIB_H +#include <stdlib.h> +#endif +#endif + +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +# if !HAVE_STRCHR +# if !defined(strchr) +# define strchr index +# endif +# if !defined(strrchr) +# define strrchr rindex +# endif +# endif +#endif + +/* on SGI this gets us BZERO */ +#if HAVE_STRINGS_H +#include <strings.h> +#endif + +#if HAVE_INTTYPES_H +#include <inttypes.h> +#else +#if HAVE_STDINT_H +#include <stdint.h> +#endif +#endif + #if HAVE_STDIO_H #include <stdio.h> #endif +#if HAVE_UNISTD_H +#include <unistd.h> +#endif + +#if HAVE_DIRENT_H +#include <dirent.h> +#define NAMLEN(dirent) strlen((dirent)->d_name) +#else +#define dirent direct +#define NAMLEN(dirent) (dirent)->d_namlen +#if HAVE_SYS_NDIR_H +#include <sys/ndir.h> +#endif +#if HAVE_SYS_DIR_H +#include <sys/dir.h> +#endif +#if HAVE_NDIR_H +#include <ndir.h> +#endif +#endif + +#if HAVE_DIRECT_H +#include <direct.h> +#endif + +#if HAVE_I86_H +#include <i86.h> +#endif + +#if HAVE_SYS_WAIT_H +# include <sys/wait.h> +#endif +#ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif +#ifndef WIFEXITED +# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif + +#if GWINSZ_IN_SYS_IOCTL +# include <sys/ioctl.h> +#define SUN_STYLE_WINDOW_SIZING 1 +#else +#if HAVE_TERMIOS_H +# include <termios.h> +#define SUN_STYLE_WINDOW_SIZING 1 +#endif +#endif + +#if HAVE_TERMIO_H +# include <termio.h> +#endif + +#if HAVE_IO_H +#include <io.h> +#endif + +#if HAVE_FCNTL_H +#include <fcntl.h> +#endif + +#if !defined(HAVE_TERMIO_H) && !defined(HAVE_TERMIOS_H) +#if HAVE_SGTTY_H +#include <sgtty.h> +#endif +#endif + +#if HAVE_SYS_FILE_H +#include <sys/file.h> +#endif + +#if HAVE_SYS_PARAM_H +#include <sys/param.h> +#endif + +#if HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif + +#if HAVE_CTYPE_H +#include <ctype.h> +#endif + +#if HAVE_ERRNO_H +#include <errno.h> +#endif + +#if HAVE_SIGNAL_H +#include <signal.h> +#endif + +#if HAVE_PWD_H +#include <pwd.h> +#endif + +#if HAVE_TERMCAP_H +#include <termcap.h> +#endif + +/* current end of autoconf stuff*/ + +#if HAVE_LIBTERMCAP +#define TERMCAP +#else +#if defined(HAVE_LIBTERMINFO) +#define TERMINFO +#endif +#endif + +#if !defined(TERMCAP) && !defined(TERMINFO) +#if defined(HAVE_LIBNCURSES) +#define TERMINFO +#endif +#endif + + +/* we prefer select over poll */ +#if HAVE_SYS_SELECT_H +#include <sys/select.h> +#define HAS_SELECT +#else +#if HAVE_POLL_H +#include <poll.h> +#define HAS_POLL +#endif +#endif + +/* + * Digital Equpment VMS Operating System + */ +#ifdef VMS +#include "tecvms.h" +#endif + +#ifndef CAUSE_BUS_ERROR +#define CAUSE_BUS_ERROR() \ + { \ + int fake_destination; \ + fake_destination = *((int *)(0x0FFFFFFF)); \ + (void)fake_destination; \ + } +#endif + +#ifdef MSDOS +#include <conio.h> +#endif + #define TECO_FILENAME_TOTAL_LENGTH FILENAME_MAX #define TECO_FILENAME_COMPONENT_LENGTH 256 #define TECO_READONLY_NAME "visit" #define TECO_INTERNAL_BUFFER_NAME "TECO-" #define TERMCAP_BUFFER_SIZE 2048 -#define SCREEN_OUTPUT_BUFFER_SIZE 4096 #define SCREEN_RESERVED_LINES 2 #define SCREEN_MAX_LABEL_FIELDS 4 #define SCREEN_NOMINAL_LINE_WIDTH 132 @@ -67,8 +308,10 @@ #if defined(MSDOS) && !defined(__HUGE__) /* make sure that all variables fit into 64kb */ #define PARSER_STRING_MAX 512 +#define SCREEN_OUTPUT_BUFFER_SIZE 512 #else #define PARSER_STRING_MAX 1024 +#define SCREEN_OUTPUT_BUFFER_SIZE 4096 #endif #define SEARCH_STRING_MAX PARSER_STRING_MAX #define NORMAL_TAB_WIDTH 8 @@ -183,7 +426,7 @@ void do_return_checks(void); */ struct position_cache { struct buff_line *lbp; - int base; + unsigned long base; }; #define BUFF_CACHE_CONTENTS(pos_cache) \ @@ -207,11 +450,11 @@ void do_return_checks(void); char *name; int buffer_number; struct buff_header *next_header; - char ismodified; - char isreadonly; - char isbackedup; - int dot; - int zee; + unsigned int ismodified : 1; + unsigned int isreadonly : 1; + unsigned int isbackedup : 1; + unsigned long dot; + unsigned long zee; int ivalue; struct position_cache pos_cache; @@ -220,8 +463,8 @@ void do_return_checks(void); struct buff_line { int lin_magic; - int buffer_size; - int byte_count; + size_t buffer_size; + size_t byte_count; char *buffer; struct buff_line *next_line; struct buff_line *prev_line; @@ -232,7 +475,7 @@ void do_return_checks(void); int fmt_magic; struct buff_header *fmt_owning_buffer; struct buff_line *fmt_buffer_line; - int fmt_buffer_size; + size_t fmt_buffer_size; short *fmt_buffer; int fmt_sequence; struct format_line *fmt_next_line; @@ -241,8 +484,8 @@ void do_return_checks(void); struct format_line *fmt_prev_alloc; struct format_line *fmt_next_window; struct format_line *fmt_prev_window; - char fmt_in_use; - char fmt_permanent; + unsigned int fmt_in_use : 1; + unsigned int fmt_permanent : 1; struct screen_line *fmt_saved_line; short fmt_visible_line_position; struct window *fmt_window_ptr; @@ -283,7 +526,7 @@ void do_return_checks(void); }; struct search_buff { - int length; + size_t length; char input[PARSER_STRING_MAX]; struct search_element data[PARSER_STRING_MAX]; char error_message_given; @@ -366,243 +609,6 @@ void do_return_checks(void); typedef unsigned long teco_ptrint_t; -/** - * We define unix except for the really different operating systems, like - * vms. It lets us write our own version of functions which simply do not - * exist outside of unix. - */ -#if !defined(VMS) && !defined(MSDOS) -#define UNIX -#define JOB_CONTROL -#endif - -/* - * Include Files From GNU Autoconf/Autoheader - * - * FIXME: The Autoconf build system does not pass down -DHAVE_CONFIG_H. - * This should be fixed by rewriting it as the original sources - * are missing. - */ -//#ifdef HAVE_CONFIG_H -#ifndef __WATCOMC__ -#include "config.h" -#endif - -#ifdef HAVE_SYS_IOCTL_H -#include <sys/ioctl.h> -#endif - -/* - * sys/filio.h has the FIONREAD definition - */ -#ifdef HAVE_SYS_FILIO_H -#include <sys/filio.h> -#endif -#ifdef FIONREAD -#define HAS_FIONREAD -#endif - -#if HAVE_SYS_TYPES_H -#include <sys/types.h> -#if HAVE_SYS_WAIT_H -# include <sys/wait.h> -#endif -#ifndef WEXITSTATUS -# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) -#endif -#ifndef WIFEXITED -# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) -#endif -#endif - -#if HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - -#if STDC_HEADERS -#include <stdlib.h> -#include <stddef.h> -#else -#if HAVE_STDLIB_H -#include <stdlib.h> -#endif -#endif - -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H -# include <memory.h> -# endif -# include <string.h> -# if !HAVE_STRCHR -# if !defined(strchr) -# define strchr index -# endif -# if !defined(strrchr) -# define strrchr rindex -# endif -# endif -#endif - -/* on SGI this gets us BZERO */ -#if HAVE_STRINGS_H -#include <strings.h> -#endif - -#if HAVE_INTTYPES_H -#include <inttypes.h> -#else -#if HAVE_STDINT_H -#include <stdint.h> -#endif -#endif - -#if HAVE_UNISTD_H -#include <unistd.h> -#endif - -#if HAVE_DIRENT_H -#include <dirent.h> -#define NAMLEN(dirent) strlen((dirent)->d_name) -#else -#define dirent direct -#define NAMLEN(dirent) (dirent)->d_namlen -#if HAVE_SYS_NDIR_H -#include <sys/ndir.h> -#endif -#if HAVE_SYS_DIR_H -#include <sys/dir.h> -#endif -#if HAVE_NDIR_H -#include <ndir.h> -#endif -#endif - -#if HAVE_DIRECT_H -#include <direct.h> -#endif - -#if HAVE_I86_H -#include <i86.h> -#endif - -#if HAVE_SYS_WAIT_H -# include <sys/wait.h> -#endif -#ifndef WEXITSTATUS -# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) -#endif -#ifndef WIFEXITED -# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) -#endif - -#if GWINSZ_IN_SYS_IOCTL -# include <sys/ioctl.h> -#define SUN_STYLE_WINDOW_SIZING 1 -#else -#if HAVE_TERMIOS_H -# include <termios.h> -#define SUN_STYLE_WINDOW_SIZING 1 -#endif -#endif - -#if HAVE_TERMIO_H -# include <termio.h> -#endif - -#if HAVE_IO_H -#include <io.h> -#endif - -#if HAVE_FCNTL_H -#include <fcntl.h> -#endif - -#if !defined(HAVE_TERMIO_H) && !defined(HAVE_TERMIOS_H) -#if HAVE_SGTTY_H -#include <sgtty.h> -#endif -#endif - -#if HAVE_SYS_FILE_H -#include <sys/file.h> -#endif - -#if HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif - -#if HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif - -#if HAVE_CTYPE_H -#include <ctype.h> -#endif - -#if HAVE_ERRNO_H -#include <errno.h> -#endif - -#if HAVE_SIGNAL_H -#include <signal.h> -#endif - -#if HAVE_PWD_H -#include <pwd.h> -#endif - -#if HAVE_TERMCAP_H -#include <termcap.h> -#endif - -/* current end of autoconf stuff*/ - -#if HAVE_LIBTERMCAP -#define TERMCAP -#else -#if defined(HAVE_LIBTERMINFO) -#define TERMINFO -#endif -#endif - -#if !defined(TERMCAP) && !defined(TERMINFO) -#if defined(HAVE_LIBNCURSES) -#define TERMINFO -#endif -#endif - - -/* we prefer select over poll */ -#if HAVE_SYS_SELECT_H -#include <sys/select.h> -#define HAS_SELECT -#else -#if HAVE_POLL_H -#include <poll.h> -#define HAS_POLL -#endif -#endif - -/* - * Digital Equpment VMS Operating System - */ -#ifdef VMS -#include "tecvms.h" -#endif - -#ifndef CAUSE_BUS_ERROR -#define CAUSE_BUS_ERROR() \ - { \ - int fake_destination; \ - fake_destination = *((int *)(0x0FFFFFFF)); \ - (void)fake_destination; \ - } -#endif - -#ifdef MSDOS -#include <conio.h> -#endif - /* method declarations */ void error_message(char * string); void tec_release(unsigned char type, char *addr); @@ -610,17 +616,17 @@ void tec_panic( char *string); int buff_switch(struct buff_header *hbp,int map_flag); int buff_read(struct buff_header *hbp,char *name); int buff_readfd(struct buff_header *hbp,char *name,int iochan); -int buff_insert(struct buff_header *hbp,int position,char *buffer,int length); +int buff_insert(struct buff_header *hbp,unsigned long position,char *buffer,unsigned long length); int screen_label_line(struct buff_header *buffer,char *string,int field); -int buff_write(struct buff_header *hbp,int chan,int start,int end); +int buff_write(struct buff_header *hbp,int chan,unsigned long start,unsigned long end); void tecmem_stats(void); void screen_free_format_lines(struct format_line *sbp); -int buff_delete_char(struct buff_header *hbp,int position); +int buff_delete_char(struct buff_header *hbp,unsigned long position); int compile_search_string(struct search_buff *search_tbl); -int cmd_forward_search(int pos1,int pos2,struct search_buff *search_tbl); +int cmd_forward_search(unsigned long pos1,unsigned long pos2,struct search_buff *search_tbl); int cmd_reverse_search(int pos1,int pos2,struct search_buff *search_tbl); -int buff_cached_contents(struct buff_header *,int,struct position_cache *); -int buff_contents(struct buff_header *hbp,int position); +int buff_cached_contents(struct buff_header *,unsigned long,struct position_cache *); +int buff_contents(struct buff_header *hbp,long position); void pause_while_in_input_wait(void); void restore_tty(void); void initialize_tty(void); @@ -631,7 +637,7 @@ void screen_message(char *string); int tty_input_pending(void); void screen_format_windows(void); void load_qname_register(void); -void buff_delete(struct buff_header *,int,int); +void buff_delete(struct buff_header *,unsigned long,unsigned long); void screen_reformat_windows(void); int tag_calc_hash(char *string); void tag_free_struct(struct tags *tp); @@ -655,15 +661,15 @@ void screen_delete_window( struct window *old_wptr); void buff_reopenbuff(struct buff_header *bp); void buff_free_line_buffer_list(struct buff_line *); int screen_display_window(struct window *wptr); -int buff_find_offset(struct buff_header *,struct buff_line *,int); +int buff_find_offset(struct buff_header *,struct buff_line *,long); int buff_openbuffnum(int,int); -int parse_illegal_buffer_position(int,int,char *); -int buff_insert_char(struct buff_header *,int,char); +int parse_illegal_buffer_position(long,long,char *); +int buff_insert_char(struct buff_header *,unsigned long,char); int push_qregister(char); -void buff_bulk_insert(struct buff_header *,int,int,struct buff_line *); +void buff_bulk_insert(struct buff_header *,unsigned long,long,struct buff_line *); void buff_destroy(struct buff_header *); -int cmd_wordmove(int count); -int cmd_search(int,int,struct search_buff *); +int cmd_wordmove(long count); +int cmd_search(long,long,struct search_buff *); int buff_openbuffer(char *,int,int); int cmd_write(struct buff_header *,char *); void screen_scroll(int); @@ -691,11 +697,11 @@ void cmd_suspend(void); int term_putnum(char *,int,int); int term_scroll_region(int,int); int init_term_description(void); -char *tec_alloc(int,int); +char *tec_alloc(int,size_t); void initialize_memory_stats( void ); struct buff_header *buff_qfind(char,char); char *error_text(int); -struct buff_line *buff_find_line(struct buff_header *hbp,int); +struct buff_line *buff_find_line(struct buff_header *hbp,unsigned long); void term_insert_line(int,int); void term_delete_line(int,int); struct buff_header *buff_find(char *); @@ -39,7 +39,7 @@ char *tecparse_c_version = "tecparse.c: $Revision: 1.3 $"; struct cmd_token *last_token_executed; struct search_buff search_string; char user_message[PARSER_STRING_MAX]; - int remembered_dot; + unsigned long remembered_dot; char immediate_execute_flag = YES; char trace_mode_flag = NO; @@ -1123,7 +1123,7 @@ int c; /* * Make sure thre are some bytes in it */ - if(qbp->zee <= 0) return(FAIL); + if(!qbp->zee) return(FAIL); /* * Get the first byte saved in the Q-register @@ -1482,7 +1482,7 @@ char tmp_message[LINE_BUFFER_SIZE]; * legal. If they are not, it generates an error message. */ int -parse_illegal_buffer_position( int pos1, int pos2, char *cmd_name ) +parse_illegal_buffer_position( long pos1, long pos2, char *cmd_name ) { char illegal_position; char tmp_message[LINE_BUFFER_SIZE]; @@ -1598,18 +1598,18 @@ register char *state_name; buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); }/* End IF */ - sprintf(tmp_message," iarg1_flag %d iarg1 %d (0x%x)\n", + sprintf(tmp_message," iarg1_flag %d iarg1 %ld (0x%lx)\n", ct0->ctx.iarg1_flag,ct0->ctx.iarg1,ct0->ctx.iarg1); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); - sprintf(tmp_message," iarg2_flag %d iarg2 %d (0x%x)\n", + sprintf(tmp_message," iarg2_flag %d iarg2 %ld (0x%lx)\n", ct0->ctx.iarg2_flag,ct0->ctx.iarg2,ct0->ctx.iarg2); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); sprintf(tmp_message," carg %p\n",ct0->ctx.carg); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); - sprintf(tmp_message," tmpval %d (0x%x)\n", + sprintf(tmp_message," tmpval %ld (0x%lx)\n", ct0->ctx.tmpval,ct0->ctx.tmpval); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); @@ -1633,21 +1633,21 @@ register char *state_name; ct1, state_name); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); - sprintf(tmp_message," iarg1_flag %d iarg1 %d (0x%x)", + sprintf(tmp_message," iarg1_flag %d iarg1 %ld (0x%lx)", ct0->ctx.iarg1_flag,ct0->ctx.iarg1,ct0->ctx.iarg1); while(strlen(tmp_message) < 39) strcat(tmp_message," "); strcat(tmp_message," "); cp = &tmp_message[strlen(tmp_message)]; - sprintf(cp," iarg1_flag %d iarg1 %d (0x%x)\n", + sprintf(cp," iarg1_flag %d iarg1 %ld (0x%lx)\n", ct1->ctx.iarg1_flag,ct1->ctx.iarg1,ct1->ctx.iarg1); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); - sprintf(tmp_message," iarg2_flag %d iarg2 %d (0x%x)", + sprintf(tmp_message," iarg2_flag %d iarg2 %ld (0x%lx)", ct0->ctx.iarg2_flag,ct0->ctx.iarg2,ct0->ctx.iarg2); while(strlen(tmp_message) < 39) strcat(tmp_message," "); strcat(tmp_message," "); cp = &tmp_message[strlen(tmp_message)]; - sprintf(cp," iarg2_flag %d iarg2 %d (0x%x)\n", + sprintf(cp," iarg2_flag %d iarg2 %ld (0x%lx)\n", ct1->ctx.iarg2_flag,ct1->ctx.iarg2,ct1->ctx.iarg2); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); @@ -1658,12 +1658,12 @@ register char *state_name; sprintf(cp," carg %p\n",ct1->ctx.carg); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); - sprintf(tmp_message," tmpval %d (0x%x)", + sprintf(tmp_message," tmpval %ld (0x%lx)", ct0->ctx.tmpval,ct0->ctx.tmpval); while(strlen(tmp_message) < 39) strcat(tmp_message," "); strcat(tmp_message," "); cp = &tmp_message[strlen(tmp_message)]; - sprintf(cp," tmpval %d (0x%x)\n", + sprintf(cp," tmpval %ld (0x%lx)\n", ct1->ctx.tmpval,ct1->ctx.tmpval); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); break; @@ -1722,18 +1722,18 @@ register char *state_name; buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); }/* End IF */ - sprintf(tmp_message," iarg1_flag %d iarg1 %d (0x%x)\n", + sprintf(tmp_message," iarg1_flag %d iarg1 %ld (0x%lx)\n", ct0->ctx.iarg1_flag,ct0->ctx.iarg1,ct0->ctx.iarg1); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); - sprintf(tmp_message," iarg2_flag %d iarg2 %d (0x%x)\n", + sprintf(tmp_message," iarg2_flag %d iarg2 %ld (0x%lx)\n", ct0->ctx.iarg2_flag,ct0->ctx.iarg2,ct0->ctx.iarg2); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); sprintf(tmp_message," carg %p\n",ct0->ctx.carg); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); - sprintf(tmp_message," tmpval %d (0x%x)\n", + sprintf(tmp_message," tmpval %ld (0x%lx)\n", ct0->ctx.tmpval,ct0->ctx.tmpval); buff_insert(qbp,qbp->zee,tmp_message,strlen(tmp_message)); @@ -36,17 +36,17 @@ struct cmd_context { char state; char flags; - char go_flag; char pnest; char inest; char cnest; - char iarg1_flag; - char iarg2_flag; + unsigned go_flag : 1; + unsigned iarg1_flag : 1; + unsigned iarg2_flag : 1; char delimeter; - int iarg1; - int iarg2; + long iarg1; + long iarg2; char *carg; - int tmpval; + long tmpval; int return_state; struct cmd_token *caller_token; }; @@ -68,8 +68,8 @@ struct cmd_token { struct undo_token { char opcode; - int iarg1; - int iarg2; + long iarg1; + long iarg2; char *carg1; struct undo_token *next_token; }; @@ -297,17 +297,17 @@ struct undo_token { #define UNDO_C_SELECT_TAGS 25 #define UNDO_C_SET_EXIT_FLAG 26 -int cmd_oscmd(struct cmd_token *, int, int, int, char *); +int cmd_oscmd(struct cmd_token *,int,unsigned long,unsigned long,char *); int buff_insert_from_buffer_with_undo( struct cmd_token *, - struct buff_header *,int,struct buff_header *,int,int); -int buff_delete_with_undo( struct cmd_token *,struct buff_header *,int,int); + struct buff_header *,unsigned long,struct buff_header *,unsigned long,size_t); +int buff_delete_with_undo( struct cmd_token *,struct buff_header *,unsigned long,long); int buff_insert_with_undo( struct cmd_token *, - struct buff_header *,int,char *,int); + struct buff_header *,unsigned long,char *,unsigned long); int rename_edit_buffer(struct buff_header *,char *,struct cmd_token *); -int cmd_setoptions(int,int,struct undo_token *); +int cmd_setoptions(long,long,struct undo_token *); void tag_dump_database(struct tags *tp,struct cmd_token *uct); int buff_insert_char_with_undo(struct cmd_token *, - struct buff_header *,int,char); + struct buff_header *,unsigned long,char); int set_search_string_with_undo(char *,struct cmd_token *uct); int cmd_tags(struct cmd_token *uct,int,int,int,char *); int tecmacro(struct buff_header *,struct cmd_token *,struct cmd_token **); @@ -99,7 +99,7 @@ register struct cmd_token *ct; hbp = buff_qfind(ut->iarg1,0); if(hbp == NULL){ sprintf(tmp_message,"?Cannot find Q-register <%c>", - ut->iarg1); + (char)ut->iarg1); error_message(tmp_message); return(FAIL); }/* End IF */ |