mirror of
https://github.com/curl/curl.git
synced 2026-08-25 14:23:39 +03:00
curl_get_line: enhance the API
To make sure callers can properly differentiate between errors and know cleanly when EOF happens. Updated all users and unit test 3200. Triggered by a remark by ZeroPath Closes #19140
This commit is contained in:
parent
990a23bb97
commit
769ccb4d42
7 changed files with 112 additions and 110 deletions
16
lib/altsvc.c
16
lib/altsvc.c
|
|
@ -228,14 +228,18 @@ static CURLcode altsvc_load(struct altsvcinfo *asi, const char *file)
|
|||
|
||||
fp = curlx_fopen(file, FOPEN_READTEXT);
|
||||
if(fp) {
|
||||
bool eof = FALSE;
|
||||
struct dynbuf buf;
|
||||
curlx_dyn_init(&buf, MAX_ALTSVC_LINE);
|
||||
while(Curl_get_line(&buf, fp)) {
|
||||
const char *lineptr = curlx_dyn_ptr(&buf);
|
||||
curlx_str_passblanks(&lineptr);
|
||||
if(curlx_str_single(&lineptr, '#'))
|
||||
altsvc_add(asi, lineptr);
|
||||
}
|
||||
do {
|
||||
result = Curl_get_line(&buf, fp, &eof);
|
||||
if(!result) {
|
||||
const char *lineptr = curlx_dyn_ptr(&buf);
|
||||
curlx_str_passblanks(&lineptr);
|
||||
if(curlx_str_single(&lineptr, '#'))
|
||||
altsvc_add(asi, lineptr);
|
||||
}
|
||||
} while(!result && !eof);
|
||||
curlx_dyn_free(&buf); /* free the line buffer */
|
||||
curlx_fclose(fp);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue