Date: Mon, 26 Feb 2001 17:30:41 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Bruno Haible cc: ST001906 AT HRZ1 DOT HRZ DOT TU-Darmstadt DOT De, djgpp-workers AT delorie DOT com Subject: Re: gettext pretest available In-Reply-To: <15002.29723.880411.704219@honolulu.ilog.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Mon, 26 Feb 2001, Bruno Haible wrote: > > > # 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. > > Does this mean your isatty() function is broken? No, I don't think isatty is broken in DJGPP. > Note that the real > test, namely INT 44,00 and checking two bits, is not found in your code. > > #define get_handle_info(handle) \ > ({ uint16_t __info; \ > __asm__ ( \ > " pushl %%ebx ;" \ > " movw %1,%%bx ; movw $0x4400,%%ax ; int $0x21 ;" \ > " popl %%ebx " \ > : "=d" /* %dx */ (__info) \ > : "ri" ((uint16_t)(handle)) \ > : "ax","cx","si","di" /* %eax,%ecx,%esi,%edi */ \ > ); \ > __info; \ > }) > > if ((get_handle_info(0) & 0x81) == 0x81) > > if ((get_handle_info(1) & 0x82) == 0x82) Where is this code from? That's not a DJGPP code. Here's the code of DJGPP's isatty, sans the copyright stuff and the include files: int isatty(int fd) { __dpmi_regs r; r.x.ax = 0x4400; r.x.bx = fd; __dpmi_int(0x21, &r); if ((r.x.ax & 0x83) == 0x83) return 1; return 0; } 0x83 checks the character device and stdin/stdout bits of the device status word. Anyway, the issue I referred to was not in isatty, but in setmode. setmode treats handle 0 specially, and doesn't look at the stdin/stdout bits at all.