Mail Archives: djgpp/1999/08/04/23:29:44
Thanks, Eli, for your reply.
One more question. Is there a way, in DJGPP, to write to the standard
input of a program, run it and the read it's standard output?
I'm asking that because reading popen and pclose documentation I got
the impression that I can only write to the standard input or read the
standard output. Not both. Am I right?
Regards,
Edevaldo
Eli Zaretskii wrote:
>
> On Wed, 28 Jul 1999, Edevaldo Pereira da Silva Junior wrote:
>
> > char *teste="12345670 1234567890ab cdefg";
> >
> >
> > e=sscanf(teste,"%o %o %x %lx",&a,&b,&c,&d);
> > printf("\n%d %d %d %d %d\n",a,b,c,d,e);
> > };
> >
> > The problem is that sscanf is recognizing 8 & 9 as octal chars and is
> > returning garbage in b & c variables.
>
> This is indeed a bug, thanks for reporting it. At the end of this
> message you will find a patch for the library module doscan.c that
> fixes this bug. It will be corrected in v2.03.
>
> > I'm not used to unix pipes and this kind of thing. Dos anybody knows if
> > there is a way to emulate this kind of functionality?
>
> The usual way is to use `popen' and `pclose' instead, then substitute
> the file handle from the FILE object returned by `popen' for the
> handle that `pipe' returns on Unix.
>
> The above will only work if the original code does not need to
> communicate with the child program more than once. For example, if it
> passes some data to the child program, then reads its output, then
> passes some more data, the `popen'/`pclose' way will NOT work, and you
> will need to give up on features that use that code.
>
> > One of the testsuit programs make recursive calls to itself until it
> > fails. As far as I know it will generate a stack overflow.
>
> What is the purpose of this test program? What can be possibly gained
> by deliberately overflowing the run-time stack?
>
> If this is done to find out how much stack does the run-time
> environment have, there are better, non-destructive ways to do that.
>
> > In other platforms is fails nicely and gives a message about too
> > many nested calls
>
> AFAIK, on some Unix platforms such a program will blow apart instead
> of printing a nice message.
>
> > but in DJGPP is crashes and the computer reboots under win95. Is
> > there a way to catch stack overflows in DJGPP?
>
> Not automatically. The stack sits in the middle of the DS segment, so
> you have no way of getting an exception when it overflows.
>
> > Is there a way to see the
> > current stack size and test if it is about to overflow?
>
> See library functions `getrlimit', which should be fairly portable to
> Unix, and `stackavail', which is DJGPP-specific.
>
> > The last for today... TCL documentation comes in manpages and DJGPP
> > uses textinfo as a standard. I believe that this two formats are result
> > of two very different concepts. Is there a way to convert the manpages
> > to info format?
>
> Why bother? The Info reader can display man pages, and it even
> converts the "SEE ALSO" references into hypertext links (try TAB and
> RET when reading a man page from Info). You need to install the man
> clone (v2misc/man12b.zip) and the ported Less, but other than that,
> you should be able to say "info tcl" and see the man page tcl.1,
> assuming there is one. (If the man pages come unformatted, install
> Groff, v2gnu/gro110b.zip, to format them automatically on the fly.)
>
> Here's the scanf patch I promised:
>
> *** src/libc/ansi/stdio/doscan.c~2 Sun Jun 13 19:12:52 1999
> --- src/libc/ansi/stdio/doscan.c Wed Jul 28 18:08:52 1999
> *************** _innum(int **ptr, int type, int len, int
> *** 225,231 ****
> base = 16;
> continue;
> }
> ! if (isdigit((unsigned)c)
> || (base==16 && (('a'<=c && c<='f') || ('A'<=c && c<='F')))) {
> ndigit++;
> if (base==8)
> --- 225,231 ----
> base = 16;
> continue;
> }
> ! if ((isdigit((unsigned)c) && c - '0' < base)
> || (base==16 && (('a'<=c && c<='f') || ('A'<=c && c<='F')))) {
> ndigit++;
> if (base==8)
--
/*********************************************************************
Edevaldo Pereira da Silva Junior IC Designer
Brazil Semiconductor Technology Center Motorola - SPS
email: Edevaldo DOT Pereira AT motorola DOT com Rodovia SP-340, Km 128,7
Phone: 55-19-847-8136 13820-000, Jaguariuna, SP
*********************************************************************/
- Raw text -