thanks krtaylor for a

Patch to cleanup some incorrect parsing, boundry conditions 
	and error checking in the llGetNotecardLine and 
	llGetNumberOfNotecardLines functions.
0.6.0-stable
Dr Scofield 2008-05-30 07:38:45 +00:00
parent d2aa2be788
commit 5b0d47dddb
1 changed files with 19 additions and 18 deletions

View File

@ -3827,7 +3827,11 @@ namespace OpenSim.Region.ScriptEngine.Common
// once it is implemented - krtaylor // once it is implemented - krtaylor
String[] notecardLines = GetNotecardLines(name); String[] notecardLines = GetNotecardLines(name);
if (!String.IsNullOrEmpty(notecardLines[0]))
line--; // array starts at 0
if ((!String.IsNullOrEmpty(notecardLines[0])) &&
(line >= 0) &&
(line < notecardLines.Length))
{ {
return notecardLines[line]; return notecardLines[line];
} }
@ -3858,7 +3862,7 @@ namespace OpenSim.Region.ScriptEngine.Common
{ {
// good, we have the notecard data as a string // good, we have the notecard data as a string
// now parse the text lines using the Linden Text delimiters // now parse the text lines using the Linden Text delimiters
notecardIndex = dataString.IndexOf("}\n"); notecardIndex = dataString.IndexOf("}\nText length ");
if (notecardIndex > 0) if (notecardIndex > 0)
{ {
notecardIndex = notecardIndex + 2; //get past delimiter notecardIndex = notecardIndex + 2; //get past delimiter
@ -3868,19 +3872,17 @@ namespace OpenSim.Region.ScriptEngine.Common
// Finally got to the first line of the notecard // Finally got to the first line of the notecard
// now find the end of the notecard text delimited by }<LF> // now find the end of the notecard text delimited by }<LF>
// parse the lines, delimited by <LF> // parse the lines, delimited by <LF>
char[] delimChar = { '\n' };
int notecardEof = dataString.IndexOf("}\n", notecardIndex);
if (notecardEof > 0)
{
int notecardLength = notecardEof - notecardIndex - 1;
notecardIndex = dataString.IndexOf("\n", notecardIndex); notecardIndex = dataString.IndexOf("\n", notecardIndex);
notecardIndex++; // get past delimiter notecardIndex++; // get past delimiter
int notecardLength = dataString.Length - notecardIndex - 3;
// create new string to parse that only consists of the actual lines in the asset // create new string to parse that only consists of the actual lines in the asset
Char[] notecardCharArray = dataString.ToCharArray(notecardIndex, notecardLength); Char[] notecardCharArray = dataString.ToCharArray(notecardIndex, notecardLength);
String notecardString = new String(notecardCharArray); String notecardString = new String(notecardCharArray);
// split the lines of the notecard into separate strings // split the lines of the notecard into separate strings
char[] delimChar = { '\n' };
notecardLines = notecardString.Split(delimChar); notecardLines = notecardString.Split(delimChar);
return notecardLines; return notecardLines;
} }
@ -3888,7 +3890,6 @@ namespace OpenSim.Region.ScriptEngine.Common
} }
} }
} }
}
return notecardLines; return notecardLines;
} }