Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

open in text mode (O_TEXT) (Developers)

posted by tkchia Homepage, 26.02.2025, 16:30

Hello kerravon,

Actually, O_TEXT and O_BINARY seem more and more like a rather inelegant (if practical) hack to me these days. I now think the Newlib library has the right idea: have read (...) and write (...) always return raw binary data, and convert between LF and CRLF at one and only one layer: at the stdio level (fopen, fread, fwrite, printf, scanf, etc.).

I think the only reason O_TEXT and O_BINARY exist is that some programs use read and write, and assume that the data handled by these routines contain Unix-style newlines. The more correct way to get these programs to work on DOS, is probably to rewrite these programs to read/write text files via stdio, but I realize this may not always be practical.

Meanwhile, int 0x21, ah = 0x3f or 0x40 have always dealt with raw bytes, and continue to do so.

So... I would advise against modifying the raw system calls (i.e. int 0x21, ah = 0x3f or 0x40) to do any sort of encoding conversion. Having LF ↔ CRLF conversion potentially happening at any and all of the 3 interface layers (machine syscall, POSIX routine, stdio) sounds like a recipe for chaos. But you do you.

Thank you!

---
https://gitlab.com/tkchia · https://codeberg.org/tkchia · 😴 "MOV AX,0D500H+CMOS_REG_D+NMI"

 

Complete thread:

Back to the forum
Board view  Mix view
22477 Postings in 2087 Threads, 400 registered users, 116 users online (1 registered, 115 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum