Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 3D696431FBC for ; Mon, 3 Dec 2012 14:17:48 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qozMOGvR7KWc for ; Mon, 3 Dec 2012 14:17:47 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7350E431FAE for ; Mon, 3 Dec 2012 14:17:47 -0800 (PST) Received: by mail-lb0-f181.google.com with SMTP id ge1so2944415lbb.26 for ; Mon, 03 Dec 2012 14:17:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=fe6/V+O1xM5x0osdonjsmHPGRXlAfhSPexCFsIkSN8E=; b=Bdhhyprf7xzv+PUffXtdB7JEektJBA2/ZBXhy44CqTJDMTHdhNOoK4lU88+XzTUyVo gUWvPVr7pDLtNnAVoRgRX9RAQFHxqdQ5qtOz9aSsp/vbqAztUOvet6p55BGcFjTTWFBe bm2dgXBhXNTPpeZNcfW8kd5lgnSjeN9yhAcWEz4Jfyz1bAbVhEUgQul2fWksKj8ZwO1E AHFKA/AaLlyc/hOQZJ0UdUi2jVOvur5hfhIRI57qXOi1E5zIbIH/s1KGaAxEnTkQZT46 Kpd6ruNTWkErzINCmhJmivYLpO3nCrrNFvAIc1nx5CmiUY2breIxksTgVEMVWC+hmE9C XpSw== Received: by 10.152.104.50 with SMTP id gb18mr11202974lab.9.1354573064706; Mon, 03 Dec 2012 14:17:44 -0800 (PST) Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi. [80.223.81.27]) by mx.google.com with ESMTPS id v6sm5984291lbf.11.2012.12.03.14.17.42 (version=SSLv3 cipher=OTHER); Mon, 03 Dec 2012 14:17:43 -0800 (PST) From: Jani Nikula To: Michal Nazarewicz , notmuch@notmuchmail.org Subject: Re: [PATCH 1/2] cli: fix notmuch top level argument parsing In-Reply-To: References: User-Agent: Notmuch/0.14+137~g9203c35 (http://notmuchmail.org) Emacs/23.4.1 (i686-pc-linux-gnu) Date: Tue, 04 Dec 2012 00:17:41 +0200 Message-ID: <874nk2aigq.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQkfpAZHwJZ5OzviS3ukM32OujtUNQJmeFMsJI/zUT4Fd9iaWo52lSbEMQFdbCOB2dt4hbSQ X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Dec 2012 22:17:48 -0000 On Mon, 03 Dec 2012, Michal Nazarewicz 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 =3D=3D 1) >> return notmuch (local); >>=20=20 >> - if (STRNCMP_LITERAL (argv[1], "--help") =3D=3D 0) >> + if (strcmp (argv[1], "--help") =3D=3D 0) >> return notmuch_help_command (NULL, argc - 1, &argv[1]); >>=20=20 >> - if (STRNCMP_LITERAL (argv[1], "--version") =3D=3D 0) { >> + if (strcmp (argv[1], "--version") =3D=3D 0) { >> printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); >> return 0; >> } > > --=20 > Best regards, _ _ > .o. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o > ..o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz = (o o) > ooo +------------------ooO--(_)--Ooo--