--- ed-0.8/buf.c +++ ed-0.8/buf.c @@ -517,7 +517,7 @@ } -static undo_t *ustack = 0; /* undo stack */ +static char *ustack = 0; /* undo stack */ static int usize = 0; /* ustack size (in bytes) */ static int u_ptr = 0; /* undo stack pointer */ static int u_current_addr = -1; /* if >= 0, undo enabled */ @@ -527,10 +527,10 @@ void clear_undo_stack( void ) { while( u_ptr-- ) - if( ustack[u_ptr].type == UDEL ) + if( ((undo_t *) ustack)[u_ptr].type == UDEL ) { - line_t *ep = ustack[u_ptr].tail->q_forw; + line_t *ep = ((undo_t *) ustack)[u_ptr].tail->q_forw; - line_t *lp = ustack[u_ptr].head; + line_t *lp = ((undo_t *) ustack)[u_ptr].head; while( lp != ep ) { line_t *tl = lp->q_forw; @@ -566,26 +566,26 @@ disable_interrupts(); for( n = u_ptr - 1; n >= 0; --n ) { - switch( ustack[n].type ) + switch( ((undo_t *) ustack)[n].type ) { - case UADD: link_nodes( ustack[n].head->q_back, ustack[n].tail->q_forw ); + case UADD: link_nodes( ((undo_t *) ustack)[n].head->q_back, ((undo_t *) ustack)[n].tail->q_forw ); break; - case UDEL: link_nodes( ustack[n].head->q_back, ustack[n].head ); + case UDEL: link_nodes( ((undo_t *) ustack)[n].head->q_back, ((undo_t *) ustack)[n].head ); - link_nodes( ustack[n].tail, ustack[n].tail->q_forw ); + link_nodes( ((undo_t *) ustack)[n].tail, ((undo_t *) ustack)[n].tail->q_forw ); break; case UMOV: - case VMOV: link_nodes( ustack[n-1].head, ustack[n].head->q_forw ); + case VMOV: link_nodes( ((undo_t *) ustack)[n-1].head, ((undo_t *) ustack)[n].head->q_forw ); - link_nodes( ustack[n].tail->q_back, ustack[n-1].tail ); + link_nodes( ((undo_t *) ustack)[n].tail->q_back, ((undo_t *) ustack)[n-1].tail ); - link_nodes( ustack[n].head, ustack[n].tail ); --n; + link_nodes( ((undo_t *) ustack)[n].head, ((undo_t *) ustack)[n].tail ); --n; break; } - ustack[n].type ^= 1; + ((undo_t *) ustack)[n].type ^= 1; } /* reverse undo stack order */ for( n = 0; 2 * n < u_ptr - 1; ++n ) { - undo_t tmp = ustack[n]; + undo_t tmp = ((undo_t *) ustack)[n]; - ustack[n] = ustack[u_ptr-1-n]; ustack[u_ptr-1-n] = tmp; + ((undo_t *) ustack)[n] = ((undo_t *) ustack)[u_ptr-1-n]; ((undo_t *) ustack)[u_ptr-1-n] = tmp; } if( isglobal ) clear_active_list(); _current_addr = u_current_addr; u_current_addr = o_current_addr; @@ -599,7 +599,7 @@ undo_t *push_undo_stack( const int type, const int from, const int to ) { disable_interrupts(); - if( !resize_buffer( (char **)(void *)&ustack, &usize, + if( !resize_buffer( &ustack, &usize, ( u_ptr + 1 ) * sizeof( undo_t ) ) ) { show_strerror( 0, errno ); @@ -615,8 +615,8 @@ enable_interrupts(); return 0; } enable_interrupts(); - ustack[u_ptr].type = type; + ((undo_t *) ustack)[u_ptr].type = type; - ustack[u_ptr].tail = search_line_node( ( to >= 0 ) ? to : _current_addr ); + ((undo_t *) ustack)[u_ptr].tail = search_line_node( ( to >= 0 ) ? to : _current_addr ); - ustack[u_ptr].head = search_line_node( ( from >= 0 ) ? from : _current_addr ); + ((undo_t *) ustack)[u_ptr].head = search_line_node( ( from >= 0 ) ? from : _current_addr ); - return ustack + u_ptr++; + return ((undo_t *) ustack) + u_ptr++; } --- ed-0.8/carg_parser.c +++ ed-0.8/carg_parser.c @@ -41,10 +41,10 @@ { const int len = strlen( argument ); ap_Record *p; - if( !ap_resize_buffer( (char **)(void *)&(ap->data), 0, + if( !ap_resize_buffer( &(ap->data), 0, ( ap->data_size + 1 ) * sizeof( ap_Record ) ) ) return 0; - p = &(ap->data[ap->data_size]); + p = &(((ap_Record *) ap->data)[ap->data_size]); p->code = code; p->argument = 0; if( !ap_resize_buffer( &(p->argument), 0, len + 1 ) ) return 0; @@ -68,7 +68,7 @@ void free_data( Arg_parser * ap ) { int i; - for( i = 0; i < ap->data_size; ++i ) free( ap->data[i].argument ); + for( i = 0; i < ap->data_size; ++i ) free( ((ap_Record *) ap->data)[i].argument ); if( ap->data ) { free( ap->data ); ap->data = 0; } ap->data_size = 0; } @@ -191,7 +191,7 @@ char ap_init( Arg_parser * ap, const int argc, const char * const argv[], const ap_Option options[], const char in_order ) { - const char ** non_options = 0; // skipped non-options + char * non_options = 0; // skipped non-options int non_options_size = 0; // number of skipped non-options int argind = 1; // index in argv int i; @@ -223,10 +223,10 @@ { if( !in_order ) { - if( !ap_resize_buffer( (char **)(void *)&non_options, 0, + if( !ap_resize_buffer( &non_options, 0, ( non_options_size + 1 ) * sizeof( char * ) ) ) return 0; - non_options[non_options_size++] = argv[argind++]; + ((const char **) non_options)[non_options_size++] = argv[argind++]; } else if( !push_back_record( ap, 0, argv[argind++] ) ) return 0; } @@ -235,7 +235,7 @@ else { for( i = 0; i < non_options_size; ++i ) - if( !push_back_record( ap, 0, non_options[i] ) ) return 0; + if( !push_back_record( ap, 0, ((const char **) non_options)[i] ) ) return 0; while( argind < argc ) if( push_back_record( ap, 0, argv[argind++] ) ) return 0; } @@ -260,13 +260,13 @@ int ap_code( const Arg_parser * ap, const int i ) { - if( i >= 0 && i < ap_arguments( ap ) ) return ap->data[i].code; + if( i >= 0 && i < ap_arguments( ap ) ) return ((ap_Record *) ap->data)[i].code; else return 0; } const char * ap_argument( const Arg_parser * ap, const int i ) { - if( i >= 0 && i < ap_arguments( ap ) ) return ap->data[i].argument; + if( i >= 0 && i < ap_arguments( ap ) ) return ((ap_Record *) ap->data)[i].argument; else return ""; } --- ed-0.8/carg_parser.h +++ ed-0.8/carg_parser.h @@ -60,7 +60,7 @@ typedef struct { - ap_Record * data; + char * data; char * error; int data_size; int error_size; --- ed-0.8/glbl.c +++ ed-0.8/glbl.c @@ -25,7 +25,7 @@ #include "ed.h" -static const line_t **active_list = 0; /* list of lines active in a global command */ +static char *active_list = 0; /* list of lines active in a global command */ static int active_size = 0; /* size (in bytes) of active_list */ static int active_last = 0; /* index of last active line in active_list */ static int active_ptr = 0; /* active_list index ( non-decreasing ) */ @@ -36,7 +36,7 @@ char set_active_node( const line_t *lp ) { disable_interrupts(); - if( !resize_buffer( (char **)(void *)&active_list, &active_size, + if( !resize_buffer( &active_list, &active_size, ( active_last + 1 ) * sizeof( line_t ** ) ) ) { show_strerror( 0, errno ); set_error_msg( "Memory exhausted" ); @@ -44,7 +44,7 @@ return 0; } enable_interrupts(); - active_list[active_last++] = lp; + ((const line_t **) active_list)[active_last++] = lp; return 1; } @@ -60,8 +60,8 @@ for( i = 0; i < active_last; ++i ) { if( ++active_ndx >= active_last ) active_ndx = 0; - if( active_list[active_ndx] == lp ) + if( ((const line_t **) active_list)[active_ndx] == lp ) - { active_list[active_ndx] = 0; break; } + { ((const line_t **) active_list)[active_ndx] = 0; break; } } lp = lp->q_forw; } @@ -71,9 +71,9 @@ /* return the next global-active line node */ const line_t *next_active_node( void ) { - while( active_ptr < active_last && !active_list[active_ptr] ) + while( active_ptr < active_last && !((const line_t **) active_list)[active_ptr] ) ++active_ptr; - return ( active_ptr < active_last ) ? active_list[active_ptr++] : 0; + return ( active_ptr < active_last ) ? ((const line_t **) active_list)[active_ptr++] : 0; }