int handle_word(char buf[], FILE *files[], struct sc_config const *config) { int ret = -1; char tmp[strlen(buf)]; char inp[MAX_WORD_LENGTH]; trim_word(buf, tmp); if (is_number(tmp)) goto NEXT; if (word_exists(files[FILE_DIC], tmp)) { fprintf(files[FILE_OUT], "%s", buf); } else { printf(CLSCRN); print_header(config->file[FILE_DOC]); print_hr(); print_preview(files[FILE_DOC], buf); print_hr(); printf("word \"%s\" not found in dict\n", tmp); print_progress(files[FILE_DOC]); switch (show_menu()) { case 'a': fprintf(files[FILE_DIC], "%s\n", tmp); fprintf(files[FILE_OUT], "%s", tmp); break; case 's': printf("substitute %s: ", buf); input_line(inp, sizeof(inp)); fprintf(files[FILE_OUT], "%s", inp); break; case 'c': fprintf(files[FILE_OUT], "%s", buf); break; case 'q': goto ERROR; } } NEXT: ret = 0; ERROR: return ret; }
static bool gather_locals( bool initted, int *counter ) { signed long wlen; bool retval = FALSE; while ( TRUE ) { wlen = get_word(); if ( wlen <= 0 ) { warn_unterm( TKERROR, "Local-Values Declaration", l_d_lineno); break; } /* Allow comments to be interspersed among the declarations. */ if ( filter_comments( statbuf) ) { /* Unterminated and Multi-line checking already handled */ continue; } /* Is this the terminator or the separator? */ if ( wlen == 1 ) /* Maybe */ { /* Check for separator */ if (locals_separator( statbuf[0] ) ) { /* If gathering initted Local names, separator is legit */ if ( initted ) { retval = TRUE; break; }else{ tokenization_error ( TKERROR, "Excess separator -- %s -- found " "in Local-Values declaration", statbuf); in_last_colon( TRUE); continue; } } /* Haven't found the separator. Check for the terminator */ if ( statbuf[0] == '}' ) { break; } } /* It was not the terminator or the separator */ { long tmp; char *where_pt1; char *where_pt2; /* Error-check for duplicated names */ if ( word_exists ( statbuf, &where_pt1, &where_pt2 ) ) { tokenization_error ( TKERROR, "Cannot declare %s " "as a Local-Name; it's already defined %s%s", statbuf, where_pt1, where_pt2 ); show_node_start(); continue; } /* Error-check for numbers. */ if ( get_number(&tmp) ) { tokenization_error ( TKERROR, "Cannot declare %s " "as a Local-Name; it's a number.\n", statbuf ); continue; } /* We've got a valid new local-name */ /* Don't need to check name length; it won't go into the FCode */ /* Increment our counting-v'ble */ *counter += 1; /* Define our new local-name in the Locals' vocabulary */ add_local( localno, statbuf ); /* Bump the running Local-Number */ localno++; } } return ( retval ); }