brickviking / list

list is a curses-based interactive file listing program that combines the functions of less and hexdump into one handy program. It displays text on the screen in one of two different formats, either in hexadecimal dump format (a la MS-DOS debug.com format), or in text format, similar to what the programs less and more do.
GNU General Public License v2.0
2 stars 0 forks source link

Port back to MS-DOS/FreeDOS? #15

Open brickviking opened 1 year ago

brickviking commented 1 year ago

The big question

Can we port list back to pdcurses and the DOS variant of LIST.C which hasn't seen any loving for over twenty years?

Why should we?

MS-DOS (and its variants such as DR-DOS/PC-DOS) hasn't seen significant development nor use since the early 2000s. It is limited in the things it can do on bare metal, and is even more constrained when run in the context of a Windows environment or under DOSBOX/DosEmu. This doesn't seem to matter for a project the size of list, but can do in the context of other bigger programs such as browsers.

Why shouldn't we?

Hey, it was the first platform I did a significant amount of learning on, and it would be nice to be able to provide a DOS executable. It would also provide me with a degree of extra experience.

Things in the way

Which version of DOS should we target?

There's a couple of options here, really. MS-DOS/PC-DOS/DR-DOS, or FreeDOS. Both now have their memory extenders (DJGPP in the case of MS-DOS) and whatever Watcom can provide under FreeDOS. FreeDOS is the only one that's definitely free to download in today's day and age, MS-DOS is de-facto available, but isn't necessarily "free" to download and use on a platform.

Which compiler should we target?

There's really only two serious options, one now a lot older than the other. One is the venerable DJGPP platform, which is still available for the moment, and the other is OpenWatcom's C compiler, which has seen recent development. I don't know any of the other candidates well enough to be able to say how well they'd each be able to compile ncurses and the list program, and how well the resulting executable would perform under DOS of whatever breed.

What will the performance be like?

I guess that can only really be determined by grabbing the respective options and trying it out. I've only got my own machine to test this on, and it's certainly not a machine from the last two years. It's also capable of being used in 32-bit mode, which may be a distinct advantage.

brickviking commented 1 year ago

Further WatcomC issues

I've come across a couple of wrinkles while trying to target Watcom as a compiler under FreeDOS. Namely, compiling list.c expects to find lib.h because I'm not on Linux, BSD, or DJGPP. I need to know what defines WatcomC has, and how to leverage those. So I'll at least be making one change to list.c when I find that out.

This will also affect stuff available from dirent, as that doesn't seem to be available in WatcomC's includes either. Would direct.h work?

screen.c is giving the compiler blue fits, and I don't exactly know why. There seems to be some weird interaction between list.h, dirent/direct.h and ShowHelp that has me completely confused.

brickviking commented 1 year ago

Okay, I've fixed enough of the Watcom issues so that list will now compile to an executable, though there are still the usual rash of warnings about debug and ruler being multiply defined. clang seems to get around that with the -fcommon parameter, I don't know what Watcom C's equivalent is.

One of the changes for screen.c was reordering the declaration of vars in ShowHelp to precede the initial memory assignment to tempstring, instead of afterwards. This is something that C++ would have enforced, as you need to have all your variables declared before actually using any of them, unlike with earlier C standards, where you could declare a variable directly before you used it, even if you'd started using other variables within the function already. I'm rather glad to have cured that bug, but it's reminded me to make sure that all the other functions also have that sorted.