Re: [dev][ii][patch] Allow calling ii without any argument (using defaults)

From: Jean-Philippe Gagné Guay <jeanphilippe150_AT_gmail.com>
Date: Thu, 1 May 2014 14:57:14 -0400

On 01/05/14 11:36, Evan Gates wrote:
> On Thu, May 1, 2014 at 8:29 AM, Jean-Philippe Gagné Guay
> <jeanphilippe150_AT_gmail.com> wrote:
> > I am not sure I understand why this would be wrong. Shouldn't calling ii (via
> > ii or not) without arguments use the default values descibed in the man page?
>
> My point is that argc will never be less than 1 (AFAIK). If you want
> to use default values when no arguments are given remove that check
> altogether.
>
> -emg
>

Ok, I initially just removed that check, but since the original code checked for
argc < 1, I kept it thinking there was perhaps something I didn't understand.

Here is the patch removing that check:

diff --git a/ii.c b/ii.c
index d93266c..c66edf4 100644
--- a/ii.c
+++ b/ii.c
_AT_@ -466,7 +466,7 @@ int main(int argc, char *argv[]) {
         }
         snprintf(nick, sizeof(nick), "%s", spw->pw_name);
         snprintf(prefix, sizeof(prefix),"%s/irc", spw->pw_dir);
- if (argc <= 1 || (argc == 2 && argv[1][0] == '-' && argv[1][1] == 'h')) usage();
+ if (argc == 2 && argv[1][0] == '-' && argv[1][1] == 'h') usage();
 
         for(i = 1; (i + 1 < argc) && (argv[i][0] == '-'); i++) {
                 switch (argv[i][1]) {
Received on Thu May 01 2014 - 20:57:14 CEST

This archive was generated by hypermail 2.3.0 : Thu May 01 2014 - 21:00:15 CEST