static int32 parse_base_line(char *line, int lineno, acmod_id_t *acmod_id, uint32 *tmat, uint32 *state, uint32 *n_state, acmod_set_t *acmod_set) { char *tok; unsigned int n; const char **attrib; tok = strtok(line, " \t"); if (acmod_set_name2id(acmod_set, tok) != NO_ACMOD) { E_ERROR("%s multiply defined at line %d\n", tok, lineno); return S3_ERROR; } for (n = 0; (n < 3) && (strcmp("-", strtok(NULL, " \t")) == 0); n++); if (n < 3) { E_ERROR("Expected l, r and posn to be \"-\" for ci phone %s at line %d, currently '%s'\n", tok, lineno, line); return S3_ERROR; } if (parse_rem(&attrib, tmat, state, n_state, lineno) != S3_SUCCESS) { return S3_ERROR; } *acmod_id = acmod_set_add_ci(acmod_set, tok, attrib); return S3_SUCCESS; }
static int32 parse_base_line(acmod_id_t *acmod_id, uint32 *tmat, uint32 *state, uint32 *n_state, acmod_set_t *acmod_set, uint32 *n_read, FILE *fp) { char buf[BIG_STR_LEN]; char *tok; unsigned int n; const char **attrib; if (read_line(buf, BIG_STR_LEN, n_read, fp) == NULL) return S3_ERROR; tok = strtok(buf, " \t"); if (acmod_set_name2id(acmod_set, tok) != NO_ACMOD) { E_ERROR("%s multiply defined at line %d\n", tok, *n_read); return S3_ERROR; } for (n = 0; (n < 3) && (strcmp("-", strtok(NULL, " \t")) == 0); n++); if (n < 3) { fflush(stdout); fprintf(stderr, "%s(%d): expected l, r and posn to be \"-\" for ci phone %s at line %d\n", __FILE__, __LINE__, tok, *n_read); fflush(stderr); return S3_ERROR; } if (parse_rem(&attrib, tmat, state, n_state, *n_read) != S3_SUCCESS) { return S3_ERROR; } *acmod_id = acmod_set_add_ci(acmod_set, tok, attrib); return S3_SUCCESS; }
// ------------------------------------------------------------ // parsemain5 : parse line int parsemain5(void) { unsigned char c; for (;;) { c = buf_fgetc(); if (c == 0) { // line end buf_fputc('\n'); break; } else { if ((c >= 0x80) && (c <= 0xf9)) { // if match, output command strings buf_fprintf(p6codelist5[c - 0x80]); if (c == CODEDATA) { // raw output until return or colon if (parse_data() == 0x00) { return(0); }; } else if (c == CODEREM) { // raw output until return parse_rem(); return(0); } } else { // if not code, output 1 byte as is buf_fputc(c); if (c == '"') { // raw output until " or return if (parse_quote() == 0x00) { return(0); }; } } } } return(0); }
static int32 parse_tri_line(acmod_id_t *acmod_id, uint32 *tmat, uint32 *state, uint32 *n_state, acmod_set_t *acmod_set, uint32 *n_read, FILE *fp) { char buf[BIG_STR_LEN]; char *tok; unsigned int i; uint32 id; char *posn_map = WORD_POSN_CHAR_MAP; const char **attrib; acmod_id_t base, left, right; word_posn_t posn; if (read_line(buf, BIG_STR_LEN, n_read, fp) == NULL) return S3_ERROR; tok = strtok(buf, " \t"); if ((id = acmod_set_name2id(acmod_set, tok)) == NO_ACMOD) { E_ERROR("%s is an undefined base phone at line %d\n", tok, *n_read); return S3_ERROR; } base = id; tok = strtok(NULL, " \t"); if ((id = acmod_set_name2id(acmod_set, tok)) == NO_ACMOD) { E_ERROR("%s is an undefined base phone at line %d\n", tok, *n_read); return S3_ERROR; } left = id; tok = strtok(NULL, " \t"); if ((id = acmod_set_name2id(acmod_set, tok)) == NO_ACMOD) { E_ERROR("%s is an undefined base phone at line %d\n", tok, *n_read); return S3_ERROR; } right = id; tok = strtok(NULL, " \t"); for (i = 0; i < strlen(posn_map); i++) if (tok[0] == posn_map[i]) break; if (i < strlen(posn_map)) { posn = (word_posn_t)i; } else { E_ERROR("Unknown word posn %s found at line %d\n", tok, *n_read); return S3_ERROR; } if (parse_rem(&attrib, tmat, state, n_state, *n_read) != S3_SUCCESS) { return S3_ERROR; } *acmod_id = acmod_set_add_tri(acmod_set, base, left, right, posn, attrib); if (*acmod_id == NO_ACMOD) { return S3_ERROR; } return S3_SUCCESS; }