On Fri, Jul 17, 2015 at 08:27:56AM +0100 I heard the voice of
Mark Carroll, and lo! it spake thus:
> 
> It's great to see some development energy going into ctwm. Cleanup
> now keeps paying back over time. (-:

That's the goal.  I'm constantly astonished by how much cruft I've
piled up in projects that are 4 or 5 years old; counting the twm
heritage, this codebase is close to 30!


Working conversion is in a branch at
<https://code.launchpad.net/~fullermd/ctwm/getopt>.

% build/ctwm --help
usage: build/ctwm [(--display | -d) dpy]  [--replace]  [--single]
          [(--file | -f) initfile]  [--cfgchk]
          [--nom4 | -n]  [--keep-defs | -k]  [(--keep | -K) m4file]
          [--verbose | -v]  [--quiet | -q]  [--mono]  [--xrm resource]
          [--version]  [--info]  [--nowelcome | -W]
          [(--window | -w) [win-id]]  [--name name]
          [--help]

Apart from having to -- instead of -'ing, the major gotcha is on the
--window param.  Because of how getopt_long() works, optional args are
slightly tricky, which means you have to use = (with the long arg) or
no space (with the short) to get the arg to catch.  e.g., you can use
"--file ctwmrc" or "--file=ctwmrc", but you can only do
"--window=foo"; if you do "--window foo" it won't find the argument
and will silently treat it as arg-less --window.  This is documented
in the manual.

Not in the manual is that -version -info -cfgchk and -display [disp]
are handed if they appear as the first arg, to make it a little easier
to run old/new versions in parallel.  This handling will probably
disappear in a release or two.


As part of the change, I also moved all the flag/etc vars the command
line options set into one structure, to cut down on the number of
free-floating globals we have, and make it easier to see at a glance
where this value you're looking at came from.  I also had to convert a
few of them, where the command-line var was also used to hold other
mutable state buried in stuff; what fun.

Now everything in CLarg is set from command-line args, and ONLY from
there.  And a few places like the captive window handling do less
mucking with floating global state; at least the global state they're
mucking with is encapsulated in Scr, which is slightly better...


Will probably land in a couple days.  I may go ahead and pull the
handling out of main() into a separate function before then, just for
cleanliness (see what you can do when you limit how many pies
everything's got its fingers in? ;).


-- 
Matthew Fuller     (MF4839)   |  [email protected]
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
           On the Internet, nobody can hear you scream.

Reply via email to