scandir.inc 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Peter Vreman
  4. This unit implements directive parsing for the scanner
  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. }
  18. const
  19. directivelen=15;
  20. type
  21. directivestr=string[directivelen];
  22. tdirectivetoken=(
  23. _DIR_NONE,
  24. _DIR_ALIGN,_DIR_APPTYPE,_DIR_ASMMODE,_DIR_ASSERTIONS,
  25. _DIR_BOOLEVAL,
  26. _DIR_D,_DIR_DEBUGINFO,_DIR_DEFINE,_DIR_DESCRIPTION,
  27. _DIR_ELSE,_DIR_ENDIF,_DIR_ERROR,_DIR_EXTENDEDSYNTAX,
  28. _DIR_FATAL,
  29. _DIR_GOTO,
  30. _DIR_HINT,_DIR_HINTS,
  31. _DIR_I,_DIR_I386_ATT,_DIR_I386_DIRECT,_DIR_I386_INTEL,_DIR_IOCHECKS,
  32. _DIR_IF,_DIR_IFDEF,_DIR_IFNDEF,_DIR_IFOPT,_DIR_INCLUDE,_DIR_INCLUDEPATH,
  33. _DIR_INFO,_DIR_INLINE,
  34. _DIR_INTERFACES,
  35. _DIR_L,_DIR_LIBRARYPATH,_DIR_LINK,_DIR_LINKLIB,_DIR_LOCALSYMBOLS,
  36. _DIR_LONGSTRINGS,
  37. _DIR_M,_DIR_MACRO,_DIR_MAXFPUREGISTERS,_DIR_MEMORY,_DIR_MESSAGE,_DIR_MINENUMSIZE,_DIR_MMX,_DIR_MODE,
  38. _DIR_NOTE,_DIR_NOTES,
  39. _DIR_OBJECTPATH,_DIR_OPENSTRINGS,_DIR_OUTPUT_FORMAT,_DIR_OVERFLOWCHECKS,
  40. _DIR_PACKENUM,_DIR_PACKRECORDS,
  41. {$IFDEF Testvarsets}
  42. _DIR_PACKSET,
  43. {$ENDIF}
  44. _DIR_R,_DIR_RANGECHECKS,_DIR_REFERENCEINFO,
  45. _DIR_SATURATION,_DIR_SMARTLINK,_DIR_STACKFRAMES,_DIR_STATIC,_DIR_STOP,
  46. _DIR_TYPEDADDRESS,_DIR_TYPEINFO,
  47. _DIR_UNDEF,_DIR_UNITPATH,
  48. _DIR_VARSTRINGCHECKS,_DIR_VERSION,
  49. _DIR_WAIT,_DIR_WARNING,_DIR_WARNINGS,
  50. _DIR_Z1,_DIR_Z2,_DIR_Z4
  51. );
  52. const
  53. firstdirective=_DIR_NONE;
  54. lastdirective=_DIR_Z4;
  55. directive:array[tdirectivetoken] of directivestr=(
  56. {12345678901234567890 (To determine longest string.)}
  57. '',
  58. 'ALIGN',
  59. 'APPTYPE',
  60. 'ASMMODE',
  61. 'ASSERTIONS',
  62. 'BOOLEVAL',
  63. 'D',
  64. 'DEBUGINFO',
  65. 'DEFINE',
  66. 'DESCRIPTION',
  67. 'ELSE',
  68. 'ENDIF',
  69. 'ERROR',
  70. 'EXTENDEDSYNTAX',
  71. 'FATAL',
  72. 'GOTO',
  73. 'HINT',
  74. 'HINTS',
  75. 'I',
  76. {12345678901234567890 (To determine longest string.)}
  77. 'I386_ATT',
  78. 'I386_DIRECT',
  79. 'I386_INTEL',
  80. 'IOCHECKS',
  81. 'IF',
  82. 'IFDEF',
  83. 'IFNDEF',
  84. 'IFOPT',
  85. 'INCLUDE',
  86. 'INCLUDEPATH',
  87. 'INFO',
  88. 'INLINE',
  89. 'INTERFACES',
  90. 'L',
  91. 'LIBRARYPATH',
  92. 'LINK',
  93. 'LINKLIB',
  94. 'LOCALSYMBOLS',
  95. 'LONGSTRINGS',
  96. 'M',
  97. {12345678901234567890 (To determine longest string.)}
  98. 'MACRO',
  99. 'MAXFPUREGISTERS',
  100. 'MEMORY',
  101. 'MESSAGE',
  102. 'MINENUMSIZE',
  103. 'MMX',
  104. 'MODE',
  105. 'NOTE',
  106. 'NOTES',
  107. 'OBJECTPATH',
  108. 'OPENSTRINGS',
  109. 'OUTPUT_FORMAT',
  110. 'OVERFLOWCHECKS',
  111. 'PACKENUM',
  112. 'PACKRECORDS',
  113. {$IFDEF testvarsets}
  114. 'PACKSET',
  115. {$ENDIF}
  116. 'R',
  117. 'RANGECHECKS',
  118. 'REFERENCEINFO',
  119. 'SATURATION',
  120. 'SMARTLINK',
  121. {12345678901234567890 (To determine longest string.)}
  122. 'STACKFRAMES',
  123. 'STATIC',
  124. 'STOP',
  125. 'TYPEDADDRESS',
  126. 'TYPEINFO',
  127. 'UNDEF',
  128. 'UNITPATH',
  129. 'VARSTRINGCHECKS',
  130. 'VERSION',
  131. 'WAIT',
  132. 'WARNING',
  133. 'WARNINGS',
  134. 'Z1',
  135. 'Z2',
  136. 'Z4'
  137. );
  138. function Get_Directive(const hs:string):tdirectivetoken;
  139. var
  140. i : tdirectivetoken;
  141. begin
  142. for i:=firstdirective to lastdirective do
  143. if directive[i]=hs then
  144. begin
  145. Get_Directive:=i;
  146. exit;
  147. end;
  148. Get_Directive:=_DIR_NONE;
  149. end;
  150. {-------------------------------------------
  151. IF Conditional Handling
  152. -------------------------------------------}
  153. var
  154. preprocpat : string;
  155. preproc_token : ttoken;
  156. procedure preproc_consume(t : ttoken);
  157. begin
  158. if t<>preproc_token then
  159. Message(scan_e_preproc_syntax_error);
  160. preproc_token:=current_scanner^.readpreproc;
  161. end;
  162. function read_expr : string;forward;
  163. function read_factor : string;
  164. var
  165. hs : string;
  166. mac : pmacro;
  167. len : byte;
  168. begin
  169. if preproc_token=_ID then
  170. begin
  171. if preprocpat='NOT' then
  172. begin
  173. preproc_consume(_ID);
  174. hs:=read_expr;
  175. if hs='0' then
  176. read_factor:='1'
  177. else
  178. read_factor:='0';
  179. end
  180. else
  181. begin
  182. mac:=pmacro(current_scanner^.macros^.search(hs));
  183. hs:=preprocpat;
  184. preproc_consume(_ID);
  185. if assigned(mac) then
  186. begin
  187. if mac^.defined and assigned(mac^.buftext) then
  188. begin
  189. if mac^.buflen>255 then
  190. begin
  191. len:=255;
  192. Message(scan_w_macro_cut_after_255_chars);
  193. end
  194. else
  195. len:=mac^.buflen;
  196. hs[0]:=char(len);
  197. move(mac^.buftext^,hs[1],len);
  198. end
  199. else
  200. read_factor:='';
  201. end
  202. else
  203. read_factor:=hs;
  204. end
  205. end
  206. else if preproc_token=_LKLAMMER then
  207. begin
  208. preproc_consume(_LKLAMMER);
  209. read_factor:=read_expr;
  210. preproc_consume(_RKLAMMER);
  211. end
  212. else
  213. Message(scan_e_error_in_preproc_expr);
  214. end;
  215. function read_term : string;
  216. var
  217. hs1,hs2 : string;
  218. begin
  219. hs1:=read_factor;
  220. while true do
  221. begin
  222. if (preproc_token=_ID) then
  223. begin
  224. if preprocpat='AND' then
  225. begin
  226. preproc_consume(_ID);
  227. hs2:=read_factor;
  228. if (hs1<>'0') and (hs2<>'0') then
  229. hs1:='1';
  230. end
  231. else
  232. break;
  233. end
  234. else
  235. break;
  236. end;
  237. read_term:=hs1;
  238. end;
  239. function read_simple_expr : string;
  240. var
  241. hs1,hs2 : string;
  242. begin
  243. hs1:=read_term;
  244. while true do
  245. begin
  246. if (preproc_token=_ID) then
  247. begin
  248. if preprocpat='OR' then
  249. begin
  250. preproc_consume(_ID);
  251. hs2:=read_term;
  252. if (hs1<>'0') or (hs2<>'0') then
  253. hs1:='1';
  254. end
  255. else
  256. break;
  257. end
  258. else
  259. break;
  260. end;
  261. read_simple_expr:=hs1;
  262. end;
  263. function read_expr : string;
  264. var
  265. hs1,hs2 : string;
  266. b : boolean;
  267. t : ttoken;
  268. w : integer;
  269. l1,l2 : longint;
  270. begin
  271. hs1:=read_simple_expr;
  272. t:=preproc_token;
  273. if not(t in [_EQUAL,_UNEQUAL,_LT,_GT,_LTE,_GTE]) then
  274. begin
  275. read_expr:=hs1;
  276. exit;
  277. end;
  278. preproc_consume(t);
  279. hs2:=read_simple_expr;
  280. if is_number(hs1) and is_number(hs2) then
  281. begin
  282. valint(hs1,l1,w);
  283. valint(hs2,l2,w);
  284. case t of
  285. _EQUAL : b:=l1=l2;
  286. _UNEQUAL : b:=l1<>l2;
  287. _LT : b:=l1<l2;
  288. _GT : b:=l1>l2;
  289. _GTE : b:=l1>=l2;
  290. _LTE : b:=l1<=l2;
  291. end;
  292. end
  293. else
  294. begin
  295. case t of
  296. _EQUAL : b:=hs1=hs2;
  297. _UNEQUAL : b:=hs1<>hs2;
  298. _LT : b:=hs1<hs2;
  299. _GT : b:=hs1>hs2;
  300. _GTE : b:=hs1>=hs2;
  301. _LTE : b:=hs1<=hs2;
  302. end;
  303. end;
  304. if b then
  305. read_expr:='1'
  306. else
  307. read_expr:='0';
  308. end;
  309. {-------------------------------------------
  310. Directives
  311. -------------------------------------------}
  312. function is_conditional(t:tdirectivetoken):boolean;
  313. begin
  314. is_conditional:=(t in [_DIR_ENDIF,_DIR_IFDEF,_DIR_IFNDEF,_DIR_IFOPT,_DIR_IF,_DIR_ELSE]);
  315. end;
  316. procedure dir_conditional(t:tdirectivetoken);
  317. var
  318. hs : string;
  319. mac : pmacro;
  320. found : boolean;
  321. state : char;
  322. oldaktfilepos : tfileposinfo;
  323. begin
  324. oldaktfilepos:=aktfilepos;
  325. while true do
  326. begin
  327. current_scanner^.gettokenpos;
  328. case t of
  329. _DIR_ENDIF : begin
  330. current_scanner^.poppreprocstack;
  331. end;
  332. _DIR_ELSE : begin
  333. current_scanner^.elsepreprocstack;
  334. end;
  335. _DIR_IFDEF : begin
  336. current_scanner^.skipspace;
  337. hs:=current_scanner^.readid;
  338. mac:=pmacro(current_scanner^.macros^.search(hs));
  339. if assigned(mac) then
  340. mac^.is_used:=true;
  341. current_scanner^.addpreprocstack(pp_ifdef,assigned(mac) and mac^.defined,hs,scan_c_ifdef_found);
  342. end;
  343. _DIR_IFOPT : begin
  344. current_scanner^.skipspace;
  345. hs:=current_scanner^.readid;
  346. if (length(hs)>1) then
  347. Message1(scan_w_illegal_switch,hs)
  348. else
  349. begin
  350. state:=current_scanner^.ReadState;
  351. if state in ['-','+'] then
  352. found:=CheckSwitch(hs[1],state);
  353. end;
  354. current_scanner^.addpreprocstack(pp_ifopt,found,hs,scan_c_ifopt_found);
  355. end;
  356. _DIR_IF : begin
  357. current_scanner^.skipspace;
  358. { start preproc expression scanner }
  359. preproc_token:=current_scanner^.readpreproc;
  360. hs:=read_expr;
  361. current_scanner^.addpreprocstack(pp_if,hs<>'0',hs,scan_c_if_found);
  362. end;
  363. _DIR_IFNDEF : begin
  364. current_scanner^.skipspace;
  365. hs:=current_scanner^.readid;
  366. mac:=pmacro(current_scanner^.macros^.search(hs));
  367. if assigned(mac) then
  368. mac^.is_used:=true;
  369. current_scanner^.addpreprocstack(pp_ifndef,not(assigned(mac) and mac^.defined),hs,scan_c_ifndef_found);
  370. end;
  371. end;
  372. { accept the text ? }
  373. if (current_scanner^.preprocstack=nil) or current_scanner^.preprocstack^.accept then
  374. break
  375. else
  376. begin
  377. current_scanner^.gettokenpos;
  378. Message(scan_c_skipping_until);
  379. repeat
  380. current_scanner^.skipuntildirective;
  381. t:=Get_Directive(current_scanner^.readid);
  382. until is_conditional(t);
  383. current_scanner^.gettokenpos;
  384. Message1(scan_d_handling_switch,'$'+directive[t]);
  385. end;
  386. end;
  387. aktfilepos:=oldaktfilepos;
  388. end;
  389. procedure dir_define(t:tdirectivetoken);
  390. var
  391. hs : string;
  392. bracketcount : longint;
  393. mac : pmacro;
  394. macropos : longint;
  395. macrobuffer : pmacrobuffer;
  396. begin
  397. current_scanner^.skipspace;
  398. hs:=current_scanner^.readid;
  399. mac:=pmacro(current_scanner^.macros^.search(hs));
  400. if not assigned(mac) then
  401. begin
  402. mac:=new(pmacro,init(hs));
  403. mac^.defined:=true;
  404. Message1(parser_m_macro_defined,mac^.name);
  405. current_scanner^.macros^.insert(mac);
  406. end
  407. else
  408. begin
  409. Message1(parser_m_macro_defined,mac^.name);
  410. mac^.defined:=true;
  411. { delete old definition }
  412. if assigned(mac^.buftext) then
  413. begin
  414. freemem(mac^.buftext,mac^.buflen);
  415. mac^.buftext:=nil;
  416. end;
  417. end;
  418. mac^.is_used:=true;
  419. if (cs_support_macro in aktmoduleswitches) then
  420. begin
  421. { key words are never substituted }
  422. if is_keyword(hs) then
  423. Message(scan_e_keyword_cant_be_a_macro);
  424. { !!!!!! handle macro params, need we this? }
  425. current_scanner^.skipspace;
  426. { may be a macro? }
  427. if c=':' then
  428. begin
  429. current_scanner^.readchar;
  430. if c='=' then
  431. begin
  432. new(macrobuffer);
  433. macropos:=0;
  434. { parse macro, brackets are counted so it's possible
  435. to have a $ifdef etc. in the macro }
  436. bracketcount:=0;
  437. repeat
  438. current_scanner^.readchar;
  439. case c of
  440. '}' :
  441. if (bracketcount=0) then
  442. break
  443. else
  444. dec(bracketcount);
  445. '{' :
  446. inc(bracketcount);
  447. #26 :
  448. current_scanner^.end_of_file;
  449. end;
  450. macrobuffer^[macropos]:=c;
  451. inc(macropos);
  452. if macropos>maxmacrolen then
  453. Message(scan_f_macro_buffer_overflow);
  454. until false;
  455. { free buffer of macro ?}
  456. if assigned(mac^.buftext) then
  457. freemem(mac^.buftext,mac^.buflen);
  458. { get new mem }
  459. getmem(mac^.buftext,macropos);
  460. mac^.buflen:=macropos;
  461. { copy the text }
  462. move(macrobuffer^,mac^.buftext^,macropos);
  463. dispose(macrobuffer);
  464. end;
  465. end;
  466. end
  467. else
  468. begin
  469. { check if there is an assignment, then we need to give a
  470. warning }
  471. current_scanner^.skipspace;
  472. if c=':' then
  473. begin
  474. current_scanner^.readchar;
  475. if c='=' then
  476. Message(scan_w_macro_support_turned_off);
  477. end;
  478. end;
  479. end;
  480. procedure dir_undef(t:tdirectivetoken);
  481. var
  482. hs : string;
  483. mac : pmacro;
  484. begin
  485. current_scanner^.skipspace;
  486. hs:=current_scanner^.readid;
  487. mac:=pmacro(current_scanner^.macros^.search(hs));
  488. if not assigned(mac) then
  489. begin
  490. mac:=new(pmacro,init(hs));
  491. Message1(parser_m_macro_undefined,mac^.name);
  492. mac^.defined:=false;
  493. current_scanner^.macros^.insert(mac);
  494. end
  495. else
  496. begin
  497. Message1(parser_m_macro_undefined,mac^.name);
  498. mac^.defined:=false;
  499. { delete old definition }
  500. if assigned(mac^.buftext) then
  501. begin
  502. freemem(mac^.buftext,mac^.buflen);
  503. mac^.buftext:=nil;
  504. end;
  505. end;
  506. mac^.is_used:=true;
  507. end;
  508. procedure dir_message(t:tdirectivetoken);
  509. var
  510. w : longint;
  511. begin
  512. case t of
  513. _DIR_STOP,
  514. _DIR_FATAL : w:=scan_f_user_defined;
  515. _DIR_ERROR : w:=scan_e_user_defined;
  516. _DIR_WARNING : w:=scan_w_user_defined;
  517. _DIR_HINT : w:=scan_h_user_defined;
  518. _DIR_NOTE : w:=scan_n_user_defined;
  519. _DIR_MESSAGE,
  520. _DIR_INFO : w:=scan_i_user_defined;
  521. end;
  522. current_scanner^.skipspace;
  523. Message1(w,current_scanner^.readcomment);
  524. end;
  525. procedure dir_moduleswitch(t:tdirectivetoken);
  526. var
  527. sw : tmoduleswitch;
  528. state : char;
  529. begin
  530. sw:=cs_modulenone;
  531. case t of
  532. _DIR_GOTO : sw:=cs_support_goto;
  533. _DIR_MACRO : sw:=cs_support_macro;
  534. _DIR_INLINE : sw:=cs_support_inline;
  535. _DIR_SMARTLINK : sw:=cs_create_smart;
  536. _DIR_STATIC : sw:=cs_static_keyword;
  537. end;
  538. state:=current_scanner^.readstate;
  539. if (sw<>cs_modulenone) and (state in ['-','+']) then
  540. begin
  541. if state='-' then
  542. aktmoduleswitches:=aktmoduleswitches-[sw]
  543. else
  544. aktmoduleswitches:=aktmoduleswitches+[sw];
  545. end;
  546. end;
  547. procedure dir_interfacesswitch(t:tdirectivetoken);
  548. var
  549. hs : string;
  550. begin
  551. {corba/com/default}
  552. current_scanner^.skipspace;
  553. hs:=current_scanner^.readid;
  554. if (hs='CORBA') then
  555. aktinterfacetype:=it_interfacecorba
  556. else if (hs='COM') then
  557. aktinterfacetype:=it_interfacecom
  558. else if (hs='DEFAULT') then
  559. aktinterfacetype:=initinterfacetype
  560. else
  561. Message(scan_e_invalid_interface_type);
  562. end;
  563. procedure dir_localswitch(t:tdirectivetoken);
  564. var
  565. sw : tlocalswitch;
  566. state : char;
  567. begin
  568. sw:=cs_localnone;
  569. {$ifdef SUPPORT_MMX}
  570. case t of
  571. _DIR_MMX : sw:=cs_mmx;
  572. _DIR_SATURATION : sw:=cs_mmx_saturation;
  573. end;
  574. {$endif}
  575. state:=current_scanner^.readstate;
  576. if (sw<>cs_localnone) and (state in ['-','+']) then
  577. begin
  578. if not localswitcheschanged then
  579. nextaktlocalswitches:=aktlocalswitches;
  580. if state='-' then
  581. nextaktlocalswitches:=nextaktlocalswitches-[sw]
  582. else
  583. nextaktlocalswitches:=nextaktlocalswitches+[sw];
  584. localswitcheschanged:=true;
  585. end;
  586. end;
  587. procedure dir_include(t:tdirectivetoken);
  588. var
  589. hs : string;
  590. path : dirstr;
  591. name : namestr;
  592. ext : extstr;
  593. hp : tinputfile;
  594. i : longint;
  595. found : boolean;
  596. begin
  597. current_scanner^.skipspace;
  598. hs:=current_scanner^.readcomment;
  599. i:=length(hs);
  600. while (i>0) and (hs[i]=' ') do
  601. dec(i);
  602. Delete(hs,i+1,length(hs)-i);
  603. if hs='' then
  604. exit;
  605. if (hs[1]='%') then
  606. begin
  607. { case insensitive }
  608. hs:=upper(hs);
  609. { remove %'s }
  610. Delete(hs,1,1);
  611. if hs[length(hs)]='%' then
  612. Delete(hs,length(hs),1);
  613. { save old }
  614. path:=hs;
  615. { first check for internal macros }
  616. if hs='TIME' then
  617. hs:=gettimestr
  618. else
  619. if hs='DATE' then
  620. hs:=getdatestr
  621. else
  622. if hs='FILE' then
  623. hs:=current_module.sourcefiles.get_file_name(aktfilepos.fileindex)
  624. else
  625. if hs='LINE' then
  626. hs:=tostr(aktfilepos.line)
  627. else
  628. if hs='FPCVERSION' then
  629. hs:=version_string
  630. else
  631. if hs='FPCTARGET' then
  632. hs:=target_cpu_string
  633. else
  634. hs:=getenv(hs);
  635. if hs='' then
  636. Message1(scan_w_include_env_not_found,path);
  637. { make it a stringconst }
  638. hs:=''''+hs+'''';
  639. current_scanner^.insertmacro(path,@hs[1],length(hs));
  640. end
  641. else
  642. begin
  643. hs:=FixFileName(hs);
  644. fsplit(hs,path,name,ext);
  645. { look for the include file
  646. 1. specified path,path of current inputfile,current dir
  647. 2. local includepath
  648. 3. global includepath }
  649. found:=false;
  650. if path<>'' then
  651. path:=path+';';
  652. path:=FindFile(name+ext,path+current_scanner^.inputfile.path^+';.'+DirSep,found);
  653. if (not found) then
  654. path:=current_module.localincludesearchpath.FindFile(name+ext,found);
  655. if (not found) then
  656. path:=includesearchpath.FindFile(name+ext,found);
  657. { save old postion and decrease linebreak }
  658. if c=newline then
  659. dec(current_scanner^.line_no);
  660. dec(longint(current_scanner^.inputpointer));
  661. { shutdown current file }
  662. current_scanner^.tempcloseinputfile;
  663. { load new file }
  664. hp:=do_openinputfile(path+name+ext);
  665. current_scanner^.addfile(hp);
  666. if not current_scanner^.openinputfile then
  667. Message1(scan_f_cannot_open_includefile,hs);
  668. Message1(scan_t_start_include_file,current_scanner^.inputfile.path^+current_scanner^.inputfile.name^);
  669. current_scanner^.reload;
  670. { process first read char }
  671. case c of
  672. #26 : current_scanner^.reload;
  673. #10,
  674. #13 : current_scanner^.linebreak;
  675. end;
  676. { register for refs }
  677. current_module.sourcefiles.register_file(hp);
  678. end;
  679. end;
  680. procedure dir_description(t:tdirectivetoken);
  681. begin
  682. if not (target_info.target in [target_i386_os2,target_i386_win32,target_i386_netware]) then
  683. Message(scan_w_decription_not_support);
  684. { change description global var in all cases }
  685. { it not used but in win32, os2 and netware }
  686. current_scanner^.skipspace;
  687. description:=current_scanner^.readcomment;
  688. end;
  689. procedure dir_version(t:tdirectivetoken);
  690. var
  691. major, minor, revision : longint;
  692. error : integer;
  693. begin
  694. if not (target_info.target in [target_i386_os2,target_i386_win32,target_i386_netware]) then // AD
  695. begin
  696. Message(scan_n_version_not_support);
  697. exit;
  698. end;
  699. if (compile_level<>1) then
  700. Message(scan_n_only_exe_version)
  701. else
  702. begin
  703. { change description global var in all cases }
  704. { it not used but in win32, os2 and netware }
  705. current_scanner^.skipspace;
  706. { we should only accept Major.Minor format for win32 and os2 }
  707. current_scanner^.readnumber;
  708. major:=0;
  709. minor:=0;
  710. revision:=0;
  711. valint(pattern,major,error);
  712. if error<>0 then
  713. begin
  714. Message1(scan_w_wrong_version_ignored,pattern);
  715. exit;
  716. end;
  717. if c='.' then
  718. begin
  719. current_scanner^.readchar;
  720. current_scanner^.readnumber;
  721. valint(pattern,minor,error);
  722. if error<>0 then
  723. begin
  724. Message1(scan_w_wrong_version_ignored,tostr(major)+'.'+pattern);
  725. exit;
  726. end;
  727. if (c='.') and
  728. (target_info.target = target_i386_netware) then // AD
  729. begin
  730. current_scanner^.readchar;
  731. current_scanner^.readnumber;
  732. valint(pattern,revision,error);
  733. if error<>0 then
  734. begin
  735. Message1(scan_w_wrong_version_ignored,tostr(revision)+'.'+pattern);
  736. exit;
  737. end;
  738. dllmajor:=major;
  739. dllminor:=minor;
  740. dllrevision:=revision;
  741. dllversion:=tostr(major)+','+tostr(minor)+','+tostr(revision);
  742. end
  743. else
  744. begin
  745. dllmajor:=major;
  746. dllminor:=minor;
  747. dllversion:=tostr(major)+'.'+tostr(minor);
  748. end;
  749. end
  750. else
  751. dllversion:=tostr(major);
  752. end;
  753. end;
  754. procedure dir_linkobject(t:tdirectivetoken);
  755. var
  756. s : string;
  757. begin
  758. current_scanner^.skipspace;
  759. s:=AddExtension(FixFileName(current_scanner^.readcomment),target_info.objext);
  760. current_module.linkotherofiles.add(s,link_allways);
  761. end;
  762. procedure dir_resource(t:tdirectivetoken);
  763. var
  764. s : string;
  765. begin
  766. current_scanner^.skipspace;
  767. s:=current_scanner^.readcomment;
  768. { replace * with current module name.
  769. This should always be defined. }
  770. if s[1]='*' then
  771. if Assigned(Current_Module) then
  772. begin
  773. delete(S,1,1);
  774. insert(lower(current_module.modulename^),S,1);
  775. end;
  776. s:=AddExtension(FixFileName(s),target_info.resext);
  777. if target_info.res<>res_none then
  778. if (target_info.res = res_i386_emx) and
  779. not (Current_module.ResourceFiles.Empty) then
  780. Message(scan_w_only_one_resourcefile_supported)
  781. else
  782. current_module.resourcefiles.insert(FixFileName(s))
  783. else
  784. Message(scan_e_resourcefiles_not_supported);
  785. end;
  786. procedure dir_linklib(t:tdirectivetoken);
  787. type
  788. tLinkMode=(lm_shared,lm_static);
  789. var
  790. s : string;
  791. quote : char;
  792. libname,
  793. linkmodestr : string;
  794. p : longint;
  795. linkMode : tLinkMode;
  796. begin
  797. current_scanner^.skipspace;
  798. s:=current_scanner^.readcomment;
  799. p:=pos(',',s);
  800. if p=0 then
  801. begin
  802. libname:=TrimSpace(s);
  803. linkmodeStr:='';
  804. end
  805. else
  806. begin
  807. libname:=TrimSpace(copy(s,1,p-1));
  808. linkmodeStr:=Upper(TrimSpace(copy(s,p+1,255)));
  809. end;
  810. if (libname='') or (libname='''''') or (libname='""') then
  811. exit;
  812. { get linkmode, default is shared linking }
  813. if linkModeStr='STATIC' then
  814. linkmode:=lm_static
  815. else if (LinkModeStr='SHARED') or (LinkModeStr='') then
  816. linkmode:=lm_shared
  817. else
  818. begin
  819. Comment(V_Error,'Wrong link mode specified: "'+Linkmodestr+'"');
  820. exit;
  821. end;
  822. { create library name }
  823. if libname[1] in ['''','"'] then
  824. begin
  825. quote:=libname[1];
  826. Delete(libname,1,1);
  827. p:=pos(quote,libname);
  828. if p>0 then
  829. Delete(libname,p,1);
  830. end;
  831. { add to the list of libraries to link }
  832. if linkMode=lm_static then
  833. current_module.linkOtherStaticLibs.add(FixFileName(libname),link_allways)
  834. else
  835. current_module.linkOtherSharedLibs.add(FixFileName(libname),link_allways);
  836. end;
  837. procedure dir_outputformat(t:tdirectivetoken);
  838. begin
  839. if not current_module.in_global then
  840. Message(scan_w_switch_is_global)
  841. else
  842. begin
  843. current_scanner^.skipspace;
  844. if set_string_asm(current_scanner^.readid) then
  845. aktoutputformat:=target_asm.id
  846. else
  847. Message1(scan_w_illegal_switch,pattern);
  848. end;
  849. end;
  850. procedure dir_unitpath(t:tdirectivetoken);
  851. begin
  852. if not current_module.in_global then
  853. Message(scan_w_switch_is_global)
  854. else
  855. begin
  856. current_scanner^.skipspace;
  857. current_module.localunitsearchpath.AddPath(current_scanner^.readcomment,false);
  858. end;
  859. end;
  860. procedure dir_includepath(t:tdirectivetoken);
  861. begin
  862. if not current_module.in_global then
  863. Message(scan_w_switch_is_global)
  864. else
  865. begin
  866. current_scanner^.skipspace;
  867. current_module.localincludesearchpath.AddPath(current_scanner^.readcomment,false);
  868. end;
  869. end;
  870. procedure dir_librarypath(t:tdirectivetoken);
  871. begin
  872. if not current_module.in_global then
  873. Message(scan_w_switch_is_global)
  874. else
  875. begin
  876. current_scanner^.skipspace;
  877. current_module.locallibrarysearchpath.AddPath(current_scanner^.readcomment,false);
  878. end;
  879. end;
  880. procedure dir_objectpath(t:tdirectivetoken);
  881. begin
  882. if not current_module.in_global then
  883. Message(scan_w_switch_is_global)
  884. else
  885. begin
  886. current_scanner^.skipspace;
  887. current_module.localobjectsearchpath.AddPath(current_scanner^.readcomment,false);
  888. end;
  889. end;
  890. procedure dir_mode(t:tdirectivetoken);
  891. begin
  892. if not current_module.in_global then
  893. Message(scan_w_switch_is_global)
  894. else
  895. begin
  896. current_scanner^.skipspace;
  897. current_scanner^.readstring;
  898. if not SetCompileMode(pattern,false) then
  899. Message1(scan_w_illegal_switch,pattern);
  900. end;
  901. end;
  902. procedure dir_packrecords(t:tdirectivetoken);
  903. var
  904. hs : string;
  905. begin
  906. current_scanner^.skipspace;
  907. if not(c in ['0'..'9']) then
  908. begin
  909. hs:=current_scanner^.readid;
  910. if (hs='C') then
  911. aktpackrecords:=packrecord_C
  912. else
  913. if (hs='NORMAL') or (hs='DEFAULT') then
  914. aktpackrecords:=packrecord_2
  915. else
  916. Message(scan_w_only_pack_records);
  917. end
  918. else
  919. begin
  920. case current_scanner^.readval of
  921. 1 : aktpackrecords:=packrecord_1;
  922. 2 : aktpackrecords:=packrecord_2;
  923. 4 : aktpackrecords:=packrecord_4;
  924. 8 : aktpackrecords:=packrecord_8;
  925. 16 : aktpackrecords:=packrecord_16;
  926. 32 : aktpackrecords:=packrecord_32;
  927. else
  928. Message(scan_w_only_pack_records);
  929. end;
  930. end;
  931. end;
  932. procedure dir_maxfpuregisters(t:tdirectivetoken);
  933. var
  934. l : longint;
  935. hs : string;
  936. begin
  937. current_scanner^.skipspace;
  938. if not(c in ['0'..'9']) then
  939. begin
  940. hs:=current_scanner^.readid;
  941. if (hs='NORMAL') or (hs='DEFAULT') then
  942. aktmaxfpuregisters:=-1
  943. else
  944. Message(scan_e_invalid_maxfpureg_value);
  945. end
  946. else
  947. begin
  948. l:=current_scanner^.readval;
  949. case l of
  950. 0..8:
  951. aktmaxfpuregisters:=l;
  952. else
  953. Message(scan_e_invalid_maxfpureg_value);
  954. end;
  955. end;
  956. end;
  957. procedure dir_packenum(t:tdirectivetoken);
  958. var
  959. hs : string;
  960. begin
  961. if t in [_DIR_Z1,_DIR_Z2,_DIR_Z4] then
  962. begin
  963. aktpackenum:=ord(pattern[2])-ord('0');
  964. exit;
  965. end;
  966. current_scanner^.skipspace;
  967. if not(c in ['0'..'9']) then
  968. begin
  969. hs:=current_scanner^.readid;
  970. if (hs='NORMAL') or (hs='DEFAULT') then
  971. aktpackenum:=4
  972. else
  973. Message(scan_w_only_pack_enum);
  974. end
  975. else
  976. begin
  977. case current_scanner^.readval of
  978. 1 : aktpackenum:=1;
  979. 2 : aktpackenum:=2;
  980. 4 : aktpackenum:=4;
  981. else
  982. Message(scan_w_only_pack_enum);
  983. end;
  984. end;
  985. end;
  986. {$ifdef testvarsets}
  987. procedure dir_setalloc(t:tdirectivetoken);
  988. var
  989. hs : string;
  990. begin
  991. current_scanner^.skipspace;
  992. if not(c in ['1','2','4']) then
  993. begin
  994. hs:=current_scanner^.readid;
  995. if (hs='FIXED') or ((hs='DEFAULT') OR (hs='NORMAL')) then
  996. aktsetalloc:=0 {Fixed mode, sets are 4 or 32 bytes}
  997. else
  998. Message(scan_w_only_packset);
  999. end
  1000. else
  1001. begin
  1002. case current_scanner^.readval of
  1003. 1 : aktpackenum:=1;
  1004. 2 : aktpackenum:=2;
  1005. 4 : aktpackenum:=4;
  1006. else
  1007. Message(scan_w_only_packset);
  1008. end;
  1009. end;
  1010. end;
  1011. {$ENDIF}
  1012. procedure dir_apptype(t:tdirectivetoken);
  1013. var
  1014. hs : string;
  1015. begin
  1016. if target_info.target<>target_i386_win32 then
  1017. Message(scan_w_app_type_not_support);
  1018. if not current_module.in_global then
  1019. Message(scan_w_switch_is_global)
  1020. else
  1021. begin
  1022. current_scanner^.skipspace;
  1023. hs:=current_scanner^.readid;
  1024. if hs='GUI' then
  1025. apptype:=app_gui
  1026. else if hs='CONSOLE' then
  1027. apptype:=app_cui
  1028. else
  1029. Message1(scan_w_unsupported_app_type,hs);
  1030. end;
  1031. end;
  1032. procedure dir_wait(t:tdirectivetoken);
  1033. var had_info : boolean;
  1034. begin
  1035. had_info:=(status.verbosity and V_Info)<>0;
  1036. { this message should allways appear !! }
  1037. status.verbosity:=status.verbosity or V_Info;
  1038. Message(scan_i_press_enter);
  1039. readln;
  1040. If not(had_info) then
  1041. status.verbosity:=status.verbosity and (not V_Info);
  1042. end;
  1043. procedure dir_asmmode(t:tdirectivetoken);
  1044. var
  1045. s : string;
  1046. begin
  1047. current_scanner^.skipspace;
  1048. s:=current_scanner^.readid;
  1049. If Inside_asm_statement then
  1050. Message1(scan_w_no_asm_reader_switch_inside_asm,s);
  1051. if s='DEFAULT' then
  1052. aktasmmode:=initasmmode
  1053. else
  1054. if not set_string_asmmode(s,aktasmmode) then
  1055. Message1(scan_w_unsupported_asmmode_specifier,s);
  1056. end;
  1057. procedure dir_oldasmmode(t:tdirectivetoken);
  1058. begin
  1059. If Inside_asm_statement then
  1060. Message1(scan_w_no_asm_reader_switch_inside_asm,directive[t]);
  1061. {$ifdef i386}
  1062. case t of
  1063. _DIR_I386_ATT : aktasmmode:=asmmode_i386_att;
  1064. _DIR_I386_DIRECT : aktasmmode:=asmmode_i386_direct;
  1065. _DIR_I386_INTEL : aktasmmode:=asmmode_i386_intel;
  1066. end;
  1067. {$endif i386}
  1068. end;
  1069. procedure dir_delphiswitch(t:tdirectivetoken);
  1070. var
  1071. sw,state : char;
  1072. begin
  1073. case t of
  1074. _DIR_ALIGN : sw:='A';
  1075. _DIR_ASSERTIONS : sw:='C';
  1076. _DIR_BOOLEVAL : sw:='B';
  1077. _DIR_DEBUGINFO : sw:='D';
  1078. _DIR_IOCHECKS : sw:='I';
  1079. _DIR_LOCALSYMBOLS : sw:='L';
  1080. _DIR_LONGSTRINGS : sw:='H';
  1081. _DIR_OPENSTRINGS : sw:='P';
  1082. _DIR_OVERFLOWCHECKS : sw:='Q';
  1083. _DIR_RANGECHECKS : sw:='R';
  1084. _DIR_REFERENCEINFO : sw:='Y';
  1085. _DIR_STACKFRAMES : sw:='W';
  1086. _DIR_TYPEDADDRESS : sw:='T';
  1087. _DIR_TYPEINFO : sw:='M';
  1088. _DIR_VARSTRINGCHECKS : sw:='V';
  1089. else
  1090. exit;
  1091. end;
  1092. { c contains the next char, a + or - would be fine }
  1093. state:=current_scanner^.readstate;
  1094. if state in ['-','+'] then
  1095. HandleSwitch(sw,state);
  1096. end;
  1097. procedure dir_memory(t:tdirectivetoken);
  1098. var
  1099. l : longint;
  1100. begin
  1101. current_scanner^.skipspace;
  1102. l:=current_scanner^.readval;
  1103. if l>1024 then
  1104. stacksize:=l;
  1105. current_scanner^.skipspace;
  1106. if c=',' then
  1107. begin
  1108. current_scanner^.readchar;
  1109. current_scanner^.skipspace;
  1110. l:=current_scanner^.readval;
  1111. if l>1024 then
  1112. heapsize:=l;
  1113. end;
  1114. if c=',' then
  1115. begin
  1116. current_scanner^.readchar;
  1117. current_scanner^.skipspace;
  1118. l:=current_scanner^.readval;
  1119. { Ignore this value, because the limit is set by the OS
  1120. info and shouldn't be changed by the user (PFV) }
  1121. end;
  1122. end;
  1123. procedure dir_setverbose(t:tdirectivetoken);
  1124. var
  1125. flag,
  1126. state : char;
  1127. begin
  1128. case t of
  1129. _DIR_HINTS : flag:='H';
  1130. _DIR_WARNINGS : flag:='W';
  1131. _DIR_NOTES : flag:='N';
  1132. else
  1133. exit;
  1134. end;
  1135. { support ON/OFF }
  1136. state:=current_scanner^.ReadState;
  1137. SetVerbosity(flag+state);
  1138. end;
  1139. type
  1140. tdirectiveproc=procedure(t:tdirectivetoken);
  1141. const
  1142. directiveproc:array[tdirectivetoken] of tdirectiveproc=(
  1143. {_DIR_NONE} nil,
  1144. {_DIR_ALIGN} dir_delphiswitch,
  1145. {_DIR_APPTYPE} dir_apptype,
  1146. {_DIR_ASMMODE} dir_asmmode,
  1147. {_DIR_ASSERTION} dir_delphiswitch,
  1148. {_DIR_BOOLEVAL} dir_delphiswitch,
  1149. {_DIR_D} dir_description,
  1150. {_DIR_DEBUGINFO} dir_delphiswitch,
  1151. {_DIR_DEFINE} dir_define,
  1152. {_DIR_DESCRIPTION} dir_description,
  1153. {_DIR_ELSE} dir_conditional,
  1154. {_DIR_ENDIF} dir_conditional,
  1155. {_DIR_ERROR} dir_message,
  1156. {_DIR_EXTENDEDSYNTAX} dir_delphiswitch,
  1157. {_DIR_FATAL} dir_message,
  1158. {_DIR_GOTO} dir_moduleswitch,
  1159. {_DIR_HINT} dir_message,
  1160. {_DIR_HINTS} dir_setverbose,
  1161. {_DIR_I} dir_include,
  1162. {_DIR_I386_ATT} dir_oldasmmode,
  1163. {_DIR_I386_DIRECT} dir_oldasmmode,
  1164. {_DIR_I386_INTEL} dir_oldasmmode,
  1165. {_DIR_IOCHECKS} dir_delphiswitch,
  1166. {_DIR_IF} dir_conditional,
  1167. {_DIR_IFDEF} dir_conditional,
  1168. {_DIR_IFNDEF} dir_conditional,
  1169. {_DIR_IFOPT} dir_conditional,
  1170. {_DIR_INCLUDE} dir_include,
  1171. {_DIR_INCLUDEPATH} dir_includepath,
  1172. {_DIR_INFO} dir_message,
  1173. {_DIR_INLINE} dir_moduleswitch,
  1174. {_DIR_INTERFACES} dir_interfacesswitch,
  1175. {_DIR_L} dir_linkobject,
  1176. {_DIR_LIBRARYPATH} dir_librarypath,
  1177. {_DIR_LINK} dir_linkobject,
  1178. {_DIR_LINKLIB} dir_linklib,
  1179. {_DIR_LOCALSYMBOLS} dir_delphiswitch,
  1180. {_DIR_LONGSTRINGS} dir_delphiswitch,
  1181. {_DIR_M} dir_memory,
  1182. {_DIR_MACRO} dir_moduleswitch,
  1183. {_DIR_MAXFPUREGISTERS} dir_maxfpuregisters,
  1184. {_DIR_MEMORY} dir_memory,
  1185. {_DIR_MESSAGE} dir_message,
  1186. {_DIR_MINENUMSIZE} dir_packenum,
  1187. {_DIR_MMX} dir_localswitch,
  1188. {_DIR_MODE} dir_mode,
  1189. {_DIR_NOTE} dir_message,
  1190. {_DIR_NOTES} dir_setverbose,
  1191. {_DIR_OBJECTPATH} dir_objectpath,
  1192. {_DIR_OPENSTRINGS} dir_delphiswitch,
  1193. {_DIR_OUTPUT_FORMAT} dir_outputformat,
  1194. {_DIR_OVERFLOWCHECKS} dir_delphiswitch,
  1195. {_DIR_PACKENUM} dir_packenum,
  1196. {_DIR_PACKRECORDS} dir_packrecords,
  1197. {$IFDEF TestVarsets}
  1198. {_DIR_PACKSET} dir_packset,
  1199. {$ENDIF}
  1200. {_DIR_R} dir_resource,
  1201. {_DIR_RANGECHECKS} dir_delphiswitch,
  1202. {_DIR_REFERENCEINFO} dir_delphiswitch,
  1203. {_DIR_SATURATION} dir_localswitch,
  1204. {_DIR_SMARTLINK} dir_moduleswitch,
  1205. {_DIR_STACKFRAMES} dir_delphiswitch,
  1206. {_DIR_STATIC} dir_moduleswitch,
  1207. {_DIR_STOP} dir_message,
  1208. {_DIR_TYPEDADDRESS} dir_delphiswitch,
  1209. {_DIR_TYPEINFO} dir_delphiswitch,
  1210. {_DIR_UNDEF} dir_undef,
  1211. {_DIR_UNITPATH} dir_unitpath,
  1212. {_DIR_VARSTRINGCHECKS} dir_delphiswitch,
  1213. {_DIR_VERSION} dir_version,
  1214. {_DIR_WAIT} dir_wait,
  1215. {_DIR_WARNING} dir_message,
  1216. {_DIR_WARNINGS} dir_setverbose,
  1217. {_DIR_Z1} dir_packenum,
  1218. {_DIR_Z2} dir_packenum,
  1219. {_DIR_Z4} dir_packenum
  1220. );
  1221. {-------------------------------------------
  1222. Main switches handling
  1223. -------------------------------------------}
  1224. procedure handledirectives;
  1225. var
  1226. t : tdirectivetoken;
  1227. p : tdirectiveproc;
  1228. hs : string;
  1229. begin
  1230. current_scanner^.gettokenpos;
  1231. current_scanner^.readchar; {Remove the $}
  1232. hs:=current_scanner^.readid;
  1233. {$ifdef PREPROCWRITE}
  1234. if parapreprocess then
  1235. begin
  1236. t:=Get_Directive(hs);
  1237. if not(is_conditional(t) or (t=_DIR_DEFINE) or (t=_DIR_UNDEF)) then
  1238. begin
  1239. preprocfile^.AddSpace;
  1240. preprocfile^.Add('{$'+hs+current_scanner^.readcomment+'}');
  1241. exit;
  1242. end;
  1243. end;
  1244. {$endif PREPROCWRITE}
  1245. { skip this directive? }
  1246. if (current_scanner^.ignoredirectives.find(hs)<>nil) then
  1247. begin
  1248. if (current_scanner^.comment_level>0) then
  1249. current_scanner^.readcomment;
  1250. { we've read the whole comment }
  1251. aktcommentstyle:=comment_none;
  1252. exit;
  1253. end;
  1254. if hs='' then
  1255. begin
  1256. Message1(scan_w_illegal_switch,'$'+hs);
  1257. end;
  1258. { Check for compiler switches }
  1259. while (length(hs)=1) and (c in ['-','+']) do
  1260. begin
  1261. HandleSwitch(hs[1],c);
  1262. current_scanner^.readchar; {Remove + or -}
  1263. if c=',' then
  1264. begin
  1265. current_scanner^.readchar; {Remove , }
  1266. { read next switch, support $v+,$+}
  1267. hs:=current_scanner^.readid;
  1268. if (hs='') then
  1269. begin
  1270. if (c='$') and (m_fpc in aktmodeswitches) then
  1271. begin
  1272. current_scanner^.readchar; { skip $ }
  1273. hs:=current_scanner^.readid;
  1274. end;
  1275. if (hs='') then
  1276. Message1(scan_w_illegal_directive,'$'+c);
  1277. end
  1278. else
  1279. Message1(scan_d_handling_switch,'$'+hs);
  1280. end
  1281. else
  1282. hs:='';
  1283. end;
  1284. { directives may follow switches after a , }
  1285. if hs<>'' then
  1286. begin
  1287. t:=Get_Directive(hs);
  1288. if t<>_DIR_NONE then
  1289. begin
  1290. p:=directiveproc[t];
  1291. if {$ifndef FPCPROCVAR}@{$endif}p<>nil then
  1292. p(t);
  1293. end
  1294. else
  1295. begin
  1296. current_scanner^.ignoredirectives.insert(hs);
  1297. Message1(scan_w_illegal_directive,'$'+hs);
  1298. end;
  1299. { conditionals already read the comment }
  1300. if (current_scanner^.comment_level>0) then
  1301. current_scanner^.readcomment;
  1302. { we've read the whole comment }
  1303. aktcommentstyle:=comment_none;
  1304. end;
  1305. end;
  1306. {
  1307. $Log$
  1308. Revision 1.16 2001-01-13 00:09:21 peter
  1309. * made Pavel O. happy ;)
  1310. Revision 1.15 2000/12/25 00:07:28 peter
  1311. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1312. tlinkedlist objects)
  1313. Revision 1.14 2000/12/24 12:24:38 peter
  1314. * moved preprocessfile into a conditional
  1315. Revision 1.13 2000/12/12 19:48:52 peter
  1316. * fixed lost char after $I directive (merged)
  1317. Revision 1.12 2000/11/12 22:17:47 peter
  1318. * some realname updates for messages
  1319. Revision 1.11 2000/11/04 14:25:21 florian
  1320. + merged Attila's changes for interfaces, not tested yet
  1321. Revision 1.10 2000/10/31 22:02:51 peter
  1322. * symtable splitted, no real code changes
  1323. Revision 1.9 2000/09/26 10:50:41 jonas
  1324. * initmodeswitches is changed is you change the compiler mode from the
  1325. command line (the -S<x> switches didn't work anymore for changing the
  1326. compiler mode) (merged from fixes branch)
  1327. Revision 1.8 2000/09/24 21:33:47 peter
  1328. * message updates merges
  1329. Revision 1.7 2000/09/24 15:06:27 peter
  1330. * use defines.inc
  1331. Revision 1.6 2000/09/11 17:00:23 florian
  1332. + first implementation of Netware Module support, thanks to
  1333. Armin Diehl ([email protected]) for providing the patches
  1334. Revision 1.5 2000/09/10 21:18:15 peter
  1335. * macro warning (merged)
  1336. Revision 1.4 2000/08/12 15:30:44 peter
  1337. * IDE patch for stream reading (merged)
  1338. Revision 1.3 2000/08/08 19:28:57 peter
  1339. * memdebug/memory patches (merged)
  1340. * only once illegal directive (merged)
  1341. Revision 1.2 2000/07/13 11:32:49 michael
  1342. + removed logs
  1343. }