Sometimes there's an advantage to skipping 10 years...

Richard <legalize-aS9lmoZGLiVWk0Htik3J/[email protected]> Thu, 06 Apr 2023 09:25:42 -0600
Newsgroups gmane.network.trn.general
Organization multi-cellular, biological
Message-ID <[email protected]>
Hi Team,

So I was finishing off my interpolation tests (all interpolation
characters now tested and passing and some bugs fixed!) last night when I
bumped into one of those portability problems that the elaborate Configure
scripts were attempting to address.  (I sure don't miss the early 90s
unix landscape where every vendor's unix was "the same, but different"!)

Namely, how do you iterate over directories?  For local news reading,
trn wants to change it's current directory to a newsgroups spool directory
and then iterate over the files in "." to locate articles.  (BTW, this is
an approach that doesn't scale well for a newsgroup with many articles
of which you've read most of them, but I digress.)  The MSDOS port path
of trn had a substitute implementation of POSIX opendir/readdir/closedir
in ndir.c.  However, this isn't the first time that I've seen code that
worked in DOS has different behavior under Win32.  Either that or the
DOS code never really worked; how many people were actually reading news
on DOS from a local spool directory?

Since the existing MSDOS branch code wasn't working correctly, I had
a couple choices.  I could write a C style directory iterator in the
existing ndir.cpp[*] that used the Win32 API to iterate over files in a
directory, or I could use <filesystem> from C++17.  Since the directory
iterating only happened in a single function, I opted to switch that
single function to use <filesystem> and iterate over the files using
a C++ range for loop.  A little bit of testing with my CMake generated
fake local spool containing two articles for a group and poof!  In about
15 minutes, the code was switched and working.  Since this is standard
library for C++17 I no longer need to test and configure for directory
iterating.  Nice!

The % interpolation code turned out to be a great way to boost my
understanding of the source code because it pretty much tickles
everything.  I think now I'm ready to merge my cmake branch back into
master and proceed from there doing smaller batches of commits on my
develop branch and frequently merging back to master.  My last task
before merging to master is to update the README with build
instructions for the current code and maybe depend explicitly on vcpkg
as a git submodule to prevent the dependencies from wandering forward
randomly.  At this time, the only external dependency is on GTest for
testing, but that might start changing soon.

On the cmake branch I have incorporated the patch from Olaf Seibert to
parse older format dates.  A simple test for parsedate was added to
verify the patch is working correctly.

Cheers,

-- Richard

[*] I've converted all the source files to C++ to allow me to access
C++ features even though it's still procedural C style programming.
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
             The Terminals Wiki <http://terminals-wiki.org>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>