Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ static void pathadd(struct option *o, const char *path)

static char *encodeassign(const char *query)
{
char *p = strchr(query, '=');
const char *p = strchr(query, '=');
char *urle;
if(p) {
/* URL encode the left and the right side of the '=' separately */
Expand Down Expand Up @@ -614,7 +614,7 @@ static int getarg(struct option *o,
gap = false;
}
else if((flag[0] == '-') && (flag[1] == '-')) {
char *equals = strchr(&flag[2], '=');
const char *equals = strchr(&flag[2], '=');
if(equals) {
arg = (const char *)&equals[1];
gap = false;
Expand Down Expand Up @@ -868,9 +868,10 @@ static void get(struct option *o, CURLU *uh)
else {
/* this is meant as a variable to output */
const char *start = ptr;
char *end;
char *cl;
const char *end;
const char *cl;
size_t vlen;
size_t badlen = 0;
bool isquery = false;
bool queryall = false;
bool strict = false; /* strict mode, fail on URL decode problems */
Expand Down Expand Up @@ -930,7 +931,7 @@ static void get(struct option *o, CURLU *uh)
else {
/* syntax error */
vlen = 0;
end[1] = '\0';
badlen = end - start + 1;
}
break;
}
Expand All @@ -945,7 +946,7 @@ static void get(struct option *o, CURLU *uh)
queryall);
}
else if(!vlen)
errorf(o, ERROR_GET, "Bad --get syntax: %s", start);
errorf(o, ERROR_GET, "Bad --get syntax: %.*s", (int)badlen, start);
else if(!strncmp(ptr, "url", vlen))
showurl(stream, o, mods, uh);
else {
Expand Down Expand Up @@ -1029,7 +1030,7 @@ static void get(struct option *o, CURLU *uh)
static const struct var *setone(CURLU *uh, const char *setline,
struct option *o)
{
char *ptr = strchr(setline, '=');
const char *ptr = strchr(setline, '=');
const struct var *v = NULL;
if(ptr && (ptr > setline)) {
size_t vlen = ptr - setline;
Expand Down Expand Up @@ -1274,8 +1275,8 @@ static bool trim(struct option *o)
}

for(i = 0; i < nqpairs; i++) {
char *q = qpairs[i].str;
char *sep = strchr(q, '=');
const char *q = qpairs[i].str;
const char *sep = strchr(q, '=');
size_t qlen;
if(sep)
qlen = sep - q;
Expand Down Expand Up @@ -1554,10 +1555,9 @@ static bool extractqpairs(CURLU *uh, struct option *o)
/* extract the query */
if(!curl_url_get(uh, CURLUPART_QUERY, &q, 0)) {
char *p = q;
char *amp;
while(*p) {
size_t len;
amp = strchr(p, o->qsep[0]);
char *amp = strchr(p, o->qsep[0]);
if(!amp)
len = strlen(p);
else
Expand Down Expand Up @@ -1692,7 +1692,7 @@ static char *canonical_path(const char *path)
{
/* split the path per slash, URL decode + encode, then put together again */
size_t len = strlen(path);
char *sl;
const char *sl;
char *dupe = NULL;

do {
Expand Down Expand Up @@ -1819,7 +1819,8 @@ static void singleurl(struct option *o,
size_t plen;
const char *w;
size_t wlen;
char *sep;
const char *sep;
char *sepw;
bool urlencode = true;
const struct var *v;

Expand Down Expand Up @@ -1860,10 +1861,10 @@ static void singleurl(struct option *o,
w = iinfo->ptr;
}

sep = strchr(w, ' ');
if(sep) {
wlen = sep - w;
iinfo->ptr = sep + 1; /* next word is here */
sepw = strchr(w, ' ');
if(sepw) {
wlen = sepw - w;
iinfo->ptr = sepw + 1; /* next word is here */
}
else {
/* last word */
Expand Down