From: ralismark <13449732+ralismark@users.noreply.github.com> Date: Thu, 2 Mar 2023 09:25:42 +0000 (+1100) Subject: Remove add_file fallback that can never run X-Git-Tag: fortune-mod-3.18.0~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=50f4c57e3476f80e8b84ad05d8fd94677bf846d6;p=fortune-mod Remove add_file fallback that can never run The original intent of this block of code is to handle arguments such as "politics-o", which would resolve to the "politics" fortune under the offensive directories. This is a documented feature. However, form_file_list() almost never calls add_file() with a file argument without slashes -- if it's not definitely an absolute/relative path, we always prepend $PWD, FORTDIR, or LOCFORTDIR, all of which are absolute paths. This means that this condition wouldn't run in almost all cases. This feature will be re-added later in a way that is more functional. --- diff --git a/fortune-mod/fortune/fortune.c b/fortune-mod/fortune/fortune.c index f01f342..f7aee0c 100644 --- a/fortune-mod/fortune/fortune.c +++ b/fortune-mod/fortune/fortune.c @@ -623,40 +623,6 @@ static int add_file(int percent, const char *file, const char *dir, debugprint("check file fd=%d path=<%s> dir=<%s> file=<%s> percent=%d\n", fd, path, dir, file, percent); bool found = false; - if (!dir && (!strchr(file, '/'))) - { - if (((sp = strrchr(file, '-')) != NULL) && (strcmp(sp, "-o") == 0)) - { -#define CALL__add_file(dir) add_file(percent, file, dir, head, tail, parent) -#define COND_CALL__add_file(loc_dir, dir) \ - ((!strcmp((loc_dir), (dir))) ? 0 : CALL__add_file(dir)) - /* BSD-style '-o' offensive file suffix */ - *sp = '\0'; - found = CALL__add_file(LOCOFFDIR) || - COND_CALL__add_file(LOCOFFDIR, OFFDIR); - /* put the suffix back in for better identification later */ - *sp = '-'; - } - else if (All_forts) - { - found = - (CALL__add_file(LOCFORTDIR) || CALL__add_file(LOCOFFDIR) || - COND_CALL__add_file(LOCFORTDIR, FORTDIR) || - COND_CALL__add_file(LOCOFFDIR, OFFDIR)); - } - else if (Offend) - { - found = (CALL__add_file(LOCOFFDIR) || - COND_CALL__add_file(LOCOFFDIR, OFFDIR)); - } - else - { - found = (CALL__add_file(LOCFORTDIR) || - COND_CALL__add_file(LOCFORTDIR, FORTDIR)); - } -#undef COND_CALL__add_file -#undef CALL__add_file - } if (!found && !parent && !dir) { /* don't display an error when trying language specific files */ if (env_lang)