[Pcre-svn] [558] code/trunk: Fix missing code for missing st…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [558] code/trunk: Fix missing code for missing strtoul() and strerror().
Revision: 558
          http://vcs.pcre.org/viewvc?view=rev&revision=558
Author:   ph10
Date:     2010-10-26 16:26:45 +0100 (Tue, 26 Oct 2010)


Log Message:
-----------
Fix missing code for missing strtoul() and strerror().

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcregrep.c
    code/trunk/pcretest.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2010-10-26 15:26:12 UTC (rev 557)
+++ code/trunk/ChangeLog    2010-10-26 15:26:45 UTC (rev 558)
@@ -52,6 +52,10 @@
     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

Modified: code/trunk/pcregrep.c
===================================================================
--- code/trunk/pcregrep.c    2010-10-26 15:26:12 UTC (rev 557)
+++ code/trunk/pcregrep.c    2010-10-26 15:26:45 UTC (rev 558)
@@ -363,9 +363,10 @@
 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 @@
     {
     *((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)


Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c    2010-10-26 15:26:12 UTC (rev 557)
+++ code/trunk/pcretest.c    2010-10-26 15:26:45 UTC (rev 558)
@@ -516,7 +516,31 @@




+
+#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            *
 *************************************************/