unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: Michal Nazarewicz <mina86@mina86.com>, notmuch@notmuchmail.org
Subject: Re: [PATCH 1/2] cli: fix notmuch top level argument parsing
Date: Tue, 04 Dec 2012 00:17:41 +0200	[thread overview]
Message-ID: <874nk2aigq.fsf@nikula.org> (raw)
In-Reply-To: <xa1tpq2qstx7.fsf@mina86.com>

On Mon, 03 Dec 2012, Michal Nazarewicz <mina86@mina86.com> wrote:
> On Mon, Dec 03 2012, Jani Nikula wrote:
>> Use strcmp instead of STRNCMP_LITERAL, which matches the prefix
>> instead of the whole argument.
>
> Perhaps add and use this instead:
>
> #define STRCMP_LITERAL(var, literal) \
>     strncmp ((var), (literal), sizeof (literal))

That's broken the same way STRNCMP_LITERAL is broken in this use case:
it matches if literal is a prefix of var.

BR,
Jani.


>
> Than again, it's argument parsing so hardly a performance critical path,
> so maybe readability is more important.
>
>> ---
>>  notmuch.c |    4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/notmuch.c b/notmuch.c
>> index 477a09c..4ff66e3 100644
>> --- a/notmuch.c
>> +++ b/notmuch.c
>> @@ -245,10 +245,10 @@ main (int argc, char *argv[])
>>      if (argc == 1)
>>  	return notmuch (local);
>>  
>> -    if (STRNCMP_LITERAL (argv[1], "--help") == 0)
>> +    if (strcmp (argv[1], "--help") == 0)
>>  	return notmuch_help_command (NULL, argc - 1, &argv[1]);
>>  
>> -    if (STRNCMP_LITERAL (argv[1], "--version") == 0) {
>> +    if (strcmp (argv[1], "--version") == 0) {
>>  	printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n");
>>  	return 0;
>>      }
>
> -- 
> Best regards,                                         _     _
> .o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
> ..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
> ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

  reply	other threads:[~2012-12-03 22:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-03 20:56 [PATCH 1/2] cli: fix notmuch top level argument parsing Jani Nikula
2012-12-03 20:56 ` [PATCH 2/2] cli: convert "notmuch new" to the argument parser Jani Nikula
2012-12-03 22:28   ` Austin Clements
2012-12-03 22:35     ` Jani Nikula
2012-12-03 21:32 ` [PATCH 1/2] cli: fix notmuch top level argument parsing Michal Nazarewicz
2012-12-03 22:17   ` Jani Nikula [this message]
2012-12-03 22:30     ` Jani Nikula
2012-12-04 14:00       ` Michal Nazarewicz
2012-12-04 13:16 ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874nk2aigq.fsf@nikula.org \
    --to=jani@nikula.org \
    --cc=mina86@mina86.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).