Skip to content

Commit ec00441

Browse files
Ayeshkocsismate
authored andcommitted
ext/curl: Fix sync-constants script
The Curl doc page that was used to check the constants was changed from `<pre></pre>` tags to an HTML page. This updates the regexps to account for the changes, the Cthulu way. - New: https://curl.se/libcurl/c/symbols-in-versions.html - Old: https://web.archive.org/web/20231201000000*/https://curl.se/libcurl/c/symbols-in-versions.html - Change in curl-www: curl/curl-www@2baba5ed45
1 parent 5517cb0 commit ec00441

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ext/curl/sync-constants.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function getCurlConstants() : array
208208
$html = file_get_contents(CURL_DOC_FILE);
209209

210210
// Extract the constant list from the HTML file (located in the only <pre> tag in the page)
211-
preg_match('~<pre>([^<]+)</pre>~', $html, $matches);
211+
preg_match('~<table>(.*?)</table>~s', $html, $matches);
212212
$constantList = $matches[1];
213213

214214
/**
@@ -220,16 +220,16 @@ function getCurlConstants() : array
220220
* CURLOPT_FTPASCII 7.1 7.11.1 7.15.5
221221
* CURLOPT_HTTPREQUEST 7.1 - 7.15.5
222222
*/
223-
$regexp = '/^([A-Za-z0-9_]+) +([0-9\.]+)(?: +([0-9\.\-]+))?(?: +([0-9\.]+))?/m';
223+
$regexp = '@<tr><td>(?:<a href=".*?">)?(?<const>[A-Za-z0-9_]+)(?:</a>)?</td><td>(?:<a href=".*?">)?(?<added>[\d\.]+)(?:</a>)?</td><td>(?:<a href=".*?">)?(?<deprecated>[\d\.]+)?(?:</a>)?</td><td>(<a href=".*?">)?(?<removed>[\d\.]+)?(</a>)?</td></tr>@m';
224224
preg_match_all($regexp, $constantList, $matches, PREG_SET_ORDER);
225225

226226
$constants = [];
227227

228228
foreach ($matches as $match) {
229-
$name = $match[1];
230-
$introduced = $match[2];
231-
$deprecated = $match[3] ?? null;
232-
$removed = $match[4] ?? null;
229+
$name = $match['const'];
230+
$introduced = $match['added'];
231+
$deprecated = $match['deprecated'] ?? null;
232+
$removed = $match['removed'] ?? null;
233233

234234
if (in_array($name, IGNORED_CURL_CONSTANTS, true) || !preg_match(CONSTANTS_REGEX_PATTERN, $name)) {
235235
// not a wanted constant

0 commit comments

Comments
 (0)