diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-05-03 20:36:25 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-05-03 20:36:25 +0300 |
commit | 9c2afb86acd2e28bef1767b7333acfb9666ec86b (patch) | |
tree | cfdedb1bd7436675654fb8374bca4e22a5f38e1d | |
parent | 9deaff57e11036f96b93e0ed79b39cac7fcffa04 (diff) | |
download | videoteco-fork-9c2afb86acd2e28bef1767b7333acfb9666ec86b.tar.gz |
various data type improvements
* fixes at least <FS>, which has been broken since b5325e00c402ec18034da4b4a4aaaefa87bb1fef.
* but probably many other commands as well in the DOS version when working with
"very large" documents
* now compiles cleanly with -Wsign-compare
-rw-r--r-- | tecbuf.c | 34 | ||||
-rw-r--r-- | teccmd.c | 21 | ||||
-rw-r--r-- | tecdisp.c | 2 | ||||
-rw-r--r-- | tecexec.c | 8 | ||||
-rw-r--r-- | teco.h | 4 | ||||
-rw-r--r-- | tecparse.c | 12 | ||||
-rw-r--r-- | tecparse.h | 2 |
7 files changed, 43 insertions, 40 deletions
@@ -555,7 +555,7 @@ register int i; /* * Insure that the specified position is legal */ - if(position > hbp->zee || position < 0){ + if((unsigned long)position > hbp->zee || position < 0){ char panic_string[LINE_BUFFER_SIZE]; sprintf(panic_string, "buff_contents: illegal position %ld specified in buffer %s", @@ -585,7 +585,7 @@ register int i; */ int buff_cached_contents( struct buff_header *hbp, - unsigned long position, struct position_cache *cache ) + long position, struct position_cache *cache ) { register struct buff_line *lbp; register int i; @@ -594,7 +594,7 @@ register int i; /* * Insure that the specified position is legal */ - if(position > hbp->zee || position < 0){ + if(position < 0 || (unsigned long)position > hbp->zee){ char tmp_message[LINE_BUFFER_SIZE]; sprintf(tmp_message,"buff_contents: illegal position %lu %s Z = %lu\n", position,hbp->name,hbp->zee); @@ -862,7 +862,7 @@ buff_readfd( struct buff_header *hbp, char *name, int iochan ) register int i; register struct buff_line *lbp; struct buff_line *olbp; - int original_zee = hbp->zee; + unsigned long original_zee = hbp->zee; int error_status = SUCCESS; PREAMBLE(); @@ -1301,16 +1301,16 @@ buff_insert_from_buffer_with_undo( struct cmd_token *ct, unsigned long src_position, size_t length ) { -register int i; +register unsigned int i; struct undo_token *ut = 0; struct buff_line *dlbp,*sb_lbp,*se_lbp,*nlbp; int doff,sb_off,se_off; int newline_included_in_src_data; -int bytes_to_copy_from_source; -int bytes_required_for_line,bytes_to_allocate; +size_t bytes_to_copy_from_source; +size_t bytes_required_for_line,bytes_to_allocate; char *new_buffer; register char *dcp,*scp; -int bytes_inserted_so_far = 0; +size_t bytes_inserted_so_far = 0; #ifdef DEBUG char outbuf[1024]; @@ -1498,7 +1498,7 @@ char outbuf[1024]; char tmp_message[1024]; sprintf( tmp_message, - "buff_insert_from_buffer_with_undo need %d alloced %d\n", + "buff_insert_from_buffer_with_undo need %lu alloced %lu\n", bytes_required_for_line, bytes_to_allocate ); @@ -1622,7 +1622,7 @@ char outbuf[1024]; char tmp_message[1024]; sprintf( tmp_message, - "buff_insert_from_buffer_with_undo needs %d alloced %d\n", + "buff_insert_from_buffer_with_undo needs %lu alloced %lu\n", bytes_required_for_line, bytes_to_allocate ); @@ -1856,7 +1856,7 @@ register int i,j; cp = lbp->buffer + i; ocp = nlbp->buffer; - while(nlbp->byte_count < j){ + while(nlbp->byte_count < (unsigned int)j){ *ocp++ = *cp++; nlbp->byte_count++; lbp->byte_count--; @@ -1988,7 +1988,8 @@ buff_delete_char( struct buff_header *hbp, register struct buff_line *lbp; struct buff_line *nlbp; register char *cp,*ocp; -register int i,j; +register int i; +register unsigned int j; PREAMBLE(); /* @@ -2134,13 +2135,14 @@ int buff_delete_with_undo( struct cmd_token *ct, struct buff_header *hbp, unsigned long position, - long count ) + unsigned long count ) { register char *cp; struct undo_token *ut; register struct buff_line *lbp; struct buff_line *top_lbp; -unsigned long top_offset,local_count,bulk_position; +unsigned long top_offset,bulk_position; +long local_count; unsigned long bytes_deleted_so_far = 0; PREAMBLE(); @@ -2195,7 +2197,7 @@ unsigned long bytes_deleted_so_far = 0; * removed in bulk. lbp gets left pointing at the final line which can be bulk * removed. */ - if(lbp && lbp->byte_count <= local_count){ + if(lbp && (ssize_t)lbp->byte_count <= local_count){ /* * We will get to bulk delete at least one line, so allocate an undo buffer. * Point the undo token at the head of the list of line buffers. Remember @@ -2221,7 +2223,7 @@ unsigned long bytes_deleted_so_far = 0; lbp->format_line = NULL; }/* End IF */ if(lbp->next_line == NULL) break; - if(lbp->next_line->byte_count > local_count) break; + if((ssize_t)lbp->next_line->byte_count > local_count) break; lbp = lbp->next_line; }/* End While */ /* @@ -198,7 +198,7 @@ cmd_forward_search( register struct search_element *ep; register unsigned char buffer_char; register int table_position; -int dotpos; +unsigned long dotpos; char token_match; char tmp_message[LINE_BUFFER_SIZE]; struct position_cache base_position; @@ -254,7 +254,7 @@ struct position_cache running_position; break; case SEARCH_C_QREGCHARS: { struct buff_header *qbp; - register int i; + register unsigned long i; qbp = buff_qfind(ep->value,0); token_match = 0; if(qbp == NULL) break; @@ -292,7 +292,7 @@ struct position_cache running_position; if(token_match){ table_position += 1; ep++; - if(table_position == search_tbl->length){ + if((size_t)table_position == search_tbl->length){ curbuf->dot = last_search_pos2 = dotpos; {/* Local Block */ register struct buff_header *hbp; @@ -332,14 +332,14 @@ struct position_cache running_position; */ int cmd_reverse_search( - int pos1, - int pos2, + unsigned long pos1, + unsigned long pos2, struct search_buff *search_tbl ) { register struct search_element *ep; register unsigned char buffer_char; register int table_position; -int dotpos; +unsigned long dotpos; char token_match; char tmp_message[LINE_BUFFER_SIZE]; struct position_cache base_position; @@ -366,7 +366,7 @@ struct position_cache running_position; while(dotpos > pos1){ - if(table_position == (search_tbl->length - 1)){ + if((size_t)table_position == (search_tbl->length - 1)){ last_search_pos2 = dotpos; base_position = running_position; }/* End IF */ @@ -398,7 +398,7 @@ struct position_cache running_position; break; case SEARCH_C_QREGCHARS: { struct buff_header *qbp; - register int i; + register unsigned long i; qbp = buff_qfind(ep->value,0); token_match = 0; if(qbp == NULL) break; @@ -478,9 +478,10 @@ set_search_string_with_undo( { register struct buff_header *qbp; register struct undo_token *ut; -register int i,c; +register unsigned long i; +register int c; register char *cp; -int new_length; +unsigned long new_length; PREAMBLE(); @@ -2394,7 +2394,7 @@ struct buff_header *hbp = wptr->win_buffer; sbp = format_line_free_list; if(sbp != NULL){ - if(sbp->fmt_buffer_size == term_columns){ + if(sbp->fmt_buffer_size == (size_t)term_columns){ format_line_free_list = sbp->fmt_next_line; } else { @@ -1250,13 +1250,13 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; * insure that the two positions specified are valid buffer positions. */ if(ct->ctx.iarg1_flag && ct->ctx.iarg2_flag){ - if(arg1 < 0 || arg1 > curbuf->zee){ + if(arg1 < 0 || (unsigned long)arg1 > curbuf->zee){ sprintf(tmp_message, "?Illegal buffer position %ld in search command",arg1); error_message(tmp_message); return(FAIL); }/* End IF */ - if(arg2 < 0 || arg2 > curbuf->zee){ + if(arg2 < 0 || (unsigned long)arg2 > curbuf->zee){ sprintf(tmp_message, "?Illegal buffer position %ld in search command",arg2); error_message(tmp_message); @@ -1410,7 +1410,7 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; * previous one. Only if we get a miscompare do we delete the contents of * the replacement q-register, and insert the new string. */ - if(qbp->zee > ct->ctx.tmpval){ + if((long)qbp->zee > ct->ctx.tmpval){ if(ct->input_byte == buff_contents(qbp,ct->ctx.tmpval)){ ct->ctx.tmpval += 1; return(SUCCESS); @@ -1433,7 +1433,7 @@ char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE]; return(FAIL); }/* End IF */ - if(qbp->zee > ct->ctx.tmpval){ + if((long)qbp->zee > ct->ctx.tmpval){ buff_delete_with_undo(uct,qbp,ct->ctx.tmpval, qbp->zee-ct->ctx.tmpval); } @@ -648,8 +648,8 @@ void screen_free_format_lines(struct format_line *sbp); int buff_delete_char(struct buff_header *hbp,unsigned long position); int compile_search_string(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 *,unsigned long,struct position_cache *); +int cmd_reverse_search(unsigned long pos1,unsigned long pos2,struct search_buff *search_tbl); +int buff_cached_contents(struct buff_header *,long,struct position_cache *); int buff_contents(struct buff_header *hbp,long position); void pause_while_in_input_wait(void); void restore_tty(void); @@ -487,7 +487,7 @@ register struct cmd_token *last_token; int c = 0; int status; char token_used; -int i; +unsigned long i; char old_modified_state; struct buff_header *old_curbuf; struct undo_token *ut; @@ -1207,10 +1207,10 @@ parser_replace_command_line( struct buff_header *qbp ) { register struct cmd_token *ct; register struct cmd_token *first_different_ct; -register int c; +register unsigned long c; char temp; register char *command_buffer; -register int cb_zee; +register unsigned long cb_zee; PREAMBLE(); @@ -1491,9 +1491,9 @@ char tmp_message[LINE_BUFFER_SIZE]; illegal_position = 0; if(pos1 < 0) illegal_position = 1; - if(pos2 < 0) illegal_position = 1; - if(pos1 > curbuf->zee) illegal_position = 1; - if(pos2 > curbuf->zee) illegal_position = 1; + else if(pos2 < 0) illegal_position = 1; + else if((unsigned long)pos1 > curbuf->zee) illegal_position = 1; + else if((unsigned long)pos2 > curbuf->zee) illegal_position = 1; if(illegal_position == 0) return(0); @@ -300,7 +300,7 @@ struct undo_token { 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 *,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_delete_with_undo( struct cmd_token *,struct buff_header *,unsigned long,unsigned long); int buff_insert_with_undo( struct cmd_token *, struct buff_header *,unsigned long,char *,unsigned long); int rename_edit_buffer(struct buff_header *,char *,struct cmd_token *); |