From: Jim H. <jh...@fr...> - 2024-08-12 20:36:49
|
If you've been exploring WordStar since author Robert J Sawyer's re-packaging of WordStar for DOS, you may need to convert your new WordStar files to another format afterwards. WordStar has a very simple file format, so I published an article last week on Both.org about how to convert WordStar files to HTML. https://www.both.org/?p=6898 Someone asked me if I could share the code from the article in a GitHub repo, so I have copied the code and adapted a README.md file here: https://github.com/freedosproject/wshtml It's available under the MIT License. |
From: Rugxulo <ru...@gm...> - 2024-08-16 11:04:04
|
You forgot to include "sample.ws" (or any other test suite). On Mon, Aug 12, 2024 at 3:37 PM Jim Hall via Freedos-devel <fre...@li...> wrote: > > I published an article last week on Both.org about how to convert WordStar files to HTML. > > Someone asked me if I could share the code from the article in a GitHub repo. |
From: Jim H. <jh...@fr...> - 2024-08-16 14:15:07
|
Jim Hall wrote: > > > > I published an article last week on Both.org about how to convert WordStar files to HTML. > > > > Someone asked me if I could share the code from the article in a GitHub repo. > Rugxulo wrote: > > You forgot to include "sample.ws" (or any other test suite). > Oops, forgot about that (a lot going on lately). I've added SAMPLE.WS and a few others in a 'wordstar' folder. |
From: Rugxulo <ru...@gm...> - 2024-08-23 10:01:50
|
Hi, On Fri, Aug 16, 2024 at 9:16 AM Jim Hall via Freedos-devel <fre...@li...> wrote: > > Jim Hall wrote: > > > > > > I published an article last week on Both.org about how to convert WordStar files to HTML. > > I've added SAMPLE.WS and a few others in a 'wordstar' folder. I'm mildly curious about your choice of C dialect. Although C++ is beyond me (in most ways), so I know very little there. (Like many languages, it has a long history and several dialects. I barely wrote a very simple C++98 program with DJGPP a few months ago.) You seem to use ANSI C, or C89/C90 (as it's sometimes called). I like your BOOL typedef (a clever solution I've also used). I also am still sympathetic to C89 (and DOS compilers). Having said that, "bool" is also a feature of (semi-modern) C++ and C99. (Well, OpenWatcom supports "bool" but TurboC++ does not, IIRC.) So are // line comments. And "for (int i=0;" declarations. (But "inline" support may be too limited to be useful.) Your article says you used GCC, which by default (last I checked) is "-std=gnu17", so it supports "bool" and // as well by default. (Okay, C++ supports bool by default. C99 needs <stdbool.h>. Obviously. I'm mainly testing OW's C++ here, basically implying that these features also are available in C99.) Are you trying to strictly stay compatible to C89? Or is it just habit? Since it works in OpenWatcom (as C++ or C99 with <stdbool.h>) and DJGPP, I would personally use such features. (Okay, I wouldn't, but I *could*. It depends on how many compilers and OSes you want to target.) In other words, in an abandoned DOS landscape, I'm halfway seriously suggesting using old C++ as if C99. Heck, you could make a simple #define, and the line comments could be trivially converted to C89 style with Sed (or a very simple util). #if !__cplusplus || defined __TURBOC__ typedef enum {false,true} BOOL; #else #define BOOL bool #endif sed -e "s,//\(.*\),/*\1*/," wshtml.c99 >wshtml.c89 * (UNCMNTC: uncomment C, it's a 3 kb .C source, public domain) * http://cpmarchives.classiccmp.org//cpm/mirrors/cbfalconer.home.att.net/download/uncmntc.zip See what I mean? You don't strictly have to do without everything. You have options. Okay, you barely mentioned GCC: "gcc -o wshtml wshtml.c". Thanks to GNU Make's built-in rules, you can probably simplify that to just "make wshtml". You hardcoded C escape sequences (char literals) as numbers instead: case 0x09: /* tab */ case 0x0a: /* new line */ case 0x0c: /* page feed */ case 0x0d: /* carr rtn */ But you could just use '\t' '\n' '\f' '\r': * https://stanislavs.org/helppc/c_escape_sequences.html I don't know why you use "return 1;" and "return 0;" instead of using <stdlib.h> EXIT_SUCCESS and EXIT_FAILURE . (It's ANSI standard, and IIRC the only DOS compiler who omits it is Pacific C.) fmt.bold = false; fmt.dblstrike = false; fmt.underline = false; You can initialize all of those at once: fmt.bold = fmt.dblstrike = fmt.underline = false; C99 and C++ also let you put "size_t i;" into the "for (i = 0 ..." statement -> "for (size_t i = 0; ..." Oh, even C89 lets you combine these two statements (at the start of a block): "BYTE low; low = ch & 0x7f;" -> "BYTE low = ch & 0x7f;" Is "if (len > 0)" even necessary? Will "for (i = 0; i < len ..." even iterate if loop count is less than 1? It probably?? shouldn't. You could simplify all of these: 'if (fmt.bold) { fputs("<b>",out); } else { fputs("</b>",out); }' 'fputs(fmt.bold ? "<b>" : "</b>",out);' You could also combine these two statements: 'pfile = fopen(argv[1],"rb");' "if (pfile==NULL) {" -> 'if ((pfile=fopen(argv[1],"rb"))==NULL) {' There are some other suggestions, but they are mostly about personal taste? N.B. I tested most of this with OpenWatcom 1.9 as C++ (under DOS), and the SAMPLE.WS output matched the C (C89) version's output. (The .EXE was barely 102 bytes bigger.) |