sysstr.inc 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375
  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(vtAnsiString,true) then
  764. hs:=ansistring(Args[doarg].VAnsiString);
  765. Index:=Length(hs);
  766. If (Prec<>-1) and (Index>Prec) then
  767. Index:=Prec;
  768. ToAdd:=Copy(hs,1,Index);
  769. end;
  770. 'P' : Begin
  771. CheckArg(vtpointer,true);
  772. ToAdd:=HexStr(Longint(Args[DoArg].VPointer),8);
  773. // Insert ':'. Is this needed in 32 bit ? No it isn't.
  774. // Insert(':',ToAdd,5);
  775. end;
  776. 'X' : begin
  777. Checkarg(vtinteger,true);
  778. If Prec>15 then
  779. ToAdd:=HexStr(Args[Doarg].VInteger,15)
  780. else
  781. begin
  782. // determine minimum needed number of hex digits.
  783. Index:=1;
  784. While (DWord(1 shl (Index*4))<=DWord(Args[DoArg].VInteger)) and (index<8) do
  785. inc(Index);
  786. If Index>Prec then
  787. Prec:=Index;
  788. ToAdd:=HexStr(Args[DoArg].VInteger,Prec);
  789. end;
  790. end;
  791. '%': ToAdd:='%';
  792. end;
  793. If Width<>-1 then
  794. If Length(ToAdd)<Width then
  795. If not Left then
  796. ToAdd:=Space(Width-Length(ToAdd))+ToAdd
  797. else
  798. ToAdd:=ToAdd+space(Width-Length(ToAdd));
  799. Result:=Result+ToAdd;
  800. end;
  801. inc(chpos);
  802. Oldpos:=chpos;
  803. end;
  804. end;
  805. Function FormatBuf (Var Buffer; BufLen : Cardinal;
  806. Const Fmt; fmtLen : Cardinal;
  807. Const Args : Array of const) : Cardinal;
  808. Var S,F : String;
  809. begin
  810. Setlength(F,fmtlen);
  811. if fmtlen > 0 then
  812. Move(fmt,F[1],fmtlen);
  813. S:=Format (F,Args);
  814. If Cardinal(Length(S))>Buflen then
  815. Result:=Length(S)
  816. else
  817. Result:=Buflen;
  818. if Result > 0 then
  819. Move(S[1],Buffer,Result);
  820. end;
  821. Procedure FmtStr(Var Res: String; Const Fmt : String; Const args: Array of const);
  822. begin
  823. Res:=Format(fmt,Args);
  824. end;
  825. Function StrFmt(Buffer,Fmt : PChar; Const args: Array of const) : Pchar;
  826. begin
  827. Buffer[FormatBuf(Buffer^,Maxint,Fmt^,strlen(fmt),args)]:=#0;
  828. Result:=Buffer;
  829. end;
  830. Function StrLFmt(Buffer : PCHar; Maxlen : Cardinal;Fmt : PChar; Const args: Array of const) : Pchar;
  831. begin
  832. Buffer[FormatBuf(Buffer^,MaxLen,Fmt^,strlen(fmt),args)]:=#0;
  833. Result:=Buffer;
  834. end;
  835. function StrToFloat(Value: string): Extended;
  836. var Error: word;
  837. begin
  838. Val(Value, result, Error);
  839. if Error <> 0 then raise
  840. EConvertError.createfmt(SInValidFLoat,[Value]);
  841. end ;
  842. Function FloatToStr(Value: Extended): String;
  843. Begin
  844. Result := FloatToStrF(Value, ffGeneral, 15, 0);
  845. End;
  846. Function FloatToText(Buffer: PChar; Value: Extended; format: TFloatFormat; Precision, Digits: Integer): Longint;
  847. Var
  848. Tmp: String[40];
  849. Begin
  850. Tmp := FloatToStrF(Value, format, Precision, Digits);
  851. Result := Length(Tmp);
  852. Move(Tmp[1], Buffer[0], Result);
  853. End;
  854. Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: Integer): String;
  855. Var
  856. P: Integer;
  857. Negative, TooSmall, TooLarge: Boolean;
  858. Begin
  859. Case format Of
  860. ffGeneral:
  861. Begin
  862. If (Precision = -1) Or (Precision > 15) Then Precision := 15;
  863. TooSmall := (Abs(Value) < 0.00001) and (Value>0.0);
  864. If Not TooSmall Then
  865. Begin
  866. Str(Value:0:999, Result);
  867. P := Pos('.', Result);
  868. Result[P] := DecimalSeparator;
  869. TooLarge := P > Precision + 1;
  870. End;
  871. If TooSmall Or TooLarge Then
  872. begin
  873. Result := FloatToStrF(Value, ffExponent, Precision, Digits);
  874. // Strip unneeded zeroes.
  875. P:=Pos('E',result)-1;
  876. If P<>-1 then
  877. While (P>1) and (Result[P]='0') do
  878. begin
  879. system.Delete(Result,P,1);
  880. Dec(P);
  881. end;
  882. end
  883. else
  884. begin
  885. P := Length(Result);
  886. While Result[P] = '0' Do Dec(P);
  887. If Result[P] = DecimalSeparator Then Dec(P);
  888. SetLength(Result, P);
  889. end;
  890. End;
  891. ffExponent:
  892. Begin
  893. If (Precision = -1) Or (Precision > 15) Then Precision := 15;
  894. Str(Value:Precision + 8, Result);
  895. Result[3] := DecimalSeparator;
  896. P:=4;
  897. While (P>0) and (Digits < P) And (Result[Precision + 5] = '0') do
  898. Begin
  899. If P<>1 then
  900. system.Delete(Result, Precision + 5, 1)
  901. else
  902. system.Delete(Result, Precision + 3, 3);
  903. Dec(P);
  904. end;
  905. If Result[1] = ' ' Then
  906. System.Delete(Result, 1, 1);
  907. End;
  908. ffFixed:
  909. Begin
  910. If Digits = -1 Then Digits := 2
  911. Else If Digits > 15 Then Digits := 15;
  912. Str(Value:0:Digits, Result);
  913. If Result[1] = ' ' Then
  914. System.Delete(Result, 1, 1);
  915. P := Pos('.', Result);
  916. If P <> 0 Then Result[P] := DecimalSeparator;
  917. End;
  918. ffNumber:
  919. Begin
  920. If Digits = -1 Then Digits := 2
  921. Else If Digits > 15 Then Digits := 15;
  922. Str(Value:0:Digits, Result);
  923. If Result[1] = ' ' Then System.Delete(Result, 1, 1);
  924. P := Pos('.', Result);
  925. If P <> 0 Then
  926. Result[P] := DecimalSeparator
  927. else
  928. P := Length(Result)+1;
  929. Dec(P, 3);
  930. While (P > 1) Do
  931. Begin
  932. If Result[P - 1] <> '-' Then Insert(ThousandSeparator, Result, P);
  933. Dec(P, 3);
  934. End;
  935. End;
  936. ffCurrency:
  937. Begin
  938. If Value < 0 Then
  939. Begin
  940. Negative := True;
  941. Value := -Value;
  942. End
  943. Else Negative := False;
  944. If Digits = -1 Then Digits := CurrencyDecimals
  945. Else If Digits > 18 Then Digits := 18;
  946. Str(Value:0:Digits, Result);
  947. If Result[1] = ' ' Then System.Delete(Result, 1, 1);
  948. P := Pos('.', Result);
  949. If P <> 0 Then Result[P] := DecimalSeparator;
  950. Dec(P, 3);
  951. While (P > 1) Do
  952. Begin
  953. Insert(ThousandSeparator, Result, P);
  954. Dec(P, 3);
  955. End;
  956. If Not Negative Then
  957. Begin
  958. Case CurrencyFormat Of
  959. 0: Result := CurrencyString + Result;
  960. 1: Result := Result + CurrencyString;
  961. 2: Result := CurrencyString + ' ' + Result;
  962. 3: Result := Result + ' ' + CurrencyString;
  963. End
  964. End
  965. Else
  966. Begin
  967. Case NegCurrFormat Of
  968. 0: Result := '(' + CurrencyString + Result + ')';
  969. 1: Result := '-' + CurrencyString + Result;
  970. 2: Result := CurrencyString + '-' + Result;
  971. 3: Result := CurrencyString + Result + '-';
  972. 4: Result := '(' + Result + CurrencyString + ')';
  973. 5: Result := '-' + Result + CurrencyString;
  974. 6: Result := Result + '-' + CurrencyString;
  975. 7: Result := Result + CurrencyString + '-';
  976. 8: Result := '-' + Result + ' ' + CurrencyString;
  977. 9: Result := '-' + CurrencyString + ' ' + Result;
  978. 10: Result := CurrencyString + ' ' + Result + '-';
  979. End;
  980. End;
  981. End;
  982. End;
  983. End;
  984. Function FloatToDateTime (Const Value : Extended) : TDateTime;
  985. begin
  986. If (Value<MinDateTime) or (Value>MaxDateTime) then
  987. Raise EConvertError.CreateFmt (SInvalidDateTime,[Value]);
  988. Result:=Value;
  989. end;
  990. Function FloatToCurr (Const Value : Extended) : Currency;
  991. begin
  992. end;
  993. Function CurrToStr(Value: Currency): string;
  994. begin
  995. end;
  996. function StrToCurr(const S: string): Currency;
  997. begin
  998. end;
  999. function StrToBool(const S: string): Boolean;
  1000. Var
  1001. Temp : String;
  1002. D : Double;
  1003. Code : word;
  1004. begin
  1005. Temp:=upcase(S);
  1006. Val(temp,D,code);
  1007. If Code=0 then
  1008. Result:=(D<>0.0)
  1009. else If Temp='TRUE' then
  1010. result:=true
  1011. else if Temp='FALSE' then
  1012. result:=false
  1013. else
  1014. Raise EConvertError.CreateFmt(SInvalidBoolean,[S]);
  1015. end;
  1016. function BoolToStr(B: Boolean): string;
  1017. begin
  1018. If B then
  1019. Result:='TRUE'
  1020. else
  1021. Result:='FALSE';
  1022. end;
  1023. {==============================================================================}
  1024. { extra functions }
  1025. {==============================================================================}
  1026. { LeftStr returns Count left-most characters from S }
  1027. function LeftStr(const S: string; Count: integer): string;
  1028. begin
  1029. result := Copy(S, 1, Count);
  1030. end ;
  1031. { RightStr returns Count right-most characters from S }
  1032. function RightStr(const S: string; Count: integer): string;
  1033. begin
  1034. If Count>Length(S) then
  1035. Count:=Length(S);
  1036. result := Copy(S, 1 + Length(S) - Count, Count);
  1037. end;
  1038. { BCDToInt converts the BCD value Value to an integer }
  1039. function BCDToInt(Value: integer): integer;
  1040. var i, j: integer;
  1041. begin
  1042. result := 0;
  1043. j := 1;
  1044. for i := 0 to SizeOf(Value) shr 1 - 1 do begin
  1045. result := result + j * (Value and 15);
  1046. j := j * 10;
  1047. Value := Value shr 4;
  1048. end ;
  1049. end ;
  1050. Function LastDelimiter(const Delimiters, S: string): Integer;
  1051. begin
  1052. Result:=Length(S);
  1053. While (Result>0) and (Pos(S[Result],Delimiters)=0) do
  1054. Dec(Result);
  1055. end;
  1056. function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;
  1057. var
  1058. Srch,OldP,RemS: string; // Srch and Oldp can contain uppercase versions of S,OldPattern
  1059. P : Integer;
  1060. begin
  1061. Srch:=S;
  1062. OldP:=OldPattern;
  1063. if rfIgnoreCase in Flags then
  1064. begin
  1065. Srch:=UpperCase(Srch);
  1066. OldP:=UpperCase(OldP);
  1067. end;
  1068. RemS:=S;
  1069. Result:='';
  1070. while (Length(Srch)<>0) do
  1071. begin
  1072. P:=Pos(OldP, Srch);
  1073. if P=0 then
  1074. begin
  1075. Result:=Result+RemS;
  1076. Srch:='';
  1077. end
  1078. else
  1079. begin
  1080. Result:=Result+Copy(RemS,1,P-1)+NewPattern;
  1081. P:=P+Length(OldP);
  1082. RemS:=Copy(RemS,P,Length(RemS)-P+1);
  1083. if not (rfReplaceAll in Flags) then
  1084. begin
  1085. Result:=Result+RemS;
  1086. Srch:='';
  1087. end
  1088. else
  1089. Srch:=Copy(Srch,P,Length(Srch)-P+1);
  1090. end;
  1091. end;
  1092. end;
  1093. {
  1094. Case Translation Tables
  1095. Can be used in internationalization support.
  1096. Although these tables can be obtained through system calls
  1097. it is better to not use those, since most implementation are not 100%
  1098. WARNING:
  1099. before modifying a translation table make sure that the current codepage
  1100. of the OS corresponds to the one you make changes to
  1101. }
  1102. const
  1103. { upper case translation table for character set 850 }
  1104. CP850UCT: array[128..255] of char =
  1105. ('€', 'š', '�', '¶', 'Ž', '¶', '�', '€', 'Ò', 'Ó', 'Ô', 'Ø', '×', 'Þ', 'Ž', '�',
  1106. '�', '’', '’', 'â', '™', 'ã', 'ê', 'ë', 'Y', '™', 'š', '�', 'œ', '�', 'ž', 'Ÿ',
  1107. 'µ', 'Ö', 'à', 'é', '¥', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯',
  1108. '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿',
  1109. 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ç', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï',
  1110. 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß',
  1111. 'à', 'á', 'â', 'ã', 'å', 'å', 'æ', 'í', 'è', 'é', 'ê', 'ë', 'í', 'í', 'î', 'ï',
  1112. 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ');
  1113. { lower case translation table for character set 850 }
  1114. CP850LCT: array[128..255] of char =
  1115. ('‡', '�', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', '�', '„', '†',
  1116. '‚', '‘', '‘', '“', '”', '•', '–', '—', '˜', '”', '�', '›', 'œ', '›', 'ž', 'Ÿ',
  1117. ' ', '¡', '¢', '£', '¤', '¤', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯',
  1118. '°', '±', '²', '³', '´', ' ', 'ƒ', '…', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿',
  1119. 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Æ', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï',
  1120. 'Ð', 'Ñ', 'ˆ', '‰', 'Š', 'Õ', '¡', 'Œ', '‹', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', '�', 'ß',
  1121. '¢', 'á', '“', '•', 'ä', 'ä', 'æ', 'í', 'è', '£', '–', '—', 'ì', 'ì', 'î', 'ï',
  1122. 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ');
  1123. { upper case translation table for character set ISO 8859/1 Latin 1 }
  1124. CPISO88591UCT: array[192..255] of char =
  1125. ( #192, #193, #194, #195, #196, #197, #198, #199,
  1126. #200, #201, #202, #203, #204, #205, #206, #207,
  1127. #208, #209, #210, #211, #212, #213, #214, #215,
  1128. #216, #217, #218, #219, #220, #221, #222, #223,
  1129. #192, #193, #194, #195, #196, #197, #198, #199,
  1130. #200, #201, #202, #203, #204, #205, #206, #207,
  1131. #208, #209, #210, #211, #212, #213, #214, #247,
  1132. #216, #217, #218, #219, #220, #221, #222, #89 );
  1133. { lower case translation table for character set ISO 8859/1 Latin 1 }
  1134. CPISO88591LCT: array[192..255] of char =
  1135. ( #224, #225, #226, #227, #228, #229, #230, #231,
  1136. #232, #233, #234, #235, #236, #237, #238, #239,
  1137. #240, #241, #242, #243, #244, #245, #246, #215,
  1138. #248, #249, #250, #251, #252, #253, #254, #223,
  1139. #224, #225, #226, #227, #228, #229, #230, #231,
  1140. #232, #233, #234, #235, #236, #237, #238, #239,
  1141. #240, #241, #242, #243, #244, #245, #246, #247,
  1142. #248, #249, #250, #251, #252, #253, #254, #255 );
  1143. {
  1144. $Log$
  1145. Revision 1.14 2002-01-24 12:33:53 jonas
  1146. * adapted ranges of native types to int64 (e.g. high cardinal is no
  1147. longer longint($ffffffff), but just $fffffff in psystem)
  1148. * small additional fix in 64bit rangecheck code generation for 32 bit
  1149. processors
  1150. * adaption of ranges required the matching talgorithm used for selecting
  1151. which overloaded procedure to call to be adapted. It should now always
  1152. select the closest match for ordinal parameters.
  1153. + inttostr(qword) in sysstr.inc/sysstrh.inc
  1154. + abs(int64), sqr(int64), sqr(qword) in systemh.inc/generic.inc (previous
  1155. fixes were required to be able to add them)
  1156. * is_in_limit() moved from ncal to types unit, should always be used
  1157. instead of direct comparisons of low/high values of orddefs because
  1158. qword is a special case
  1159. Revision 1.13 2001/09/20 14:38:41 michael
  1160. Implemented missing StringReplace function
  1161. Revision 1.12 2001/08/01 21:44:20 peter
  1162. Revision 1.1.2.9 2001/09/20 14:35:34 michael
  1163. Implemented missing StringReplace function
  1164. Revision 1.1.2.8 2001/08/14 20:06:23 carl
  1165. -* replace ifdef linux -> ifdef unix
  1166. Revision 1.1.2.7 2001/08/01 21:45:22 peter
  1167. * fix thousend separator when no decimal separator is available
  1168. * allow precision to be left away like %10.n
  1169. Revision 1.11 2001/01/18 22:09:09 michael
  1170. + Merged fixes from fixbranch - file modes
  1171. Revision 1.10 2000/12/16 15:58:18 jonas
  1172. * removed warnings about possible range check errors
  1173. Revision 1.9 2000/12/07 21:58:30 michael
  1174. + Merged lastdelimiter from fixbranch
  1175. Revision 1.8 2000/12/06 22:55:29 michael
  1176. + Merged format fix from fixbranch
  1177. Revision 1.1.2.4 2000/12/07 21:48:57 michael
  1178. + Added LastDelimiter function
  1179. }