mirror of
https://github.com/curl/curl.git
synced 2026-08-26 20:23:32 +03:00
lib: rename curlx_strtoofft to Curl_str_numblanks()
The function is no longer used via the curlx shortcut. Remove the strtoofft.[ch] files. Closes #16642
This commit is contained in:
parent
fc04eca8f8
commit
09a5b2f2de
17 changed files with 53 additions and 160 deletions
|
|
@ -233,7 +233,6 @@ LIB_CFILES = \
|
|||
strequal.c \
|
||||
strerror.c \
|
||||
strparse.c \
|
||||
strtoofft.c \
|
||||
system_win32.c \
|
||||
telnet.c \
|
||||
tftp.c \
|
||||
|
|
@ -374,7 +373,6 @@ LIB_HFILES = \
|
|||
strdup.h \
|
||||
strerror.h \
|
||||
strparse.h \
|
||||
strtoofft.h \
|
||||
system_win32.h \
|
||||
telnet.h \
|
||||
tftp.h \
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
#include "vtls/vtls.h"
|
||||
#include "transfer.h"
|
||||
#include "multiif.h"
|
||||
#include "strtoofft.h"
|
||||
#include "strparse.h"
|
||||
|
||||
/* The last 3 #include files should be in this order */
|
||||
#include "curl_printf.h"
|
||||
|
|
@ -315,8 +315,8 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf,
|
|||
k->httpcode);
|
||||
}
|
||||
else {
|
||||
if(curlx_strtoofft(header + strlen("Content-Length:"),
|
||||
NULL, 10, &ts->cl)) {
|
||||
const char *p = header + strlen("Content-Length:");
|
||||
if(Curl_str_numblanks(&p, &ts->cl)) {
|
||||
failf(data, "Unsupported Content-Length value");
|
||||
return CURLE_WEIRD_SERVER_REPLY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,11 +37,6 @@
|
|||
#include "strcase.h"
|
||||
/* "strcase.h" provides the strcasecompare protos */
|
||||
|
||||
#include "strtoofft.h"
|
||||
/* "strtoofft.h" provides this function: curlx_strtoofft(), returns a
|
||||
curl_off_t number from a given string.
|
||||
*/
|
||||
|
||||
#include "nonblock.h"
|
||||
/* "nonblock.h" provides curlx_nonblock() */
|
||||
|
||||
|
|
@ -66,4 +61,7 @@
|
|||
#include "version_win32.h"
|
||||
/* "version_win32.h" provides curlx_verify_windows_version() */
|
||||
|
||||
#include "strparse.h"
|
||||
/* The curlx_str_* parsing functions */
|
||||
|
||||
#endif /* HEADER_CURL_CURLX_H */
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@
|
|||
#include "urldata.h"
|
||||
#include "fileinfo.h"
|
||||
#include "llist.h"
|
||||
#include "strtoofft.h"
|
||||
#include "ftp.h"
|
||||
#include "ftplistparser.h"
|
||||
#include "curl_fnmatch.h"
|
||||
|
|
@ -627,13 +626,11 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
|
|||
case PL_UNIX_SIZE_NUMBER:
|
||||
parser->item_length++;
|
||||
if(c == ' ') {
|
||||
char *p;
|
||||
const char *p = mem + parser->item_offset;
|
||||
curl_off_t fsize;
|
||||
mem[parser->item_offset + parser->item_length - 1] = 0;
|
||||
if(!curlx_strtoofft(mem + parser->item_offset,
|
||||
&p, 10, &fsize)) {
|
||||
if(p[0] == '\0' && fsize != CURL_OFF_T_MAX &&
|
||||
fsize != CURL_OFF_T_MIN) {
|
||||
if(!Curl_str_numblanks(&p, &fsize)) {
|
||||
if(p[0] == '\0' && fsize != CURL_OFF_T_MAX) {
|
||||
parser->file_data->info.flags |= CURLFINFOFLAG_KNOWN_SIZE;
|
||||
parser->file_data->info.size = fsize;
|
||||
}
|
||||
|
|
@ -954,10 +951,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
|
|||
finfo->size = 0;
|
||||
}
|
||||
else {
|
||||
char *endptr;
|
||||
if(curlx_strtoofft(mem +
|
||||
parser->item_offset,
|
||||
&endptr, 10, &finfo->size)) {
|
||||
const char *p = mem + parser->item_offset;
|
||||
if(Curl_str_numblanks(&p, &finfo->size)) {
|
||||
parser->error = CURLE_FTP_BAD_FILE_LIST;
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@
|
|||
#include "headers.h"
|
||||
#include "select.h"
|
||||
#include "parsedate.h" /* for the week day and month names */
|
||||
#include "strtoofft.h"
|
||||
#include "multiif.h"
|
||||
#include "strcase.h"
|
||||
#include "content_encoding.h"
|
||||
|
|
@ -3027,13 +3026,13 @@ static CURLcode http_header(struct Curl_easy *data,
|
|||
HD_VAL(hd, hdlen, "Content-Length:") : NULL;
|
||||
if(v) {
|
||||
curl_off_t contentlength;
|
||||
CURLofft offt = curlx_strtoofft(v, NULL, 10, &contentlength);
|
||||
int offt = Curl_str_numblanks(&v, &contentlength);
|
||||
|
||||
if(offt == CURL_OFFT_OK) {
|
||||
if(offt == STRE_OK) {
|
||||
k->size = contentlength;
|
||||
k->maxdownload = k->size;
|
||||
}
|
||||
else if(offt == CURL_OFFT_FLOW) {
|
||||
else if(offt == STRE_OVERFLOW) {
|
||||
/* out of range */
|
||||
if(data->set.max_filesize) {
|
||||
failf(data, "Maximum file size exceeded");
|
||||
|
|
|
|||
|
|
@ -212,6 +212,16 @@ int Curl_str_octal(const char **linep, curl_off_t *nump, curl_off_t max)
|
|||
return str_num_base(linep, nump, max, 8);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse a positive number up to 63-bit number written in ASCII. Skip leading
|
||||
* blanks. No support for prefixes.
|
||||
*/
|
||||
int Curl_str_numblanks(const char **str, curl_off_t *num)
|
||||
{
|
||||
Curl_str_passblanks(str);
|
||||
return Curl_str_number(str, num, CURL_OFF_T_MAX);
|
||||
}
|
||||
|
||||
/* CR or LF
|
||||
return non-zero on error */
|
||||
int Curl_str_newline(const char **linep)
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ int Curl_str_singlespace(const char **linep);
|
|||
/* Get an unsigned decimal number. Return non-zero on error */
|
||||
int Curl_str_number(const char **linep, curl_off_t *nump, curl_off_t max);
|
||||
|
||||
/* As above with CURL_OFF_T_MAX but also pass leading blanks */
|
||||
int Curl_str_numblanks(const char **str, curl_off_t *num);
|
||||
|
||||
/* Get an unsigned hexadecimal number. Return non-zero on error */
|
||||
int Curl_str_hex(const char **linep, curl_off_t *nump, curl_off_t max);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "curl_setup.h"
|
||||
|
||||
#include "strtoofft.h"
|
||||
#include "strparse.h"
|
||||
|
||||
/*
|
||||
* Parse a positive number up to 63-bit number written in ASCII. Skip leading
|
||||
* blanks. No support for prefixes.
|
||||
*/
|
||||
CURLofft curlx_strtoofft(const char *str, char **endp, int base,
|
||||
curl_off_t *num)
|
||||
{
|
||||
curl_off_t number;
|
||||
int rc;
|
||||
*num = 0; /* clear by default */
|
||||
DEBUGASSERT((base == 10) || (base == 16));
|
||||
|
||||
Curl_str_passblanks(&str);
|
||||
rc = base == 10 ?
|
||||
Curl_str_number(&str, &number, CURL_OFF_T_MAX) :
|
||||
Curl_str_hex(&str, &number, CURL_OFF_T_MAX);
|
||||
|
||||
if(endp)
|
||||
*endp = (char *)str;
|
||||
if(rc == STRE_OVERFLOW)
|
||||
/* overflow */
|
||||
return CURL_OFFT_FLOW;
|
||||
else if(rc)
|
||||
/* nothing parsed */
|
||||
return CURL_OFFT_INVAL;
|
||||
|
||||
*num = number;
|
||||
return CURL_OFFT_OK;
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
#ifndef HEADER_CURL_STRTOOFFT_H
|
||||
#define HEADER_CURL_STRTOOFFT_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "curl_setup.h"
|
||||
#include "strparse.h"
|
||||
|
||||
typedef enum {
|
||||
CURL_OFFT_OK, /* parsed fine */
|
||||
CURL_OFFT_FLOW, /* over or underflow */
|
||||
CURL_OFFT_INVAL /* nothing was parsed */
|
||||
} CURLofft;
|
||||
|
||||
CURLofft curlx_strtoofft(const char *str, char **endp, int base,
|
||||
curl_off_t *num);
|
||||
|
||||
#endif /* HEADER_CURL_STRTOOFFT_H */
|
||||
|
|
@ -65,7 +65,6 @@
|
|||
#include "inet_ntop.h"
|
||||
#include "parsedate.h" /* for the week day and month names */
|
||||
#include "sockaddr.h" /* required for Curl_sockaddr_storage */
|
||||
#include "strtoofft.h"
|
||||
#include "strparse.h"
|
||||
#include "multiif.h"
|
||||
#include "select.h"
|
||||
|
|
@ -1603,29 +1602,29 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
}
|
||||
if(data->state.use_range) {
|
||||
curl_off_t from, to;
|
||||
char *ptr;
|
||||
char *ptr2;
|
||||
CURLofft to_t;
|
||||
CURLofft from_t;
|
||||
const char *p = data->state.range;
|
||||
int from_t, to_t;
|
||||
|
||||
from_t = curlx_strtoofft(data->state.range, &ptr, 10, &from);
|
||||
if(from_t == CURL_OFFT_FLOW) {
|
||||
from_t = Curl_str_number(&p, &from, CURL_OFF_T_MAX);
|
||||
if(from_t == STRE_OVERFLOW)
|
||||
return CURLE_RANGE_ERROR;
|
||||
}
|
||||
while(*ptr && (ISBLANK(*ptr) || (*ptr == '-')))
|
||||
ptr++;
|
||||
to_t = curlx_strtoofft(ptr, &ptr2, 10, &to);
|
||||
if(to_t == CURL_OFFT_FLOW) {
|
||||
Curl_str_passblanks(&p);
|
||||
(void)Curl_str_single(&p, '-');
|
||||
|
||||
to_t = Curl_str_numblanks(&p, &to);
|
||||
if(to_t == STRE_OVERFLOW)
|
||||
return CURLE_RANGE_ERROR;
|
||||
}
|
||||
if((to_t == CURL_OFFT_INVAL) /* no "to" value given */
|
||||
|| (to >= size)) {
|
||||
|
||||
if((to_t == STRE_NO_NUM) || (to >= size)) {
|
||||
to = size - 1;
|
||||
to_t = STRE_OK;
|
||||
}
|
||||
if(from_t) {
|
||||
|
||||
if(from_t == STRE_NO_NUM) {
|
||||
/* from is relative to end of file */
|
||||
from = size - to;
|
||||
to = size - 1;
|
||||
from_t = STRE_OK;
|
||||
}
|
||||
if(from > size) {
|
||||
failf(data, "Offset (%" FMT_OFF_T ") was beyond file size (%"
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@
|
|||
#include "inet_ntop.h"
|
||||
#include "parsedate.h" /* for the week day and month names */
|
||||
#include "sockaddr.h" /* required for Curl_sockaddr_storage */
|
||||
#include "strtoofft.h"
|
||||
#include "multiif.h"
|
||||
#include "select.h"
|
||||
#include "warnless.h"
|
||||
|
|
@ -1474,20 +1473,19 @@ sftp_download_stat(struct Curl_easy *data,
|
|||
}
|
||||
if(data->state.use_range) {
|
||||
curl_off_t from, to;
|
||||
char *ptr;
|
||||
char *ptr2;
|
||||
CURLofft to_t;
|
||||
CURLofft from_t;
|
||||
const char *p = data->state.range;
|
||||
int to_t, from_t;
|
||||
|
||||
from_t = curlx_strtoofft(data->state.range, &ptr, 10, &from);
|
||||
if(from_t == CURL_OFFT_FLOW)
|
||||
from_t = Curl_str_number(&p, &from, CURL_OFF_T_MAX);
|
||||
if(from_t == STRE_OVERFLOW)
|
||||
return CURLE_RANGE_ERROR;
|
||||
while(*ptr && (ISBLANK(*ptr) || (*ptr == '-')))
|
||||
ptr++;
|
||||
to_t = curlx_strtoofft(ptr, &ptr2, 10, &to);
|
||||
if(to_t == CURL_OFFT_FLOW)
|
||||
Curl_str_passblanks(&p);
|
||||
(void)Curl_str_single(&p, '-');
|
||||
|
||||
to_t = Curl_str_numblanks(&p, &to);
|
||||
if(to_t == STRE_OVERFLOW)
|
||||
return CURLE_RANGE_ERROR;
|
||||
if((to_t == CURL_OFFT_INVAL) /* no "to" value given */
|
||||
if((to_t == STRE_NO_NUM) /* no "to" value given */
|
||||
|| (to >= size)) {
|
||||
to = size - 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue