sysstr.inc 35 KB

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