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/edk2@12116 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -2956,6 +2956,7 @@ FileBufferSearch (
|
|||||||
BOOLEAN Found;
|
BOOLEAN Found;
|
||||||
|
|
||||||
Column = 0;
|
Column = 0;
|
||||||
|
Position = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// search if in current line
|
// search if in current line
|
||||||
@ -2969,20 +2970,20 @@ FileBufferSearch (
|
|||||||
Current = FileBuffer.CurrentLine->Buffer + FileBuffer.CurrentLine->Size;
|
Current = FileBuffer.CurrentLine->Buffer + FileBuffer.CurrentLine->Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Found = FALSE;
|
||||||
|
|
||||||
CharPos = StrStr (Current, Str);
|
CharPos = StrStr (Current, Str);
|
||||||
if (CharPos != NULL) {
|
if (CharPos != NULL) {
|
||||||
Position = CharPos - Current;
|
Position = CharPos - Current + 1;
|
||||||
} else {
|
Found = TRUE;
|
||||||
Position = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// found
|
// found
|
||||||
//
|
//
|
||||||
if (Position != 0) {
|
if (Found == TRUE) {
|
||||||
Column = (Position - 1) + FileBuffer.FilePosition.Column + Offset;
|
Column = (Position - 1) + FileBuffer.FilePosition.Column + Offset;
|
||||||
Row = FileBuffer.FilePosition.Row;
|
Row = FileBuffer.FilePosition.Row;
|
||||||
Found = TRUE;
|
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// not found so find through next lines
|
// not found so find through next lines
|
||||||
@ -2995,9 +2996,11 @@ FileBufferSearch (
|
|||||||
// Position = StrStr (Line->Buffer, Str);
|
// Position = StrStr (Line->Buffer, Str);
|
||||||
CharPos = StrStr (Line->Buffer, Str);
|
CharPos = StrStr (Line->Buffer, Str);
|
||||||
if (CharPos != NULL) {
|
if (CharPos != NULL) {
|
||||||
Position = CharPos - Line->Buffer;
|
Position = CharPos - Line->Buffer + 1;
|
||||||
|
Found = TRUE;
|
||||||
}
|
}
|
||||||
if (Position != 0) {
|
|
||||||
|
if (Found == TRUE) {
|
||||||
//
|
//
|
||||||
// found
|
// found
|
||||||
//
|
//
|
||||||
@ -3096,14 +3099,14 @@ FileBufferReplace (
|
|||||||
//
|
//
|
||||||
// set replace into it
|
// 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++) {
|
for (Index = 0; Index < ReplaceLen; Index++) {
|
||||||
Buffer[Index] = Replace[Index];
|
Buffer[Index] = Replace[Index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ReplaceLen < SearchLen) {
|
if (ReplaceLen < SearchLen) {
|
||||||
Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column;
|
Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column - 1;
|
||||||
|
|
||||||
for (Index = 0; Index < ReplaceLen; Index++) {
|
for (Index = 0; Index < ReplaceLen; Index++) {
|
||||||
Buffer[Index] = Replace[Index];
|
Buffer[Index] = Replace[Index];
|
||||||
@ -3122,7 +3125,7 @@ FileBufferReplace (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ReplaceLen == SearchLen) {
|
if (ReplaceLen == SearchLen) {
|
||||||
Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column;
|
Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column - 1;
|
||||||
for (Index = 0; Index < ReplaceLen; Index++) {
|
for (Index = 0; Index < ReplaceLen; Index++) {
|
||||||
Buffer[Index] = Replace[Index];
|
Buffer[Index] = Replace[Index];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user