ANU News Patch Patch ID: 940601_news.c!mark.martinec@ijs.si Date: 01-Jun-1994 Author: Mark Martinec mark.martinec@ijs.si News Version: 6.1beta9 News Files: News.C, NewsFiles.C, NewsUtility.C Description: - Prevents one (most probable) cause of loop when SMG is hit by an unexpected error (like broken connection to a terminal); - Partially fix the cursor repositioning problem after displaying broadcast message. *** news.c --- news_new.c ************** *** 50,52 **-- **/ --- 50,56 ----- + ** V6.1b9 1-Jun-1994 mark.martinec@ijs.si + ** - test for status==0 returned from get_input_general() + ** which happens when UNWIND takes place during terminal I/O; + ** this prevents looping in case of SMG I/O errors. **-- **/ ************** *** 527,532 for (;;) { status = get_input_general(&cmd_dsc,c$dsc("NEWS> "),&cmd_len, 0,0,1,line_editing); if ((cmd_len >= 4) && (toupper(cmd[0]) == 'M' ) && (toupper(cmd[1]) == 'E') && (toupper(cmd[2]) == 'N' ) &&(toupper(cmd[3]) == 'U') ) { strcpy (cmd,get_menu_input()); cmd_len = strlen( cmd ); --- 531,537 ----- for (;;) { status = get_input_general(&cmd_dsc,c$dsc("NEWS> "),&cmd_len, 0,0,1,line_editing); + if (! (status&1) ) break; if ((cmd_len >= 4) && (toupper(cmd[0]) == 'M' ) && (toupper(cmd[1]) == 'E') && (toupper(cmd[2]) == 'N' ) &&(toupper(cmd[3]) == 'U') ) { strcpy (cmd,get_menu_input()); cmd_len = strlen( cmd ); ************** *** 542,547 exit(1); } if ((status == SMG$_EOF) || (status == RMS$_EOF)) break; } brdcst_line = 0; --- 547,555 ----- exit(1); } if ((status == SMG$_EOF) || (status == RMS$_EOF)) break; + if (status == 0) break; /* break the main loop in case of UNWIND + from within get_input_general() + ( condition handler returns 0 in %r0 ) */ } brdcst_line = 0; *** newsfiles.c --- newsfiles_new.c ************** *** 49,51 **-- */ --- 49,59 ----- + ** V6.1b9 1-Jun-1994 mark.martinec@ijs.si + ** - set variable brdcst_col in get_input_general() (which knows + ** the actual size of the prompt) as a temporary remedy for + ** cursor repositioning problems after displaying broadcast messages. + ** The true solution would be to move the call to display_brdcst() + ** out of the AST routine. The problem remains as the code stands now + ** because during data entry in smg$read_composed_line() + ** the exact cursor position is not known outside SMG. **-- */ ************** *** 1156,1161 tmp_init_dsc.dsc$w_length = tmp_init_str_l; tmp_prompt_dsc.dsc$w_length = tmp_prompt_str_l; tmp_get_dsc.dsc$w_length = min(get_dsc->dsc$w_length,tmp_get_str_size-1); stat = smg$read_composed_line(&kid,&keytab, (use_tmp_init ? &tmp_get_dsc : get_dsc), (use_tmp_prompt ? &tmp_prompt_dsc : prompt_dsc), --- 1164,1174 ----- tmp_init_dsc.dsc$w_length = tmp_init_str_l; tmp_prompt_dsc.dsc$w_length = tmp_prompt_str_l; tmp_get_dsc.dsc$w_length = min(get_dsc->dsc$w_length,tmp_get_str_size-1); + + brdcst_col = 1; + if (use_tmp_prompt) brdcst_col += tmp_prompt_dsc.dsc$w_length; + else brdcst_col += (!prompt_dsc ? 0 : prompt_dsc->dsc$w_length); + stat = smg$read_composed_line(&kid,&keytab, (use_tmp_init ? &tmp_get_dsc : get_dsc), (use_tmp_prompt ? &tmp_prompt_dsc : prompt_dsc), *** newsutility.c --- newsutility_new.c ************** *** 2237,2243 int bell_cnt, dst, j, at_the_beginning; if (((sts = smg$get_broadcast_message(&pid,&bm_dsc,&bm_len,0)) & 1) ! && (sts != SMG$_NO_MORMSG)) { bm[bm_len] = '\0'; /* remove and count chars and remove before line terminators */ --- 2237,2243 ----- int bell_cnt, dst, j, at_the_beginning; if (((sts = smg$get_broadcast_message(&pid,&bm_dsc,&bm_len,0)) & 1) ! && (sts != SMG$_NO_MORMSG) && (sts != SMG$_NONBRDMSG)) { bm[bm_len] = '\0'; /* remove and count chars and remove before line terminators */ ************** *** 2251,2257 bm[dst] = '\0'; bm_len = dst; if (bell_cnt > 3) bell_cnt = 3; ! _c$cks(smg$ring_bell(&trailer_vd,&bell_cnt)); _c$cks(smg$erase_line(&trailer_vd,&line,c$ac(1))); smg_put_chars(trailer_vd,bm,line,1,1,SMG$M_BOLD); --- 2251,2257 ----- bm[dst] = '\0'; bm_len = dst; if (bell_cnt > 3) bell_cnt = 3; ! if (bell_cnt > 0) _c$cks(smg$ring_bell(&trailer_vd,&bell_cnt)); _c$cks(smg$erase_line(&trailer_vd,&line,c$ac(1))); smg_put_chars(trailer_vd,bm,line,1,1,SMG$M_BOLD);