jdict

command line tool for looking up terms in yomidict dictionaries
git clone anongit@rnpnr.xyz:jdict.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 05cee0ef80317dbe162adc00956fbb35c941607f
Parent: 24b0bf6dc11da6d7fac84fca67a38a55eac6863f
Author: Randy Palamar
Date:   Wed, 26 Apr 2023 09:31:28 -0600

repl(): refactor to make prompt printing more clear

Diffstat:
Mjdict.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/jdict.c b/jdict.c @@ -316,16 +316,16 @@ repl(struct Dict *dicts, size_t ndicts) nents = xreallocarray(NULL, ndicts, sizeof(size_t)); ents = make_dicts(dicts, ndicts, nents); - fputs(repl_prompt, stdout); - fflush(stdout); - while (fgets(buf, LEN(buf), stdin)) { + for (;;) { + fputs(repl_prompt, stdout); + fflush(stdout); + if (fgets(buf, LEN(buf), stdin) == NULL) + break; trim(buf); for (i = 0; i < ndicts; i++) { puts(dicts[i].name); find_and_print(buf, ents[i], nents[i]); } - fputs(repl_prompt, stdout); - fflush(stdout); } puts(repl_quit);