]> granicus.if.org Git - fortune-mod/commitdiff
Remove add_file fallback that can never run
authorralismark <13449732+ralismark@users.noreply.github.com>
Thu, 2 Mar 2023 09:25:42 +0000 (20:25 +1100)
committerShlomi Fish <shlomif@shlomifish.org>
Fri, 3 Mar 2023 04:58:47 +0000 (06:58 +0200)
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.

fortune-mod/fortune/fortune.c

index f01f342569a6dc0ee3db2ed3bcb8bd5865795737..f7aee0ca6b3d58d059771c527830d186531cea4d 100644 (file)
@@ -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)