(Note: this file has been re-arranged to be in reverse chronological
order, which is The Right Thing for ChangeLogs - DLC)
+March 30, 2020 (fortune-mod 2.18.0)
+
+ Avoid double traversal if FORTDIR == LOCFORTDIR.
+
February 26, 2020 (fortune-mod 2.16.0)
Better portability to Microsoft Windows and other OSes
* form_file_list:
* Form the file list from the file specifications.
*/
+
+static int cond_top_level__add_file(const char *dirpath, const char*possible_dup)
+{
+ if (!strcmp(dirpath, possible_dup))
+ {
+ return 0;
+ }
+ return add_file(NO_PROB, dirpath, NULL, &File_list, &File_tail, NULL);
+}
+
static int form_file_list(register char **files, register int file_cnt)
{
register int i, percent;
&File_tail, NULL)
| add_file(NO_PROB, LOCOFFDIR, NULL, &File_list,
&File_tail, NULL)
- | add_file(NO_PROB, FORTDIR, NULL, &File_list,
- &File_tail, NULL)
- | add_file(NO_PROB, OFFDIR, NULL, &File_list,
- &File_tail, NULL));
+ | cond_top_level__add_file(FORTDIR, LOCFORTDIR)
+ | cond_top_level__add_file(OFFDIR, LOCOFFDIR));
else if (Offend)
return (add_file(NO_PROB, LOCOFFDIR, NULL, &File_list,
&File_tail, NULL)
- | add_file(NO_PROB, OFFDIR, NULL, &File_list,
- &File_tail, NULL));
+ | cond_top_level__add_file(OFFDIR, LOCOFFDIR));
else {
if (env_lang) {
char *lang;
/* default */
return (add_file(NO_PROB, LOCFORTDIR, NULL, &File_list,
&File_tail, NULL)
- | add_file(NO_PROB, FORTDIR, NULL, &File_list,
- &File_tail, NULL));
+ | cond_top_level__add_file(FORTDIR, LOCFORTDIR));
}
else
/* no locales available, use default */
return (add_file(NO_PROB, LOCFORTDIR, NULL, &File_list,
&File_tail, NULL)
- | add_file(NO_PROB, FORTDIR, NULL, &File_list,
- &File_tail, NULL));
-
+ | cond_top_level__add_file(FORTDIR, LOCFORTDIR));
}
}
use FindBin;
use lib "$FindBin::Bin/lib";
use FortTestInst ();
-use Test::More tests => 1;
+use Test::More tests => 3;
{
my $inst_dir = FortTestInst::install("fortune-m");
# TEST
like( $text, qr/Newton/, 'fortune -m matched' );
}
+
+{
+ my $inst_dir = FortTestInst::install("fortune-m");
+ my $IS_WIN = ( $^O eq "MSWin32" );
+ my @cmd = ( $inst_dir->child( 'games', 'fortune' ), '-m', '"wet paint"' );
+
+ # Does not help:
+ # if ($IS_WIN)
+ if (0)
+ {
+ print "IS_WIN=1\n";
+ $cmd[0] = ( "$cmd[0]" =~ s#/#\\\\#gr );
+ $cmd[0] .= ".exe";
+ print "TransformedRun [@cmd]\n";
+ }
+ print "Running [@cmd]\n";
+ my $text = `@cmd`;
+ my $rc = $?;
+ print "AfterRun rc=$rc [@cmd]\n";
+
+ # TEST
+ like( $text, qr/wet paint/, 'fortune -m matched' );
+
+ # TEST
+ unlike( $text, qr/wet paint.*?wet paint/ms, 'no duplicate fortunes' );
+}