#1 2023-03-11 06:10:19

lfyey121
Member
From: china
Registered: 2022-08-25
Posts: 66

CsvToIntegerDynArray bug?

function CsvToIntegerDynArray(Csv: PUtf8Char; var List: TIntegerDynArray) 

If csv is empty string , list will contain a [0].

Is this a bug? or That should be it

Last edited by lfyey121 (2023-03-11 06:49:38)

Offline

#2 2023-03-11 08:49:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: CsvToIntegerDynArray bug?

What do you call an "empty string"?
IMHO CsvToIntegerDynArray(nil, List) won't add any item.
But CsvToIntegerDynArray(#0, List) would add a [0]. It is as expected: it is handled as a single item with no text, i.e. converted as 0.
The idea is to compute Csv from pointer(SomeRawUtf8Variable), i.e. '' will return nil, never #0.

But perhaps https://github.com/synopse/mORMot2/commit/a7e6ac51 make it more easy to understand.
Your expectations do make sense.

Note that it ADDs/APPENDs items to the list. If the list is not void, it is kept as it is.

Offline

#3 2023-03-11 09:34:51

lfyey121
Member
From: china
Registered: 2022-08-25
Posts: 66

Re: CsvToIntegerDynArray bug?

Thank you, that's what I hope, I don't have to check again if it's an empty string

Offline

Board footer

Powered by FluxBB