mirror of
https://github.com/curl/curl.git
synced 2024-11-27 05:50:21 +08:00
tool_urlglob.c: reverse two loops
By counting from 0 and up instead of backwards like before, we remove the need for the "funny" check of the unsigned variable when decreased passed zero. Easier to read and less risk for compiler warnings.
This commit is contained in:
parent
64854c0364
commit
dc19789444
@ -465,8 +465,7 @@ void glob_cleanup(URLGlob* glob)
|
|||||||
size_t i;
|
size_t i;
|
||||||
int elem;
|
int elem;
|
||||||
|
|
||||||
/* the < condition is required since i underflows! */
|
for(i = 0; i < glob->size; i++) {
|
||||||
for(i = glob->size - 1; (i >= 0) && (i < glob->size); --i) {
|
|
||||||
if((glob->pattern[i].type == UPTSet) &&
|
if((glob->pattern[i].type == UPTSet) &&
|
||||||
(glob->pattern[i].content.Set.elements)) {
|
(glob->pattern[i].content.Set.elements)) {
|
||||||
for(elem = glob->pattern[i].content.Set.size - 1;
|
for(elem = glob->pattern[i].content.Set.size - 1;
|
||||||
@ -485,7 +484,6 @@ int glob_next_url(char **globbed, URLGlob *glob)
|
|||||||
{
|
{
|
||||||
URLPattern *pat;
|
URLPattern *pat;
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t j;
|
|
||||||
size_t len;
|
size_t len;
|
||||||
size_t buflen = glob->urllen + 1;
|
size_t buflen = glob->urllen + 1;
|
||||||
char *buf = glob->glob_buffer;
|
char *buf = glob->glob_buffer;
|
||||||
@ -498,9 +496,8 @@ int glob_next_url(char **globbed, URLGlob *glob)
|
|||||||
bool carry = TRUE;
|
bool carry = TRUE;
|
||||||
|
|
||||||
/* implement a counter over the index ranges of all patterns,
|
/* implement a counter over the index ranges of all patterns,
|
||||||
starting with the rightmost pattern */
|
starting with the leftmost pattern */
|
||||||
/* the < condition is required since i underflows! */
|
for(i = 0; carry && (i < glob->size); i++) {
|
||||||
for(i = glob->size - 1; carry && (i >= 0) && (i < glob->size); --i) {
|
|
||||||
carry = FALSE;
|
carry = FALSE;
|
||||||
pat = &glob->pattern[i];
|
pat = &glob->pattern[i];
|
||||||
switch (pat->type) {
|
switch (pat->type) {
|
||||||
@ -512,8 +509,9 @@ int glob_next_url(char **globbed, URLGlob *glob)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UPTCharRange:
|
case UPTCharRange:
|
||||||
pat->content.CharRange.ptr_c = (char)(pat->content.CharRange.step +
|
pat->content.CharRange.ptr_c =
|
||||||
(int)((unsigned char)pat->content.CharRange.ptr_c));
|
(char)(pat->content.CharRange.step +
|
||||||
|
(int)((unsigned char)pat->content.CharRange.ptr_c));
|
||||||
if(pat->content.CharRange.ptr_c > pat->content.CharRange.max_c) {
|
if(pat->content.CharRange.ptr_c > pat->content.CharRange.max_c) {
|
||||||
pat->content.CharRange.ptr_c = pat->content.CharRange.min_c;
|
pat->content.CharRange.ptr_c = pat->content.CharRange.min_c;
|
||||||
carry = TRUE;
|
carry = TRUE;
|
||||||
@ -537,8 +535,8 @@ int glob_next_url(char **globbed, URLGlob *glob)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(j = 0; j < glob->size; ++j) {
|
for(i = 0; i < glob->size; ++i) {
|
||||||
pat = &glob->pattern[j];
|
pat = &glob->pattern[i];
|
||||||
switch(pat->type) {
|
switch(pat->type) {
|
||||||
case UPTSet:
|
case UPTSet:
|
||||||
if(pat->content.Set.elements) {
|
if(pat->content.Set.elements) {
|
||||||
|
Loading…
Reference in New Issue
Block a user