From d5a4230901e6c6e20b03b3e9873d2f788e834d8c Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sun, 28 Jul 2024 16:26:00 -0400 Subject: [PATCH] talk: Make talk_fullpath() do the right thing when voicing a directory The component after the final '/' can be a directory, so don't unconditionally treat it as a file. Also check to make sure there is something after the final '/' otherwise we end up voicing it as '//' Change-Id: I56d69ea3f299e524df29c328ec9eeb3cfc22ff42 --- apps/talk.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/talk.c b/apps/talk.c index c590c5db1b..b5622ad6d1 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -1232,8 +1232,18 @@ int talk_fullpath(const char* path, bool enqueue) ptr = strchr(start, PATH_SEPCH); } - /* no more slashes, final component is a filename */ - return talk_file_or_spell(NULL, buf, NULL, true); + /* no more slashes, figure out final component */ + if (!*start) { + return 1; + } + + DIR* dir = opendir(buf); + if (dir) { + closedir(dir); + return talk_dir_or_spell(buf, NULL, true); + } else { + return talk_file_or_spell(NULL, buf, NULL, true); + } } /* say a numeric value, this word ordering works for english,