From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.101.70; helo=foss.arm.com; envelope-from=supreeth.venkatesh@arm.com; receiver=edk2-devel@lists.01.org Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id D108321B02822 for ; Wed, 28 Nov 2018 14:30:01 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 75D7A80D; Wed, 28 Nov 2018 14:30:01 -0800 (PST) Received: from supven01-VirtualBox (u203142.arm.com [10.118.30.24]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 451683F575; Wed, 28 Nov 2018 14:30:01 -0800 (PST) Message-ID: From: Supreeth Venkatesh To: Lokesh B V , edk2-devel@lists.01.org Date: Wed, 28 Nov 2018 16:29:58 -0600 In-Reply-To: <1543397402-19411-5-git-send-email-lokesh.bv@arm.com> References: <1543397402-19411-1-git-send-email-lokesh.bv@arm.com> <1543397402-19411-5-git-send-email-lokesh.bv@arm.com> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Subject: Re: [edk2-test][PATCH v2] SctPkg/Tools: Fix incorrect line ending detection by GenBin tool X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 X-List-Received-Date: Wed, 28 Nov 2018 22:30:02 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit On Wed, 2018-11-28 at 15:00 +0530, Lokesh B V wrote: > Some windows editors uses "\r\n" for line feed. While processing uefi > sct testcase info file, the GenBin tool logic to skip line feed > doesn't > consider the presence of carraige return(\r) in line feed. So this Changed to "consider the presence of carriage return(\r)" > results > in incorrect format error. > > Fixed this issue by changing logic of Trim and Getline functions used > in GenBin source code. > > Cc: Supreeth Venkatesh > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Lokesh B V Reviewed-by: Supreeth Venkatesh Pushed with additional changes inline below. > --- > Changes since v1: > * Adopted changes suggested by Supreeth. > * modified Copyright content > > uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c | 58 +++++++++++++----- > ---------- > 1 file changed, 26 insertions(+), 32 deletions(-) > > diff --git a/uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c b/uefi- > sct/SctPkg/Tools/Source/GenBin/GenBin.c > index 61bb35b..6d8e844 100644 > --- a/uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c > +++ b/uefi-sct/SctPkg/Tools/Source/GenBin/GenBin.c > @@ -2,6 +2,7 @@ > > Copyright 2006 - 2010 Unified EFI, Inc.
> Copyright (c) 2010 Intel Corporation. All rights reserved.
> + Copyright (c) 2018 ARM Ltd. All rights reserved.
> > This program and the accompanying materials > are licensed and made available under the terms and conditions of > the BSD License > @@ -32,6 +33,7 @@ Abstract: > #include > #include > #include > +#include > > // > // Definitions > @@ -49,7 +51,7 @@ PrintUsage ( > void > ); > > -void > +char * > Trim ( > char *String > ); > @@ -159,50 +161,42 @@ PrintUsage ( > } > > > -void > +char * > Trim ( > char *String > ) > { > - int Index1; > - int Index2; > int Length; > + char *end; > > Length = strlen (String); > > - // > - // Remove the space characters from the beginning of this string > - // > - for (Index1 = 0; Index1 < Length; Index1++) { > - if ((String[Index1] != ' ' ) && > - (String[Index1] != '\t') && > - (String[Index1] != '\n')) { > - break; > - } > - } > - > - for (Index2 = Index1; Index2 < Length; Index2++) { > - String[Index2 - Index1] = String[Index2]; > + if (!Length) { > + return String; > } > > - Length = Length - Index1; > + end = String + Length - 1; > > // > // Remove the space characters from the end of this string > // > - for (Index1 = 0; Index1 < Length; Index1++) { > - if ((String[Length - 1 - Index1] != ' ' ) && > - (String[Length - 1 - Index1] != '\t') && > - (String[Length - 1 - Index1] != '\n')) { > - break; > - } > + while (end >= String && isspace (*end)) { > + end--; > } > > - String[Length - Index1] = '\0'; > + *(end + 1) = '\0'; > + > + // > + // Remove the space characters from the beginning of this string > + // > + while (*String && isspace (*String)) { > + String++; > + } > > // > // Done > // > + return String; > } > > > @@ -227,20 +221,20 @@ GetLine ( > return -1; > } > > - (*LineNo)++; > - > // > // Remove the beginning and ending space characters > // > - Trim (String); > + String = Trim (Result); > > // > - // Ignore the empty line and comment line > + // Skip the empty line and comment line > // > - if ((String[0] != '\0') && > - (String[0] != '#' )) { > - break; > + if ((String[0] == '\0') || > + (String[0] == '#' )) { > + continue; > } > + > + (*LineNo)++; As LineNo is being used only for printing where the issue is, we should increment line number as soon as fgets yields successful output. Changed this and committed. > } > > //