X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellDebug1CommandsLib%2FEdit%2FFileBuffer.c;fp=ShellPkg%2FLibrary%2FUefiShellDebug1CommandsLib%2FEdit%2FFileBuffer.c;h=ba622983e1a19ccc066da1b7ca961a98d6e44bef;hb=382e78c09ccaee02c8e709f630c9e094d37be470;hp=9a2427f4e995f8aba9fd80ca168f6ba2129b359c;hpb=b5827cbd09f9fe3fa649036bd7aeae4f8546cd18;p=mirror_edk2.git diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c index 9a2427f4e9..ba622983e1 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c @@ -2956,7 +2956,8 @@ FileBufferSearch ( BOOLEAN Found; Column = 0; - + Position = 0; + // // search if in current line // @@ -2969,20 +2970,20 @@ FileBufferSearch ( Current = FileBuffer.CurrentLine->Buffer + FileBuffer.CurrentLine->Size; } + Found = FALSE; + CharPos = StrStr (Current, Str); if (CharPos != NULL) { - Position = CharPos - Current; - } else { - Position = 0; - } + Position = CharPos - Current + 1; + Found = TRUE; + } // // found // - if (Position != 0) { + if (Found == TRUE) { Column = (Position - 1) + FileBuffer.FilePosition.Column + Offset; Row = FileBuffer.FilePosition.Row; - Found = TRUE; } else { // // not found so find through next lines @@ -2995,9 +2996,11 @@ FileBufferSearch ( // Position = StrStr (Line->Buffer, Str); CharPos = StrStr (Line->Buffer, Str); if (CharPos != NULL) { - Position = CharPos - Line->Buffer; - } - if (Position != 0) { + Position = CharPos - Line->Buffer + 1; + Found = TRUE; + } + + if (Found == TRUE) { // // found // @@ -3096,14 +3099,14 @@ FileBufferReplace ( // // set replace into it // - Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column; + Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column - 1; for (Index = 0; Index < ReplaceLen; Index++) { Buffer[Index] = Replace[Index]; } } if (ReplaceLen < SearchLen) { - Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column; + Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column - 1; for (Index = 0; Index < ReplaceLen; Index++) { Buffer[Index] = Replace[Index]; @@ -3122,7 +3125,7 @@ FileBufferReplace ( } if (ReplaceLen == SearchLen) { - Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column; + Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column - 1; for (Index = 0; Index < ReplaceLen; Index++) { Buffer[Index] = Replace[Index]; }