From 61b4313d03a93f50c5cb9d7320f3db7c21caa9f3 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 5 Dec 2021 18:16:30 -0500 Subject: Improvements, and heavy optimization to string search * Add error checking to all allocs * Add general format checking * Add acronym format checking * Consolidate dictionary creation into different helper functions * Add ability to get a random word of a type without scanning the entire dictionary * Added function doc strings (incomplete) --- jdtalk.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'jdtalk.h') diff --git a/jdtalk.h b/jdtalk.h index f28f3c8..1e7a1ad 100644 --- a/jdtalk.h +++ b/jdtalk.h @@ -40,6 +40,8 @@ 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); +struct Dictionary *dictionary_of(struct Dictionary **src, unsigned type); void dictionary_free(struct Dictionary *dict); char *str_random_case(char *s); @@ -48,10 +50,12 @@ char *str_leet(char *s); char *str_title_case(char *s); char *str_randomize_words(char *s); char *str_reverse(char *s); +char *str_album(char *s, char **parts); -char *talkf(struct Dictionary *dict, const char *fmt, char **parts); -char *talk_salad(struct Dictionary *dict, size_t limit, char **parts); -char *talk_acronym(struct Dictionary *dict, const char *fmt, char *s, char **parts); -int acronym_safe(const char *acronym, const char *pattern); +char *talkf(struct Dictionary *dict[], char *fmt, char **parts, size_t parts_max); +char *talk_salad(struct Dictionary *dict[], size_t limit, char **parts, size_t parts_max); +char *talk_acronym(struct Dictionary *dict[], __attribute__((unused)) char *fmt, char *s, char **parts, size_t parts_max); +int acronym_safe(struct Dictionary *dict, const char *acronym, const char *pattern, const char *fmt); +int format_safe(char *s); #endif //JDTALKC_JDTALK_H -- cgit