Mail Archives: djgpp-workers/2001/02/23/02:49:56
> From: "Juan Manuel Guerrero" <ST001906 AT HRZ1 DOT HRZ DOT TU-Darmstadt DOT De>
> Organization: Darmstadt University of Technology
> Date: Thu, 22 Feb 2001 21:04:17 +0200
>
> > > #if ((__DJGPP__ == 2) && (__DJGPP_MINOR__ <= 3))
> > > /* DJGPP 2.03 and prior only supports C and POSIX. */
> >
> > What about DJGPP 2.04 or 2.1? Do these versions have a full
> > setlocale()?
> Good question. I don't know. If someone of the djgpp-workers envolved
> with libc.a developement knows something about this, I will seriously
> appreciate a response to this question. Meanwhile I will replace
> #if ((__DJGPP__ == 2) && (__DJGPP_MINOR__ <= 3))
> simply by
> #ifdef __DJGPP__
I'm not aware of any real activity to add a working, non-trivial
setlocale to DJGPP, apart of someone who posted a partial-solution
code that was not reviewed yet. Since adding working locales is a
huge job, it is IMHO prudent to assume that DJGPP doesn't yet support
locales and won't support them for an observable future.
> Of course, you are right. All the pertinent DJGPP libc functions
> work as you have described (they recognize CRLF *and* LF as '\n' if
> the file has been fopen()'ed in text mode) makeing the code I have
> added redundant and superfluous.
One caveat: can the files that are read as text have unprintable
characters, such as lone CRs or ^Z? If they can, text mode is not
reliable enough to be used with such files.
> > Then the setmode() macro should take care of it.
> I will assume you are makeing reference to setmode() macro defined in lib/system.h.
> I will add a setmode() macro to system.h for djgpp:
> 1) DJGPP:
> # define setmode(fd, mode) do { \
> if (!isatty ((fd))) \
> setmode ((fd), mode); \
> } while (0)
This will only DTRT if this macro is called _only_ for switching
stdin/stdout to binary mode and back. If you ever call the macro on a
handle other than 0 or 1, it might silently do nothing without a good
reason.
It is okay to do this if you _know_ setmode will only be invoked on
stdin/stdout, but I'd suggest a prominent comment to that effect where
the macro is defined, lest someone forgets this caveat.
- Raw text -