Commit graph

873 commits

Author SHA1 Message Date
Sei Lisa
dc655e3501 Monkey-patch some string functions in narrow string builds
The official distribution of Python 2.7 on Windows is built with "narrow strings" (UTF-16 strings with no proper indexing or length). This makes some tests fail. "Fix" this by monkey-patching a few functions and using a wrapping unicode class, as we can't monkey-patch the actual unicode type.

This is very fragile code, but it's the best we could do given the limitations.
2022-12-11 23:22:42 +01:00
Sei Lisa
79a57e6532 Fix some discrepancies between main and run-tests
These discrepancies were in how line endings are interpreted, and were causing issues under Windows.

Also simplify CRLF handling.
2022-12-11 18:54:48 +01:00
Sei Lisa
cc55c4c23e Revamp encoding handling in lslloadlib
There were multiple encoding issues, especially on Windows. Address them by loading the file in binary and converting to Unicode for internal use. This means that the function/event tables are now Unicode.

Originally reported by @Tonaie (see #20).
2022-12-08 17:19:19 +01:00
Sei Lisa
0b7d04e5ff Deal with changes in llChar, strengthen some tests
Previously, llChar formed an UTF-8-1993 string with the given code and converted that, resulting in multiple question marks when the conversion to Unicode forced by Mono caused errors in multiple characters. They have changed the implementation and now it also considers U+FFFF invalid, and only returns one U+FFFD character if the input is invalid, and LSO behaves the same as Mono (no UTF-8-1993 anymore).

We've also detected problems with Windows (who else would it be) for the Unicode "astral" planes (planes beyond the Basic Multilingual Plane), so now there are new tests that include characters > U+FFFF. And since some builds of Python 2 use UTF-16 internally, we also check llSubString and friends with positions after an astral plane character. This is currently failing under Windows, as there are numerous encoding and line ending problems happening on that OS, especially with Python 3.
2022-12-08 13:22:54 +01:00
Sei Lisa
947dcd9383 Add new LinksetData functions and other builtins 2022-11-15 23:11:38 +01:00
Sei Lisa
08c429f22b Add IfElseSwap option
This enables an option that was being done unconditionally: to swap the `if` and `else` branches if the condition is shorter when negated.

Enabled by default.
2022-10-31 20:08:26 +01:00
Sei Lisa
e62b5ffcb6 Fix exception when a global references another without constfold
Fixes #19. Thanks to SaladDais for the report and test case.

With constant folding inactive, the dead code removal optimization was removing globals and their symbols when they were e.g. integer constants, without substituting them in other globals. This produced a crash when the output module tried to access said symbols.

For example, in this code:

```
integer A = 1;
integer B = A;
default{timer(){llBreakLink(B);}}
```

the line `integer A = 1` was being removed, as well as the `A` global symbol, but the line `integer B = A` was retained with the missing symbol, and the output module crashed when trying to look up the `A` symbol.

Apparently, it wasn't an issue when constant folding was active (which is why it went unnoticed for so long) because the constant folding code sets 'orig' in the symbol table to the original value the variable was being set to, which let the output module know what to output.

The fix is to replace the references to deleted symbols with their values in global definitions. In normal code that was already happening.
2022-10-31 18:42:19 +01:00
Sei Lisa
1df05ed0d7 The grammar comment for simple_expr_except_list was missing IDENT 2022-10-31 17:20:25 +01:00
Sei Lisa
9c281dec64 New function, llSHA256String
Implement it in lslbasefuncs.py, and add tests. Also add more test vectors for llMD5String and llSHA1String.
2022-10-14 18:39:04 +02:00
Sei Lisa
8966b9de97 New upstream function: llGetObjectLinkKey 2022-10-01 01:18:12 +02:00
Sei Lisa
3f77f14eac Upstream update, new function llSetEnvironment
This commit was in the preprocessor branch by mistake; it has now been brought to the master branch.
2022-09-15 01:10:33 +02:00
Sei Lisa
bc992e6182 LL change: the status of STATUS_DIE_AT_* is returned
As of Second Life Server 2022-09-09.574921, STATUS_DIE_AT_EDGE and STATUS_DIE_AT_NO_ENTRY return their corresponding settings rather than always FALSE.

Regression/coverage tests are clearly lacking in this area, as the change didn't trigger any test breakage, therefore add some unit tests.
2022-09-15 01:09:12 +02:00
Sei Lisa
95d0fb4b13 New upstream version of builtins.txt; minor fix
Add comment to llGetStatus and make it more future-proof by adding unused flags.
2022-08-26 12:51:02 +02:00
Sei Lisa
52771ce630 Add pperrors variable to ease rebasing the preprocessor branch 2022-06-17 16:13:49 +02:00
Sei Lisa
7eaa4cb0ad Fix --postarg and add option --preproc-show-cmdline + unit test
Thanks to @Blues-Today for reporting that --postarg was not working.

This needed a regression test, and the best way to distinguish --prearg from --postarg is to display the full preprocessor command line, therefore a new option was added for that purpose: --preproc-show-cmdline

Fixes #18.
2022-06-17 16:13:22 +02:00
Sei Lisa
8d413f910e Forgot to update copyright year 2022-06-07 19:46:31 +02:00
Sei Lisa
fb61e00780 Minor cleanup 2022-06-07 19:39:26 +02:00
Sei Lisa
9dedabfa71 Don't rely on Python generating Indet on (float)"-nan"
We did the same for vectors. We don't have enough guarantee that Python will return Indet when evaluating float(u"-nan").
2022-05-19 14:42:01 +02:00
Sei Lisa
07cf4fe30f LSO does not force positive zero in llDumpList2String
And minor aesthetic change.
2022-05-19 14:29:14 +02:00
Sei Lisa
828b020b8c Remove disabled code 2022-05-17 22:30:07 +02:00
Sei Lisa
d2e64e25a6 Rewrite Mono float to string conversion; fix llDumpList2String
llDumpList2String has changed its behaviour with respect to minus zero. Now it converts -0.0 to a string without the minus sign.

While testing this, we noticed several mismatches in the float to string conversions; the existing routine did not properly convert some values because as we discovered later, it is subject to double rounding; one of them is the built-in round-to-nearest-or-even while getting the first 7 significant digits, and the other is just an increment when the digit is a 5 or more, so round to nearest, ties away from zero, and is performed on the digit past the five or six visible digits that LSL shows.

The new code is a tad easier to understand and more robust.

A first variant of the new code is left commented out for history's sake, and will be removed in the next commit.
2022-05-17 22:28:49 +02:00
Sei Lisa
281ff4d96a Strings representing denormals no longer give 0 when cast to float
This annoyance and discrepancy with LSO was finally fixed by Linden Lab. The change has prompted some modifications to the test suite to accommodate for the new results. A further improvement has been to make these tests more friendly to be run in SL, making it easier to verify the results.

Fixes #17.

Reported by SaladDais@users.noreply.github.com - thanks!
2022-05-17 13:48:05 +02:00
Sei Lisa
7c630f4ce4 Fix crash in conversion to string for floats < 1e-13
Fixes part of #17.

Reported by SaladDais@users.noreply.github.com, thanks!
2022-05-17 13:37:39 +02:00
Sei Lisa
c29475d072 New constants and functions; some refactoring of lslfuncopt
TODO: unit tests
2022-05-13 14:49:18 +02:00
Sei Lisa
be479771aa Implement llListRandomize for the calculator 2022-03-29 23:29:09 +02:00
Sei Lisa
02b37d6dad Add OBJECT_ACCOUNT_LEVEL, fix PRIM_PROJECTOR 2022-03-06 02:54:58 +01:00
Sei Lisa
bf72d2c3bf Allow //pragma inline or /*pragma inline*/ for inlining a function
They are transformed by the scanner to the identifier `inline`, which is how the parser identifies it. This solves the comment problem, but it results in a funny side effect. Now, in inline mode, /*pragma inline*/ will always be the identifier `inline`, therefore this is valid:

    integer /*pragma inline*/ = 5;
    llOwnerSay((string)inline); // will say 5

Not overly elegant, but better than making up a specific token or declaring comments as tokens or the like.
2021-10-17 20:29:22 +02:00
Sei Lisa
064a8c4319 Add PRIM_PROJECTOR, add PRIM_TYPE_LEGACY, minor cleanups 2021-10-17 19:08:21 +02:00
Sei Lisa
f6fe3dd7bd Add llGetInventoryAcquireTime 2021-06-12 19:18:23 +02:00
Sei Lisa
03c33d1471 Simplify comparisons for most cases in llChar 2021-05-19 22:49:14 +02:00
Sei Lisa
cfafb1e9d1 Add llOpenFloater 2021-05-19 22:48:44 +02:00
Sei Lisa
c4f210138f Add newly introduced functions llOrd, llChar, llHash 2021-05-08 22:43:31 +02:00
Sei Lisa
3400d19132 Remove indents from list generator 2021-05-08 18:45:15 +02:00
Sei Lisa
53e8bd659a The Base64 functions that used to produce garbage no longer do 2021-03-21 19:05:37 +01:00
Sei Lisa
b6a5e01ed4 New upstream version of builtins.txt 2021-01-28 12:06:20 +01:00
Sei Lisa
da05d1e1c2 Add Pop to the list of idents that GetNextShortest can't generate
It's unlikely to hit this one (requires more than 10,000 identifiers to trigger) but it's a bug nevertheless.

While touching the file, try to explain the situation better in the first comment.
2021-01-05 23:27:49 +01:00
Sei Lisa
81906475ff Update copyright year 2021-01-05 23:27:21 +01:00
Sei Lisa
0b266db758 Fix InternalUTF8ToString to consider U+FFFE as invalid
This commit also adds the foldtabs option as default for the eval test suite, and substantially improves the Unicode valid/invalid character test.
2020-11-19 22:26:42 +01:00
Sei Lisa
4771c76d85 Greatly simplify InternalUTF8ToString using a regular expression 2020-11-19 20:23:44 +01:00
Sei Lisa
c77607d318 Document the behaviour of InternalUTF8ToString 2020-11-19 20:22:11 +01:00
Sei Lisa
e1bcccb979 All tests pass now 2020-11-10 02:14:15 +01:00
Sei Lisa
16d8c4c9d1 More progress in migration to dual Python 2&3. Just 2 tests left. 2020-11-10 00:15:48 +01:00
Sei Lisa
f8cf78dfac Progress towards dual Python 2 & 3 2020-11-09 02:28:57 +01:00
Sei Lisa
dde9577cea Additions for strutil: xrange, python2, python3, any2str
Also output to stderr with str instead of unicode.
2020-11-09 02:12:29 +01:00
Sei Lisa
4fd4bf71aa Use frozenset more consistently 2020-11-09 02:11:35 +01:00
Sei Lisa
d9938f1a37 Misc small non-user-visible fixes
Some are Unicode vs Str stuff, others are style adjustments, others in unused functions, and so on.
2020-11-09 02:00:40 +01:00
Sei Lisa
59c3f9fc71 Add newest llGetEnv settings 2020-11-09 01:27:13 +01:00
Pedro Gimeno
4c49e87f4c Add -y to test entries without an .err file; improve consistency 2020-11-08 19:07:07 +01:00
Pedro Gimeno
f1d5905d7e Process arguments as str instead of bytes 2020-11-08 17:26:59 +01:00
Sei Lisa
5e88adcff3 Update to latest pcpp, remove expression evaluator
PCPP now includes a decent expression evaluator instead of relying on Python's, therefore our evaluator is removed. The corresponding license text no longer applies, because the snippet that used it has been removed.

This patch also corrects the handling of include files, which was supposed to raise an exception or return something (and now it needs an extra parameter). We just report an error and raise the special exception that pcpp uses to ignore and remove the directive.

This patch also handles #error and invalid directives, which were passed through in previous versions. #warning and #line are also passed through.
2020-11-04 13:09:34 +01:00