sysstr.inc 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  1. {
  2. *********************************************************************
  3. $Id$
  4. Copyright (C) 1997, 1998 Gertjan Schouten
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. *********************************************************************
  17. System Utilities For Free Pascal
  18. }
  19. { NewStr creates a new PString and assigns S to it
  20. if length(s) = 0 NewStr returns Nil }
  21. function NewStr(const S: string): PString;
  22. begin
  23. if (S='') then
  24. Result:=nil
  25. else
  26. begin
  27. getmem(Result,length(s)+1);
  28. if (Result<>nil) then
  29. Result^:=s;
  30. end;
  31. end;
  32. { DisposeStr frees the memory occupied by S }
  33. procedure DisposeStr(S: PString);
  34. begin
  35. if S <> Nil then
  36. begin
  37. Freemem(S,Length(S^)+1);
  38. S:=nil;
  39. end;
  40. end;
  41. { AssignStr assigns S to P^ }
  42. procedure AssignStr(var P: PString; const S: string);
  43. begin
  44. P^ := s;
  45. end ;
  46. { AppendStr appends S to Dest }
  47. procedure AppendStr(var Dest: String; const S: string);
  48. begin
  49. Dest := Dest + S;
  50. end ;
  51. { UpperCase returns a copy of S where all lowercase characters ( from a to z )
  52. have been converted to uppercase }
  53. function UpperCase(const S: string): string;
  54. var i: integer;
  55. begin
  56. result := S;
  57. i := Length(S);
  58. while i <> 0 do begin
  59. if (result[i] in ['a'..'z']) then result[i] := char(byte(result[i]) - 32);
  60. Dec(i);
  61. end;
  62. end;
  63. { LowerCase returns a copy of S where all uppercase characters ( from A to Z )
  64. have been converted to lowercase }
  65. function LowerCase(const S: string): string;
  66. var i: integer;
  67. begin
  68. result := S;
  69. i := Length(result);
  70. while i <> 0 do begin
  71. if (result[i] in ['A'..'Z']) then result[i] := char(byte(result[i]) + 32);
  72. dec(i);
  73. end;
  74. end;
  75. { CompareStr compares S1 and S2, the result is the based on
  76. substraction of the ascii values of the characters in S1 and S2
  77. case result
  78. S1 < S2 < 0
  79. S1 > S2 > 0
  80. S1 = S2 = 0 }
  81. function CompareStr(const S1, S2: string): Integer;
  82. var count, count1, count2: integer;
  83. begin
  84. result := 0;
  85. Count1 := Length(S1);
  86. Count2 := Length(S2);
  87. if Count1 > Count2 then Count := Count2
  88. else Count := Count1;
  89. result := CompareMemRange(Pointer(S1),Pointer(S2), Count);
  90. if (result = 0) and (Count1 <> Count2) then begin
  91. if Count1 > Count2 then result := ord(s1[Count1 + 1])
  92. else result := -ord(s2[Count2 + 1]);
  93. end ;
  94. end ;
  95. { CompareMemRange returns the result of comparison of Length bytes at P1 and P2
  96. case result
  97. P1 < P2 < 0
  98. P1 > P2 > 0
  99. P1 = P2 = 0 }
  100. function CompareMemRange(P1, P2: Pointer; Length: cardinal): integer;
  101. var i: cardinal;
  102. begin
  103. i := 0;
  104. result := 0;
  105. while (result = 0) and (i < length) do begin
  106. result := byte(P1^) - byte(P2^);
  107. P1 := P1 + 1;
  108. P2 := P2 + 1;
  109. i := i + 1;
  110. end ;
  111. end ;
  112. function CompareMem(P1, P2: Pointer; Length: cardinal): Boolean;
  113. var
  114. i: cardinal;
  115. begin
  116. for i := 0 to Length - 1 do
  117. begin
  118. if Byte(P1^) <> Byte(P2^) then
  119. begin
  120. Result := False;
  121. exit;
  122. end;
  123. Inc(P1);
  124. Inc(P2);
  125. end;
  126. Result := True;
  127. end;
  128. { CompareText compares S1 and S2, the result is the based on
  129. substraction of the ascii values of characters in S1 and S2
  130. comparison is case-insensitive
  131. case result
  132. S1 < S2 < 0
  133. S1 > S2 > 0
  134. S1 = S2 = 0 }
  135. function CompareText(const S1, S2: string): integer;
  136. var i, count, count1, count2: integer; Chr1, Chr2: byte;
  137. begin
  138. result := 0;
  139. Count1 := Length(S1);
  140. Count2 := Length(S2);
  141. if Count1 > Count2 then Count := Count2
  142. else Count := Count1;
  143. i := 0;
  144. while (result = 0) and (i < count) do begin
  145. inc (i);
  146. Chr1 := byte(s1[i]);
  147. Chr2 := byte(s2[i]);
  148. if Chr1 in [97..122] then dec(Chr1,32);
  149. if Chr2 in [97..122] then dec(Chr2,32);
  150. result := Chr1 - Chr2;
  151. end ;
  152. if (result = 0) then
  153. result:=(count1-count2);
  154. end ;
  155. {==============================================================================}
  156. { Ansi string functions }
  157. { these functions rely on the character set loaded by the OS }
  158. {==============================================================================}
  159. function AnsiUpperCase(const s: string): string;
  160. var len, i: integer;
  161. begin
  162. len := length(s);
  163. SetLength(result, len);
  164. for i := 1 to len do
  165. result[i] := UpperCaseTable[ord(s[i])];
  166. end ;
  167. function AnsiLowerCase(const s: string): string;
  168. var len, i: integer;
  169. begin
  170. len := length(s);
  171. SetLength(result, len);
  172. for i := 1 to len do
  173. result[i] := LowerCaseTable[ord(s[i])];
  174. end ;
  175. function AnsiCompareStr(const S1, S2: string): integer;
  176. Var I,L1,L2 : Longint;
  177. begin
  178. Result:=0;
  179. L1:=Length(S1);
  180. L2:=Length(S2);
  181. I:=1;
  182. While (Result=0) and ((I<=L1) and (I<=L2)) do
  183. begin
  184. Result:=Ord(S1[I])-Ord(S2[I]); //!! Must be replaced by ansi characters !!
  185. Inc(I);
  186. end;
  187. If Result=0 Then
  188. Result:=L1-L2;
  189. end;
  190. function AnsiCompareText(const S1, S2: string): integer;
  191. Var I,L1,L2 : Longint;
  192. begin
  193. Result:=0;
  194. L1:=Length(S1);
  195. L2:=Length(S2);
  196. I:=1;
  197. While (Result=0) and ((I<=L1) and (I<=L2)) do
  198. begin
  199. Result:=Ord(LowerCaseTable[Ord(S1[I])])-Ord(LowerCaseTable[Ord(S2[I])]); //!! Must be replaced by ansi characters !!
  200. Inc(I);
  201. end;
  202. If Result=0 Then
  203. Result:=L1-L2;
  204. end;
  205. function AnsiStrComp(S1, S2: PChar): integer;
  206. begin
  207. Result:=0;
  208. If S1=Nil then
  209. begin
  210. If S2=Nil Then Exit;
  211. result:=-1;
  212. exit;
  213. end;
  214. If S2=Nil then
  215. begin
  216. Result:=1;
  217. exit;
  218. end;
  219. Repeat
  220. Result:=Ord(S1[0])-Ord(S2[0]); //!! Must be replaced by ansi characters !!
  221. Inc(S1);
  222. Inc(S2);
  223. Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0))
  224. end;
  225. function AnsiStrIComp(S1, S2: PChar): integer;
  226. begin
  227. Result:=0;
  228. If S1=Nil then
  229. begin
  230. If S2=Nil Then Exit;
  231. result:=-1;
  232. exit;
  233. end;
  234. If S2=Nil then
  235. begin
  236. Result:=1;
  237. exit;
  238. end;
  239. Repeat
  240. Result:=Ord(LowerCaseTable[Ord(S1[0])])-Ord(LowerCaseTable[Ord(S2[0])]); //!! Must be replaced by ansi characters !!
  241. Inc(S1);
  242. Inc(S2);
  243. Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0))
  244. end;
  245. function AnsiStrLComp(S1, S2: PChar; MaxLen: cardinal): integer;
  246. Var I : cardinal;
  247. begin
  248. Result:=0;
  249. If MaxLen=0 then exit;
  250. If S1=Nil then
  251. begin
  252. If S2=Nil Then Exit;
  253. result:=-1;
  254. exit;
  255. end;
  256. If S2=Nil then
  257. begin
  258. Result:=1;
  259. exit;
  260. end;
  261. I:=0;
  262. Repeat
  263. Result:=Ord(S1[0])-Ord(S2[0]); //!! Must be replaced by ansi characters !!
  264. Inc(S1);
  265. Inc(S2);
  266. Inc(I);
  267. Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0)) or (I=MaxLen)
  268. end ;
  269. function AnsiStrLIComp(S1, S2: PChar; MaxLen: cardinal): integer;
  270. Var I : cardinal;
  271. begin
  272. Result:=0;
  273. If MaxLen=0 then exit;
  274. If S1=Nil then
  275. begin
  276. If S2=Nil Then Exit;
  277. result:=-1;
  278. exit;
  279. end;
  280. If S2=Nil then
  281. begin
  282. Result:=1;
  283. exit;
  284. end;
  285. I:=0;
  286. Repeat
  287. Result:=Ord(LowerCaseTable[Ord(S1[0])])-Ord(LowerCaseTable[Ord(S2[0])]); //!! Must be replaced by ansi characters !!
  288. Inc(S1);
  289. Inc(S2);
  290. Inc(I);
  291. Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0)) or (I=MaxLen)
  292. end ;
  293. function AnsiStrLower(Str: PChar): PChar;
  294. begin
  295. result := Str;
  296. if Str <> Nil then begin
  297. while Str^ <> #0 do begin
  298. Str^ := LowerCaseTable[byte(Str^)];
  299. Str := Str + 1;
  300. end ;
  301. end ;
  302. end ;
  303. function AnsiStrUpper(Str: PChar): PChar;
  304. begin
  305. result := Str;
  306. if Str <> Nil then begin
  307. while Str^ <> #0 do begin
  308. Str^ := UpperCaseTable[byte(Str^)];
  309. Str := Str + 1;
  310. end ;
  311. end ;
  312. end ;
  313. function AnsiLastChar(const S: string): PChar;
  314. begin
  315. //!! No multibyte yet, so we return the last one.
  316. result:=StrEnd(Pchar(S));
  317. Dec(Result);
  318. end ;
  319. function AnsiStrLastChar(Str: PChar): PChar;
  320. begin
  321. //!! No multibyte yet, so we return the last one.
  322. result:=StrEnd(Str);
  323. Dec(Result);
  324. end ;
  325. {==============================================================================}
  326. { End of Ansi functions }
  327. {==============================================================================}
  328. { Trim returns a copy of S with blanks characters on the left and right stripped off }
  329. Const WhiteSpace = [' ',#10,#13,#9];
  330. function Trim(const S: string): string;
  331. var Ofs, Len: integer;
  332. begin
  333. len := Length(S);
  334. while (Len>0) and (S[Len] in WhiteSpace) do
  335. dec(Len);
  336. Ofs := 1;
  337. while (Ofs<=Len) and (S[Ofs] in WhiteSpace) do
  338. Inc(Ofs);
  339. result := Copy(S, Ofs, 1 + Len - Ofs);
  340. end ;
  341. { TrimLeft returns a copy of S with all blank characters on the left stripped off }
  342. function TrimLeft(const S: string): string;
  343. var i,l:integer;
  344. begin
  345. l := length(s);
  346. i := 1;
  347. while (i<=l) and (s[i] in whitespace) do
  348. inc(i);
  349. Result := copy(s, i, l);
  350. end ;
  351. { TrimRight returns a copy of S with all blank characters on the right stripped off }
  352. function TrimRight(const S: string): string;
  353. var l:integer;
  354. begin
  355. l := length(s);
  356. while (l>0) and (s[l] in whitespace) do
  357. dec(l);
  358. result := copy(s,1,l);
  359. end ;
  360. { QuotedStr returns S quoted left and right and every single quote in S
  361. replaced by two quotes }
  362. function QuotedStr(const S: string): string;
  363. begin
  364. result := AnsiQuotedStr(s, '''');
  365. end ;
  366. { AnsiQuotedStr returns S quoted left and right by Quote,
  367. and every single occurance of Quote replaced by two }
  368. function AnsiQuotedStr(const S: string; Quote: char): string;
  369. var i, j, count: integer;
  370. begin
  371. result := '' + Quote;
  372. count := length(s);
  373. i := 0;
  374. j := 0;
  375. while i < count do begin
  376. i := i + 1;
  377. if S[i] = Quote then begin
  378. result := result + copy(S, 1 + j, i - j) + Quote;
  379. j := i;
  380. end ;
  381. end ;
  382. if i <> j then
  383. result := result + copy(S, 1 + j, i - j);
  384. result := result + Quote;
  385. end ;
  386. { AnsiExtractQuotedStr returns a copy of Src with quote characters
  387. deleted to the left and right and double occurances
  388. of Quote replaced by a single Quote }
  389. function AnsiExtractQuotedStr(Const Src: PChar; Quote: Char): string;
  390. var i: integer; P, Q: PChar;
  391. begin
  392. P := Src;
  393. if Src^ = Quote then P := P + 1;
  394. Q := StrEnd(P);
  395. if PChar(Q - 1)^ = Quote then Q := Q - 1;
  396. SetLength(result, Q - P);
  397. i := 0;
  398. while P <> Q do begin
  399. i := i + 1;
  400. result[i] := P^;
  401. if (P^ = Quote) and (PChar(P + 1)^ = Quote) then
  402. P := P + 1;
  403. P := P + 1;
  404. end ;
  405. SetLength(result, i);
  406. end ;
  407. { AdjustLineBreaks returns S with all CR characters not followed by LF
  408. replaced with CR/LF }
  409. // under Linux all CR characters or CR/LF combinations should be replaced with LF
  410. function AdjustLineBreaks(const S: string): string;
  411. var i, j, count: integer;
  412. begin
  413. result := '';
  414. i := 0;
  415. j := 0;
  416. count := Length(S);
  417. while i < count do begin
  418. i := i + 1;
  419. {$ifndef Unix}
  420. if (S[i] = #13) and ((i = count) or (S[i + 1] <> #10)) then
  421. begin
  422. result := result + Copy(S, 1 + j, i - j) + #10;
  423. j := i;
  424. end;
  425. {$else}
  426. If S[i]=#13 then
  427. begin
  428. Result:= Result+Copy(S,J+1,i-j-1)+#10;
  429. If I<>Count Then
  430. If S[I+1]=#10 then inc(i);
  431. J :=I;
  432. end;
  433. {$endif}
  434. end ;
  435. if j <> i then
  436. result := result + copy(S, 1 + j, i - j);
  437. end ;
  438. { IsValidIdent returns true if the first character of Ident is in:
  439. 'A' to 'Z', 'a' to 'z' or '_' and the following characters are
  440. on of: 'A' to 'Z', 'a' to 'z', '0'..'9' or '_' }
  441. function IsValidIdent(const Ident: string): boolean;
  442. var i, len: integer;
  443. begin
  444. result := false;
  445. len := length(Ident);
  446. if len <> 0 then begin
  447. result := Ident[1] in ['A'..'Z', 'a'..'z', '_'];
  448. i := 1;
  449. while (result) and (i < len) do begin
  450. i := i + 1;
  451. result := result and (Ident[i] in ['A'..'Z', 'a'..'z', '0'..'9', '_']);
  452. end ;
  453. end ;
  454. end ;
  455. { IntToStr returns a string representing the value of Value }
  456. function IntToStr(Value: integer): string;
  457. begin
  458. System.Str(Value, result);
  459. end ;
  460. function IntToStr(Value: int64): string;
  461. begin
  462. System.Str(Value, result);
  463. end ;
  464. function IntToStr(Value: QWord): string;
  465. begin
  466. System.Str(Value, result);
  467. end ;
  468. { IntToHex returns a string representing the hexadecimal value of Value }
  469. const
  470. HexDigits: array[0..15] of char = '0123456789ABCDEF';
  471. function IntToHex(Value: integer; Digits: integer): string;
  472. var i: integer;
  473. begin
  474. SetLength(result, digits);
  475. for i := 0 to digits - 1 do
  476. begin
  477. result[digits - i] := HexDigits[value and 15];
  478. value := value shr 4;
  479. end ;
  480. end ;
  481. function IntToHex(Value: int64; Digits: integer): string;
  482. var i: integer;
  483. begin
  484. SetLength(result, digits);
  485. for i := 0 to digits - 1 do
  486. begin
  487. result[digits - i] := HexDigits[value and 15];
  488. value := value shr 4;
  489. end ;
  490. end ;
  491. { StrToInt converts the string S to an integer value,
  492. if S does not represent a valid integer value EConvertError is raised }
  493. function StrToInt(const S: string): integer;
  494. var Error: word;
  495. begin
  496. Val(S, result, Error);
  497. if Error <> 0 then raise EConvertError.createfmt(SInValidInteger,[S]);
  498. end ;
  499. function StrToInt64(const S: string): int64;
  500. var Error: word;
  501. begin
  502. Val(S, result, Error);
  503. if Error <> 0 then raise EConvertError.createfmt(SInValidInteger,[S]);
  504. end ;
  505. { StrToIntDef converts the string S to an integer value,
  506. Default is returned in case S does not represent a valid integer value }
  507. function StrToIntDef(const S: string; Default: integer): integer;
  508. var Error: word;
  509. begin
  510. Val(S, result, Error);
  511. if Error <> 0 then result := Default;
  512. end ;
  513. { StrToIntDef converts the string S to an integer value,
  514. Default is returned in case S does not represent a valid integer value }
  515. function StrToInt64Def(const S: string; Default: int64): int64;
  516. var Error: word;
  517. begin
  518. Val(S, result, Error);
  519. if Error <> 0 then result := Default;
  520. end ;
  521. { LoadStr returns the string resource Ident. }
  522. function LoadStr(Ident: integer): string;
  523. begin
  524. result:='';
  525. end ;
  526. { FmtLoadStr returns the string resource Ident and formats it accordingly }
  527. function FmtLoadStr(Ident: integer; const Args: array of const): string;
  528. begin
  529. result:='';
  530. end;
  531. Const
  532. feInvalidFormat = 1;
  533. feMissingArgument = 2;
  534. feInvalidArgIndex = 3;
  535. {$ifdef fmtdebug}
  536. Procedure Log (Const S: String);
  537. begin
  538. Writeln (S);
  539. end;
  540. {$endif}
  541. Procedure DoFormatError (ErrCode : Longint);
  542. Var
  543. S : String;
  544. begin
  545. //!! must be changed to contain format string...
  546. S:='';
  547. Case ErrCode of
  548. feInvalidFormat : raise EConvertError.Createfmt(SInvalidFormat,[s]);
  549. feMissingArgument : raise EConvertError.Createfmt(SArgumentMissing,[s]);
  550. feInvalidArgIndex : raise EConvertError.Createfmt(SInvalidArgIndex,[s]);
  551. end;
  552. end;
  553. Function Format (Const Fmt : String; const Args : Array of const) : String;
  554. Var ChPos,OldPos,ArgPos,DoArg,Len : Longint;
  555. Hs,ToAdd : String;
  556. Index,Width,Prec : Longint;
  557. Left : Boolean;
  558. Fchar : char;
  559. {
  560. ReadFormat reads the format string. It returns the type character in
  561. uppercase, and sets index, Width, Prec to their correct values,
  562. or -1 if not set. It sets Left to true if left alignment was requested.
  563. In case of an error, DoFormatError is called.
  564. }
  565. Function ReadFormat : Char;
  566. Var Value : longint;
  567. Procedure ReadInteger;
  568. Var Code : Word;
  569. begin
  570. If Value<>-1 then exit; // Was already read.
  571. OldPos:=chPos;
  572. While (Chpos<=Len) and
  573. (Pos(Fmt[chpos],'1234567890')<>0) do inc(chpos);
  574. If Chpos>len then
  575. DoFormatError(feInvalidFormat);
  576. If Fmt[Chpos]='*' then
  577. begin
  578. If (Chpos>OldPos) or (ArgPos>High(Args))
  579. or (Args[ArgPos].Vtype<>vtInteger) then
  580. DoFormatError(feInvalidFormat);
  581. Value:=Args[ArgPos].VInteger;
  582. Inc(ArgPos);
  583. Inc(chPos);
  584. end
  585. else
  586. begin
  587. If (OldPos<chPos) Then
  588. begin
  589. Val (Copy(Fmt,OldPos,ChPos-OldPos),value,code);
  590. // This should never happen !!
  591. If Code>0 then DoFormatError (feInvalidFormat);
  592. end
  593. else
  594. Value:=-1;
  595. end;
  596. end;
  597. Procedure ReadIndex;
  598. begin
  599. ReadInteger;
  600. If Fmt[ChPos]=':' then
  601. begin
  602. If Value=-1 then DoFormatError(feMissingArgument);
  603. Index:=Value;
  604. Value:=-1;
  605. Inc(Chpos);
  606. end;
  607. {$ifdef fmtdebug}
  608. Log ('Read index');
  609. {$endif}
  610. end;
  611. Procedure ReadLeft;
  612. begin
  613. If Fmt[chpos]='-' then
  614. begin
  615. left:=True;
  616. Inc(chpos);
  617. end
  618. else
  619. Left:=False;
  620. {$ifdef fmtdebug}
  621. Log ('Read Left');
  622. {$endif}
  623. end;
  624. Procedure ReadWidth;
  625. begin
  626. ReadInteger;
  627. If Value<>-1 then
  628. begin
  629. Width:=Value;
  630. Value:=-1;
  631. end;
  632. {$ifdef fmtdebug}
  633. Log ('Read width');
  634. {$endif}
  635. end;
  636. Procedure ReadPrec;
  637. begin
  638. If Fmt[chpos]='.' then
  639. begin
  640. inc(chpos);
  641. ReadInteger;
  642. If Value=-1 then
  643. Value:=0;
  644. prec:=Value;
  645. end;
  646. {$ifdef fmtdebug}
  647. Log ('Read precision');
  648. {$endif}
  649. end;
  650. begin
  651. {$ifdef fmtdebug}
  652. Log ('Start format');
  653. {$endif}
  654. Index:=-1;
  655. Width:=-1;
  656. Prec:=-1;
  657. Value:=-1;
  658. inc(chpos);
  659. If Fmt[Chpos]='%' then exit('%');
  660. ReadIndex;
  661. ReadLeft;
  662. ReadWidth;
  663. ReadPrec;
  664. ReadFormat:=Upcase(Fmt[ChPos]);
  665. {$ifdef fmtdebug}
  666. Log ('End format');
  667. {$endif}
  668. end;
  669. {$ifdef fmtdebug}
  670. Procedure DumpFormat (C : char);
  671. begin
  672. Write ('Fmt : ',fmt:10);
  673. Write (' Index : ',Index:3);
  674. Write (' Left : ',left:5);
  675. Write (' Width : ',Width:3);
  676. Write (' Prec : ',prec:3);
  677. Writeln (' Type : ',C);
  678. end;
  679. {$endif}
  680. function Checkarg (AT : Longint;err:boolean):boolean;
  681. {
  682. Check if argument INDEX is of correct type (AT)
  683. If Index=-1, ArgPos is used, and argpos is augmented with 1
  684. DoArg is set to the argument that must be used.
  685. }
  686. begin
  687. result:=false;
  688. if Index=-1 then
  689. begin
  690. DoArg:=Argpos;
  691. inc(ArgPos);
  692. end
  693. else
  694. DoArg:=Index;
  695. If (Doarg>High(Args)) or (Args[Doarg].Vtype<>AT) then
  696. begin
  697. if err then
  698. DoFormatError(feInvalidArgindex);
  699. dec(ArgPos);
  700. exit;
  701. end;
  702. result:=true;
  703. end;
  704. Const Zero = '000000000000000000000000000000000000000000000000000000000000000';
  705. begin
  706. Result:='';
  707. Len:=Length(Fmt);
  708. Chpos:=1;
  709. OldPos:=1;
  710. ArgPos:=0;
  711. While chpos<=len do
  712. begin
  713. While (ChPos<=Len) and (Fmt[chpos]<>'%') do
  714. inc(chpos);
  715. If ChPos>OldPos Then
  716. Result:=Result+Copy(Fmt,OldPos,Chpos-Oldpos);
  717. If ChPos<Len then
  718. begin
  719. FChar:=ReadFormat;
  720. {$ifdef fmtdebug}
  721. DumpFormat(FCHar);
  722. {$endif}
  723. Case FChar of
  724. 'D' : begin
  725. if Checkarg(vtinteger,false) then
  726. Str(Args[Doarg].VInteger,ToAdd)
  727. else if CheckArg(vtInt64,true) then
  728. Str(Args[DoArg].VInt64^,toadd);
  729. Width:=Abs(width);
  730. Index:=Prec-Length(ToAdd);
  731. If ToAdd[1]<>'-' then
  732. ToAdd:=StringOfChar('0',Index)+ToAdd
  733. else
  734. // + 1 to accomodate for - sign in length !!
  735. Insert(StringOfChar('0',Index+1),toadd,2);
  736. end;
  737. 'E' : begin
  738. CheckArg(vtExtended,true);
  739. ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffexponent,Prec,3);
  740. end;
  741. 'F' : begin
  742. CheckArg(vtExtended,true);
  743. ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffFixed,9999,Prec);
  744. end;
  745. 'G' : begin
  746. CheckArg(vtExtended,true);
  747. ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffGeneral,Prec,3);
  748. end;
  749. 'N' : begin
  750. CheckArg(vtExtended,true);
  751. ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffNumber,9999,Prec);
  752. end;
  753. 'M' : begin
  754. CheckArg(vtExtended,true);
  755. ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffCurrency,9999,Prec);
  756. end;
  757. 'S' : begin
  758. if CheckArg(vtString,false) then
  759. hs:=Args[doarg].VString^
  760. else
  761. if CheckArg(vtChar,false) then
  762. hs:=Args[doarg].VChar
  763. else
  764. if CheckArg(vtPChar,false) then
  765. hs:=Args[doarg].VPChar
  766. else
  767. if CheckArg(vtPWideChar,false) then
  768. hs:=char(Args[doarg].VPWideChar^)
  769. else
  770. if CheckArg(vtWideChar,false) then
  771. hs:=char(Args[doarg].VWideChar)
  772. else
  773. if CheckArg(vtWidestring,false) then
  774. hs:=ansistring(Args[doarg].VWideString)
  775. else
  776. if CheckArg(vtAnsiString,true) then
  777. hs:=ansistring(Args[doarg].VAnsiString);
  778. Index:=Length(hs);
  779. If (Prec<>-1) and (Index>Prec) then
  780. Index:=Prec;
  781. ToAdd:=Copy(hs,1,Index);
  782. end;
  783. 'P' : Begin
  784. CheckArg(vtpointer,true);
  785. ToAdd:=HexStr(Longint(Args[DoArg].VPointer),8);
  786. // Insert ':'. Is this needed in 32 bit ? No it isn't.
  787. // Insert(':',ToAdd,5);
  788. end;
  789. 'X' : begin
  790. Checkarg(vtinteger,true);
  791. If Prec>15 then
  792. ToAdd:=HexStr(Args[Doarg].VInteger,15)
  793. else
  794. begin
  795. // determine minimum needed number of hex digits.
  796. Index:=1;
  797. While (DWord(1 shl (Index*4))<=DWord(Args[DoArg].VInteger)) and (index<8) do
  798. inc(Index);
  799. If Index>Prec then
  800. Prec:=Index;
  801. ToAdd:=HexStr(Args[DoArg].VInteger,Prec);
  802. end;
  803. end;
  804. '%': ToAdd:='%';
  805. end;
  806. If Width<>-1 then
  807. If Length(ToAdd)<Width then
  808. If not Left then
  809. ToAdd:=Space(Width-Length(ToAdd))+ToAdd
  810. else
  811. ToAdd:=ToAdd+space(Width-Length(ToAdd));
  812. Result:=Result+ToAdd;
  813. end;
  814. inc(chpos);
  815. Oldpos:=chpos;
  816. end;
  817. end;
  818. Function FormatBuf (Var Buffer; BufLen : Cardinal;
  819. Const Fmt; fmtLen : Cardinal;
  820. Const Args : Array of const) : Cardinal;
  821. Var S,F : String;
  822. begin
  823. Setlength(F,fmtlen);
  824. if fmtlen > 0 then
  825. Move(fmt,F[1],fmtlen);
  826. S:=Format (F,Args);
  827. If Length(S)<Buflen then
  828. Result:=Length(S)
  829. else
  830. Result:=Buflen;
  831. Move(S[1],Buffer,Result);
  832. end;
  833. Procedure FmtStr(Var Res: String; Const Fmt : String; Const args: Array of const);
  834. begin
  835. Res:=Format(fmt,Args);
  836. end;
  837. Function StrFmt(Buffer,Fmt : PChar; Const args: Array of const) : Pchar;
  838. begin
  839. Buffer[FormatBuf(Buffer^,Maxint,Fmt^,strlen(fmt),args)]:=#0;
  840. Result:=Buffer;
  841. end;
  842. Function StrLFmt(Buffer : PCHar; Maxlen : Cardinal;Fmt : PChar; Const args: Array of const) : Pchar;
  843. begin
  844. Buffer[FormatBuf(Buffer^,MaxLen,Fmt^,strlen(fmt),args)]:=#0;
  845. Result:=Buffer;
  846. end;
  847. function StrToFloat(Value: string): Extended;
  848. var Error: word;
  849. begin
  850. Val(Value, result, Error);
  851. if Error <> 0 then raise
  852. EConvertError.createfmt(SInValidFLoat,[Value]);
  853. end ;
  854. Function FloatToStr(Value: Extended): String;
  855. Begin
  856. Result := FloatToStrF(Value, ffGeneral, 15, 0);
  857. End;
  858. Function FloatToText(Buffer: PChar; Value: Extended; format: TFloatFormat; Precision, Digits: Integer): Longint;
  859. Var
  860. Tmp: String[40];
  861. Begin
  862. Tmp := FloatToStrF(Value, format, Precision, Digits);
  863. Result := Length(Tmp);
  864. Move(Tmp[1], Buffer[0], Result);
  865. End;
  866. Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: Integer): String;
  867. Var
  868. P: Integer;
  869. Negative, TooSmall, TooLarge: Boolean;
  870. Begin
  871. Case format Of
  872. ffGeneral:
  873. Begin
  874. If (Precision = -1) Or (Precision > 15) Then Precision := 15;
  875. TooSmall := (Abs(Value) < 0.00001) and (Value>0.0);
  876. If Not TooSmall Then
  877. Begin
  878. Str(Value:0:999, Result);
  879. P := Pos('.', Result);
  880. Result[P] := DecimalSeparator;
  881. TooLarge := P > Precision + 1;
  882. End;
  883. If TooSmall Or TooLarge Then
  884. begin
  885. Result := FloatToStrF(Value, ffExponent, Precision, Digits);
  886. // Strip unneeded zeroes.
  887. P:=Pos('E',result)-1;
  888. If P<>-1 then
  889. While (P>1) and (Result[P]='0') do
  890. begin
  891. system.Delete(Result,P,1);
  892. Dec(P);
  893. end;
  894. end
  895. else
  896. begin
  897. P := Length(Result);
  898. While Result[P] = '0' Do Dec(P);
  899. If Result[P] = DecimalSeparator Then Dec(P);
  900. SetLength(Result, P);
  901. end;
  902. End;
  903. ffExponent:
  904. Begin
  905. If (Precision = -1) Or (Precision > 15) Then Precision := 15;
  906. Str(Value:Precision + 8, Result);
  907. Result[3] := DecimalSeparator;
  908. P:=4;
  909. While (P>0) and (Digits < P) And (Result[Precision + 5] = '0') do
  910. Begin
  911. If P<>1 then
  912. system.Delete(Result, Precision + 5, 1)
  913. else
  914. system.Delete(Result, Precision + 3, 3);
  915. Dec(P);
  916. end;
  917. If Result[1] = ' ' Then
  918. System.Delete(Result, 1, 1);
  919. End;
  920. ffFixed:
  921. Begin
  922. If Digits = -1 Then Digits := 2
  923. Else If Digits > 15 Then Digits := 15;
  924. Str(Value:0:Digits, Result);
  925. If Result[1] = ' ' Then
  926. System.Delete(Result, 1, 1);
  927. P := Pos('.', Result);
  928. If P <> 0 Then Result[P] := DecimalSeparator;
  929. End;
  930. ffNumber:
  931. Begin
  932. If Digits = -1 Then Digits := 2
  933. Else If Digits > 15 Then Digits := 15;
  934. Str(Value:0:Digits, Result);
  935. If Result[1] = ' ' Then System.Delete(Result, 1, 1);
  936. P := Pos('.', Result);
  937. If P <> 0 Then
  938. Result[P] := DecimalSeparator
  939. else
  940. P := Length(Result)+1;
  941. Dec(P, 3);
  942. While (P > 1) Do
  943. Begin
  944. If Result[P - 1] <> '-' Then Insert(ThousandSeparator, Result, P);
  945. Dec(P, 3);
  946. End;
  947. End;
  948. ffCurrency:
  949. Begin
  950. If Value < 0 Then
  951. Begin
  952. Negative := True;
  953. Value := -Value;
  954. End
  955. Else Negative := False;
  956. If Digits = -1 Then Digits := CurrencyDecimals
  957. Else If Digits > 18 Then Digits := 18;
  958. Str(Value:0:Digits, Result);
  959. If Result[1] = ' ' Then System.Delete(Result, 1, 1);
  960. P := Pos('.', Result);
  961. If P <> 0 Then Result[P] := DecimalSeparator;
  962. Dec(P, 3);
  963. While (P > 1) Do
  964. Begin
  965. Insert(ThousandSeparator, Result, P);
  966. Dec(P, 3);
  967. End;
  968. If Not Negative Then
  969. Begin
  970. Case CurrencyFormat Of
  971. 0: Result := CurrencyString + Result;
  972. 1: Result := Result + CurrencyString;
  973. 2: Result := CurrencyString + ' ' + Result;
  974. 3: Result := Result + ' ' + CurrencyString;
  975. End
  976. End
  977. Else
  978. Begin
  979. Case NegCurrFormat Of
  980. 0: Result := '(' + CurrencyString + Result + ')';
  981. 1: Result := '-' + CurrencyString + Result;
  982. 2: Result := CurrencyString + '-' + Result;
  983. 3: Result := CurrencyString + Result + '-';
  984. 4: Result := '(' + Result + CurrencyString + ')';
  985. 5: Result := '-' + Result + CurrencyString;
  986. 6: Result := Result + '-' + CurrencyString;
  987. 7: Result := Result + CurrencyString + '-';
  988. 8: Result := '-' + Result + ' ' + CurrencyString;
  989. 9: Result := '-' + CurrencyString + ' ' + Result;
  990. 10: Result := CurrencyString + ' ' + Result + '-';
  991. End;
  992. End;
  993. End;
  994. End;
  995. End;
  996. Function FloatToDateTime (Const Value : Extended) : TDateTime;
  997. begin
  998. If (Value<MinDateTime) or (Value>MaxDateTime) then
  999. Raise EConvertError.CreateFmt (SInvalidDateTime,[Value]);
  1000. Result:=Value;
  1001. end;
  1002. Function FloatToCurr (Const Value : Extended) : Currency;
  1003. begin
  1004. end;
  1005. Function CurrToStr(Value: Currency): string;
  1006. begin
  1007. end;
  1008. function StrToCurr(const S: string): Currency;
  1009. begin
  1010. end;
  1011. function StrToBool(const S: string): Boolean;
  1012. Var
  1013. Temp : String;
  1014. D : Double;
  1015. Code : word;
  1016. begin
  1017. Temp:=upcase(S);
  1018. Val(temp,D,code);
  1019. If Code=0 then
  1020. Result:=(D<>0.0)
  1021. else If Temp='TRUE' then
  1022. result:=true
  1023. else if Temp='FALSE' then
  1024. result:=false
  1025. else
  1026. Raise EConvertError.CreateFmt(SInvalidBoolean,[S]);
  1027. end;
  1028. function BoolToStr(B: Boolean): string;
  1029. begin
  1030. If B then
  1031. Result:='TRUE'
  1032. else
  1033. Result:='FALSE';
  1034. end;
  1035. {==============================================================================}
  1036. { extra functions }
  1037. {==============================================================================}
  1038. { LeftStr returns Count left-most characters from S }
  1039. function LeftStr(const S: string; Count: integer): string;
  1040. begin
  1041. result := Copy(S, 1, Count);
  1042. end ;
  1043. { RightStr returns Count right-most characters from S }
  1044. function RightStr(const S: string; Count: integer): string;
  1045. begin
  1046. If Count>Length(S) then
  1047. Count:=Length(S);
  1048. result := Copy(S, 1 + Length(S) - Count, Count);
  1049. end;
  1050. { BCDToInt converts the BCD value Value to an integer }
  1051. function BCDToInt(Value: integer): integer;
  1052. var i, j: integer;
  1053. begin
  1054. result := 0;
  1055. j := 1;
  1056. for i := 0 to SizeOf(Value) shr 1 - 1 do begin
  1057. result := result + j * (Value and 15);
  1058. j := j * 10;
  1059. Value := Value shr 4;
  1060. end ;
  1061. end ;
  1062. Function LastDelimiter(const Delimiters, S: string): Integer;
  1063. begin
  1064. Result:=Length(S);
  1065. While (Result>0) and (Pos(S[Result],Delimiters)=0) do
  1066. Dec(Result);
  1067. end;
  1068. function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;
  1069. var
  1070. Srch,OldP,RemS: string; // Srch and Oldp can contain uppercase versions of S,OldPattern
  1071. P : Integer;
  1072. begin
  1073. Srch:=S;
  1074. OldP:=OldPattern;
  1075. if rfIgnoreCase in Flags then
  1076. begin
  1077. Srch:=UpperCase(Srch);
  1078. OldP:=UpperCase(OldP);
  1079. end;
  1080. RemS:=S;
  1081. Result:='';
  1082. while (Length(Srch)<>0) do
  1083. begin
  1084. P:=Pos(OldP, Srch);
  1085. if P=0 then
  1086. begin
  1087. Result:=Result+RemS;
  1088. Srch:='';
  1089. end
  1090. else
  1091. begin
  1092. Result:=Result+Copy(RemS,1,P-1)+NewPattern;
  1093. P:=P+Length(OldP);
  1094. RemS:=Copy(RemS,P,Length(RemS)-P+1);
  1095. if not (rfReplaceAll in Flags) then
  1096. begin
  1097. Result:=Result+RemS;
  1098. Srch:='';
  1099. end
  1100. else
  1101. Srch:=Copy(Srch,P,Length(Srch)-P+1);
  1102. end;
  1103. end;
  1104. end;
  1105. {
  1106. Case Translation Tables
  1107. Can be used in internationalization support.
  1108. Although these tables can be obtained through system calls
  1109. it is better to not use those, since most implementation are not 100%
  1110. WARNING:
  1111. before modifying a translation table make sure that the current codepage
  1112. of the OS corresponds to the one you make changes to
  1113. }
  1114. const
  1115. { upper case translation table for character set 850 }
  1116. CP850UCT: array[128..255] of char =
  1117. ('€', 'š', '�', '¶', 'Ž', '¶', '�', '€', 'Ò', 'Ó', 'Ô', 'Ø', '×', 'Þ', 'Ž', '�',
  1118. '�', '’', '’', 'â', '™', 'ã', 'ê', 'ë', 'Y', '™', 'š', '�', 'œ', '�', 'ž', 'Ÿ',
  1119. 'µ', 'Ö', 'à', 'é', '¥', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯',
  1120. '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿',
  1121. 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ç', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï',
  1122. 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß',
  1123. 'à', 'á', 'â', 'ã', 'å', 'å', 'æ', 'í', 'è', 'é', 'ê', 'ë', 'í', 'í', 'î', 'ï',
  1124. 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ');
  1125. { lower case translation table for character set 850 }
  1126. CP850LCT: array[128..255] of char =
  1127. ('‡', '�', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', '�', '„', '†',
  1128. '‚', '‘', '‘', '“', '”', '•', '–', '—', '˜', '”', '�', '›', 'œ', '›', 'ž', 'Ÿ',
  1129. ' ', '¡', '¢', '£', '¤', '¤', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯',
  1130. '°', '±', '²', '³', '´', ' ', 'ƒ', '…', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿',
  1131. 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Æ', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï',
  1132. 'Ð', 'Ñ', 'ˆ', '‰', 'Š', 'Õ', '¡', 'Œ', '‹', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', '�', 'ß',
  1133. '¢', 'á', '“', '•', 'ä', 'ä', 'æ', 'í', 'è', '£', '–', '—', 'ì', 'ì', 'î', 'ï',
  1134. 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ');
  1135. { upper case translation table for character set ISO 8859/1 Latin 1 }
  1136. CPISO88591UCT: array[192..255] of char =
  1137. ( #192, #193, #194, #195, #196, #197, #198, #199,
  1138. #200, #201, #202, #203, #204, #205, #206, #207,
  1139. #208, #209, #210, #211, #212, #213, #214, #215,
  1140. #216, #217, #218, #219, #220, #221, #222, #223,
  1141. #192, #193, #194, #195, #196, #197, #198, #199,
  1142. #200, #201, #202, #203, #204, #205, #206, #207,
  1143. #208, #209, #210, #211, #212, #213, #214, #247,
  1144. #216, #217, #218, #219, #220, #221, #222, #89 );
  1145. { lower case translation table for character set ISO 8859/1 Latin 1 }
  1146. CPISO88591LCT: array[192..255] of char =
  1147. ( #224, #225, #226, #227, #228, #229, #230, #231,
  1148. #232, #233, #234, #235, #236, #237, #238, #239,
  1149. #240, #241, #242, #243, #244, #245, #246, #215,
  1150. #248, #249, #250, #251, #252, #253, #254, #223,
  1151. #224, #225, #226, #227, #228, #229, #230, #231,
  1152. #232, #233, #234, #235, #236, #237, #238, #239,
  1153. #240, #241, #242, #243, #244, #245, #246, #247,
  1154. #248, #249, #250, #251, #252, #253, #254, #255 );
  1155. {
  1156. $Log$
  1157. Revision 1.20 2002-09-15 17:50:35 peter
  1158. * Fixed AnsiStrComp crashes
  1159. Revision 1.19 2002/09/07 16:01:22 peter
  1160. * old logs removed and tabs fixed
  1161. Revision 1.18 2002/09/02 06:07:16 michael
  1162. + Fix for formatbuf not applied correct
  1163. Revision 1.17 2002/08/29 10:04:48 michael
  1164. + Fix for bug report 2097 in formatbuf
  1165. Revision 1.16 2002/08/29 10:04:25 michael
  1166. + Fix for bug report 2097 in formatbuf
  1167. Revision 1.15 2002/07/06 12:14:03 daniel
  1168. - Changes from Strasbourg
  1169. Revision 1.14 2002/01/24 12:33:53 jonas
  1170. * adapted ranges of native types to int64 (e.g. high cardinal is no
  1171. longer longint($ffffffff), but just $fffffff in psystem)
  1172. * small additional fix in 64bit rangecheck code generation for 32 bit
  1173. processors
  1174. * adaption of ranges required the matching talgorithm used for selecting
  1175. which overloaded procedure to call to be adapted. It should now always
  1176. select the closest match for ordinal parameters.
  1177. + inttostr(qword) in sysstr.inc/sysstrh.inc
  1178. + abs(int64), sqr(int64), sqr(qword) in systemh.inc/generic.inc (previous
  1179. fixes were required to be able to add them)
  1180. * is_in_limit() moved from ncal to types unit, should always be used
  1181. instead of direct comparisons of low/high values of orddefs because
  1182. qword is a special case
  1183. }