Surround boolean expressions with parenthesis.
Switch a for with an empty body into a while.
+2008-06-30 Guillem Jover <guillem@debian.org>
+
+ * dselect/baselist.cc (baselist::wordwrapinfo): Surround expression
+ with parenthesis.
+ * dselect/pkgcmds.cc (packagelist::affectedmatches): Likewise.
+ (packagelist::affectedrange): Switch a for with an empty body into a
+ while.
+ * dselect/basecmds.cc (baselist::displayhelp): Likewise.
+ * dselect/bindings.cc (keybindings::bind, keybindings::find)
+ (keybindings::operator(), keybindings::key2name)
+ (keybindings::name2key): Likewise.
+ * dselect/main.cc (urq_menu, main): Likewise.
+ * dselect/methparse.cc (readmethods, getcurrentopt): Likewise.
+ * dselect/pkgdepcon.cc (packagelist::resolvedepcon): Likewise.
+ * dselect/pkgsublist.cc (packagelist::alreadydone): Likewise.
+
2008-06-30 Guillem Jover <guillem@debian.org>
* lib/trigdeferred.l: Define YY_NO_INPUT to make flex not include
void baselist::displayhelp(const struct helpmenuentry *helpmenu, int key) {
- const struct helpmenuentry *hme;
int maxx, maxy, i, y, x, nextkey;
getmaxyx(stdscr,maxy,maxx);
clearok(stdscr,TRUE);
for (;;) {
werase(stdscr);
- for (hme= helpmenu; hme->key && hme->key != key; hme++);
+ const struct helpmenuentry *hme = helpmenu;
+ while (hme->key && hme->key != key)
+ hme++;
if (hme->key) {
attrset(helpscreen_attr);
mvaddstr(1,0, gettext(hme->msg->text));
const char *p= strchr(m,'\n');
int l= p ? (int)(p-m) : strlen(m);
while (l && isspace(m[l-1])) l--;
- if (!l || *m == '.' && l == 1) {
+ if (!l || (*m == '.' && l == 1)) {
if (wrapping) waddch(infopad,'\n');
waddch(infopad,'\n');
wrapping= 0;
int keybindings::bind(int key, const char *action) {
if (key == -1) return 0;
- const interpretation *interp;
- for (interp=interps; interp->action && strcmp(interp->action,action); interp++);
+ const interpretation *interp = interps;
+ while (interp->action && strcmp(interp->action, action))
+ interp++;
if (!interp->action) return 0;
- const description *desc;
- for (desc=descriptions; desc->action && strcmp(desc->action,action); desc++);
+ const description *desc = descriptions;
+ while (desc->action && strcmp(desc->action, action))
+ desc++;
- binding *bind;
- for (bind=bindings; bind && bind->key != key; bind=bind->next);
+ binding *bind = bindings;
+ while (bind && bind->key != key)
+ bind = bind->next;
if (!bind) {
bind= new binding;
}
const char *keybindings::find(const char *action) {
- binding *b;
- for (b=bindings; b && strcmp(action,b->interp->action); b=b->next);
+ binding *b = bindings;
+ while (b && strcmp(action, b->interp->action))
+ b = b->next;
if (!b) return _("[not bound]");
const char *n= key2name(b->key);
if (n) return n;
}
const keybindings::interpretation *keybindings::operator()(int key) {
- binding *b;
- for (b=bindings; b && b->key != key; b=b->next);
+ binding *b = bindings;
+ while (b && b->key != key)
+ b = b->next;
if (!b) return 0;
return b->interp;
}
}
const char *keybindings::key2name(int key) {
- const keyname *search;
- for (search=keynames; search->key != -1 && search->key != key; search++);
+ const keyname *search = keynames;
+ while (search->key != -1 && search->key != key)
+ search++;
return search->kname;
}
int keybindings::name2key(const char *name) {
- const keyname *search;
- for (search=keynames; search->kname && strcasecmp(search->kname,name); search++);
+ const keyname *search = keynames;
+ while (search->kname && strcasecmp(search->kname, name))
+ search++;
return search->key;
}
urqresult urq_menu(void) {
#define C(x) ((x)-'a'+1)
- int entries, c, i;
+ int entries, c;
entries= refreshmenu();
int cursor=0;
dme(0,1);
}
} else if (isalpha(c)) {
c= tolower(c);
- for (i=0; i<entries && gettext(menuentries[i].key)[0] != c; i++);
+ int i = 0;
+ while (i < entries && gettext(menuentries[i].key)[0] != c)
+ i++;
if (i < entries) {
dme(cursor,0); cursor=i; dme(cursor,1);
} else {
if (*argv) {
const char *a;
while ((a= *argv++) != 0) {
- const menuentry *me;
- for (me= menuentries; me->command && strcmp(me->command,a); me++);
+ const menuentry *me = menuentries;
+ while (me->command && strcmp(me->command, a))
+ me++;
if (!me->command) badusage(_("unknown action string `%.50s'"),a);
me->fn();
}
};
const char *const *ccpp;
int methodlen, c, baselen;
- char *p, *pathinmeth, *pathbuf, *pathmeth;
+ char *pathinmeth, *pathbuf, *pathmeth;
DIR *dir;
FILE *names, *descfile;
struct dirent *dent;
struct varbuf vb;
method *meth;
- dselect_option *opt, **optinsert;
+ dselect_option *opt;
struct stat stab;
baselen= strlen(pathbase);
if (debug) fprintf(debug,"readmethods(`%s',...) considering `%s' ...\n",
pathbase,dent->d_name);
if (c != '_' && !isalpha(c)) continue;
- for (p= dent->d_name+1; (c= *p) != 0 && isalnum(c) && c != '_'; p++);
+ char *p = dent->d_name + 1;
+ while ((c = *p) != 0 && isalnum(c) && c != '_')
+ p++;
if (c) continue;
methodlen= strlen(dent->d_name);
if (methodlen > IMETHODMAXLEN)
opt->description ? "`...'" : "null",
opt->description ? (long) strlen(opt->description) : -1,
opt->meth->name, opt->meth->path, opt->meth->pathinmeth);
- for (optinsert= optionspp;
- *optinsert && strcmp(opt->index,(*optinsert)->index) > 0;
- optinsert= &(*optinsert)->next);
+
+ dselect_option **optinsert = optionspp;
+ while (*optinsert && strcmp(opt->index, (*optinsert)->index) > 0)
+ optinsert = &(*optinsert)->next;
opt->next= *optinsert;
*optinsert= opt;
(*nread)++;
int l;
int admindirlen;
char *p;
- method *meth;
- dselect_option *opt;
if (!methoptfile) {
admindirlen= strlen(admindir);
if (debug) fprintf(debug,"getcurrentopt() cmethopt space\n");
*p++= 0;
if (debug) fprintf(debug,"getcurrentopt() cmethopt meth name `%s'\n", methoptbuf);
- for (meth= methods; meth && strcmp(methoptbuf,meth->name); meth= meth->next);
+ method *meth = methods;
+ while (meth && strcmp(methoptbuf, meth->name))
+ meth = meth->next;
if (!meth) return;
if (debug) fprintf(debug,"getcurrentopt() cmethopt meth found; opt `%s'\n",p);
- for (opt= options; opt && (opt->meth != meth || strcmp(p,opt->name)); opt= opt->next);
+ dselect_option *opt = options;
+ while (opt && (opt->meth != meth || strcmp(p, opt->name)))
+ opt = opt->next;
if (!opt) return;
if (debug) fprintf(debug,"getcurrentopt() cmethopt opt found\n");
coption= opt;
}
if (comparewith->priority != pkginfo::pri_unset &&
(comparewith->priority != pkg->priority ||
- comparewith->priority == pkginfo::pri_other &&
- strcasecmp(comparewith->otherpriority,pkg->otherpriority)))
+ (comparewith->priority == pkginfo::pri_other &&
+ strcasecmp(comparewith->otherpriority, pkg->otherpriority))))
return 0;
if (comparewith->section &&
strcasecmp(comparewith->section,
*endp= cursorline+1;
return;
}
- int index;
- for (index= cursorline; index < nitems && !table[index]->pkg->name; index++);
+ int index = cursorline;
+ while (index < nitems && !table[index]->pkg->name)
+ index++;
if (index >= nitems) {
*startp= *endp= cursorline;
return;
fixbyupgrade= 0;
- for (possi= depends->list;
- possi && !deppossatisfied(possi,&fixbyupgrade);
- possi= possi->next);
+ possi = depends->list;
+ while (possi && !deppossatisfied(possi, &fixbyupgrade))
+ possi = possi->next;
if (depdebug && debug)
fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): depends found %s\n",
this,depends,
}
int packagelist::alreadydone(doneent **done, void *check) {
- doneent *search;
+ doneent *search = *done;
- for (search= *done; search && search->dep != check; search=search->next);
+ while (search && search->dep != check)
+ search = search->next;
if (search) return 1;
if (debug) fprintf(debug,"packagelist[%p]::alreadydone(%p,%p) new\n",
this,done,check);