diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2010-10-26 15:26:45 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2010-10-26 15:26:45 +0000 |
commit | b73b31cd6024879a40e33a40edd121b186eb7f9d (patch) | |
tree | 37beec7212bbdb7c92f19f8d8cc80b97a2e72cde | |
parent | 2d84b92907706e92e18d3e579ff3e7cd924f73aa (diff) | |
download | pcre-b73b31cd6024879a40e33a40edd121b186eb7f9d.tar.gz |
Fix missing code for missing strtoul() and strerror().
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@558 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pcregrep.c | 16 | ||||
-rw-r--r-- | pcretest.c | 24 |
3 files changed, 40 insertions, 4 deletions
@@ -52,6 +52,10 @@ Version 8.11 10-Oct-2010 comments when looking ahead for named forward references to subpatterns, the only newline sequence it recognized was NL. It now handles newlines according to the set newline convention. + +8. SunOS4 doesn't have strerror() or strtoul(); pcregrep dealt with the + former, but used strtoul(), whereas pcretest avoided strtoul() but did not + cater for a lack of strerror(). These oversights have been fixed. Version 8.10 25-Jun-2010 @@ -363,9 +363,10 @@ return isatty(fileno(f)); Lionel Fourquaux. David Burgess added a patch to define INVALID_FILE_ATTRIBUTES when it did not exist. David Byron added a patch that moved the #include of <windows.h> to before the INVALID_FILE_ATTRIBUTES definition rather than after. -*/ +The double test below stops gcc 4.4.4 grumbling that HAVE_WINDOWS_H is +undefined when it is indeed undefined. */ -#elif HAVE_WINDOWS_H +#elif defined HAVE_WINDOWS_H && HAVE_WINDOWS_H #ifndef STRICT # define STRICT @@ -2196,10 +2197,17 @@ for (i = 1; i < argc; i++) { *((char **)op->dataptr) = option_data; } + + /* Avoid the use of strtoul() because SunOS4 doesn't have it. This is used + only for unpicking arguments, so just keep it simple. */ + else { - char *endptr; - int n = strtoul(option_data, &endptr, 10); + int n = 0; + char *endptr = option_data; + while (*endptr != 0 && isspace((unsigned char)(*endptr))) endptr++; + while (isdigit((unsigned char)(*endptr))) + n = n * 10 + (int)(*endptr++ - '0'); if (*endptr != 0) { if (longop) @@ -516,6 +516,30 @@ static const unsigned char tables1[] = { + +#ifndef HAVE_STRERROR +/************************************************* +* Provide strerror() for non-ANSI libraries * +*************************************************/ + +/* Some old-fashioned systems still around (e.g. SunOS4) don't have strerror() +in their libraries, but can provide the same facility by this simple +alternative function. */ + +extern int sys_nerr; +extern char *sys_errlist[]; + +char * +strerror(int n) +{ +if (n < 0 || n >= sys_nerr) return "unknown error number"; +return sys_errlist[n]; +} +#endif /* HAVE_STRERROR */ + + + + /************************************************* * Read or extend an input line * *************************************************/ |