From 9ba597bed72bfa5c8cc671eb7f601de2deaff640 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 3 Apr 2025 13:41:50 -0700 Subject: [PATCH] lib: make Curl_easyopts const Also, make the optiontable rule work in an out-of-tree build. Closes #16950 --- lib/Makefile.am | 2 +- lib/easygetopt.c | 4 ++-- lib/easyoptions.c | 2 +- lib/easyoptions.h | 2 +- lib/optiontable.pl | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Makefile.am b/lib/Makefile.am index b8aaadab80..b10c9a13be 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -185,7 +185,7 @@ tidy: $(TIDY) $$_csources $(TIDYFLAGS) $(CURL_CLANG_TIDYFLAGS) -- $(AM_CPPFLAGS) $(CPPFLAGS) -DHAVE_CONFIG_H) optiontable: - perl optiontable.pl < $(top_srcdir)/include/curl/curl.h > easyoptions.c + @PERL@ $(srcdir)/optiontable.pl < $(top_srcdir)/include/curl/curl.h > $(srcdir)/easyoptions.c if HAVE_WINDRES .rc.lo: diff --git a/lib/easygetopt.c b/lib/easygetopt.c index 86833bf6b9..5d30d39a49 100644 --- a/lib/easygetopt.c +++ b/lib/easygetopt.c @@ -29,12 +29,12 @@ #ifndef CURL_DISABLE_GETOPTIONS /* Lookups easy options at runtime */ -static struct curl_easyoption *lookup(const char *name, CURLoption id) +static const struct curl_easyoption *lookup(const char *name, CURLoption id) { DEBUGASSERT(name || id); DEBUGASSERT(!Curl_easyopts_check()); if(name || id) { - struct curl_easyoption *o = &Curl_easyopts[0]; + const struct curl_easyoption *o = &Curl_easyopts[0]; do { if(name) { if(strcasecompare(o->name, name)) diff --git a/lib/easyoptions.c b/lib/easyoptions.c index be617b5d2a..860aa4c2ba 100644 --- a/lib/easyoptions.c +++ b/lib/easyoptions.c @@ -28,7 +28,7 @@ #include "easyoptions.h" /* all easy setopt options listed in alphabetical order */ -struct curl_easyoption Curl_easyopts[] = { +const struct curl_easyoption Curl_easyopts[] = { {"ABSTRACT_UNIX_SOCKET", CURLOPT_ABSTRACT_UNIX_SOCKET, CURLOT_STRING, 0}, {"ACCEPTTIMEOUT_MS", CURLOPT_ACCEPTTIMEOUT_MS, CURLOT_LONG, 0}, {"ACCEPT_ENCODING", CURLOPT_ACCEPT_ENCODING, CURLOT_STRING, 0}, diff --git a/lib/easyoptions.h b/lib/easyoptions.h index 24b4cd93ed..44b6a8280a 100644 --- a/lib/easyoptions.h +++ b/lib/easyoptions.h @@ -29,7 +29,7 @@ #include /* generated table with all easy options */ -extern struct curl_easyoption Curl_easyopts[]; +extern const struct curl_easyoption Curl_easyopts[]; #ifdef DEBUGBUILD int Curl_easyopts_check(void); diff --git a/lib/optiontable.pl b/lib/optiontable.pl index 350262c70f..b1fa69d982 100755 --- a/lib/optiontable.pl +++ b/lib/optiontable.pl @@ -31,7 +31,7 @@ print <