delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/30/03:10:11

Date: Thu, 29 Jul 1999 11:03:19 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Edevaldo Pereira da Silva Junior <Edevaldo DOT Pereira AT motorola DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: TCL Port to DJGPP - Bug + Advices.
In-Reply-To: <379EF8E7.98BB0896@motorola.com>
Message-ID: <Pine.SUN.3.91.990729110252.25908G-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019