cvarutil.inc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2000,2001 by the Free Pascal development team
  5. Interface and OS-dependent part of variant support
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$ifdef HASVARIANT}
  13. Resourcestring
  14. SNoWidestrings = 'No widestrings supported';
  15. SNoInterfaces = 'No interfaces supported';
  16. Procedure NoWidestrings;
  17. begin
  18. Raise Exception.Create(SNoWideStrings);
  19. end;
  20. Procedure NoInterfaces;
  21. begin
  22. Raise Exception.Create(SNoInterfaces);
  23. end;
  24. Constructor EVariantError.CreateCode (Code : longint);
  25. begin
  26. ErrCode:=Code;
  27. end;
  28. Procedure VariantTypeMismatch;
  29. begin
  30. Raise EVariantError.CreateCode(VAR_TYPEMISMATCH);
  31. end;
  32. Function ExceptionToVariantError (E : Exception): HResult;
  33. begin
  34. If E is EoutOfMemory then
  35. Result:=VAR_OUTOFMEMORY
  36. else
  37. Result:=VAR_EXCEPTION;
  38. end;
  39. { ---------------------------------------------------------------------
  40. OS-independent functions not present in Windows
  41. ---------------------------------------------------------------------}
  42. Function VariantToSmallInt(Const VargSrc : TVarData) : SmallInt;
  43. begin
  44. With VargSrc do
  45. Case (VType and VarTypeMask) of
  46. VarSmallInt: Result:=VSmallInt;
  47. VarShortInt: Result:=VShortInt;
  48. VarInteger : Result:=VInteger;
  49. VarSingle : Result:=Round(VSingle);
  50. VarDouble : Result:=Round(VDouble);
  51. VarCurrency: Result:=Round(VCurrency);
  52. VarDate : Result:=Round(VDate);
  53. VarOleStr : Result:=StrToInt(WideCharToString(vOleStr));
  54. VarBoolean : Result:=SmallInt(VBoolean);
  55. VarByte : Result:=VByte;
  56. VarWord : Result:=VWord;
  57. VarLongWord : Result:=VLongWord;
  58. VarInt64 : Result:=VInt64;
  59. VarQword : Result:=VQWord;
  60. else
  61. VariantTypeMismatch;
  62. end;
  63. end;
  64. Function VariantToShortInt(Const VargSrc : TVarData) : ShortInt;
  65. begin
  66. With VargSrc do
  67. Case (VType and VarTypeMask) of
  68. VarSmallInt: Result:=VSmallInt;
  69. VarShortInt: Result:=VShortInt;
  70. VarInteger : Result:=VInteger;
  71. VarSingle : Result:=Round(VSingle);
  72. VarDouble : Result:=Round(VDouble);
  73. VarCurrency: Result:=Round(VCurrency);
  74. VarDate : Result:=Round(VDate);
  75. VarOleStr : Result:=StrToInt(WideCharToString(vOleStr));
  76. VarBoolean : Result:=SmallInt(VBoolean);
  77. VarByte : Result:=VByte;
  78. VarWord : Result:=VWord;
  79. VarLongWord : Result:=VLongWord;
  80. VarInt64 : Result:=VInt64;
  81. VarQword : Result:=VQWord;
  82. else
  83. VariantTypeMismatch;
  84. end;
  85. end;
  86. Function VariantToLongint(Const VargSrc : TVarData) : Longint;
  87. begin
  88. With VargSrc do
  89. Case (VType and VarTypeMask) of
  90. VarSmallInt: Result:=VSmallInt;
  91. VarShortInt: Result:=VShortInt;
  92. VarInteger : Result:=VInteger;
  93. VarSingle : Result:=Round(VSingle);
  94. VarDouble : Result:=Round(VDouble);
  95. VarCurrency: Result:=Round(VCurrency);
  96. VarDate : Result:=Round(VDate);
  97. VarOleStr :
  98. if not(TryStrToInt(WideCharToString(vOleStr),Result)) then
  99. VariantTypeMismatch;
  100. VarString :
  101. if not(TryStrToInt(ansistring(vString),Result)) then
  102. VariantTypeMismatch;
  103. VarBoolean : Result:=Longint(VBoolean);
  104. VarByte : Result:=VByte;
  105. VarWord : Result:=VWord;
  106. VarLongWord : Result:=VLongWord;
  107. VarInt64 : Result:=VInt64;
  108. VarQword : Result:=VQWord;
  109. else
  110. VariantTypeMismatch;
  111. end;
  112. end;
  113. Function VariantToCardinal(Const VargSrc : TVarData) : Cardinal;
  114. var
  115. l : longint;
  116. begin
  117. With VargSrc do
  118. Case (VType and VarTypeMask) of
  119. VarSmallInt: Result:=VSmallInt;
  120. VarShortInt: Result:=VShortInt;
  121. VarInteger : Result:=VInteger;
  122. VarSingle : Result:=Round(VSingle);
  123. VarDouble : Result:=Round(VDouble);
  124. VarCurrency: Result:=Round(VCurrency);
  125. VarDate : Result:=Round(VDate);
  126. VarOleStr :
  127. begin
  128. if not(TryStrToInt(WideCharToString(vOleStr),l)) then
  129. VariantTypeMismatch;
  130. result:=l;
  131. end;
  132. VarString :
  133. begin
  134. if not(TryStrToInt(ansistring(vString),l)) then
  135. VariantTypeMismatch;
  136. result:=l;
  137. end;
  138. VarBoolean : Result:=Longint(VBoolean);
  139. VarByte : Result:=VByte;
  140. VarWord : Result:=VWord;
  141. VarLongWord : Result:=VLongWord;
  142. VarInt64 : Result:=VInt64;
  143. VarQword : Result:=VQWord;
  144. else
  145. VariantTypeMismatch;
  146. end;
  147. end;
  148. Function VariantToSingle(Const VargSrc : TVarData) : Single;
  149. var
  150. e : extended;
  151. begin
  152. With VargSrc do
  153. Case (VType and VarTypeMask) of
  154. VarSmallInt: Result:=VSmallInt;
  155. VarShortInt: Result:=VShortInt;
  156. VarInteger : Result:=VInteger;
  157. VarSingle : Result:=VSingle;
  158. VarDouble : Result:=VDouble;
  159. VarCurrency: Result:=VCurrency;
  160. VarDate : Result:=VDate;
  161. VarOleStr :
  162. begin
  163. if not(TryStrToFloat(WideCharToString(vOleStr),Result)) then
  164. VariantTypeMismatch;
  165. result:=e;
  166. end;
  167. VarString :
  168. begin
  169. if not(TryStrToFloat(ansistring(vString),Result)) then
  170. VariantTypeMismatch;
  171. result:=e;
  172. end;
  173. VarBoolean : Result:=Longint(VBoolean);
  174. VarByte : Result:=VByte;
  175. VarWord : Result:=VWord;
  176. VarLongWord : Result:=VLongWord;
  177. VarInt64 : Result:=VInt64;
  178. VarQword : Result:=VQWord;
  179. else
  180. VariantTypeMismatch;
  181. end;
  182. end;
  183. Function VariantToDouble(Const VargSrc : TVarData) : Double;
  184. var
  185. e : extended;
  186. begin
  187. With VargSrc do
  188. Case (VType and VarTypeMask) of
  189. VarSmallInt: Result:=VSmallInt;
  190. VarShortInt: Result:=VShortInt;
  191. VarInteger : Result:=VInteger;
  192. VarSingle : Result:=VSingle;
  193. VarDouble : Result:=VDouble;
  194. VarCurrency: Result:=VCurrency;
  195. VarDate : Result:=VDate;
  196. VarOleStr :
  197. begin
  198. if not(TryStrToFloat(WideCharToString(vOleStr),Result)) then
  199. VariantTypeMismatch;
  200. result:=e;
  201. end;
  202. VarString :
  203. begin
  204. if not(TryStrToFloat(ansistring(vString),Result)) then
  205. VariantTypeMismatch;
  206. result:=e;
  207. end;
  208. VarBoolean : Result:=Longint(VBoolean);
  209. VarByte : Result:=VByte;
  210. VarWord : Result:=VWord;
  211. VarLongWord : Result:=VLongWord;
  212. VarInt64 : Result:=VInt64;
  213. VarQword : Result:=VQWord;
  214. else
  215. VariantTypeMismatch;
  216. end;
  217. end;
  218. Function VariantToCurrency(Const VargSrc : TVarData) : Currency;
  219. begin
  220. Try
  221. With VargSrc do
  222. Case (VType and VarTypeMask) of
  223. VarSmallInt: Result:=VSmallInt;
  224. VarShortInt: Result:=VShortInt;
  225. VarInteger : Result:=VInteger;
  226. VarSingle : Result:=FloatToCurr(VSingle);
  227. VarDouble : Result:=FloatToCurr(VDouble);
  228. VarCurrency: Result:=VCurrency;
  229. VarDate : Result:=FloatToCurr(VDate);
  230. VarOleStr :
  231. if not(TryStrToCurr(WideCharToString(vOleStr),Result)) then
  232. VariantTypeMismatch;
  233. VarString :
  234. if not(TryStrToCurr(ansistring(vString),Result)) then
  235. VariantTypeMismatch;
  236. VarBoolean : Result:=Longint(VBoolean);
  237. VarByte : Result:=VByte;
  238. VarWord : Result:=VWord;
  239. VarLongWord : Result:=VLongWord;
  240. VarInt64 : Result:=VInt64;
  241. VarQword : Result:=VQWord;
  242. else
  243. VariantTypeMismatch;
  244. end;
  245. except
  246. On EConvertError do
  247. VariantTypeMismatch;
  248. else
  249. Raise;
  250. end;
  251. end;
  252. Function VariantToDate(Const VargSrc : TVarData) : TDateTime;
  253. begin
  254. Try
  255. With VargSrc do
  256. Case (VType and VarTypeMask) of
  257. VarSmallInt: Result:=FloatToDateTime(VSmallInt);
  258. VarShortInt: Result:=FloatToDateTime(VShortInt);
  259. VarInteger : Result:=FloatToDateTime(VInteger);
  260. VarSingle : Result:=FloatToDateTime(VSingle);
  261. VarDouble : Result:=FloatToDateTime(VDouble);
  262. VarCurrency: Result:=FloatToDateTime(VCurrency);
  263. VarDate : Result:=VDate;
  264. VarOleStr : NoWideStrings;
  265. VarBoolean : Result:=FloatToDateTime(Longint(VBoolean));
  266. VarByte : Result:=FloatToDateTime(VByte);
  267. VarWord : Result:=FloatToDateTime(VWord);
  268. VarLongWord : Result:=FloatToDateTime(VLongWord);
  269. VarInt64 : Result:=FloatToDateTime(VInt64);
  270. VarQWord : Result:=FloatToDateTime(VQword);
  271. else
  272. VariantTypeMismatch;
  273. end;
  274. except
  275. On EConvertError do
  276. VariantTypeMismatch;
  277. else
  278. Raise;
  279. end;
  280. end;
  281. Function VariantToBoolean(Const VargSrc : TVarData) : Boolean;
  282. begin
  283. With VargSrc do
  284. Case (VType and VarTypeMask) of
  285. VarSmallInt: Result:=VSmallInt<>0;
  286. VarShortInt: Result:=VShortInt<>0;
  287. VarInteger : Result:=VInteger<>0;
  288. VarSingle : Result:=VSingle<>0;
  289. VarDouble : Result:=VDouble<>0;
  290. VarCurrency: Result:=VCurrency<>0;
  291. VarDate : Result:=VDate<>0;
  292. VarOleStr : NoWideStrings;
  293. VarBoolean : Result:=VBoolean;
  294. VarByte : Result:=VByte<>0;
  295. VarWord : Result:=VWord<>0;
  296. VarLongWord : Result:=VLongWord<>0;
  297. VarInt64 : Result:=Vint64<>0;
  298. VarQword : Result:=VQWord<>0;
  299. else
  300. VariantTypeMismatch;
  301. end;
  302. end;
  303. Function VariantToByte(Const VargSrc : TVarData) : Byte;
  304. begin
  305. Try
  306. With VargSrc do
  307. Case (VType and VarTypeMask) of
  308. VarSmallInt: Result:=VSmallInt;
  309. VarShortInt: Result:=VShortInt;
  310. VarInteger : Result:=VInteger;
  311. VarSingle : Result:=Round(VSingle);
  312. VarDouble : Result:=Round(VDouble);
  313. VarCurrency: Result:=Round(VCurrency);
  314. VarDate : Result:=Round(VDate);
  315. VarOleStr : NoWideStrings;
  316. VarBoolean : Result:=Longint(VBoolean);
  317. VarByte : Result:=VByte;
  318. VarWord : Result:=VWord;
  319. VarLongWord : Result:=VLongWord;
  320. VarInt64 : Result:=Vint64;
  321. VarQword : Result:=VQWord;
  322. else
  323. VariantTypeMismatch;
  324. end;
  325. except
  326. On EConvertError do
  327. VariantTypeMismatch;
  328. else
  329. Raise;
  330. end;
  331. end;
  332. Function VariantToInt64(Const VargSrc : TVarData) : Int64;
  333. begin
  334. Try
  335. With VargSrc do
  336. Case (VType and VarTypeMask) of
  337. VarSmallInt: Result:=VSmallInt;
  338. VarShortInt: Result:=VShortInt;
  339. VarInteger : Result:=VInteger;
  340. VarSingle : Result:=Trunc(VSingle);
  341. VarDouble : Result:=Trunc(VDouble);
  342. {$ifdef HASCURRENCY}
  343. VarCurrency: Result:=Trunc(VCurrency);
  344. {$else}
  345. VarCurrency: Result:=VCurrency;
  346. {$endif}
  347. VarDate : Result:=Trunc(VDate);
  348. VarOleStr : NoWideStrings;
  349. VarBoolean : Result:=Longint(VBoolean);
  350. VarByte : Result:=VByte;
  351. VarWord : Result:=VWord;
  352. VarLongWord : Result:=VLongWord;
  353. VarInt64 : Result:=VInt64;
  354. VarQword : Result:=VQWord;
  355. else
  356. VariantTypeMismatch;
  357. end;
  358. except
  359. On EConvertError do
  360. VariantTypeMismatch;
  361. else
  362. Raise;
  363. end;
  364. end;
  365. Function VariantToQWord(Const VargSrc : TVarData) : QWord;
  366. begin
  367. Try
  368. With VargSrc do
  369. Case (VType and VarTypeMask) of
  370. VarSmallInt: Result:=VSmallint;
  371. VarShortInt: Result:=VShortInt;
  372. VarInteger : Result:=VInteger;
  373. VarSingle : Result:=Trunc(VSingle);
  374. VarDouble : Result:=Trunc(VDouble);
  375. {$ifdef HASCURRENCY}
  376. VarCurrency: Result:=Trunc(VCurrency);
  377. {$else}
  378. VarCurrency: Result:=VCurrency;
  379. {$endif}
  380. VarDate : Result:=Trunc(VDate);
  381. VarOleStr : NoWideStrings;
  382. VarBoolean : Result:=Longint(VBoolean);
  383. VarByte : Result:=VByte;
  384. VarWord : Result:=VWord;
  385. VarLongWord : Result:=VLongWord;
  386. VarInt64 : Result:=VInt64;
  387. VarQword : Result:=VQWord;
  388. else
  389. VariantTypeMismatch;
  390. end;
  391. except
  392. On EConvertError do
  393. VariantTypeMismatch;
  394. else
  395. Raise;
  396. end;
  397. end;
  398. Function VariantToWideString(Const VargSrc : TVarData) : WideString;
  399. Const
  400. BS : Array[Boolean] of WideString = ('False','True');
  401. begin
  402. Try
  403. With VargSrc do
  404. Case (VType and VarTypeMask) of
  405. VarSmallInt : Result:=IntTostr(VSmallint);
  406. VarShortInt : Result:=IntToStr(VShortInt);
  407. VarInteger : Result:=IntToStr(VInteger);
  408. VarSingle : Result:=FloatToStr(VSingle);
  409. VarDouble : Result:=FloatToStr(VDouble);
  410. VarCurrency : Result:=FloatToStr(VCurrency);
  411. VarDate : Result:=DateTimeToStr(VDate);
  412. VarOleStr : Result:=WideString(Pointer(VOleStr));
  413. VarBoolean : Result:=BS[VBoolean];
  414. VarByte : Result:=IntToStr(VByte);
  415. VarWord : Result:=IntToStr(VWord);
  416. VarLongWord : Result:=IntToStr(VLongWord);
  417. VarInt64 : Result:=IntToStr(VInt64);
  418. VarQword : Result:=IntToStr(VQWord);
  419. else
  420. VariantTypeMismatch;
  421. end;
  422. except
  423. On EConvertError do
  424. VariantTypeMismatch;
  425. else
  426. Raise;
  427. end;
  428. end;
  429. Function VariantToAnsiString(Const VargSrc : TVarData) : AnsiString;
  430. Const
  431. BS : Array[Boolean] of AnsiString = ('False','True');
  432. begin
  433. Try
  434. With VargSrc do
  435. Case (VType and VarTypeMask) of
  436. VarSmallInt : Result:=IntTostr(VSmallint);
  437. VarShortInt : Result:=IntToStr(VShortInt);
  438. VarInteger : Result:=IntToStr(VInteger);
  439. VarSingle : Result:=FloatToStr(VSingle);
  440. VarDouble : Result:=FloatToStr(VDouble);
  441. VarCurrency : Result:=FloatToStr(VCurrency);
  442. VarDate : Result:=DateTimeToStr(VDate);
  443. VarOleStr : Result:=WideCharToString(VOleStr);
  444. VarBoolean : Result:=BS[VBoolean];
  445. VarByte : Result:=IntToStr(VByte);
  446. VarWord : Result:=IntToStr(VWord);
  447. VarLongWord : Result:=IntToStr(VLongWord);
  448. VarInt64 : Result:=IntToStr(VInt64);
  449. VarQword : Result:=IntToStr(VQWord);
  450. VarString : Result:=ansistring(VString);
  451. else
  452. VariantTypeMismatch;
  453. end;
  454. except
  455. On EConvertError do
  456. VariantTypeMismatch;
  457. else
  458. Raise;
  459. end;
  460. end;
  461. Function VariantToShortString(Const VargSrc : TVarData) : ShortString;
  462. Var
  463. S : AnsiString;
  464. begin
  465. S:=VariantToAnsiString(VArgSrc);
  466. Result:=S;
  467. end;
  468. { ---------------------------------------------------------------------
  469. Some debug routines
  470. ---------------------------------------------------------------------}
  471. Procedure DumpVariant(Const VArgSrc : TVarData);
  472. begin
  473. DumpVariant(Output,VArgSrc);
  474. end;
  475. (*
  476. tvardata = packed record
  477. vtype : tvartype;
  478. case integer of
  479. 0:(res1 : word;
  480. case integer of
  481. 0:
  482. (res2,res3 : word;
  483. case word of
  484. varsmallint : (vsmallint : smallint);
  485. varinteger : (vinteger : longint);
  486. varsingle : (vsingle : single);
  487. vardouble : (vdouble : double);
  488. varcurrency : (vcurrency : currency);
  489. vardate : (vdate : tdatetime);
  490. varolestr : (volestr : pwidechar);
  491. vardispatch : (vdispatch : pointer);
  492. varerror : (verror : dword);
  493. varboolean : (vboolean : wordbool);
  494. varunknown : (vunknown : pointer);
  495. // vardecimal : ( : );
  496. varshortint : (vshortint : shortint);
  497. varbyte : (vbyte : byte);
  498. varword : (vword : word);
  499. varlongword : (vlongword : dword);
  500. varint64 : (vint64 : int64);
  501. varqword : (vqword : qword);
  502. varword64 : (vword64 : qword);
  503. varstring : (vstring : pointer);
  504. varany : (vany : pointer);
  505. vararray : (varray : pvararray);
  506. varbyref : (vpointer : pointer);
  507. );
  508. 1:
  509. (vlongs : array[0..2] of longint);
  510. );
  511. 1:(vwords : array[0..6] of word);
  512. 2:(vbytes : array[0..13] of byte);
  513. end;
  514. *)
  515. Const
  516. VarTypeStrings : Array [varEmpty..varqword] of string = (
  517. 'empty', 'null', 'smallint', 'integer', 'single', 'double',
  518. 'currency', 'date', 'olestr', 'dispatch', 'error', 'boolean',
  519. 'variant', 'unknown', 'unknown','decimal', 'shortint', 'byte', 'word',
  520. 'longword', 'int64', 'qword');
  521. Procedure DumpVariant(Var F : Text; Const VArgSrc : TVarData);
  522. Var
  523. W : WideString;
  524. begin
  525. If VArgSrc.vType in [varEmpty..varqword] then
  526. Writeln(F,'Variant has type : ',VarTypeStrings[VArgSrc.vType])
  527. else if (VArgSrc.vType=VarArray) Then
  528. begin
  529. Write(F,'Variant is array.');
  530. exit;
  531. end
  532. else if (VargSrc.vType=VarByRef) then
  533. begin
  534. Writeln(F,'Variant is by reference.');
  535. exit;
  536. end
  537. else
  538. begin
  539. Writeln(F,'Variant has unknown type: ', VargSrc.vType);
  540. Exit;
  541. end;
  542. If VArgSrc.vType<>varEmpty then
  543. With VArgSrc do
  544. begin
  545. Write(F,'Value is: ') ;
  546. Case vtype of
  547. varnull : Write(F,'Null');
  548. varsmallint : Write(F,vsmallint);
  549. varinteger : Write(F,vinteger);
  550. varsingle : Write(F,vsingle);
  551. vardouble : Write(F,vdouble);
  552. varcurrency : Write(F,vcurrency) ;
  553. vardate : Write(F,vdate) ;
  554. varolestr : begin
  555. W:=vOleStr;
  556. Write(F,W) ;
  557. end;
  558. vardispatch : Write(F,'Not suppordted') ;
  559. varerror : Write(F,'Error') ;
  560. varboolean : Write(F,vboolean) ;
  561. varvariant : Write(F,'Unsupported') ;
  562. varunknown : Write(F,'Unsupported') ;
  563. vardecimal : Write(F,'Unsupported') ;
  564. varshortint : Write(F,vshortint) ;
  565. varbyte : Write(F,vbyte) ;
  566. varword : Write(F,vword) ;
  567. varlongword : Write(F,vlongword) ;
  568. varint64 : Write(F,vint64) ;
  569. varqword : Write(F,vqword) ;
  570. end;
  571. Writeln(f);
  572. end;
  573. end;
  574. {$endif HASVARIANT}
  575. {
  576. $Log$
  577. Revision 1.14 2005-04-28 09:15:44 florian
  578. + variants: string -> float/int casts
  579. Revision 1.13 2005/03/28 20:36:14 florian
  580. * some variant <-> string types fixes
  581. Revision 1.12 2005/03/10 21:05:36 florian
  582. + writing of variants implemented
  583. Revision 1.11 2005/02/14 17:13:31 peter
  584. * truncate log
  585. }