[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] line-endings and MiNT-Lib?



Le Thu, 17 Apr 2003 17:02:05 +0200 (CEST)
Xavier Joubert <xavier.joubert@free.fr> a écrit:

> En réponse à Frank Naumann <fnaumann@cs.uni-magdeburg.de>:
> > Some tools (I remember gnupg and rpm) don't work correctly if the
> > stdin/stdout/stderr isn't initialized statically (this is why the
> > previous
> > dynamic initialiazion isn't fail safe in every case). Beside from that
> > it's a little bit mysterious as the static initialization should be
> > exatcly the same as the dynamic (at least I can't see any difference).
> 
> But the difference is here nevertheless. Under TOS, static initialization make 
> *printf output LF only while it should output CRLF.
> 
> > > Does that mean that for the time being we are stuck with the ugly
> > > (and error-prone) search-and-replace solution?
> > I don't understand what do you mean with that.
> 
> I would vote for the removal of static initialization (ie application of 
> Patrice's patch). Then, if we have trouble with some software under MiNT, we 
> will need to find a way to fix this without breaking TOS support.

I think we should take time to investigate the differences in the initialization of the descriptors.
I remember the change was done around the 0.56.1 version.

The files that are concerned in the mintlib (for people interested):
mintlib/globals.c (current static init of stdin/stdout/stderr descriptors).
mintlib/main.c (previous dynamic init, which is #ifdef 0)
unix/write.c (add '\r' when writing a '\n' under some conditions).

According to source in unix/write.c:
- '\r' is added if:

__mint==0 (we are not under MiNT)

isatty(fd)==TRUE (the file descriptor is a terminal)

Then this code (reading a handle associated to the fd)
r = __OPEN_INDEX(fd);
if (r < 0 || r >= __NHANDLES) {
r = __NHANDLES - 1;
}
Maybe the problem lies there.

(__open_stat[fd].flags & RAW)==RAW (RAW flag is set, what does it is used for ?) OR
_sig_handler[SIGINT] != SIG_DFL (the SIGINT handler is caught by the application)

Then in the loop to convert the input string, '\r' is added if
(__open_stat[fd].flags & CRMOD)==CRMOD (CRMOD flags is set, i.e. really modify
carriage return at end of lines).

-- 
Patrice Mandin
WWW: http://membres.lycos.fr/pmandin/
Programmeur Linux, Atari
Spécialité: Développement, jeux