diff options
author | John Hurliman | 2010-09-17 14:32:49 -0700 |
---|---|---|
committer | John Hurliman | 2010-09-17 14:32:49 -0700 |
commit | e603521fd765fc42274aafff3ca35272e172a9cf (patch) | |
tree | c65174abfad467bde6b22c888429f085c9cd0842 /OpenSim/Region/ScriptEngine/Shared/Api | |
parent | Fixed a regression in SOG.Copy() (diff) | |
download | opensim-SC_OLD-e603521fd765fc42274aafff3ca35272e172a9cf.zip opensim-SC_OLD-e603521fd765fc42274aafff3ca35272e172a9cf.tar.gz opensim-SC_OLD-e603521fd765fc42274aafff3ca35272e172a9cf.tar.bz2 opensim-SC_OLD-e603521fd765fc42274aafff3ca35272e172a9cf.tar.xz |
Applying the llParseString2List() patch from #5036 that Melanie claims was already applied
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 103 |
1 files changed, 22 insertions, 81 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 01c026e..d59cafa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -5579,78 +5579,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5579 | ScriptSleep(5000); | 5579 | ScriptSleep(5000); |
5580 | } | 5580 | } |
5581 | 5581 | ||
5582 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | ||
5583 | { | ||
5584 | m_host.AddScriptLPS(1); | ||
5585 | LSL_List ret = new LSL_List(); | ||
5586 | LSL_List spacers = new LSL_List(); | ||
5587 | if (in_spacers.Length > 0 && separators.Length > 0) | ||
5588 | { | ||
5589 | for (int i = 0; i < in_spacers.Length; i++) | ||
5590 | { | ||
5591 | object s = in_spacers.Data[i]; | ||
5592 | for (int j = 0; j < separators.Length; j++) | ||
5593 | { | ||
5594 | if (separators.Data[j].ToString() == s.ToString()) | ||
5595 | { | ||
5596 | s = null; | ||
5597 | break; | ||
5598 | } | ||
5599 | } | ||
5600 | if (s != null) | ||
5601 | { | ||
5602 | spacers.Add(s); | ||
5603 | } | ||
5604 | } | ||
5605 | } | ||
5606 | object[] delimiters = new object[separators.Length + spacers.Length]; | ||
5607 | separators.Data.CopyTo(delimiters, 0); | ||
5608 | spacers.Data.CopyTo(delimiters, separators.Length); | ||
5609 | bool dfound = false; | ||
5610 | do | ||
5611 | { | ||
5612 | dfound = false; | ||
5613 | int cindex = -1; | ||
5614 | string cdeli = ""; | ||
5615 | for (int i = 0; i < delimiters.Length; i++) | ||
5616 | { | ||
5617 | int index = str.IndexOf(delimiters[i].ToString()); | ||
5618 | bool found = index != -1; | ||
5619 | if (found && String.Empty != delimiters[i].ToString()) | ||
5620 | { | ||
5621 | if ((cindex > index) || (cindex == -1)) | ||
5622 | { | ||
5623 | cindex = index; | ||
5624 | cdeli = delimiters[i].ToString(); | ||
5625 | } | ||
5626 | dfound = dfound || found; | ||
5627 | } | ||
5628 | } | ||
5629 | if (cindex != -1) | ||
5630 | { | ||
5631 | if (cindex > 0) | ||
5632 | { | ||
5633 | ret.Add(new LSL_String(str.Substring(0, cindex))); | ||
5634 | } | ||
5635 | // Cannot use spacers.Contains() because spacers may be either type String or LSLString | ||
5636 | for (int j = 0; j < spacers.Length; j++) | ||
5637 | { | ||
5638 | if (spacers.Data[j].ToString() == cdeli) | ||
5639 | { | ||
5640 | ret.Add(new LSL_String(cdeli)); | ||
5641 | break; | ||
5642 | } | ||
5643 | } | ||
5644 | str = str.Substring(cindex + cdeli.Length); | ||
5645 | } | ||
5646 | } while (dfound); | ||
5647 | if (str != "") | ||
5648 | { | ||
5649 | ret.Add(new LSL_String(str)); | ||
5650 | } | ||
5651 | return ret; | ||
5652 | } | ||
5653 | |||
5654 | public LSL_Integer llOverMyLand(string id) | 5582 | public LSL_Integer llOverMyLand(string id) |
5655 | { | 5583 | { |
5656 | m_host.AddScriptLPS(1); | 5584 | m_host.AddScriptLPS(1); |
@@ -8414,7 +8342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8414 | // of arrays or other objects. | 8342 | // of arrays or other objects. |
8415 | // </remarks> | 8343 | // </remarks> |
8416 | 8344 | ||
8417 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | 8345 | private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
8418 | { | 8346 | { |
8419 | int beginning = 0; | 8347 | int beginning = 0; |
8420 | int srclen = src.Length; | 8348 | int srclen = src.Length; |
@@ -8434,8 +8362,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8434 | 8362 | ||
8435 | LSL_List tokens = new LSL_List(); | 8363 | LSL_List tokens = new LSL_List(); |
8436 | 8364 | ||
8437 | m_host.AddScriptLPS(1); | ||
8438 | |||
8439 | // All entries are initially valid | 8365 | // All entries are initially valid |
8440 | 8366 | ||
8441 | for (int i = 0; i < mlen; i++) | 8367 | for (int i = 0; i < mlen; i++) |
@@ -8507,14 +8433,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8507 | { | 8433 | { |
8508 | // no markers were found on this pass | 8434 | // no markers were found on this pass |
8509 | // so we're pretty much done | 8435 | // so we're pretty much done |
8510 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | 8436 | if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) |
8437 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
8511 | break; | 8438 | break; |
8512 | } | 8439 | } |
8513 | 8440 | ||
8514 | // Otherwise we just add the newly delimited token | 8441 | // Otherwise we just add the newly delimited token |
8515 | // and recalculate where the search should continue. | 8442 | // and recalculate where the search should continue. |
8516 | 8443 | if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) | |
8517 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 8444 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); |
8518 | 8445 | ||
8519 | if (best < seplen) | 8446 | if (best < seplen) |
8520 | { | 8447 | { |
@@ -8523,7 +8450,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8523 | else | 8450 | else |
8524 | { | 8451 | { |
8525 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | 8452 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; |
8526 | tokens.Add(new LSL_String(spcarray[best - seplen].ToString())); | 8453 | string str = spcarray[best - seplen].ToString(); |
8454 | if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) | ||
8455 | tokens.Add(new LSL_String(str)); | ||
8527 | } | 8456 | } |
8528 | } | 8457 | } |
8529 | 8458 | ||
@@ -8533,7 +8462,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8533 | // arduous. Alternatively the 'break' could be replced with a return | 8462 | // arduous. Alternatively the 'break' could be replced with a return |
8534 | // but that's shabby programming. | 8463 | // but that's shabby programming. |
8535 | 8464 | ||
8536 | if (beginning == srclen) | 8465 | if ((beginning == srclen) && (keepNulls)) |
8537 | { | 8466 | { |
8538 | if (srclen != 0) | 8467 | if (srclen != 0) |
8539 | tokens.Add(new LSL_String("")); | 8468 | tokens.Add(new LSL_String("")); |
@@ -8541,7 +8470,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8541 | 8470 | ||
8542 | return tokens; | 8471 | return tokens; |
8543 | } | 8472 | } |
8544 | 8473 | ||
8474 | public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) | ||
8475 | { | ||
8476 | m_host.AddScriptLPS(1); | ||
8477 | return this.ParseString(src, separators, spacers, false); | ||
8478 | } | ||
8479 | |||
8480 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | ||
8481 | { | ||
8482 | m_host.AddScriptLPS(1); | ||
8483 | return this.ParseString(src, separators, spacers, true); | ||
8484 | } | ||
8485 | |||
8545 | public LSL_Integer llGetObjectPermMask(int mask) | 8486 | public LSL_Integer llGetObjectPermMask(int mask) |
8546 | { | 8487 | { |
8547 | m_host.AddScriptLPS(1); | 8488 | m_host.AddScriptLPS(1); |