mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 13:29:19 +02:00
* part of r16533, forgot to commit
* also fixes CharLengthPChar() for non-BeOS by initialising the mbstate parameter passed to mbrlen() to 0 (otherwise its contents are interpreted as already valid, containing information about the current shiftstate etc) git-svn-id: trunk@16552 -
This commit is contained in:
parent
2f5f98d7e5
commit
a2e8134b7c
@ -566,6 +566,9 @@ function CharLengthPChar(const Str: PChar): PtrInt;
|
|||||||
begin
|
begin
|
||||||
result:=0;
|
result:=0;
|
||||||
s:=str;
|
s:=str;
|
||||||
|
{$ifndef beos}
|
||||||
|
fillchar(mbstate,sizeof(mbstate),0);
|
||||||
|
{$endif not beos}
|
||||||
repeat
|
repeat
|
||||||
{$ifdef beos}
|
{$ifdef beos}
|
||||||
nextlen:=ptrint(mblen(str,MB_CUR_MAX));
|
nextlen:=ptrint(mblen(str,MB_CUR_MAX));
|
||||||
@ -581,6 +584,26 @@ function CharLengthPChar(const Str: PChar): PtrInt;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function CodePointLength(const Str: PChar; maxlookahead: ptrint): PtrInt;
|
||||||
|
var
|
||||||
|
nextlen: ptrint;
|
||||||
|
{$ifndef beos}
|
||||||
|
mbstate: mbstate_t;
|
||||||
|
{$endif not beos}
|
||||||
|
begin
|
||||||
|
{$ifdef beos}
|
||||||
|
result:=ptrint(mblen(str,maxlookahead));
|
||||||
|
{$else beos}
|
||||||
|
fillchar(mbstate,sizeof(mbstate),0);
|
||||||
|
result:=ptrint(mbrlen(str,maxlookahead,@mbstate));
|
||||||
|
{ mbrlen can also return -2 for "incomplete but potially valid character
|
||||||
|
and data has been processed" }
|
||||||
|
if result<0 then
|
||||||
|
result:=-1;
|
||||||
|
{$endif beos}
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function StrCompAnsiIntern(s1,s2 : PChar; len1, len2: PtrInt; canmodifys1, canmodifys2: boolean): PtrInt;
|
function StrCompAnsiIntern(s1,s2 : PChar; len1, len2: PtrInt; canmodifys1, canmodifys2: boolean): PtrInt;
|
||||||
var
|
var
|
||||||
a,b: pchar;
|
a,b: pchar;
|
||||||
@ -758,6 +781,7 @@ begin
|
|||||||
CompareTextWideStringProc:=@CompareTextWideString;
|
CompareTextWideStringProc:=@CompareTextWideString;
|
||||||
|
|
||||||
CharLengthPCharProc:=@CharLengthPChar;
|
CharLengthPCharProc:=@CharLengthPChar;
|
||||||
|
CodePointLengthProc:=@CodePointLength;
|
||||||
|
|
||||||
UpperAnsiStringProc:=@UpperAnsiString;
|
UpperAnsiStringProc:=@UpperAnsiString;
|
||||||
LowerAnsiStringProc:=@LowerAnsiString;
|
LowerAnsiStringProc:=@LowerAnsiString;
|
||||||
|
Loading…
Reference in New Issue
Block a user