On Mon, 2011-04-18 at 14:44 +0200, Miroslav Lichvar wrote:
- unsigned rating = rating_str ? xatou(rating_str) : 4;
+ unsigned i, rating = rating_str ? xatou(rating_str) : 4;
This looks like a step back to me (wrt readability).
I suggest putting these two variables on two separate lines.
+ char reporter_number[10], *c;
I suggest "reporter_number[sizeof(int)*3 + 2]" instead.
...
+ read_from_stdin(_("Which reporter(s) do you want to
use? "), wanted_reporters, sizeof(wanted_reporters));
...
+
+ /* Was this reporter requested? */
+ len = snprintf(reporter_number, sizeof(reporter_number), "%d",
i);
+ for (c = wanted_reporters; *c; c++) {
^^^^^^^^^^^^^ style violation
+ c = strstr(c, reporter_number);
+ if (!c || ((c == wanted_reporters || !isdigit(c[-1])) &&
!isdigit(c[len])))
+ break;
}
+ if (!c || !*c)
+ continue;
This code is sufficiently obscure to warrant comments.
Such as:
/* For each reporter, we check whether its number is in user's response */
len = snprintf...
for (c = wanted_reporters; *c; c++)
{
c = strstr(c, reporter_number);
if (!c)
break; /* no such number in user response at all */
if ((c == wanted_reporters || !isdigit(c[-1])) && !isdigit(c[len]))
break; /* we found exactly this number in user response */
/* the substring is inside some other number (example: "1" in
"11"),
* continue checking from the next position.
*/
}
if (!c || !*c)
continue; /* no such number in user response, skip this reporter
*/
--
vda