String Length and Array Indexes in macros

classic Classic list List threaded Threaded
6 messages Options
Andrew Pitonyak Andrew Pitonyak
Reply | Threaded
Open this post in threaded view
|

String Length and Array Indexes in macros

Last time I documented Strings and arrays, an array index was limited to +/-32K and a string was similarly limited.

I am now documenting them again and I am hoping that someone knows off hand what the new limitations are so that I do not need to scour the code to find out. My best guess is that this now uses a 32-bit long, so, +/- 2G.

Andrew Pitonyak


_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
Eike Rathke-2 Eike Rathke-2
Reply | Threaded
Open this post in threaded view
|

Re: String Length and Array Indexes in macros

Hi Andrew,

On Tuesday, 2018-05-15 13:43:15 +0000, Andrew Pitonyak wrote:

> Last time I documented Strings and arrays, an array index was limited to
> +/-32K and a string was similarly limited.
>
> I am now documenting them again and I am hoping that someone knows off hand
> what the new limitations are so that I do not need to scour the code to find
> out. My best guess is that this now uses a 32-bit long, so, +/- 2G.

While internally an SbxArray can handle uint32 indices, there still are
the same limitations. For example DimArray() is limited to uint16
dimensions. The Array() function could digest uint16 (=64K) elements,
but storage index still uses a short int16. Most code has been
untouched, there still may be some other places that access things
through a short (int16) which limits the reliable size to 32K elements.

For strings OUString is used, which theoretically can hold int32 (=2G)
UTF-16 code points during runtime, so that's probably the most
interesting change (well, at least compared to 6 years ago or so).

BUT, probably for some (stream?) compatibility (or oversight?), for
example the TypeLen() function still returns an int16 value because the
result is stored as an int16 (while seeing that, I think it could be
fixed). Also, for persistent storage UTF-16 may have to be converted to
a different encoding, which may halve or third the theoretical capacity
depending on the actual characters used.

Hope that helps

  Eike

--
LibreOffice Calc developer. Number formatter stricken i18n transpositionizer.
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A
Care about Free Software, support the FSFE https://fsfe.org/support/?erack

_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice

signature.asc (849 bytes) Download Attachment
Michael Stahl-3 Michael Stahl-3
Reply | Threaded
Open this post in threaded view
|

Re: String Length and Array Indexes in macros

On 15/05/18 22:27, Eike Rathke wrote:

> BUT, probably for some (stream?) compatibility (or oversight?), for
> example the TypeLen() function still returns an int16 value because the
> result is stored as an int16 (while seeing that, I think it could be
> fixed). Also, for persistent storage UTF-16 may have to be converted to
> a different encoding, which may halve or third the theoretical capacity
> depending on the actual characters used.

there is a bytecode representation for StarBasic that is used if you
store "encrypted" macros inside a document - i.e. the StarBasic source
code is encrypted then, but an unencrypted bytecode representation is
stored as well that can be executed without access to the source code.

this is of course a silly enterprise-grade feature, but it's possible
that it may limit what we can easily change in the StarBasic implementation.
_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
Noel Grandin-2 Noel Grandin-2
Reply | Threaded
Open this post in threaded view
|

Re: String Length and Array Indexes in macros



On 2018/05/16 10:23 AM, Michael Stahl wrote:
> there is a bytecode representation for StarBasic that is used if you store "encrypted" macros inside a document - i.e.
> the StarBasic source code is encrypted then, but an unencrypted bytecode representation is stored as well that can be
> executed without access to the source code.
>
> this is of course a silly enterprise-grade feature, but it's possible that it may limit what we can easily change in the
> StarBasic implementation.

I tried to update StarBasic once to remove some of the limits and this was exactly the issue I ran into.



_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
Eike Rathke-2 Eike Rathke-2
Reply | Threaded
Open this post in threaded view
|

Re: String Length and Array Indexes in macros

Hi,

On Wednesday, 2018-05-16 10:42:22 +0200, Noel Grandin wrote:

> On 2018/05/16 10:23 AM, Michael Stahl wrote:
> > there is a bytecode representation for StarBasic that is used if you
> > store "encrypted" macros inside a document - i.e. the StarBasic source
> > code is encrypted then, but an unencrypted bytecode representation is
> > stored as well that can be executed without access to the source code.
> >
> > this is of course a silly enterprise-grade feature, but it's possible
> > that it may limit what we can easily change in the StarBasic
> > implementation.
>
> I tried to update StarBasic once to remove some of the limits and this was exactly the issue I ran into.
*Cough* ok, I'll refrain from getting my hands dirty there..

  Eike

--
LibreOffice Calc developer. Number formatter stricken i18n transpositionizer.
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A
Care about Free Software, support the FSFE https://fsfe.org/support/?erack

_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice

signature.asc (849 bytes) Download Attachment
Arnaud VERSINI Arnaud VERSINI
Reply | Threaded
Open this post in threaded view
|

Re: String Length and Array Indexes in macros

In reply to this post by Noel Grandin-2
Hello everyone,

Le 16/05/2018 à 10:42, Noel Grandin a écrit :

>
>
> On 2018/05/16 10:23 AM, Michael Stahl wrote:
>> there is a bytecode representation for StarBasic that is used if you
>> store "encrypted" macros inside a document - i.e. the StarBasic
>> source code is encrypted then, but an unencrypted bytecode
>> representation is stored as well that can be executed without access
>> to the source code.
>>
>> this is of course a silly enterprise-grade feature, but it's possible
>> that it may limit what we can easily change in the StarBasic
>> implementation.
>
> I tried to update StarBasic once to remove some of the limits and this
> was exactly the issue I ran into.
>
I made some cleanup inside the basic interpreter and stopped because of
this stored compiled  bytecode too. Perhaps some new instructions
compatible with 32 bits string could be possible.
>
>
> _______________________________________________
> LibreOffice mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/libreoffice


_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice