]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
OS400: avoid using awk in the build scripts
authorPatrick Monnerat <patrick@monnerat.net>
Wed, 31 Jan 2024 13:04:41 +0000 (14:04 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 1 Feb 2024 21:31:35 +0000 (22:31 +0100)
Awk is a PASE program and its use may cause a failure depending on the
CCSID of the calling script (IBM bug?).

For this reason, revert to an sed-only solution to extract the exported
symbols from the header files.

Closes #12826

packages/OS400/make-lib.sh

index 860cb5d76da24edf5bd9dadb0b3d23b8f37a2715..8179d816d57c81552337bd32f30d32519b5bfc1a 100755 (executable)
@@ -98,26 +98,21 @@ fi
 
 
 #       Gather the list of symbols to export.
-#       First use awk to pull all CURL_EXTERN function prototypes from
-#       the header files, pass through to sed to strip CURL_DEPRECATED(..)
-#       and CURL_TEMP_PRINTF(..) then back to awk to pull the string
-#       immediately to the left of a bracket stripping any spaces or *'s.
-
-EXPORTS=`awk '/^CURL_EXTERN/,/;/'                                       \
-              "${TOPDIR}"/include/curl/*.h                              \
-              "${SCRIPTDIR}/ccsidcurl.h"                                |
-         sed 's/ CURL_DEPRECATED(.*)//g;s/ CURL_TEMP_PRINTF(.*)//g'     |
-         awk '{br=index($0,"(");                                        \
-              if (br) {                                                 \
-                for(c=br-1; ;c--) {                                     \
-                  if (c==1) {                                           \
-                    print substr($0,c,br-1); break                      \
-                  } else if (match(substr($0, c, br-c), "[ *]") != 0) { \
-                    print substr($0, c+1, br-c-1); break                \
-                  }                                                     \
-                }                                                       \
-              }                                                         \
-        }'`
+#       - Unfold lines from the header files so that they contain a semicolon.
+#       - Keep only CURL_EXTERN definitions.
+#       - Remove the CURL_DEPRECATED and CURL_TEMP_PRINTF macro calls.
+#      - Drop the parenthesized function arguments and what follows.
+#       - Keep the trailing function name only.
+
+EXPORTS=`cat "${TOPDIR}"/include/curl/*.h "${SCRIPTDIR}/ccsidcurl.h"   |
+         sed -e 'H;s/.*//;x;s/\n//;s/.*/& /'                            \
+             -e '/^CURL_EXTERN[[:space:]]/!d'                           \
+             -e '/\;/!{x;d;}'                                           \
+             -e 's/ CURL_DEPRECATED([^)]*)//g'                          \
+             -e 's/ CURL_TEMP_PRINTF([^)]*)//g'                         \
+             -e 's/[[:space:]]*(.*$//'                                  \
+             -e 's/^.*[^A-Za-z0-9_]\([A-Za-z0-9_]*\)$/\1/'`
+
 
 #       Create the service program exportation file in DB2 member if needed.