/* This subroutine is in charge with a/ getting file for disk b/ engendering all the necessaries structures c/ setting up the pointers */ int16_t begin(uchar batch_run) { /* int16_t *p;*/ uint16_t i; uint16_t i1; /* uint32_t l;*/ SPQ.real_num = 0; SPQ.sw_symb = 0; SPQ.new_s = 0 ; SPQ.beg_sheet = 0; //sign new_sheet passed and there were no fragm SPQ.stack = (struct state_stack_elem *)( SPQ.end_alloc_mem - sizeof(struct state_stack_elem)); SPQ.tab_ptr = (struct tab *)SPQ.free_alloc_mem; SPQ.free_alloc_mem += sizeof(struct tab); //AK!!!! wich stupid not attented bounds of array!!!!!! for (i=0; i < MAX_SHEET; i++) for (i1=0; i1 < MAX_FRAGM; i1++) SPQ.tab_ptr->tab_fragm[i][i1].first_segm = NULL; SPQ.st.cur_segm = (struct segm *)(SPQ.free_alloc_mem); SPQ.st.cur_segm->busy_lth = 0; SPQ.st.cur_segm->string_lth = 0; SPQ.free_alloc_mem += sizeof(struct segm); SPQ.str_ptr = SPQ.st.cur_segm->string; SPQ.st.cur_segm->next_in_sheet = NULL; SPQ.st.cur_segm->prev_in_sheet = NULL; SPQ.st.cur_segm->prev_in_fragm = NULL; SPQ.st.cur_segm->next_in_fragm = NULL; SPQ.end_l = 0; SPQ.last_del_line = NULL; SPQ.stack_change_flag = YES; memset(SPQ.fragm_flag,NONEXIST,sizeof(SPQ.fragm_flag)); if( read_file(batch_run)== FALSE) return FALSE; SPQ.st.cur_segm=(struct segm *)SPQ.tab_ptr->tab_fragm[0][0].first_segm; skip_letter_in_line(SPQ.st.cur_segm,0); SPQ.st.cur_symb=SPQ.ns_symb; create_new_stack(); SPQ.stack->map_ref.row=0; SPQ.stack->map_ref.col=0; return TRUE; }
/* ********************************************************************** */ int16_t shift_left(int16_t v_s,struct segm * cur_segm, char * cur_symb) { char *c; /*int16_t l;*/ char *from; char *to; char *end; c=cur_symb; if (c == NULL) return(OK); /* end=(char *)cur_segm; end+=sizeof(struct segm)+cur_segm->busy_lth-1; */ end=&cur_segm ->string[cur_segm->busy_lth]; end+=0; from=(char *)cur_symb; to=from-v_s; while (from < end) *to++=*from++; cur_segm->busy_lth -=v_s; /***************************************************** if(cur_segm == SPQ.ns_segm) // THIS IS WRONG SPQ.ns_symb-= v_s; *****************************************************/ if(cur_segm == SPQ.ns_segm) { if (cur_segm->busy_lth+v_s == SPQ.ns_symb-(uchar *)cur_segm->string+2) { uchar *symb; /* Set SPQ.ns_symb onto the last line position */ skip_letter_in_line (cur_segm,-1) ; /* Set SPQ.ns_symb onto the last alt of the last pos */ do symb=SPQ.ns_symb; while((SPQ.ns_symb=next_symb(YES,NO,YES,SPQ.ns_segm,SPQ.ns_symb))!= NULL); SPQ.ns_symb=symb; } else SPQ.ns_symb -= v_s; } return(OK); }