From patchwork Thu Dec 8 04:27:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9465765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74D5C60459 for ; Thu, 8 Dec 2016 04:28:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C0CD2852C for ; Thu, 8 Dec 2016 04:28:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50D8F28549; Thu, 8 Dec 2016 04:28:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E023C2852C for ; Thu, 8 Dec 2016 04:28:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752958AbcLHE2R (ORCPT ); Wed, 7 Dec 2016 23:28:17 -0500 Received: from mx2.suse.de ([195.135.220.15]:43982 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752887AbcLHE2Q (ORCPT ); Wed, 7 Dec 2016 23:28:16 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A2065AAC8; Thu, 8 Dec 2016 04:28:15 +0000 (UTC) From: NeilBrown To: "J. Bruce Fields" , Steve Dickson Date: Thu, 08 Dec 2016 15:27:25 +1100 Subject: [PATCH 05/10] conffile: allow embedded spaces in values. Cc: linux-nfs@vger.kernel.org Message-ID: <148117124518.31271.13171167527354823323.stgit@noble> In-Reply-To: <148117122602.31271.13586847542442809540.stgit@noble> References: <148117122602.31271.13586847542442809540.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The code that said "Skip trailing spaces" actually skipped everything after the first space. Change to to only skip trailing spaces, or comments that start after a space. This is useful for lists: Foo: a, b, c The list handling already allows for internal spaces. Signed-off-by: NeilBrown --- support/nfs/conffile.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c index e4f685c558fa..57f58a2bcdc7 100644 --- a/support/nfs/conffile.c +++ b/support/nfs/conffile.c @@ -308,14 +308,18 @@ conf_parse_line(int trans, char *line, size_t sz) line ++; j = strcspn(line, "'"); line[j] = 0; - } else + } else { /* Skip trailing spaces and comments */ for (j = 0; val[j]; j++) { - if (val[j] == '#' || val[j] == ';' || isspace(val[j])) { + if ((val[j] == '#' || val[j] == ';') + && (j == 0 || isspace(val[j-1]))) { val[j] = '\0'; break; } } + while (j && isspace(val[j-1])) + val[--j] = '\0'; + } if (strcasecmp(line, "include") == 0) conf_load(trans, val); else