diff options
-rw-r--r-- | dictionary.c | 2 | ||||
-rw-r--r-- | jdtalk.h | 4 | ||||
-rw-r--r-- | main.c | 3 | ||||
-rw-r--r-- | talk.c | 3 |
4 files changed, 8 insertions, 4 deletions
diff --git a/dictionary.c b/dictionary.c index a0c8f72..3766525 100644 --- a/dictionary.c +++ b/dictionary.c @@ -172,7 +172,7 @@ struct Dictionary *dictionary_populate() { * @param s dictionary word to search for * @return a string containing the word types (i.e. n,a,d,v) */ -char *dictionary_word_formats(struct Dictionary *dict, char *s) { +char *dictionary_word_formats(struct Dictionary *dict, const char *s) { static char buf[OUTPUT_SIZE_MAX]; buf[0] = '\0'; @@ -15,6 +15,8 @@ #define OUTPUT_PART_MAX 255 #define OUTPUT_SIZE_MAX 1024 +#define DEFAULT_FORMAT "andv" + #define WT_ICASE 0x80 #define WT_ANY 0 #define WT_NOUN 1 @@ -40,7 +42,7 @@ int dictionary_read(FILE *fp, struct Dictionary **dict, unsigned type); struct Dictionary *dictionary_populate(); int dictionary_contains(struct Dictionary *dict, const char *s, unsigned type); char *dictionary_word(struct Dictionary *dict, unsigned type); -char *dictionary_word_formats(struct Dictionary *dict, char *s); +char *dictionary_word_formats(struct Dictionary *dict, const char *s); struct Dictionary *dictionary_of(struct Dictionary **src, unsigned type); void dictionary_free(struct Dictionary *dict); @@ -103,7 +103,7 @@ int main(int argc, char *argv[]) { limit = 0; salad_limit = 10; - strcpy(format, "andv"); + strcpy(format, DEFAULT_FORMAT); pattern[0] = '\0'; buf[0] = '\0'; acronym[0] = '\0'; @@ -241,6 +241,7 @@ int main(int argc, char *argv[]) { if (do_salad) { strcpy(buf, talk_salad(dicts, salad_limit, part, OUTPUT_PART_MAX)); } else if (do_acronym) { + if (strcmp(format, DEFAULT_FORMAT) == 0) strcpy(format, "xxxx"); strcpy(buf, talk_acronym(dicts, format, acronym, part, OUTPUT_PART_MAX)); } else { strcpy(buf, talkf(dicts, format, part, OUTPUT_PART_MAX)); @@ -46,6 +46,7 @@ char *talkf(struct Dictionary *dict[], char *fmt, char **parts, size_t parts_max word = dictionary_word(dict[WT_VERB], WT_VERB); break; default: + fprintf(stderr, "INVALID FORMAT: %x\n", fmt[i]); break; } @@ -173,7 +174,7 @@ int acronym_safe(struct Dictionary *dict, const char *acronym, const char *patte int format_safe(char *s) { size_t valid; - const char *formatter = "nadvx"; + const char *formatter = DEFAULT_FORMAT"x"; valid = 0; for (size_t i = 0; i < strlen(formatter); i++) { |