summaryrefslogtreecommitdiff
path: root/edk2/ShellPkg
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-10 14:48:14 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-10 14:48:14 +0000
commit792af29e88821708dd12b9093ffabbe5cfe0afff (patch)
tree9c48a562cf2d5d29401a21a71031f456cdc2db81 /edk2/ShellPkg
parent991611d32ab6e21ddc47aaef565ffa5e1bab2977 (diff)
ShellPkg: bug fix for edit search/replace function
* Fix the search bug: if word to be searched at the beginning of the line, it can not be found out. Signed-off-by: kidzyoung reviewed-by: jcarsey git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk@12116 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'edk2/ShellPkg')
-rw-r--r--edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c b/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
index 9a2427f4e..ba622983e 100644
--- a/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
+++ b/edk2/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];
}