From nobody Mon Apr 29 17:40:59 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1487749599748562.9326131165832; Tue, 21 Feb 2017 23:46:39 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8F1E182241; Tue, 21 Feb 2017 23:46:37 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 323C88216E for ; Tue, 21 Feb 2017 23:46:36 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Feb 2017 23:46:36 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by orsmga003.jf.intel.com with ESMTP; 21 Feb 2017 23:46:35 -0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,193,1484035200"; d="scan'208";a="936736463" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 22 Feb 2017 15:46:29 +0800 Message-Id: <20170222074630.545800-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 In-Reply-To: <20170222074630.545800-1-ruiyu.ni@intel.com> References: <20170222074630.545800-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 1/2] ShellPkg/comp: Rename variable names to proper ones X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jaben Carsey , Chen A Chen MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen A Chen The change doesn't impact the functionality. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen A Chen Cc: Jaben Carsey Reviewed-by: Jaben Carsey --- ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c | 46 +++++++++++-------= ---- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c b/ShellPkg/= Library/UefiShellDebug1CommandsLib/Comp.c index 2ab7dd3..829c49a 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c @@ -2,7 +2,7 @@ Main file for Comp shell Debug1 function. =20 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -31,11 +31,14 @@ ShellCommandRunComp ( EFI_STATUS Status; LIST_ENTRY *Package; CHAR16 *ProblemParam; + CHAR16 *FileName1; + CHAR16 *FileName2; + CONST CHAR16 *TempParam; SHELL_STATUS ShellStatus; UINTN LoopVar; SHELL_FILE_HANDLE FileHandle1; SHELL_FILE_HANDLE FileHandle2; - UINT8 ErrorCount; + UINT8 DifferentCount; UINT64 Size1; UINT64 Size2; UINT8 DataFromFile1; @@ -48,12 +51,9 @@ ShellCommandRunComp ( UINT8 ADF_File23; UINTN DataSizeFromFile1; UINTN DataSizeFromFile2; - CHAR16 *FileName1; - CHAR16 *FileName2; - CONST CHAR16 *TempParam; - UINTN ErrorAddress; + UINTN DiffPointAddress; =20 - ErrorCount =3D 0; + DifferentCount =3D 0; ShellStatus =3D SHELL_SUCCESS; Status =3D EFI_SUCCESS; FileName1 =3D NULL; @@ -125,12 +125,12 @@ ShellCommandRunComp ( ASSERT_EFI_ERROR(Status); if (Size1 !=3D Size2) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_SIZE_FAIL),= gShellDebug1HiiHandle); - ErrorCount++; + DifferentCount++; ShellStatus =3D SHELL_NOT_EQUAL; } } if (ShellStatus =3D=3D SHELL_SUCCESS) { - for (LoopVar =3D 0 ; LoopVar < Size1 && ErrorCount <=3D 10 ; LoopV= ar++) { + for (LoopVar =3D 0 ; LoopVar < Size1 && DifferentCount <=3D 10 ; L= oopVar++) { DataSizeFromFile1 =3D 1; DataSizeFromFile2 =3D 1; Status =3D gEfiShellProtocol->ReadFile(FileHandle1, &DataSizeFro= mFile1, &DataFromFile1); @@ -138,7 +138,7 @@ ShellCommandRunComp ( Status =3D gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFro= mFile2, &DataFromFile2); ASSERT_EFI_ERROR(Status); if (DataFromFile1 !=3D DataFromFile2) { - ErrorAddress =3D LoopVar; + DiffPointAddress =3D LoopVar; ADF_File11 =3D 0; ADF_File12 =3D 0; ADF_File13 =3D 0; @@ -188,13 +188,13 @@ ShellCommandRunComp ( NULL, STRING_TOKEN (STR_COMP_SPOT_FAIL4), gShellDebug1HiiHandle, - ++ErrorCount, + ++DifferentCount, FileName1, - ErrorAddress, + DiffPointAddress, DataFromFile1, ADF_File11, ADF_File12, ADF_File13, DataFromFile1, ADF_File11, ADF_File12, ADF_File13, FileName2, - ErrorAddress, + DiffPointAddress, DataFromFile2, ADF_File21, ADF_File22, ADF_File23, DataFromFile2, ADF_File21, ADF_File22, ADF_File23 ); @@ -205,13 +205,13 @@ ShellCommandRunComp ( NULL, STRING_TOKEN (STR_COMP_SPOT_FAIL3), gShellDebug1HiiHandle, - ++ErrorCount, + ++DifferentCount, FileName1, - ErrorAddress, + DiffPointAddress, DataFromFile1, ADF_File11, ADF_File12, DataFromFile1, ADF_File11, ADF_File12, FileName2, - ErrorAddress, + DiffPointAddress, DataFromFile2, ADF_File21, ADF_File22, DataFromFile2, ADF_File21, ADF_File22 ); @@ -222,13 +222,13 @@ ShellCommandRunComp ( NULL, STRING_TOKEN (STR_COMP_SPOT_FAIL2), gShellDebug1HiiHandle, - ++ErrorCount, + ++DifferentCount, FileName1, - ErrorAddress, + DiffPointAddress, DataFromFile1, ADF_File11, DataFromFile1, ADF_File11, FileName2, - ErrorAddress, + DiffPointAddress, DataFromFile2, ADF_File21, DataFromFile2, ADF_File21 ); @@ -239,13 +239,13 @@ ShellCommandRunComp ( NULL, STRING_TOKEN (STR_COMP_SPOT_FAIL1), gShellDebug1HiiHandle, - ++ErrorCount, + ++DifferentCount, FileName1, - ErrorAddress, + DiffPointAddress, DataFromFile1, DataFromFile1, FileName2, - ErrorAddress, + DiffPointAddress, DataFromFile2, DataFromFile2 ); @@ -253,7 +253,7 @@ ShellCommandRunComp ( ShellStatus =3D SHELL_NOT_EQUAL; } } - if (ErrorCount =3D=3D 0) { + if (DifferentCount =3D=3D 0) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_PASS= ), gShellDebug1HiiHandle); } else { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_FAIL= ), gShellDebug1HiiHandle); --=20 2.9.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Apr 29 17:40:59 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1487749602875413.1512005172044; Tue, 21 Feb 2017 23:46:42 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E847782223; Tue, 21 Feb 2017 23:46:39 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3A9C98216E for ; Tue, 21 Feb 2017 23:46:37 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Feb 2017 23:46:37 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by orsmga003.jf.intel.com with ESMTP; 21 Feb 2017 23:46:36 -0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,193,1484035200"; d="scan'208";a="936736470" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 22 Feb 2017 15:46:30 +0800 Message-Id: <20170222074630.545800-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 In-Reply-To: <20170222074630.545800-1-ruiyu.ni@intel.com> References: <20170222074630.545800-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 2/2] ShellPkg/comp: Add "-n "/"-s " support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jaben Carsey , Chen A Chen MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen A Chen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen A Chen Signed-off-by: Ruiyu Ni Cc: Jaben Carsey Reviewed-by: Jaben Carsey --- ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c | 357 +++++++++++++----= ---- .../UefiShellDebug1CommandsLib.uni | 27 +- 2 files changed, 229 insertions(+), 155 deletions(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c b/ShellPkg/= Library/UefiShellDebug1CommandsLib/Comp.c index 829c49a..62b59d7 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c @@ -15,6 +15,71 @@ =20 #include "UefiShellDebug1CommandsLib.h" =20 +STATIC CONST SHELL_PARAM_ITEM ParamList[] =3D { + {L"-n", TypeValue}, + {L"-s", TypeValue}, + {NULL, TypeMax} + }; + +typedef enum { + OutOfDiffPoint, + InDiffPoint, + InPrevDiffPoint +} READ_STATUS; + +/** + Function to print differnt point data. + + @param[in] FileName File name + @param[in] Buffer Data buffer to be printed. + @param[in] BufferSize Size of the data to be printed. + @param[in] Address Address of the differnt point. + @param[in] DifferentBytes Total size of the buffer. + +**/ +VOID +PrintDifferentPoint( + CONST CHAR16 *FileName, + UINT8 *Buffer, + UINT64 DataSize, + UINTN Address, + UINT64 BufferSize + ) +{ + UINTN Index; + + ShellPrintEx (-1, -1, L"%s: %s\r\n %08x:", L"File1", FileName, Address); + + // + // Print data in hex-format. + // + for (Index =3D 0; Index < DataSize; Index++) { + ShellPrintEx (-1, -1, L" %02x", Buffer[Index]); + } + + if (DataSize < BufferSize) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_COMP_END_OF_FILE), gS= hellDebug1HiiHandle); + } + + ShellPrintEx (-1, -1, L" *"); + + // + // Print data in char-format. + // + for (Index =3D 0; Index < DataSize; Index++) { + if (Buffer[Index] >=3D 0x20 && Buffer[Index] <=3D 0x7E) { + ShellPrintEx (-1, -1, L"%c", Buffer[Index]); + } else { + // + // Print dots for control characters + // + ShellPrintEx (-1, -1, L"."); + } + } + + ShellPrintEx (-1, -1, L"*\r\n"); +} + /** Function for 'comp' command. =20 @@ -35,32 +100,41 @@ ShellCommandRunComp ( CHAR16 *FileName2; CONST CHAR16 *TempParam; SHELL_STATUS ShellStatus; - UINTN LoopVar; SHELL_FILE_HANDLE FileHandle1; SHELL_FILE_HANDLE FileHandle2; - UINT8 DifferentCount; UINT64 Size1; UINT64 Size2; - UINT8 DataFromFile1; - UINT8 DataFromFile2; - UINT8 ADF_File11; - UINT8 ADF_File12; - UINT8 ADF_File13; - UINT8 ADF_File21; - UINT8 ADF_File22; - UINT8 ADF_File23; + UINT64 DifferentBytes; + UINT64 DifferentCount; + UINT8 DiffPointNumber; + UINT8 OneByteFromFile1; + UINT8 OneByteFromFile2; + UINT8 *DataFromFile1; + UINT8 *DataFromFile2; + UINTN InsertPosition1; + UINTN InsertPosition2; UINTN DataSizeFromFile1; UINTN DataSizeFromFile2; + UINTN TempAddress; + UINTN Index; UINTN DiffPointAddress; + READ_STATUS ReadStatus; =20 - DifferentCount =3D 0; ShellStatus =3D SHELL_SUCCESS; Status =3D EFI_SUCCESS; FileName1 =3D NULL; FileName2 =3D NULL; FileHandle1 =3D NULL; FileHandle2 =3D NULL; - Size1 =3D 0; + DataFromFile1 =3D NULL; + DataFromFile2 =3D NULL; + ReadStatus =3D OutOfDiffPoint; + DifferentCount =3D 10; + DifferentBytes =3D 4; + DiffPointNumber =3D 0; + InsertPosition1 =3D 0; + InsertPosition2 =3D 0; + TempAddress =3D 0; =20 // // initialize the shell lib (we must be in non-auto-init...) @@ -74,7 +148,7 @@ ShellCommandRunComp ( // // parse the command line // - Status =3D ShellCommandLineParse (EmptyParamList, &Package, &ProblemPara= m, TRUE); + Status =3D ShellCommandLineParse (ParamList, &Package, &ProblemParam, TR= UE); if (EFI_ERROR(Status)) { if (Status =3D=3D EFI_VOLUME_CORRUPTED && ProblemParam !=3D NULL) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShell= Debug1HiiHandle, L"comp", ProblemParam); =20 @@ -118,142 +192,165 @@ ShellCommandRunComp ( } } if (ShellStatus =3D=3D SHELL_SUCCESS) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_HEADER), gShe= llDebug1HiiHandle, FileName1, FileName2); Status =3D gEfiShellProtocol->GetFileSize(FileHandle1, &Size1); ASSERT_EFI_ERROR(Status); Status =3D gEfiShellProtocol->GetFileSize(FileHandle2, &Size2); ASSERT_EFI_ERROR(Status); - if (Size1 !=3D Size2) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_SIZE_FAIL),= gShellDebug1HiiHandle); - DifferentCount++; - ShellStatus =3D SHELL_NOT_EQUAL; + + if (ShellCommandLineGetFlag (Package, L"-n")) { + TempParam =3D ShellCommandLineGetValue (Package, L"-n"); + if (TempParam =3D=3D NULL) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE)= , gShellDebug1HiiHandle, L"comp", L"-n"); + ShellStatus =3D SHELL_INVALID_PARAMETER; + } else { + if (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)= TempParam, L"all") =3D=3D 0) { + DifferentCount =3D MAX_UINTN; + } else { + Status =3D ShellConvertStringToUint64 (TempParam, &Different= Count, FALSE, TRUE); + if (EFI_ERROR(Status) || DifferentCount =3D=3D 0) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBL= EM_VAL), gShellDebug1HiiHandle, L"comp", TempParam, L"-n"); + ShellStatus =3D SHELL_INVALID_PARAMETER; + } + } + } + } + + if (ShellCommandLineGetFlag (Package, L"-s")) { + TempParam =3D ShellCommandLineGetValue (Package, L"-s"); + if (TempParam =3D=3D NULL) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE)= , gShellDebug1HiiHandle, L"comp", L"-s"); + ShellStatus =3D SHELL_INVALID_PARAMETER; + } else { + Status =3D ShellConvertStringToUint64 (TempParam, &DifferentBy= tes, FALSE, TRUE); + if (EFI_ERROR(Status) || DifferentBytes =3D=3D 0) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM= _VAL), gShellDebug1HiiHandle, L"comp", TempParam, L"-s"); + ShellStatus =3D SHELL_INVALID_PARAMETER; + } else { + if (DifferentBytes > MAX (Size1, Size2)) { + DifferentBytes =3D MAX (Size1, Size2); + } + } + } } } + if (ShellStatus =3D=3D SHELL_SUCCESS) { - for (LoopVar =3D 0 ; LoopVar < Size1 && DifferentCount <=3D 10 ; L= oopVar++) { + DataFromFile1 =3D AllocateZeroPool ((UINTN)DifferentBytes); + DataFromFile2 =3D AllocateZeroPool ((UINTN)DifferentBytes); + if (DataFromFile1 =3D=3D NULL || DataFromFile2 =3D=3D NULL) { + ShellStatus =3D SHELL_OUT_OF_RESOURCES; + SHELL_FREE_NON_NULL (DataFromFile1); + SHELL_FREE_NON_NULL (DataFromFile2); + } + } + + if (ShellStatus =3D=3D SHELL_SUCCESS) { + while (DiffPointNumber < DifferentCount) { DataSizeFromFile1 =3D 1; DataSizeFromFile2 =3D 1; - Status =3D gEfiShellProtocol->ReadFile(FileHandle1, &DataSizeFro= mFile1, &DataFromFile1); - ASSERT_EFI_ERROR(Status); - Status =3D gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFro= mFile2, &DataFromFile2); - ASSERT_EFI_ERROR(Status); - if (DataFromFile1 !=3D DataFromFile2) { - DiffPointAddress =3D LoopVar; - ADF_File11 =3D 0; - ADF_File12 =3D 0; - ADF_File13 =3D 0; - ADF_File21 =3D 0; - ADF_File22 =3D 0; - ADF_File23 =3D 0; + OneByteFromFile1 =3D 0; + OneByteFromFile2 =3D 0; + Status =3D gEfiShellProtocol->ReadFile (FileHandle1, &DataSizeFr= omFile1, &OneByteFromFile1); + ASSERT_EFI_ERROR (Status); + Status =3D gEfiShellProtocol->ReadFile (FileHandle2, &DataSizeFr= omFile2, &OneByteFromFile2); + ASSERT_EFI_ERROR (Status); =20 - // - // Now check the next 3 bytes if possible. This will make out= put - // cleaner when there are a sequence of differences. - // - if (LoopVar + 1 < Size1) { - LoopVar++; - DataSizeFromFile1 =3D 1; - DataSizeFromFile2 =3D 1; - Status =3D gEfiShellProtocol->ReadFile(FileHandle1, &DataSiz= eFromFile1, &ADF_File11); - ASSERT_EFI_ERROR(Status); - Status =3D gEfiShellProtocol->ReadFile(FileHandle2, &DataSiz= eFromFile2, &ADF_File21); - ASSERT_EFI_ERROR(Status); - if (LoopVar + 1 < Size1) { - LoopVar++; - DataSizeFromFile1 =3D 1; - DataSizeFromFile2 =3D 1; - Status =3D gEfiShellProtocol->ReadFile(FileHandle1, &DataS= izeFromFile1, &ADF_File12); - ASSERT_EFI_ERROR(Status); - Status =3D gEfiShellProtocol->ReadFile(FileHandle2, &DataS= izeFromFile2, &ADF_File22); - ASSERT_EFI_ERROR(Status); - if (LoopVar + 1 < Size1) { - LoopVar++; - DataSizeFromFile1 =3D 1; - DataSizeFromFile2 =3D 1; - Status =3D gEfiShellProtocol->ReadFile(FileHandle1, &Dat= aSizeFromFile1, &ADF_File13); - ASSERT_EFI_ERROR(Status); - Status =3D gEfiShellProtocol->ReadFile(FileHandle2, &Dat= aSizeFromFile2, &ADF_File23); - ASSERT_EFI_ERROR(Status); - } + TempAddress++; + + // + // 1.When end of file and no chars in DataFromFile buffer, then = break while. + // 2.If no more char in File1 or File2, The ReadStatus is InPrev= DiffPoint forever. + // So the previous different point is the last one, then break= the while block. + // + if ( (DataSizeFromFile1 =3D=3D 0 && InsertPosition1 =3D=3D 0 && = DataSizeFromFile2 =3D=3D 0 && InsertPosition2 =3D=3D 0) || + (ReadStatus =3D=3D InPrevDiffPoint && (DataSizeFromFile1 = =3D=3D 0 || DataSizeFromFile2 =3D=3D 0)) + ) { + break; + } + + if (ReadStatus =3D=3D OutOfDiffPoint) { + if (OneByteFromFile1 !=3D OneByteFromFile2) { + ReadStatus =3D InDiffPoint; + DiffPointAddress =3D TempAddress; + if (DataSizeFromFile1 =3D=3D 1) { + DataFromFile1[InsertPosition1++] =3D OneByteFromFile1; + } + if (DataSizeFromFile2 =3D=3D 1) { + DataFromFile2[InsertPosition2++] =3D OneByteFromFile2; } } + } else if (ReadStatus =3D=3D InDiffPoint) { + if (DataSizeFromFile1 =3D=3D 1) { + DataFromFile1[InsertPosition1++] =3D OneByteFromFile1; + } + if (DataSizeFromFile2 =3D=3D 1) { + DataFromFile2[InsertPosition2++] =3D OneByteFromFile2; + } + } else if (ReadStatus =3D=3D InPrevDiffPoint) { + if (OneByteFromFile1 =3D=3D OneByteFromFile2) { + ReadStatus =3D OutOfDiffPoint; + } + } + + // + // ReadStatus should be always equal InDiffPoint. + // + if ( InsertPosition1 =3D=3D DifferentBytes || + InsertPosition2 =3D=3D DifferentBytes || + (DataSizeFromFile1 =3D=3D 0 && DataSizeFromFile2 =3D=3D 0) + ) { + + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_COMP_DIFFEREN= CE_POINT), gShellDebug1HiiHandle, ++DiffPointNumber); + PrintDifferentPoint (FileName1, DataFromFile1, InsertPosition1= , DiffPointAddress, DifferentBytes); + PrintDifferentPoint (FileName2, DataFromFile2, InsertPosition2= , DiffPointAddress, DifferentBytes); =20 // - // Print out based on highest of the 4 bytes that are differen= t. + // One of two buffuers is empty, it means this is the last dif= ferent point. // - if (ADF_File13 !=3D ADF_File23) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_COMP_SPOT_FAIL4), - gShellDebug1HiiHandle, - ++DifferentCount, - FileName1, - DiffPointAddress, - DataFromFile1, ADF_File11, ADF_File12, ADF_File13, - DataFromFile1, ADF_File11, ADF_File12, ADF_File13, - FileName2, - DiffPointAddress, - DataFromFile2, ADF_File21, ADF_File22, ADF_File23, - DataFromFile2, ADF_File21, ADF_File22, ADF_File23 - ); - } else if (ADF_File12 !=3D ADF_File22) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_COMP_SPOT_FAIL3), - gShellDebug1HiiHandle, - ++DifferentCount, - FileName1, - DiffPointAddress, - DataFromFile1, ADF_File11, ADF_File12, - DataFromFile1, ADF_File11, ADF_File12, - FileName2, - DiffPointAddress, - DataFromFile2, ADF_File21, ADF_File22, - DataFromFile2, ADF_File21, ADF_File22 - ); - } else if (ADF_File11 !=3D ADF_File21) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_COMP_SPOT_FAIL2), - gShellDebug1HiiHandle, - ++DifferentCount, - FileName1, - DiffPointAddress, - DataFromFile1, ADF_File11, - DataFromFile1, ADF_File11, - FileName2, - DiffPointAddress, - DataFromFile2, ADF_File21, - DataFromFile2, ADF_File21 - ); + if (InsertPosition1 =3D=3D 0 || InsertPosition2 =3D=3D 0) { + break; + } + + for (Index =3D 1; Index < InsertPosition1 && Index < InsertPos= ition2; Index++) { + if (DataFromFile1[Index] =3D=3D DataFromFile2[Index]) { + ReadStatus =3D OutOfDiffPoint; + break; + } + } + + if (ReadStatus =3D=3D OutOfDiffPoint) { + // + // Try to find a new different point in the rest of DataFrom= File. + // + for (; Index < MAX (InsertPosition1,InsertPosition2); Index+= +) { + if (DataFromFile1[Index] !=3D DataFromFile2[Index]) { + ReadStatus =3D InDiffPoint; + DiffPointAddress +=3D Index; + break; + } + } } else { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_COMP_SPOT_FAIL1), - gShellDebug1HiiHandle, - ++DifferentCount, - FileName1, - DiffPointAddress, - DataFromFile1, - DataFromFile1, - FileName2, - DiffPointAddress, - DataFromFile2, - DataFromFile2 - ); + // + // Doesn't find a new different point, still in the same dif= ferent point. + // + ReadStatus =3D InPrevDiffPoint; } - ShellStatus =3D SHELL_NOT_EQUAL; + + CopyMem (DataFromFile1, DataFromFile1 + Index, InsertPosition1= - Index); + CopyMem (DataFromFile2, DataFromFile2 + Index, InsertPosition2= - Index); + + SetMem (DataFromFile1 + InsertPosition1 - Index, (UINTN)Differ= entBytes - InsertPosition1 + Index, 0); + SetMem (DataFromFile2 + InsertPosition2 - Index, (UINTN)Differ= entBytes - InsertPosition2 + Index, 0); + + InsertPosition1 -=3D Index; + InsertPosition2 -=3D Index; } } - if (DifferentCount =3D=3D 0) { + + SHELL_FREE_NON_NULL (DataFromFile1); + SHELL_FREE_NON_NULL (DataFromFile2); + + if (DiffPointNumber =3D=3D 0) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_PASS= ), gShellDebug1HiiHandle); } else { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_FAIL= ), gShellDebug1HiiHandle); diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Com= mandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1C= ommandsLib.uni index 7c0ca98..2d5d16f 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLi= b.uni +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLi= b.uni @@ -65,31 +65,8 @@ #string STR_DBLK_HEADER #language en-US "LBA %016LX Size %08x by= tes BlkIo %0x\r\n" =20 #string STR_COMP_HEADER #language en-US "Compare %s to %s.\r\n" -#string STR_COMP_SIZE_FAIL #language en-US "Difference # 1: File si= ze mismatch.\r\n" -#string STR_COMP_SPOT_FAIL1 #language en-US "" - "Difference #% 2d:\r\n" - "File1: %s\r\n" - " %08x: %02x = *%c*\r\n" - "File2: %s\r\n" - " %08x: %02x = *%c*\r\n" -#string STR_COMP_SPOT_FAIL2 #language en-US "" - "Difference #% 2d:\r\n" - "File1: %s\r\n" - " %08x: %02x %02x = *%c%c*\r\n" - "File2: %s\r\n" - " %08x: %02x %02x = *%c%c*\r\n" -#string STR_COMP_SPOT_FAIL3 #language en-US "" - "Difference #% 2d:\r\n" - "File1: %s\r\n" - " %08x: %02x %02x %02x = *%c%c%c*\r\n" - "File2: %s\r\n" - " %08x: %02x %02x %02x = *%c%c%c*\r\n" -#string STR_COMP_SPOT_FAIL4 #language en-US "" - "Difference #% 2d:\r\n" - "File1: %s\r\n" - " %08x: %02x %02x %02x = %02x *%c%c%c%c*\r\n" - "File2: %s\r\n" - " %08x: %02x %02x %02x = %02x *%c%c%c%c*\r\n" +#string STR_COMP_DIFFERENCE_POINT #language en-US "Difference #% 2u:\r\n" +#string STR_COMP_END_OF_FILE #language en-US " " =20 #string STR_COMP_FOOTER_FAIL #language en-US "[difference(s) encounte= red] \r\n" #string STR_COMP_FOOTER_PASS #language en-US "[no differences encount= ered]\r\n" --=20 2.9.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel