Fossil SCM

Replaced a complicated bit of logic with something slighlty less complicated, having the same effect. The glob parser used a mix of second-clause for-loop testing and internal break and continue checks without any other internal processing inside the loop. Combining all of this into a single expression requires the line to wrap (bad for clarity) but it does make clear all of the conditions required for this loop to continue iterating. I think it's a net improvement in clarity, though the margin is admittedly small. Testing shows no regression in functionality, limiting this non-functional change to a style improvement.

wyoung 2023-05-22 21:27 trunk
Commit b878923997bbcf1eded6861a357b5ab454bb442369effe1c9eea20f2d9498393
1 file changed +4 -4
+4 -4
--- src/glob.c
+++ src/glob.c
@@ -126,14 +126,14 @@
126126
}else{
127127
delimiter = ',';
128128
}
129129
p->azPattern = fossil_realloc(p->azPattern, (p->nPattern+1)*sizeof(char*) );
130130
p->azPattern[p->nPattern++] = z;
131
- /* Find the next delimter (or the end of the string). */
132
- for(i=0; z[i] && z[i]!=delimiter; i++){
133
- if( delimiter!=',' ) continue; /* If quoted, keep going. */
134
- if( fossil_isspace(z[i]) ) break; /* If space, stop. */
131
+ /* Find the next delimiter (or the end of the string). */
132
+ for(i=0; z[i] && z[i]!=delimiter &&
133
+ !(delimiter==',' && fossil_isspace(z[i])); i++){
134
+ /* keep looking for the end of the glob pattern */
135135
}
136136
if( z[i]==0 ) break;
137137
z[i] = 0;
138138
z += i+1;
139139
}
140140
--- src/glob.c
+++ src/glob.c
@@ -126,14 +126,14 @@
126 }else{
127 delimiter = ',';
128 }
129 p->azPattern = fossil_realloc(p->azPattern, (p->nPattern+1)*sizeof(char*) );
130 p->azPattern[p->nPattern++] = z;
131 /* Find the next delimter (or the end of the string). */
132 for(i=0; z[i] && z[i]!=delimiter; i++){
133 if( delimiter!=',' ) continue; /* If quoted, keep going. */
134 if( fossil_isspace(z[i]) ) break; /* If space, stop. */
135 }
136 if( z[i]==0 ) break;
137 z[i] = 0;
138 z += i+1;
139 }
140
--- src/glob.c
+++ src/glob.c
@@ -126,14 +126,14 @@
126 }else{
127 delimiter = ',';
128 }
129 p->azPattern = fossil_realloc(p->azPattern, (p->nPattern+1)*sizeof(char*) );
130 p->azPattern[p->nPattern++] = z;
131 /* Find the next delimiter (or the end of the string). */
132 for(i=0; z[i] && z[i]!=delimiter &&
133 !(delimiter==',' && fossil_isspace(z[i])); i++){
134 /* keep looking for the end of the glob pattern */
135 }
136 if( z[i]==0 ) break;
137 z[i] = 0;
138 z += i+1;
139 }
140

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button