Parcourir la source

dselect: Do not reuse variable r in packagelist::checksearch()

Use a different variable with a more meaningful name instead.
Guillem Jover il y a 12 ans
Parent
commit
931bb3cc27
1 fichiers modifiés avec 10 ajouts et 9 suppressions
  1. 10 9
      dselect/pkglist.cc

+ 10 - 9
dselect/pkglist.cc

@@ -496,6 +496,7 @@ bool
 packagelist::checksearch(char *rx)
 {
   int r,opt = REG_NOSUB;
+  int pos;
 
   if (str_is_unset(rx))
     return false;
@@ -507,23 +508,23 @@ packagelist::checksearch(char *rx)
   }
 
   /* look for search options */
-  for (r=strlen(rx)-1; r>=0; r--)
-    if ((rx[r]=='/') && ((r==0) || (rx[r-1]!='\\')))
+  for (pos = strlen(rx) - 1; pos >= 0; pos--)
+    if ((rx[pos] == '/') && ((pos == 0) || (rx[pos - 1] != '\\')))
       break;
 
-  if (r>=0) {
-    rx[r++]='\0';
-    if (strcspn(rx+r, "di")!=0) {
+  if (pos >= 0) {
+    rx[pos++] = '\0';
+    if (strcspn(rx + pos, "di") != 0) {
       displayerror(_("invalid search option given"));
       return false;
     }
 
-   while (rx[r]) {
-     if (rx[r]=='i')
+   while (rx[pos]) {
+     if (rx[pos] == 'i')
        opt|=REG_ICASE;
-     else if (rx[r]=='d')
+     else if (rx[pos] == 'd')
        searchdescr = true;
-     r++;
+     pos++;
    }
   }