Jiri Moskovcak jmoskovc@redhat.com writes:
On 04/27/2011 04:58 PM, Miroslav Lichvar wrote:
On Wed, Apr 27, 2011 at 03:43:39PM +0200, Nikola Pajkovsky wrote:
Denys Vlasenkodvlasenk@redhat.com writes:
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 */
Massive NACK.
We could let users to put selected reporters into list separated by space. Then there is a nice function GList *str_to_glist(char *str, int delim) to parse list. Check what is selected and what reporters are actually printed out is piece of cake.
- so you're proposing to force users to write "Bugzilla, Logger" instead
of "1, 2" ?? And how is that better?
Of course the numbers! I wanted propose better solution than the ugly for cycle.
Not sure I understand. You are proposing to create a list of strings from the string entered by the user and then compare the two (unsorted) lists?
- I agree with Mirek's solution as it has been approved earlier. Nikola
couldn't know that because he wasn't here when we discussed it so that's why he might be confused.
put me into picture