bug-guile
[Top][All Lists]
Advanced

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

["Nelson H. F. Beebe" <address@hidden>] Re: guile-1.5.6: some build comm


From: Neil Jerram
Subject: ["Nelson H. F. Beebe" <address@hidden>] Re: guile-1.5.6: some build comments: regcomp() behavior
Date: 01 Apr 2002 19:34:59 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

--- Begin Message --- Subject: Re: guile-1.5.6: some build comments: regcomp() behavior Date: Mon, 1 Apr 2002 09:06:50 -0700 (MST)
>> ...
>>     Nelson> Sun Solaris 2.7 and 2.8:
>>     Nelson>     Testing
>> /export/staff/computing/beebe/i386/build/guile-1.5.6/pre-inst-guile ...
>>     Nelson>     with 
>> GUILE_LOAD_PATH=/export/staff/computing/beebe/i386/build/guile-1.5.6/test-suite
>>     Nelson>     ERROR: regexp.test: regexp-substitute/global: ("" "" ""):
>> port is string port - arguments: ((regular-expression-syntax "make-regexp"
>> "empty (sub)expression" #f #f))
>>     Nelson>     ERROR: regexp.test: regexp-substitute/global: ("" "" ""):
>> port is #f - arguments: ((regular-expression-syntax "make-regexp" "empty
>> (sub)expression" #f #f))
>>
>> These errors are being passed through from the Solaris libc's
>> implementation of regcomp and regerror - apparently, its regcomp
>> doesn't handle empty expressions.  Perhaps best just documented and
>> lived with, although we could probably code a workaround on the Scheme
>> level if we wanted to.
>> ...

I made a small test program, with one illegal pattern to regcomp(),
and one empty one, and then ran it on 16 or so platforms:

        % cat regcomp.c
        #include <stdio.h>
        #include <stdlib.h>
        #include <sys/types.h>
        #include <regex.h>
        #include <errno.h>

        #ifndef EXIT_SUCCESS
        #define EXIT_SUCCESS 0
        #endif

        int
        main(int argc, char* argv[])
        {
            int ret;
            regex_t preg;

            ret = regcomp(&preg, "[", 0);
            if (ret != 0)
            {
                (void)printf("regcomp(&preg, \"[\", 0) returns %ld\n", ret);
                perror("perror() says: ");
            }

            ret = regcomp(&preg, "", 0);
            if (ret != 0)
            {
                (void)printf("regcomp(&preg, \"\", 0) returns %ld\n", ret);
                perror("perror() says: ");
            }

            return (EXIT_SUCCESS);
        }

Most platforms produced output like this:

        cc regcomp.c && ./a.out
        regcomp(&preg, "[", 0) returns 7
        perror() says: : Error 0

Both Solaris 2.7 and 2.8 behaved this way.

However, two platforms, Apple Darwin (== MacOS X) and FreeBSD 4.4.0,
gave an error for the empty string:

        % cc regcomp.c && ./a.out
        regcomp(&preg, "[", 0) returns 7
        perror() says: : Undefined error: 0
        regcomp(&preg, "", 0) returns 14
        perror() says: : Undefined error: 0

On HP-UX 10.01, a.out appeared to go into an infinite loop, and I had
to kill the xterm window to it, since it did not respond to Ctl-C.
That could be a different problem: that particular local system has a
history of suddenly becoming inaccessible, and at the moment, I cannot
get a fresh connection to it.

Based on these experiments, I recommend that guile should take special
care never to pass an empty pattern to regcomp().


-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- Center for Scientific Computing       FAX: +1 801 585 1640, +1 801 581 4148 -
- University of Utah                    Internet e-mail: address@hidden  -
- Department of Mathematics, 110 LCB        address@hidden  address@hidden -
- 155 S 1400 E RM 233                       address@hidden                    -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe  -
-------------------------------------------------------------------------------





--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]