Skip to content

Commit

Permalink
Skip over legacy method for new versions
Browse files Browse the repository at this point in the history
Fixes #354
  • Loading branch information
jeroen committed Nov 11, 2024
1 parent bba6722 commit 7887570
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
32 changes: 17 additions & 15 deletions R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@ curl_options <- function(filter = ""){
opts[m]
}

option_table <- (function(){
env <- new.env()
if(file.exists("tools/option_table.txt")){
source("tools/option_table.txt", env)
} else if(file.exists("../tools/option_table.txt")){
source("../tools/option_table.txt", env)
} else {
stop("Failed to find 'tools/option_table.txt' from:", getwd())
}

option_table <- unlist(as.list(env))
names(option_table) <- sub("^curlopt_", "", tolower(names(option_table)))
option_table[order(names(option_table))]
})()
# Remove this when RHEL-8 is EOL
option_table_legacy <- if(libcurlVersion() < "7.73.0"){
(function(){
env <- new.env()
if(file.exists("tools/option_table.txt")){
source("tools/option_table.txt", env)
} else if(file.exists("../tools/option_table.txt")){
source("../tools/option_table.txt", env)
} else {
stop("Failed to find 'tools/option_table.txt' from:", getwd())
}

option_table <- unlist(as.list(env))
names(option_table) <- sub("^curlopt_", "", tolower(names(option_table)))
option_table[order(names(option_table))]
})()
}

#' @useDynLib curl R_option_types
make_option_type_table <- function(){
Expand All @@ -57,7 +59,7 @@ curl_options_list <- local({
structure(option_type_table$value, names = option_type_table$name)
} else {
# Fallback method: extracted from headers at build-time
option_table
option_table_legacy
}
}
return(cache)
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fi
# Write to Makevars
sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" src/Makevars.in > src/Makevars

# Extract curlopt symbols
# Legacy option list (remove this when RHEL8 is EOL)
echo '#include <curl/curl.h>' | ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E -xc - \
| grep "^[ \t]*CURLOPT_.*," | sed s/,// > tools/option_table.txt

Expand Down

0 comments on commit 7887570

Please sign in to comment.