/*! * Convert a string to an ichar_t, storing the result in a static area. * * \param in String to convert * \param canonical NZ if input is in canonical form * * \return */ ichar_t *ISpellChecker::strtosichar(char *in, int canonical) { static ichar_t out[STRTOSICHAR_SIZE / sizeof(ichar_t)]; if(strtoichar(out, in, sizeof out, canonical)) fprintf(stderr, WORD_TOO_LONG(in)); return out; }
/*! * Convert an ichar_t to a string, storing the result in a static area. * * \param in Internal string to convert * \param canonical NZ for canonical conversion * * \return */ char *ISpellChecker::ichartosstr(ichar_t *in, int canonical) { static char out[ICHARTOSSTR_SIZE]; if(ichartostr(out, in, sizeof out, canonical)) fprintf(stderr, WORD_TOO_LONG(out)); return out; }
/* How to print: * 1 = expansions only * 2 = original line + expansions * 3 = original paired w/ expansions * 4 = add length ratio */ static void expandmode(int option) { char buf[BUFSIZ]; int explength; /* Total length of all expansions */ register char *flagp; /* Pointer to next flag char */ ichar_t ibuf[BUFSIZ]; MASKTYPE mask[MASKSIZE]; char origbuf[BUFSIZ]; /* Original contents of buf */ char ratiobuf[20]; /* Expansion/root length ratio */ int rootlength; /* Length of root word */ register int temp; /* char strg_out[MAXSOLLEN]; */ while (xgets(buf, sizeof buf, stdin) != NULL) { rootlength = strlen(buf); if (buf[rootlength - 1] == '\n') buf[--rootlength] = '\0'; strcpy(origbuf, buf); if ((flagp = index(buf, hashheader.flagmarker)) != NULL) { rootlength = flagp - buf; *flagp++ = '\0'; } if (option == 2 || option == 3 || option == 4) printf("%s ", origbuf); if (flagp != NULL) { if (flagp - buf > INPUTWORDLEN) buf[INPUTWORDLEN] = '\0'; } else { if ((int) strlen(buf) > INPUTWORDLEN - 1) buf[INPUTWORDLEN] = '\0'; } fputs(buf, stdout); fputc(' ', stdout); /* strtoichar(ibuf, buf, sizeof ibuf, 1); if (good(ibuf, 0, 0, 0)) { get_info(hits[0]); sprintf(strg_out, o_form, root, macro(root_class), pre_class, macro(suf_class), suf2_class); printf("%s ", strg_out); } */ if (flagp != NULL) { bzero((char *) mask, sizeof(mask)); while (*flagp != '\0' && *flagp != '\n') { #if MASKBITS <= 32 temp = CHARTOBIT(mytoupper(chartoichar(*flagp))); #else temp = CHARTOBIT((unsigned char) *flagp); #endif if (temp >= 0 && temp <= LARGESTFLAG) SETMASKBIT (mask, temp); flagp++; /* Accept old-format dicts with extra slashes */ if (*flagp == hashheader.flagmarker) flagp++; } if (strtoichar(ibuf, buf, sizeof ibuf, 1)) fprintf(stderr, WORD_TOO_LONG(buf)); explength = expand_pre(origbuf, ibuf, mask, option, ""); explength += expand_suf(origbuf, ibuf, mask, 0, option, "", ""); explength += rootlength; if (option == 4) { sprintf(ratiobuf, " %f", (double) explength / (double) rootlength); fputs(ratiobuf, stdout); expand_pre(origbuf, ibuf, mask, 3, ratiobuf); expand_suf(origbuf, ibuf, mask, 0, 3, ratiobuf, ""); } } printf(SEP4); } }