diff --git a/rtl/haiku/ptypes.inc b/rtl/haiku/ptypes.inc index 323b75182f..ff677dcf3c 100644 --- a/rtl/haiku/ptypes.inc +++ b/rtl/haiku/ptypes.inc @@ -164,7 +164,8 @@ type end; pthread_mutexattr_t = record - __mutexkind: cint; + __mutexkind: cint32; + process_shared: cbool; end; pthread_cond_t = record diff --git a/rtl/objpas/sysutils/sysencoding.inc b/rtl/objpas/sysutils/sysencoding.inc index 23e27ab730..a50b3eac55 100644 --- a/rtl/objpas/sysutils/sysencoding.inc +++ b/rtl/objpas/sysutils/sysencoding.inc @@ -38,7 +38,10 @@ end; function TEncoding.GetAnsiBytes(const S: string): TBytes; begin - Result := GetAnsiBytes(S, 1, Length(S)); + if S='' then + Result := nil + else + Result := GetAnsiBytes(S, 1, Length(S)); end; function TEncoding.GetAnsiBytes(const S: string; CharIndex, CharCount: Integer @@ -49,7 +52,10 @@ end; function TEncoding.GetAnsiString(const Bytes: TBytes): string; begin - Result := GetAnsiString(Bytes, 0, Length(Bytes)); + if Length(Bytes)=0 then + Result := '' + else + Result := GetAnsiString(Bytes, 0, Length(Bytes)); end; function TEncoding.GetAnsiString(const Bytes: TBytes; ByteIndex, @@ -294,7 +300,10 @@ end; function TEncoding.GetByteCount(const Chars: TUnicodeCharArray): Integer; begin - Result := GetByteCount(Chars, 0, Length(Chars)); + if Length(Chars)=0 then + Result := 0 + else + Result := GetByteCount(Chars, 0, Length(Chars)); end; function TEncoding.GetByteCount(const Chars: TUnicodeCharArray; CharIndex, @@ -309,7 +318,10 @@ end; function TEncoding.GetByteCount(const S: UnicodeString): Integer; begin - Result := GetByteCount(PUnicodeChar(S), Length(S)); + if S='' then + Result := 0 + else + Result := GetByteCount(PUnicodeChar(S), Length(S)); end; function TEncoding.GetByteCount(const S: UnicodeString; CharIndex, CharCount: Integer): Integer; @@ -324,7 +336,8 @@ end; function TEncoding.GetBytes(const Chars: TUnicodeCharArray): TBytes; begin SetLength(Result, GetByteCount(Chars)); - GetBytes(@Chars[0], Length(Chars), @Result[0], Length(Result)); + if Length(Result)>0 then + GetBytes(@Chars[0], Length(Chars), @Result[0], Length(Result)); end; function TEncoding.GetBytes(const Chars: TUnicodeCharArray; CharIndex, @@ -358,7 +371,8 @@ end; function TEncoding.GetBytes(const S: UnicodeString): TBytes; begin SetLength(Result, GetByteCount(S)); - GetBytes(@S[1], Length(S), @Result[0], Length(Result)); + if Length(Result)>0 then + GetBytes(@S[1], Length(S), @Result[0], Length(Result)); end; function TEncoding.GetBytes(const S: UnicodeString; CharIndex, CharCount: Integer; @@ -380,7 +394,10 @@ end; function TEncoding.GetCharCount(const Bytes: TBytes): Integer; begin - Result := GetCharCount(@Bytes[0], Length(Bytes)); + if Length(Bytes)=0 then + Result := 0 + else + Result := GetCharCount(@Bytes[0], Length(Bytes)); end; function TEncoding.GetCharCount(const Bytes: TBytes; ByteIndex, @@ -394,7 +411,8 @@ end; function TEncoding.GetChars(const Bytes: TBytes): TUnicodeCharArray; begin SetLength(Result, GetCharCount(Bytes)); - GetChars(@Bytes[0], Length(Bytes), @Result[0], Length(Result)); + if Length(Result)>0 then + GetChars(@Bytes[0], Length(Bytes), @Result[0], Length(Result)); end; function TEncoding.GetChars(const Bytes: TBytes; ByteIndex, ByteCount: Integer): TUnicodeCharArray; @@ -444,8 +462,13 @@ function TEncoding.GetString(const Bytes: TBytes): UnicodeString; var Chars: TUnicodeCharArray; begin - Chars := GetChars(Bytes); - SetString(Result, PUnicodeChar(Chars), Length(Chars)); + if Length(Bytes)=0 then + Result := '' + else + begin + Chars := GetChars(Bytes); + SetString(Result, PUnicodeChar(Chars), Length(Chars)); + end; end; function TEncoding.GetString(const Bytes: TBytes; ByteIndex, ByteCount: Integer): UnicodeString; diff --git a/rtl/objpas/sysutils/sysutilh.inc b/rtl/objpas/sysutils/sysutilh.inc index 0e568c9cb9..16d2da23dc 100644 --- a/rtl/objpas/sysutils/sysutilh.inc +++ b/rtl/objpas/sysutils/sysutilh.inc @@ -101,7 +101,7 @@ type PWordarray = ^TWordArray; TWordArray = array[0..{$ifdef CPU16}16382{$else}16383{$endif}] of Word; - TBytes = array of Byte; + TBytes = array of Byte; { exceptions } Exception = class(TObject) @@ -120,10 +120,9 @@ type constructor CreateResFmtHelp(ResString: PString; const Args: array of const; AHelpContext: Longint); Function ToString : String; override; - { !!!! } + property HelpContext : longint read fhelpcontext write fhelpcontext; property Message : string read fmessage write fmessage; - end; ExceptClass = class of Exception; @@ -141,7 +140,7 @@ type end; { integer math exceptions } - EInterror = Class(EExternal); + EIntError = Class(EExternal); EDivByZero = Class(EIntError); ERangeError = Class(EIntError); EIntOverflow = Class(EIntError);