mbc4.cc 601 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604
  1. // *********************************************************************
  2. // Created with MBC (V) 4.0-Beta3 (2018/12/09)Ported to OSX by Armando Rivera
  3. // Ported from BCX32 BASIC To C/C++ Translator (V) 5.12
  4. // BCX (c) 1999 - 2018 by Kevin Diggins
  5. // LinuxBC (c) 2009 by Mike Henning
  6. // MBC (c) 2009 - 2018 by Armando Rivera
  7. // *********************************************************************
  8. // Translated for compiling with the g++ Compiler
  9. // g++ -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$.cc -ldl -o $FILE$
  10. // *********************************************************************
  11. #include <stdbool.h>
  12. #include <ctype.h>
  13. #include <math.h>
  14. #include <stdio.h>
  15. #include <iostream>
  16. #include <fstream>
  17. #include <string.h>
  18. #include <stddef.h>
  19. #include <stdlib.h>
  20. #include <setjmp.h>
  21. #include <time.h>
  22. #include <stdarg.h>
  23. #include <dirent.h>
  24. #include <sys/types.h>
  25. #include <sys/stat.h>
  26. #include <sys/wait.h>
  27. #include <unistd.h>
  28. #include <dlfcn.h>
  29. // ***************************************************
  30. // Compiler Defines
  31. // ***************************************************
  32. #define C_EXPORT extern "C"
  33. #define C_IMPORT extern "C"
  34. #ifndef stat
  35. #define lstat stat
  36. #endif
  37. #ifndef _fcloseall
  38. #define _fcloseall _fcloseall
  39. #endif
  40. #ifndef HWND
  41. #define HWND GHWND
  42. #endif
  43. #ifndef MAX_PATH
  44. #define MAX_PATH 2048
  45. #endif
  46. #ifndef CALLBACK
  47. #define CALLBACK
  48. #endif
  49. typedef unsigned int HINSTANCE;
  50. typedef void* LPVOID;
  51. typedef char* PCHAR;
  52. typedef unsigned char BYTE;
  53. typedef unsigned int UINT;
  54. typedef unsigned char UCHAR;
  55. typedef unsigned char* PUCHAR;
  56. typedef unsigned long ULONG;
  57. typedef unsigned long* ULONG_PTR;
  58. typedef unsigned long DWORD;
  59. #ifndef TRUE
  60. #define TRUE 1
  61. #endif
  62. #ifndef FALSE
  63. #define FALSE 0
  64. #endif
  65. #define BOOL bool
  66. // ***************************************************
  67. typedef long (*CPP_FARPROC)(char *);
  68. // *************************************************
  69. // User Defined Constants
  70. // *************************************************
  71. #define Version "4.0-Beta3 (2018/12/09)"
  72. #define __BCX__ 1
  73. #define vt_VarMin 2
  74. #define vt_VarMax vt_VARIANT
  75. #define fprintf ReDirectFPrint
  76. #define MaxElements 128
  77. #define MaxTypes 512
  78. #define MaxLocalVars 512
  79. #define MaxGlobalVars 4096
  80. #define MaxLib 64
  81. #define c_SglQt 39
  82. #define c_DblQt 34
  83. #define c_LPar 40
  84. #define c_RPar 41
  85. #define c_Komma 44
  86. #define c_LtBkt 91
  87. #define c_RtBkt 93
  88. #define BCX_STR_RUNTIME "Runtime Functions"
  89. #define BCX_STR_MAIN_PROG "Main Program"
  90. #define BCX_STR_SYS_VARS "System Variables"
  91. #define BCX_STR_STD_MACROS "Standard Macros"
  92. #define BCX_STR_STD_PROTOS "Standard Prototypes"
  93. #define BCX_STR_USR_PROCS "User Subs and Functions"
  94. #define BCX_STR_USR_VARS "User Global Variables"
  95. #define BCX_STR_USR_PROTOS "User Prototypes"
  96. #define BCX_STR_USR_CONST "User Defined Constants"
  97. #define BCX_STR_USR_TYPES "User Defined Types, Classes (CPP Mode), And Unions"
  98. #define FUNCTIONPARSE_CLASS struct _FUNCTIONPARSE*
  99. #define VarTypes "%$#!@¦"
  100. #define ARGTYPE_CLASS struct _ARGTYPE*
  101. #define PROTOSTORE_CLASS struct _PROTOSTORE*
  102. #define ELEMENT_CLASS struct _ELEMENT*
  103. #define USERTYPEDEFS_CLASS struct _USERTYPEDEFS*
  104. #define VARINFO_CLASS struct _VARINFO*
  105. #define VARCODE_CLASS struct _VARCODE*
  106. #define iMatchLft(A,B) iMatch (A ,B ,0)
  107. #define iMatchWrd(A,B) iMatch (A ,B ,1)
  108. #define iMatchRgt(A,B) iMatch (A ,B ,2)
  109. // *************************************************
  110. // User's GLOBAL ENUM blocks
  111. // *************************************************
  112. enum
  113. {
  114. vt_UNKNOWN,
  115. vt_STRLIT,
  116. vt_INTEGER,
  117. vt_SINGLE,
  118. vt_DOUBLE,
  119. vt_LDOUBLE,
  120. VT_LLONG,
  121. vt_STRVAR,
  122. vt_DECFUNC,
  123. vt_NUMBER,
  124. vt_FILEPTR,
  125. vt_UDT,
  126. vt_STRUCT,
  127. vt_UNION,
  128. vt_BOOL,
  129. vt_CHAR,
  130. vt_LPSTRPTR,
  131. vt_PCHAR,
  132. vt_CHARPTR,
  133. vt_VOID,
  134. vt_LONG,
  135. vt_DWORD,
  136. vt_FARPROC,
  137. vt_LPBYTE,
  138. vt_LRESULT,
  139. vt_BYTE,
  140. vt_SHORT,
  141. vt_USHORT,
  142. vt_UINT,
  143. vt_ULONG,
  144. vt_HWND,
  145. vt_HDC,
  146. vt_COLORREF,
  147. vt_HANDLE,
  148. vt_HINSTANCE,
  149. vt_WNDCLASSEX,
  150. vt_HFONT,
  151. vt_VARIANT
  152. };
  153. enum
  154. {
  155. mt_ProcessSetCommand,
  156. mt_FuncSubDecC_Dec,
  157. mt_FuncSubDecC_Dec2,
  158. mt_Opts,
  159. mt_Opts2,
  160. mt_Opts3,
  161. mt_OverLoad,
  162. mt_OverLoad2,
  163. mt_FuncSubx1,
  164. mt_FuncSubx2
  165. };
  166. // *************************************************
  167. // User Defined Types, Classes (CPP Mode), And Unions
  168. // *************************************************
  169. typedef struct _functionParse
  170. {
  171. int NumArgs;
  172. int CommaPos[128];
  173. }functionParse, *LPFUNCTIONPARSE;
  174. typedef struct _ARGTYPE
  175. {
  176. char Arg[2048];
  177. int ArgType;
  178. }ARGTYPE, *LPARGTYPE;
  179. typedef struct _ProtoStore
  180. {
  181. char Prototype[2048];
  182. char Condition[512];
  183. int CondLevel;
  184. }ProtoStore, *LPPROTOSTORE;
  185. typedef struct _Element
  186. {
  187. int ElementType;
  188. int ElementID;
  189. int ElementDynaPtr;
  190. char ElementName[64];
  191. }Element, *LPELEMENT;
  192. typedef struct _UserTypeDefs
  193. {
  194. int TypeofDef;
  195. int EleCnt;
  196. struct _Element Elements[MaxElements];
  197. char VarName[64];
  198. }UserTypeDefs, *LPUSERTYPEDEFS;
  199. typedef struct _VarInfo
  200. {
  201. int VarLine;
  202. int VarType;
  203. int VarDef;
  204. int VarPntr;
  205. int VarSF;
  206. int VarExtn;
  207. int VarCondLevel;
  208. int VarEmitFlag;
  209. int VarConstant;
  210. char VarName[64];
  211. char VarDim[128];
  212. char VarModule[300];
  213. char VarCondDef[128];
  214. }VarInfo, *LPVARINFO;
  215. typedef struct _VARCODE
  216. {
  217. int VarNo;
  218. int Method;
  219. int IsPtrFlag;
  220. char Header[2048];
  221. char Proto[2048];
  222. char Functype[2048];
  223. char StaticOut[2048];
  224. char Token[2048];
  225. char AsToken[2048];
  226. }VARCODE, *LPVARCODE;
  227. // *************************************************
  228. // System Variables
  229. // *************************************************
  230. char TAB [2]={9,0}; // Horz Tab
  231. char LF [2]={10,0}; // Line Feed
  232. char ESC [2]={27,0}; // Escape
  233. char SPC [2]={32,0}; // Space
  234. char DQ [2]={34,0}; // Double-Quote
  235. char DDQ [3]={34,34,0}; // Double-Double-Quote
  236. char CRLF[3]={13,10,0}; // Carr Rtn & Line Feed
  237. char *AR_fgets_retval;
  238. // *************************************************
  239. // User Global Variables
  240. // *************************************************
  241. static PCHAR *G_argv;
  242. static int G_argc;
  243. static int NoRT;
  244. static int ByrefCnt;
  245. static char CurLine[65535];
  246. static int gLinesWritten;
  247. static int LoopLocalCnt;
  248. static int GlobalVarCnt;
  249. static int TypeDefsCnt;
  250. static int LocalVarCnt;
  251. static int LocalDynArrCount;
  252. static int LocalDynaCnt;
  253. static int GlobalDynaCnt;
  254. static int ModuleNdx;
  255. static int FPtrNdx;
  256. static int SplitCnt;
  257. static int SplitCur;
  258. static char SrcTmp[65535];
  259. static int StartNdx;
  260. static int ExitNdx;
  261. static VARCODE VarCode;
  262. static int UmQt;
  263. static char LD_FLAGS[65535];
  264. static char Accelerator[65535];
  265. static char CallType[65535];
  266. static int CaseFlag;
  267. static char CaseVar[65535];
  268. static char Cmd[65535];
  269. static char Compiler[65535];
  270. static char CmdLineConst[65535];
  271. static char CmdLineFileOut[65535];
  272. static int CurrentFuncType;
  273. static char DimType[65535];
  274. static int DllCnt;
  275. static int LoadLibsCnt;
  276. static float Elapsed;
  277. static int EndOfProgram;
  278. static int EntryCnt;
  279. static int ErrFile;
  280. static char szFile[65535];
  281. static char Filnam[65535];
  282. static int ForceMainToFunc;
  283. static char Funcname[65535];
  284. static char Handl[65535];
  285. static int HFileCnt;
  286. static char HFile[65535];
  287. static int InConditional;
  288. static char InIfDef[65535];
  289. static int Indent;
  290. static int InFunc;
  291. static int InMain;
  292. static int IsCallBack;
  293. static int TurboSize;
  294. static int UseCProto;
  295. static int InTypeDef;
  296. static int IsAuto;
  297. static int NoTypeDeclare;
  298. static int IsDim;
  299. static int IsExported;
  300. static int IsRegister;
  301. static int IsStatic;
  302. static int IsStdFunc;
  303. static int IsLocal;
  304. static int IsRaw;
  305. static int IsApple;
  306. static int KillCFile;
  307. static char Keyword1[65535];
  308. static int LastCmd;
  309. static int LinesRead;
  310. static char Linker[65535];
  311. static char Lookup[65535];
  312. static int MakeDLL;
  313. static int Ndx;
  314. static int NoMain;
  315. static int NoDllMain;
  316. static int OkayToSend;
  317. static char Op[65535];
  318. static int OptionBase;
  319. static char OutfileClone[65535];
  320. static int PassOne;
  321. static int ProtoCnt;
  322. static int Pusher;
  323. static int Quiet;
  324. static int ReDirect;
  325. static FILE *SaveOutfileNum;
  326. static char Scoot[65535];
  327. static int ShowStatus;
  328. static int SrcCnt;
  329. static int SrcFlag;
  330. static int TrcFlag;
  331. static int TestForBcxIni;
  332. static char FileIn[65535];
  333. static char FileOut[65535];
  334. static char FileErr[65535];
  335. static char T[65535];
  336. static int Test;
  337. static int Statements;
  338. static int TestState;
  339. static char Tipe[65535];
  340. static int TranslateSlash;
  341. static int UseCpp;
  342. static int UseFlag;
  343. static int InNameSpace;
  344. static int Use_Virtual;
  345. static char vproc[65535];
  346. static int UseStdCall;
  347. static int UseLCaseTbl;
  348. static char Var[65535];
  349. static int XitCount;
  350. static char Z[65535];
  351. static char ConstLastDef[65535];
  352. static int Use_AnsiToWide;
  353. static int Use_Asc;
  354. static int Use_AppExeName;
  355. static int Use_AppExePath;
  356. static int Use_Boolstr;
  357. static int Use_Bor;
  358. static int Use_Band;
  359. static int Use_Bnot;
  360. static int Use_BcxSplitPath;
  361. static int Use_Bin;
  362. static int Use_Bin2dec;
  363. static int Use_Osx;
  364. static int Use_Cvd;
  365. static int Use_Cvld;
  366. static int Use_Cvi;
  367. static int Use_Cvl;
  368. static int Use_Cvs;
  369. static int Use_Chr;
  370. static int Use_Cdbl;
  371. static int Use_Cldbl;
  372. static int Use_Csng;
  373. static int Use_Clear;
  374. static int Use_Cbool;
  375. static int Use_Cint;
  376. static int Use_Clng;
  377. static int Use_Cls;
  378. static int Use_Color;
  379. static int Use_Command;
  380. static int Use_ContainedIn;
  381. static int Use_Console;
  382. static int Use_CopyFile;
  383. static int Use_Static;
  384. static int Use_Crlf;
  385. static int Use_Curdir;
  386. static int Use_Del;
  387. static int Use_Download;
  388. static int Use_Dynacall;
  389. static int Use_DynamicA;
  390. static int Use_Embed;
  391. static int Use_Enclose;
  392. static int Use_Environ;
  393. static int Use_EnumFile;
  394. static int Use_Eof;
  395. static int Use_Exist;
  396. static int Use_ExitCode;
  397. static int Use_Extract;
  398. static int Use_LoadFile;
  399. static int Use_FillArray;
  400. static int Use_Findfirst;
  401. static int Use_Findnext;
  402. static int Use_FindInType;
  403. static int Use_Fint;
  404. static int Use_Fix;
  405. static int Use_FileLocked;
  406. static int Use_Frac;
  407. static int Use_Fracl;
  408. static int Use_Freefile;
  409. static int Use_Get;
  410. static int Use_GetCh;
  411. static int Use_GenFree;
  412. static int Use_Gosub;
  413. static int Use_Gtk;
  414. static int Use_Glib;
  415. static int Use_Hex;
  416. static int Use_Hex2Dec;
  417. static int Use_Iif;
  418. static int Use_Imod;
  419. static int Use_Inkey;
  420. static int Use_InkeyD;
  421. static int Use_Ins;
  422. static int Use_Instr;
  423. static int Use_Inchr;
  424. static int Use_Isptr;
  425. static int Use_iReplace;
  426. static int Use_IRemove;
  427. static int Use_Instrrev;
  428. static int Use_Join;
  429. static int Use_Keypress;
  430. static int Use_Lcase;
  431. static int Use_Ldouble;
  432. static int Use_Left;
  433. static int Use_Like;
  434. static int Use_Lineinput;
  435. static int Use_Loc;
  436. static int Use_Locate;
  437. static int Use_Lof;
  438. static int Use_Lpad;
  439. static int Use_Ltrim;
  440. static int Use_Mcase;
  441. static int Use_Mid;
  442. static int Use_Midstr;
  443. static int Use_Mkd;
  444. static int Use_Mkld;
  445. static int Use_Mki;
  446. static int Use_Mkl;
  447. static int Use_Mks;
  448. static int Use_Min;
  449. static int Use_Max;
  450. static int Use_Now;
  451. static int Use_Numqsortdint;
  452. static int Use_Numqsortaint;
  453. static int Use_Numqsortdfloat;
  454. static int Use_Numqsortafloat;
  455. static int Use_Numqsortddouble;
  456. static int Use_Numqsortadouble;
  457. static int Use_Idxqsort;
  458. static int Use_IdxqsortSt;
  459. static int Use_PtrqsortSt;
  460. static int Use_Oct;
  461. static int Use_Overloaded;
  462. static int Use_OSVersion;
  463. static int Use_Pause;
  464. static int Use_PeekStr;
  465. static int Use_Put;
  466. static int Use_QBColor;
  467. static int Use_Randomize;
  468. static int Use_Rec;
  469. static int Use_RecCount;
  470. static int Use_Remain;
  471. static int Use_Remove;
  472. static int Use_Repeat;
  473. static int Use_Replace;
  474. static int Use_Reverse;
  475. static int Use_Right;
  476. static int Use_Rpad;
  477. static int Use_Rnd;
  478. static int Use_Exp;
  479. static int Use_Retain;
  480. static int Use_Round;
  481. static int Use_Rtrim;
  482. static int Use_Run;
  483. static int Use_Scan;
  484. static int Use_Inputbuffer;
  485. static int Use_SearchPath;
  486. static int Use_StrUpLow;
  487. static int Use_Shell;
  488. static int Use_Sgn;
  489. static int Use_SingleFile;
  490. static int Use_Space;
  491. static int Use_Split;
  492. static int Use_DSplit;
  493. static int Use_StartupCode;
  494. static int Use_Stristr;
  495. static int Use_StrStr;
  496. static int Use_Str;
  497. static int Use_Strl;
  498. static int Use_Str_Cmp;
  499. static int Use_Strim;
  500. static int Use_String;
  501. static int Use_Strptr;
  502. static int Use_Strqsorta;
  503. static int Use_Strqsortd;
  504. static int Use_Strtoken;
  505. static int Use_DynStrqsorta;
  506. static int Use_DynStrqsortd;
  507. static int Use_Swap;
  508. static int Use_Sysdir;
  509. static int Use_SysStr;
  510. static int Use_sziif;
  511. static int Use_Tally;
  512. static int Use_Tempdir;
  513. static int Use_TempFileName;
  514. static int Use_Threads;
  515. static int Use_Time;
  516. static int Use_Timer;
  517. static int Use_Trim;
  518. static int Use_Turbo;
  519. static int Use_Ubound;
  520. static int Use_Ucase;
  521. static int Use_Using;
  522. static int Use_VChr;
  523. static int Use_Verify;
  524. static int Use_Val;
  525. static int Use_Vall;
  526. static int Use_WideToAnsi;
  527. static int Use_Wx;
  528. static int Use_WxC;
  529. static int Use_Ctor;
  530. static int Use_Instat;
  531. static int Use_Socket;
  532. static int Use_IOS;
  533. static int Use_RegEx;
  534. static int Use_BEL;
  535. static int Use_BS;
  536. static int Use_CR;
  537. static int Use_DDQ;
  538. static int Use_DQ;
  539. static int Use_EOF;
  540. static int Use_ESC;
  541. static int Use_FF;
  542. static int Use_LF;
  543. static int Use_NUL;
  544. static int Use_SPC;
  545. static int Use_TAB;
  546. static int Use_VT;
  547. static char prcFile[65535];
  548. static char udtFile[65535];
  549. static char datFile[65535];
  550. static char cstFile[65535];
  551. static char ovrFile[65535];
  552. static char hdrFile[65535];
  553. static char setFile[65535];
  554. static char enuFile[65535];
  555. static char *szTmp;
  556. static char *Src;
  557. static char *AbortSrc;
  558. static char *WarnMsg;
  559. static char *RmLibs;
  560. static FILE *SourceFile;
  561. static FILE *FP2;
  562. static FILE *FP3;
  563. static FILE *FP4;
  564. static FILE *FP5;
  565. static FILE *FP6;
  566. static FILE *FP7;
  567. static FILE *FP8;
  568. static FILE *FP9;
  569. static FILE *FP11;
  570. static FILE *Outfile;
  571. static FILE *FP1;
  572. static int DoCountLines;
  573. static FILE *FP10;
  574. static FILE *ResIn;
  575. static FILE *ResOut;
  576. static FILE *UserResIn;
  577. static FILE *fpErr;
  578. static FILE *fpHFile;
  579. static FILE *FP68;
  580. static FILE *fpdef;
  581. static int SFPOINTER;
  582. static int WithCnt;
  583. static char ByrefVars[1024][65535];
  584. static int LoopLocalVar[256];
  585. static int BaseTypeDefsCnt[16];
  586. static char Modules[256][65535];
  587. static int ModuleLineNos[256];
  588. static FILE *FPtr[256];
  589. static char Stk[4096][65535];
  590. static ProtoStore ProtoType[1024];
  591. static char SrcStk[128][65535];
  592. static char SplitStk[128][65535];
  593. static char CaseStk[256][65535];
  594. static int CaseElseFlag[256];
  595. static char Entry[256][65535];
  596. static char Xit[256][65535];
  597. static char LocalDynArrName[256][65535];
  598. static char GlobalDynaStr[256][65535];
  599. static char DynaStr[256][65535];
  600. static char StartSub[32][65535];
  601. static char ExitSub[32][65535];
  602. static char Library[MaxLib][65535];
  603. static int GlobalVarHash[MaxGlobalVars];
  604. static VarInfo GlobalVars[MaxGlobalVars];
  605. static VarInfo LocalVars[MaxLocalVars];
  606. static UserTypeDefs TypeDefs[MaxTypes];
  607. static char DllDecl[800][512];
  608. static char Loadlibs[128][512];
  609. static char HFiles[128][65535];
  610. static char TypeName[16][65535];
  611. static char WithVar[8][65535];
  612. // *************************************************
  613. // Standard Macros
  614. // *************************************************
  615. #define FDRV 2
  616. #define FPATH 4
  617. #define FNAME 8
  618. #define FEXT 16
  619. #define BAND &
  620. #define BOR |
  621. #define imod(a,b)((a)%(b))
  622. #define VAL(a)(double)atof(a)
  623. // *************************************************
  624. // Standard Prototypes
  625. // *************************************************
  626. int str_cmp(char*, char*);
  627. int EoF (FILE*);
  628. void cls(void);
  629. void locate (int,int,int=1,int=12);
  630. void midstr (char*, int, int, char *);
  631. char* BCX_TmpStr(size_t);
  632. char* sziif (bool,char*,char*);
  633. char* TempFileName (char*,char*);
  634. char* AppExePath (void);
  635. char* AppExeName (void);
  636. char* lcase (char*);
  637. char* ucase (char*);
  638. char* mid (char*, int, int=-1);
  639. char* ltrim (char*,char=32);
  640. char* rtrim (char*,char=32);
  641. char* trim (char*);
  642. char* strim (char*);
  643. char* left (char*,int);
  644. char* right (char*,int);
  645. char* rpad (char*,int,int=32);
  646. char* lpad (char*,int,int=32);
  647. char* stringx (int,int);
  648. char* extract (char*,char*);
  649. char* remain (char*,char*);
  650. char* command (int=-1);
  651. char* replace (char*,char*,char*);
  652. char* iReplace (char*,char*,char*);
  653. void Shell (char *);
  654. char* space (int a);
  655. char* str (double);
  656. char* curdir (void);
  657. char* tempdir (void);
  658. char* Environ (char*);
  659. char* _strupr_(char *);
  660. char* _strlwr_(char *);
  661. char* BcxSplitPath (char *, int);
  662. void _splitpath_(const char* path, char* drv, char* dir, char* name, char* ext);
  663. char* StrToken (char*,char*,int);
  664. char* RemoveStr (char*,char*);
  665. char* IRemoveStr (char*,char*);
  666. char* join (int, ... );
  667. char* enc (char*, int=0, int=0);
  668. char* chr(int,int=0,int=0,int=0,int=0,int=0,int=0,int=0,int=0,int=0);
  669. char* vchr (int,...);
  670. int InstrRev (char*,char*,int=0,int=0);
  671. int instr_b(char*,char*,int=0,int=0);
  672. char *MakeLCaseTbl(void);
  673. char *_stristr_(char*,char*);
  674. char *_strstr_(char*,char*);
  675. int inchr (char*,char*);
  676. int tally (char*,char*,int=0);
  677. BOOL Exist (char*);
  678. char* ins (char *S, int i, char *a);
  679. char* del (char*,int,int);
  680. DWORD lof (char*);
  681. double Round (double,int);
  682. float rnd (void);
  683. double _MIN_ (double,double);
  684. double _MAX_ (double,double);
  685. int containedin(char * ,char **,int=0);
  686. // *************************************************
  687. // User Prototypes
  688. // *************************************************
  689. int main (int, PCHAR* );
  690. void EmitCmdLineConst (void);
  691. void EmitCompilerDefines (void);
  692. void MakeFreeGlobals (void);
  693. void ProcessSetCommand (int);
  694. int Directives (void);
  695. int SubVarType (int);
  696. char * PrintWriteFormat (int);
  697. void EmitInputCode (void);
  698. void EmitFileInputCode (void);
  699. void AddFuncs (void);
  700. int CheckLocal (char *, int* );
  701. int CheckGlobal (char *, int* );
  702. int CheckType (char *);
  703. void ExportInternalConst (void);
  704. int RestrictedWords (char *);
  705. int DataType (char *);
  706. void CloseAll (void);
  707. char * Clean (char *);
  708. void RemoveAll (char* ,char* ,int=0);
  709. void Warning (char* ,int=0);
  710. PCHAR GetVarTypeName (int);
  711. int HashNumber (char *);
  712. void AddLibrary (char *);
  713. void RemoveLibrary (char *);
  714. void EmitLibs (void);
  715. void AddGlobal (char* ,int,int,char* ,int,int,int,int,int=0);
  716. void AddLocal (char* ,int,int,char* ,int,int,int,int=0);
  717. int IsNumber (char *);
  718. int IsNumberEx (char *);
  719. void StripTabs (void);
  720. void PushFileIO (void);
  721. void PopFileIO (void);
  722. int Inset (char *, char *);
  723. void CheckParQuotes (void);
  724. void ClearIfThenStacks (void);
  725. int IsQuoted (char *);
  726. void PostProcess (void);
  727. void XParse (char *);
  728. void TokenSubstitutions (void);
  729. void JoinStrings (int, int);
  730. void Transforms (void);
  731. void Parse (char *);
  732. void FuncSubDecs1 (char *);
  733. void RemEmptyTokens (void);
  734. void FuncSubDecs2 (char *, int);
  735. void FuncSubDecs3 (VARCODE* );
  736. void AddTypeDefs (char *, int);
  737. int DefsID (char *);
  738. void GetTypeInfo (char *, int* , int* , int* );
  739. void AddTypedefElement (int, int, char *, char *, int);
  740. char * GetElement (int, int* , int* , int);
  741. int GetElementInfo (int* , int* , char *);
  742. void HandleNonsense (void);
  743. void ValidVar (char *);
  744. void PointerFix (void);
  745. void DimDynaString (char *, int, int);
  746. int SubFuncTest (void);
  747. int DimSubFunc (int);
  748. void Emit (void);
  749. void Abort (char *);
  750. void BumpDown (void);
  751. void BumpUp (void);
  752. int BraceCount (char *);
  753. char* BracketHandler (char *, int);
  754. void Push (char *);
  755. void Pop (char *);
  756. void EmitEpilog (void);
  757. void EmitProlog (void);
  758. void DeclareVariables (void);
  759. int GetNumArgs (int,int* =NULL);
  760. void GetVarCode (VARCODE* );
  761. void AddProtos (void);
  762. void RunTimeFunctions (void);
  763. int JoinLines (char *);
  764. void StripCode (char *);
  765. void ProcSingleLineIf (int* );
  766. int SplitLines (char *);
  767. int iMatch (char *, char *, int);
  768. int iMatchNQ (char *, char *);
  769. int SpecialCaseHandler (char *);
  770. void FastLexer (char* ,char* ,char* ,int=1);
  771. void InsertTokens (int, int, ...);
  772. void EmitExportDef (char *);
  773. char * GetArg (int, functionParse* );
  774. int SepFuncArgs (int, functionParse* , int);
  775. PCHAR MakeDecProto (functionParse* );
  776. void AsmUnknownStructs (int);
  777. void EmitIfCond (char *);
  778. void PrintGlobal (int, int, char *, char *, char *, char *);
  779. void ReDirectFPrint (FILE*, char *, ...);
  780. int IsReservedWord (char *);
  781. int GetAsPos (void);
  782. void FreeGlobals (void);
  783. // *************************************************
  784. // User Global Initialized Arrays
  785. // *************************************************
  786. // *************************************************
  787. // User GLOBAL SET Statements
  788. // *************************************************
  789. static char* VarTypeLookup[]=
  790. {
  791. "int","int","char *","double","float","FILE *","long double"
  792. };
  793. static char VarConst[2][8]=
  794. {
  795. "",
  796. "const "
  797. };
  798. static char VarStorage[6][18]=
  799. {
  800. "static ",
  801. "extern ",
  802. "",
  803. "static volatile ",
  804. "extern volatile ",
  805. "volatile "
  806. };
  807. static char* ReservedWord[]=
  808. {
  809. "IF",
  810. "ELSEIF",
  811. "THEN",
  812. "ELSE",
  813. "AND",
  814. "OR",
  815. "NOT",
  816. "BOR",
  817. "BAND",
  818. "XOR",
  819. ""
  820. };
  821. // *******************************************************************************
  822. // Developer Guidelines
  823. // *******************************************************************************
  824. // Code should be written in BCX Basic. If it can not be written in BCX Basic for
  825. // some reason or results in code that seems too inefficient then this may be a
  826. // cue that a new Basic function is needed.
  827. // * All KEYWORDS should be capitalized
  828. // * Use two space indentation
  829. // * Use spaces not tabs
  830. // * Record all notes in reverse chronological order
  831. // * And most importantly....Have fun!
  832. // ******************************************************************************************
  833. // This section is used to communicate to-do 's, changes, ideas, suggestions, etc.
  834. // ******************************************************************************************
  835. // -------------------------------------------
  836. // 2018-12-12 Armando Rivera
  837. // * Changed BcxRegEx function to REGMATCH
  838. // * Changed BcxRegEx keyword to REGMATCH
  839. // * Added $MODULE as alias to $INCLUDE to support external modules. ** MUST BE AT TOP OF MAIN SOURCE FILE **
  840. // * Added $LDFLAGS directive to support external modules
  841. // -------------------------------------------
  842. // -------------------------------------------
  843. // 2016-02-15 Armando Rivera
  844. // -------------------------------------------
  845. // * Changed default string size to 65K from
  846. // 2k, which was limiting.
  847. // * Updated output of PRINT command, eliminating
  848. // leading spaces from numbers.
  849. // -------------------------------------------
  850. // 2015-07-03 Armando Rivera
  851. // -------------------------------------------
  852. // * Changed $OSX flag to use Cocoa instead of Carbon in MacOS
  853. // This is in preparation of the new custom libcocoa library
  854. // that I'm currently creating that will allow mbc
  855. // to create 64bit GUI applications in OSX
  856. // -------------------------------------------
  857. // 2013-06-26 Armando Rivera
  858. // -------------------------------------------
  859. // * Added BcxRegex keyword, based on Posix Regex in Libc
  860. // * Broke up main source file into files containing Runtime, Declarations, etc.
  861. // * Added BYTE type
  862. //
  863. // -------------------------------------------
  864. // 2013-06-17 Armando Rivera
  865. // -------------------------------------------
  866. // * Tweaked HEX$ so that it will emit 2-digit hex numbers
  867. // * Added PUCHAR (unsigned char*) typedef
  868. // -------------------------------------------
  869. // 2011-03-11 Armando Rivera
  870. // -------------------------------------------
  871. // * Added Wayne's suggestion to support Reference Variables as return types.
  872. //
  873. // -------------------------------------------
  874. // 2011-03-10 Armando Rivera
  875. // -------------------------------------------
  876. // * Ported $PROJECT directive from ConsoleBC. This doesn't emit the RTL yet, but it's a start.
  877. // It's the first step towards re-writing the RT code to leverage CPP/WX.
  878. //
  879. // * Fixed bug where BCX_TmpStr sometimes wasn't emitted when returning a string from a function
  880. //
  881. // * Added Named Enum support. Syntax:
  882. // myenum AS ENUM
  883. // …
  884. // END ENUM
  885. //
  886. // This required moving the Enum emit code to before the User Prototype emit code
  887. // to allow passing the named enum to user defined functions.
  888. //
  889. // -------------------------------------------
  890. // 2011-01-23 Armando Rivera
  891. // -------------------------------------------
  892. // * Initial Beta1 Release
  893. //
  894. // * Fixed bug in INPUT statement to remove trailing newlines (James Fuller)
  895. //
  896. // * Removed COLOR statements to avoid terminal output issues with redirected
  897. // translator output (James Fuller)
  898. //
  899. // * Added CONST keyword when declaring variables (Global, Local, and as Function/Sub parameters)
  900. // At the moment, this is experimental (meaning I haven't fully tested it) but it seems to work
  901. //
  902. // * Added PRIVATE keyword for CPP classes
  903. // -------------------------------------------
  904. // 2010/12/21 Armando Rivera
  905. // -------------------------------------------
  906. // * Cleaned up code emission so that unneeded defines/global vars are not emitted
  907. //
  908. // * Added new $IOS directive, which is MAC ONLY, to compile source for iDevices (iPhone/iTouch/AppleTV2)
  909. // At this point in time, running binaries built this way requires a jailbroken iDevice.
  910. // This is experimental, and for console apps only for now.
  911. // A simple console example is in the Examples/IOS folder
  912. // -------------------------------------------
  913. // 2010/12/11 Armando Rivera
  914. // -------------------------------------------
  915. // * Add new Socket keywords: BcxSocket, BcxSocketSend, BcxSocketRead, and BcxSocketClose
  916. // See the BcxSocket.bas demo in the Examples/Socket folder for info.
  917. //
  918. // * Added kbhit() , which doesn't exist outside of Windows
  919. // This is a custom sub which emulates what kbhit() does
  920. //
  921. // * Changed the conditional emission of term.h to only be emitted when
  922. // Use_Keypress is TRUE (InKey)
  923. //
  924. // -------------------------------------------
  925. // 2010/12/01 Armando Rivera
  926. // -------------------------------------------
  927. // * Changed wxApp emission to use BCXPLITHPATH$, per James Fuller's suggestion.
  928. //
  929. // * Added support for Abstract Classes (gcc doesn't have the INTERFACE keyword)
  930. //
  931. // Example:
  932. // Class MyAbstractClass
  933. // public
  934. //
  935. // virtual sub Proc1() = 0
  936. // Virtual sub Proc2()=0
  937. // virtual function Proc3(a$,b$) as integer = 0
  938. //
  939. // End Class
  940. // -------------------------------------------
  941. // 2010/11/30 Armando Rivera
  942. // -------------------------------------------
  943. // * Removed $CLASS/$ENDCLASS $NAMESPACE/$ENDNAMESPACE
  944. // Using either will emit a message stating that they have been replaced.
  945. //
  946. // * Addded NAMESPACE / END NAMESPACE
  947. // This allows creating methods within the NAMESPACE like so:
  948. //
  949. // $CPP
  950. // $NOMAIN
  951. // $EXECON
  952. // '==============================================================================
  953. // NAMESPACE Dlg_01
  954. // Sub DoIt()
  955. // Print "Dlg_01"
  956. // End Sub
  957. //
  958. // Function GetString$(A$) as string
  959. // function = "The String you Passed Was: " + enc$(A$)
  960. // end function
  961. // END NAMESPACE
  962. // '==============================================================================
  963. // Function main(argc as INTEGER, argv as PCHAR ptr) as INTEGER
  964. // Print "James"
  965. // Dlg_01::DoIt()
  966. // print Dlg_01::GetString$("Hello, World!")
  967. // End Function
  968. //
  969. // * If using $WX, the #define for Clear() will not be emitted due to conflict
  970. // with Classes that have that method defined
  971. //
  972. // * Made the inclusion of "term.h" conditional based on whether $WX/$WXC
  973. // is used. "term.h" is required for the implementation of
  974. // the PAUSE keyword in CONSOLE apps.
  975. //
  976. // -------------------------------------------
  977. // 2010/11/25 Armando Rivera
  978. // -------------------------------------------
  979. // * Changed code so that in $CPP mode, the case of the emitted
  980. // .cpp filename is preserved (James Fuller bug report)
  981. //
  982. // -------------------------------------------
  983. // 2010/11/24 Armando Rivera
  984. // -------------------------------------------
  985. // * Minor change in StripCode() to correct
  986. // possible overflow issue under 64bit Linux (James Fuller bug report)
  987. //
  988. // * Added $WXC Directive to support WX Console-Based Apps
  989. // Using this switch, neither a wxApp or the IMPLEMENT_APP() macro are
  990. // auto added to the translated source (James Fuller request)
  991. // -------------------------------------------
  992. // 2010/11/20 Armando Rivera
  993. // -------------------------------------------
  994. // * Changed $DLL directive so that it would generate *nix Shared Libraries.
  995. // * Added $DLL support to $EXECON
  996. // * Added required flags to LD_FLAGS$ for creating *nix Shared Libraries
  997. // Example:
  998. // $dll
  999. // $execon
  1000. //
  1001. // function printdemo() export
  1002. // print "This was called from a Dynamic Library"
  1003. // end function
  1004. //
  1005. // Note that this is currently only useful for creating shared libraries
  1006. // for **OTHER** languages; it won't work with MBC created apps because of
  1007. // duplicate naming conflicts.
  1008. //
  1009. // -------------------------------------------
  1010. // 2010/11/18 Armando Rivera
  1011. // -------------------------------------------
  1012. // * Removed "-Os" compiler optimization flag from $EXECON for fastest tranlator compliation
  1013. // during Alpha testing stage.
  1014. //
  1015. // This will be re-added when translator is not longer in Alpha status
  1016. //
  1017. // * Added USE_CTOR global as flag for supporting Constructor/Destructor syntax
  1018. //
  1019. // * Added "USING" keyword for CONSTRUCTOR/DESTRUCTOR methods. It is used like this:
  1020. //
  1021. // CONSTRUCTOR MainWin::MainWin(title as wxString, winStyle as long) USING wxFrame( 0, -1, title, wxPoint(50,50), wxSize(490,296), winStyle )
  1022. //
  1023. // Which will emit:
  1024. //
  1025. // MainWin::MainWin (wxString title, long winStyle)
  1026. // : wxFrame( 0, -1, title, wxPoint(50,50), wxSize(490,296), winStyle )
  1027. // {
  1028. //
  1029. // * Added code to extract and emit derived class methods
  1030. //
  1031. // -------------------------------------------
  1032. // 2010/11/17 Armando Rivera
  1033. // -------------------------------------------
  1034. // * Added new CLASS / END CLASS / PUBLIC / PROTECTED / CONSTRUCTOR / DESTRUCTOR keywords.
  1035. // These additions flesh out Basic-Like C++ CLASS support, superceding $CLASS/$ENDCLASS,
  1036. // and now allows syntax like the following:
  1037. //
  1038. // $CPP
  1039. // $NOMAIN
  1040. // $execon
  1041. //
  1042. // class MyClass
  1043. //
  1044. // protected
  1045. // first as string
  1046. // secnd$
  1047. // third%
  1048. //
  1049. // public
  1050. // type ATest
  1051. // a as PCHAR
  1052. // b as long
  1053. // c as single
  1054. // d as float
  1055. // end type
  1056. //
  1057. // Constructor MyClass(a$, b)
  1058. // Destructor MyClass()
  1059. // end class
  1060. //
  1061. // FUNCTION main(argc as INTEGER, argv as PCHAR ptr) as INTEGER
  1062. // RAW theClass as MyClass PTR
  1063. //
  1064. // theClass = new MyClass("Hello", 12)
  1065. //
  1066. // print (char*)theClass->ATest.a
  1067. // print theClass->ATest.b
  1068. // END FUNCTION
  1069. //
  1070. // Constructor MyClass::MyClass(a$,b)
  1071. // ATest.a = a$
  1072. // ATest.b = b
  1073. // END Constructor
  1074. // '
  1075. // Destructor MyClass::~MyClass()
  1076. //
  1077. // END Destructor
  1078. //
  1079. // -------------------------------------------
  1080. // 2010/11/12 Armando Rivera
  1081. // -------------------------------------------
  1082. // * Added code that (mostly) eliminates the need for a trailing ";" in $class/$endclass
  1083. //
  1084. // * Added code to allow the use of "SUB" in $class/$endclass. It just substitutes "void" for "sub"
  1085. // at this point.
  1086. //
  1087. // * Fixed "THIS" keyword code so that it emits a lowercase "this". Linux/OSX aren't affected
  1088. // by this breaking COM statements. :-P Thanks to JCFULLER for the tip!
  1089. //
  1090. // * For $CPP mode, added typedefs for std::string (CSTRING) and std::fstream (CFILE)
  1091. // These are direct replacements for STRING and FILE, and allows the full use of each
  1092. // C++ object/class.
  1093. //
  1094. // So instead of "dim mystring as string", for example, you would do "dim mystring as CSTRING".
  1095. // You would then have access to all of std::string's methods like .replace, .substr, .compare, etc.
  1096. //
  1097. // I'm considering doing the same with the other toolkit directives ($OSX, $GTK, etc) but we'll see...
  1098. //
  1099. // * Added "inherits" in $CPP mode so that subclassing can be done like so:
  1100. //
  1101. // $class MyClass inherits AnotherClass
  1102. //
  1103. // * For $WX mode, added code to automatically emit the required derived wxApp class.
  1104. // Note that it will be named the same as your sourcefile (minus the extension), and you MUST provide
  1105. // a "FUNCTION ::OnInit() as bool" for it:
  1106. //
  1107. // FUNCTION TestApp::OnInit() as bool
  1108. // <initialize app here>
  1109. // END FUNCTION
  1110. //
  1111. // * For $WX mode, made "$NOMAIN" the default, so no need to pass that directive
  1112. //
  1113. // * Colorized some of the compiler output text. Just because I can.
  1114. //
  1115. // * Back-ported Wayne's changes to "WITH" to allow the use of "->" syntax
  1116. //
  1117. // * TODO:
  1118. // Finish off the $class/$endclass code to allow full basic syntax for method and variable
  1119. // declarations.
  1120. //
  1121. // Remove ALL remaining WIN32 related code and ifdefs.
  1122. // No need for that stuff under Linux/OSX, the Windows version of BCX can handle all
  1123. // of the Windows stuff one might need.
  1124. //
  1125. // Other stuff I can't remember right now…..
  1126. // -------------------------------------------
  1127. // 2010/03/31 Armando Rivera
  1128. // Beginning with this version of the console compiler,
  1129. // the goal is to have a 100% unified code-base, because
  1130. // I'm fracking tired of trying to maintain separate builds
  1131. // for different Operating Systems.
  1132. // -------------------------------------------
  1133. //
  1134. // * Added $OSX, $GTK¸$GLIB and $WX Directives
  1135. // (Use_Osx, Use_Wx, Use_Gtk, Use_Glib and LD_FLAGS$ Globals added)
  1136. //
  1137. // $OSX will automatically enable Carbon GUI support, and if $EXECON is invoked
  1138. // will also build a Universal Binary with 32bit and 64bit support
  1139. //
  1140. // $GTK will automatically enable GTK/GLIB support, and if $EXECON is invoked
  1141. // will build the executable linking in libgtk and it's support libraries.
  1142. //
  1143. // $GLIB will automatically enable >GLIB ONLY< support, and if $EXECON is invoked
  1144. // will build the executable linking in libglib and it's support libraries.
  1145. //
  1146. // $WX will automatically enable wxWidgets with $CPP set to "TRUE", and if $EXECON
  1147. // is invoked will build the executable linking in libwx and it's support libraries
  1148. //
  1149. // This is, in part, in preparation for moving the GTK support from the core of the
  1150. // LinuxBC translator to an external library which will be linked in as required. This
  1151. // will GREATLY simplify maintenence of the translator core once the lib is ready.
  1152. //
  1153. // * Changed alls instances of byte* to UCHAR* in SWAP() Function
  1154. //
  1155. // * Added internal return values for PUT/GET to get rid of ALL compiler warnings.
  1156. //
  1157. // * Updated runtime functions calling PUT()/GET()/fread()/fwrite so that they
  1158. // will not trigger compiler warnings
  1159. //
  1160. // * Reworked the way functions declared using C_DECLARE with the LIB and ALIAS keywords
  1161. // are emitted. This is so that you can dynamically load functions from a shared
  1162. // library at runtime via dlopen/dlsym.
  1163. //
  1164. // The syntax is:
  1165. // C_DECLARE FUNCTION <YOUR FUNCTION NAME> LIB <shared library> ALIAS <quoted name of actual function (<parameters>) AS <return type>
  1166. //
  1167. // For example:
  1168. // C_DECLARE FUNCTION b64encode LIB "libglib-2.0.so" ALIAS "g_base64_encode" (txt AS char*, length AS integer) AS string
  1169. // C_DECLARE FUNCTION g_base64_decode LIB "libglib-2.0.so" ALIAS "g_base64_decode" (txt AS char*, length AS INTEGER PTR) AS string
  1170. //
  1171. // NOTE that the ALIAS is the actual name of the function you want to call from the shared library.
  1172. // This is so you avoid redeclaration errors if you attempt to link to a library (libm is a good example)
  1173. // that is already compile-time linked with g++.
  1174. //
  1175. // NOTE 2: There is currently no checking whether the function was loaded without error. It is on the TODO list.
  1176. //
  1177. // * Changed compiler invocation to include -Wformat and -D_FORTIFY_SOURCE=2 (Ubuntu Standard)
  1178. //
  1179. // * Fixed User Include File handling in order to support mixed case filenames
  1180. //
  1181. // * Updated the CURDIR$, TEMPDIR$, AND SHELL code to eliminate warnings emitted when compiling on
  1182. // a system that has "_FORTIFY_SOURCE=2" enabled by default in GCC/G++ (Ubuntu)
  1183. //
  1184. // * Fixed a potential overflow problem with LINE INPUT that would also cause G++ to emit
  1185. // warnings as above.
  1186. //
  1187. // *Re-coded the $RESOURCE directive and the GETRESOURCE$ function to allow
  1188. // linking of Resources under Linux/Unix. Using $RESOURCE generates a #define
  1189. // allowing you to reference the embedded resource using an arbitrary IDENTIFIER.
  1190. //
  1191. // For example:
  1192. //
  1193. // DIRECTIVE FILE IDENTIFIER
  1194. // -------------------------------
  1195. // $RESOURCE "file.txt" "myres"
  1196. //
  1197. //
  1198. // Note that you reference the resource using the identifier you passed as the
  1199. // SECOND parameter to the $RESOURCE directive, minus the quotes.
  1200. //
  1201. // "file.txt" above can be any arbitrary file on one's system
  1202. //
  1203. // At the moment, the resource is returned as a string with the GETRESOURCE$ function.
  1204. // *****************************************************************************************************
  1205. // ** YOU WILL HAVE TO ENSURE THAT A BUFFER WITH ENOUGH SPACE TO HOLD THE RESOURCE HAS BEEN ALLOCATED **
  1206. // *****************************************************************************************************
  1207. // To aid in this, a constant is automatically created with the size of the resource. It will have the
  1208. // name you specified as the second parameter to $RESOURCE, with _SIZE appended.
  1209. // Using the example above, the constant would be defined as: myres_SIZE
  1210. //
  1211. //
  1212. // You should be able to manually cast the reference *itself* to what you require, since it is
  1213. // merely a pointer to the location of the resource itself.
  1214. //
  1215. // The resource will be converted to an object file, named using the filename provided with ".o" apppended.
  1216. // "file.txt" will be converted to "file.txt.o" in the above example, which can then be linked
  1217. // to the final executable via $EXECON "file.txt.o" or $EXEGUI "file.txt.o"
  1218. //
  1219. // * Tweaked $GUI directive and GUI keyword so that one can use the directive without
  1220. // having all of the support for BCX_* form objects automatically added to one's app.
  1221. //
  1222. // This is usefull when using GtkBuilder or Glade to build the user interface.
  1223. //
  1224. // -------------------------------------------
  1225. // 2010-01-17 Armando Rivera
  1226. // -------------------------------------------
  1227. // modified the $CLASS/$ENDCLASS directives to allow creation and inheritance of C++ Classes
  1228. //
  1229. // modified the Function/Sub prototype emitter so that it would not emit prototypes
  1230. // for C++ Class Methods, which are supposed to be prototyped within the Class itself
  1231. //
  1232. // made the inclusion of <term.h> conditional based on whether UseCPP is true/false
  1233. // it will not be included if UseCpp is "true" because some C++ toolkits (wxWidgets)
  1234. // throw a "redefined" error when it's included
  1235. //
  1236. // -------------------------------------------
  1237. // 2010-01-15 Armando Rivera
  1238. // -------------------------------------------
  1239. // per wmhalsdorf's recommendation, modified SplitLines and Emit procs to support
  1240. // C++ Method syntax (CLASSNAME::METHOD) [see Yahoo group Message #40282]
  1241. //
  1242. // -------------------------------------------
  1243. // 2010-01-10 Armando Rivera
  1244. // -------------------------------------------
  1245. // changed $CPP directive to output lowercase filenames
  1246. //
  1247. // -------------------------------------------
  1248. // 2009-10-18 Armando Rivera
  1249. // -------------------------------------------
  1250. // added Carbon.h as a default include, to support Carbon/CoreFoundation calls
  1251. // added Carbon framework to $execon section
  1252. // removed TRUE and FALSE defines, which are now provided by Carbon.h
  1253. // changed Handle$ to Handl$ to resolve conflict with Carbon.h
  1254. //
  1255. // -------------------------------------------
  1256. // 2009-10-13 Armando Rivera
  1257. // -------------------------------------------
  1258. // added typedef for "byte" type (typedef unsigned char byte;)
  1259. //
  1260. // *************************************************
  1261. // Runtime Functions
  1262. // *************************************************
  1263. char *BCX_TmpStr (size_t Bites)
  1264. {
  1265. static int StrCnt;
  1266. static char *StrFunc[512];
  1267. StrCnt=((StrCnt+1) &511);
  1268. #if defined BCX_MAX_VAR_SIZE
  1269. if(Bites*sizeof(char)>BCX_MAX_VAR_SIZE)
  1270. {
  1271. printf("Buffer Overflow caught in BCX_TmpStr - requested space of %d EXCEEDS %d\n",(int)(Bites*sizeof(char)),BCX_MAX_VAR_SIZE);
  1272. abort();
  1273. }
  1274. #endif
  1275. StrFunc[StrCnt]=(char*)realloc(StrFunc[StrCnt],Bites + 128);
  1276. return (char*)memset(StrFunc[StrCnt],0,Bites+128);
  1277. }
  1278. int str_cmp (char *a, char *b)
  1279. {
  1280. int counter=0;
  1281. for(;;)
  1282. {
  1283. if((a[counter]^b[counter]))
  1284. {
  1285. if((UINT) a[counter]>= (UINT) b[counter])
  1286. return 1;
  1287. return -1;
  1288. }
  1289. if(!a[counter]) return 0;
  1290. counter++;
  1291. }
  1292. }
  1293. int EoF (FILE* stream)
  1294. {
  1295. register int c, status = ((c = fgetc(stream)) == EOF);
  1296. ungetc(c,stream);
  1297. return status;
  1298. }
  1299. char *left (char *S, int length)
  1300. {
  1301. int tmplen = strlen(S);
  1302. if(length<1) return BCX_TmpStr(1);
  1303. if(length<tmplen) tmplen=length;
  1304. char *strtmp = BCX_TmpStr(tmplen);
  1305. return (char*)memcpy(strtmp,S,tmplen);
  1306. }
  1307. char *right (char *S, int length)
  1308. {
  1309. int tmplen = strlen(S);
  1310. char *BCX_RetStr = BCX_TmpStr(tmplen);
  1311. tmplen -= length;
  1312. if (tmplen<0) tmplen = 0;
  1313. return strcpy(BCX_RetStr, &S[tmplen]);
  1314. }
  1315. char *rpad (char *a, int L, int c)
  1316. {
  1317. char *strtmp;
  1318. int s = strlen(a);
  1319. if((L-s)<1) return a;
  1320. strtmp=BCX_TmpStr(L);
  1321. strcpy(strtmp,a);
  1322. memset(&strtmp[s],c,(L-s));
  1323. return strtmp;
  1324. }
  1325. char *lpad (char *a, int L, int c)
  1326. {
  1327. char *strtmp;
  1328. L=L-strlen(a);
  1329. if(L<1) return a;
  1330. strtmp = BCX_TmpStr(L);
  1331. memset(strtmp,c,L);
  1332. return strcat(strtmp,a);
  1333. }
  1334. char *mid (char *S, int start, int length)
  1335. {
  1336. char *strtmp;
  1337. int tmplen = strlen(S);
  1338. if(start>tmplen||start<1) return BCX_TmpStr(1);
  1339. if (length<0 || length>(tmplen-start)+1)
  1340. length = (tmplen-start)+1;
  1341. strtmp = BCX_TmpStr(length);
  1342. return (char*)memcpy(strtmp,&S[start-1],length);
  1343. }
  1344. char *trim (char *S)
  1345. {
  1346. while(*S==32 || *S==9 || *S==10 || *S==11 || *S==13)
  1347. S++;
  1348. int i = strlen(S);
  1349. while( i>0 && (S[i-1]==32 || S[i-1]==9 || S[i-1]==10
  1350. || S[i-1]==11 || S[i-1]==13))
  1351. i--;
  1352. char *strtmp=BCX_TmpStr(i);
  1353. return (char*)memcpy(strtmp,S,i);
  1354. }
  1355. char *ltrim (char *S, char c)
  1356. {
  1357. if(S[0]==0) return S;
  1358. while((*S==32 || *S==c) && *S !=0) S++;
  1359. char *strtmp = BCX_TmpStr(strlen(S));
  1360. return strcpy(strtmp,S);
  1361. }
  1362. char *rtrim (char *S,char c)
  1363. {
  1364. if(S[0]==0) return S;
  1365. int i = strlen(S);
  1366. while(i>0 && (S[i-1]==c || S[i-1]==32))
  1367. i--;
  1368. char *strtmp = BCX_TmpStr(i);
  1369. return (char*)memcpy(strtmp,S,i);
  1370. }
  1371. char *strim (char *src)
  1372. {
  1373. char *strtmp = BCX_TmpStr(strlen(src));
  1374. char *dst = strtmp;
  1375. while (isspace((unsigned char)*src)) src++;
  1376. do
  1377. {
  1378. while (*src && !isspace((unsigned char)*src)) *dst++ = *src++;
  1379. if (*src)
  1380. {
  1381. *dst++ = *src++;
  1382. while (isspace((unsigned char)*src)) src++;
  1383. }
  1384. } while (*src);
  1385. if (isspace((unsigned char)*(--dst))) *dst = 0;
  1386. return strtmp;
  1387. }
  1388. char *command (int nArg)
  1389. {
  1390. int i = 0;
  1391. char *retstr=BCX_TmpStr(1);
  1392. if(nArg < i) // return entire commandline
  1393. {
  1394. retstr = BCX_TmpStr(G_argc * 2048);
  1395. for(i=1; i < G_argc; i++)
  1396. {
  1397. strcat(retstr, G_argv[i]);
  1398. strcat(retstr, SPC);
  1399. }
  1400. }
  1401. else if(nArg < G_argc)
  1402. {
  1403. retstr = BCX_TmpStr(strlen(G_argv[nArg]) + 1);
  1404. strcpy(retstr, G_argv[nArg]);
  1405. }
  1406. return retstr;
  1407. }
  1408. char *extract (char *mane, char *match)
  1409. {
  1410. char *a;
  1411. char *strtmp = BCX_TmpStr(strlen(mane));
  1412. if(*match!=0)
  1413. {
  1414. a=_strstr_(mane,match);
  1415. if(a) return (char*)memcpy(strtmp,mane,a-mane);
  1416. }
  1417. return strcpy(strtmp,mane);
  1418. }
  1419. char *remain (char *mane, char *mat)
  1420. {
  1421. char *p = strstr(mane,mat);
  1422. if(p)
  1423. {
  1424. p+=(strlen(mat));
  1425. return p;
  1426. }
  1427. return mane;
  1428. }
  1429. char *replace (char *src, char *pat, char *rep)
  1430. {
  1431. size_t patsz, repsz, tmpsz, delta;
  1432. char *strtmp, *p, *q, *r;
  1433. if (!pat || !*pat)
  1434. {
  1435. strtmp = BCX_TmpStr(strlen(src));
  1436. if (!strtmp) return NULL;
  1437. return strcpy(strtmp, src);
  1438. }
  1439. repsz = strlen(rep);
  1440. patsz = strlen(pat);
  1441. for (tmpsz=0, p=src; (q=_strstr_(p,pat))!=0; p=q+patsz)
  1442. tmpsz += (size_t) (q - p) + repsz;
  1443. tmpsz += strlen(p);
  1444. strtmp = BCX_TmpStr(tmpsz);
  1445. if (!strtmp) return NULL;
  1446. for (r=strtmp,p=src; (q=_strstr_(p,pat))!=0;p=q+patsz)
  1447. {
  1448. delta = (size_t) (q-p);
  1449. memcpy(r,p,delta); r += delta;
  1450. strcpy(r,rep); r += repsz;
  1451. }
  1452. strcpy(r,p);
  1453. return strtmp;
  1454. }
  1455. char *ucase (char *S)
  1456. {
  1457. char *strtmp = BCX_TmpStr(strlen(S));
  1458. return _strupr_(strcpy(strtmp,S));
  1459. }
  1460. char *lcase (char *S)
  1461. {
  1462. char *strtmp = BCX_TmpStr(strlen(S));
  1463. return _strlwr_(strcpy(strtmp,S));
  1464. }
  1465. char *RemoveStr (char *a, char *b)
  1466. {
  1467. char *strtmp, *p, *d;
  1468. int tmplen;
  1469. strtmp = d = BCX_TmpStr(strlen(a));
  1470. if(!b || !*b) return strcpy(strtmp,a);
  1471. p=_strstr_(a,b); tmplen = strlen(b);
  1472. while(p)
  1473. {
  1474. memcpy(d,a,p-a);
  1475. d+= (p-a);
  1476. a=p+tmplen;
  1477. p=_strstr_(a,b);
  1478. }
  1479. strcpy(d,a);
  1480. return strtmp;
  1481. }
  1482. char *IRemoveStr (char *a, char *b)
  1483. {
  1484. char *strtmp, *p, *d;
  1485. int tmplen;
  1486. strtmp = d = BCX_TmpStr(strlen(a));
  1487. if(!b || !*b) return strcpy(strtmp,a);
  1488. p=_stristr_(a,b); tmplen = strlen(b);
  1489. while(p)
  1490. {
  1491. memcpy(d,a,p-a);
  1492. d+= (p-a);
  1493. a=p+tmplen;
  1494. p=_stristr_(a,b);
  1495. }
  1496. strcpy(d,a);
  1497. return strtmp;
  1498. }
  1499. char *ins (char *S, int i, char *a)
  1500. {
  1501. int j = strlen(S);
  1502. if(i<1 || i>j+1) return S;
  1503. char *strtmp = BCX_TmpStr(j + strlen(a));
  1504. memcpy(strtmp,S,--i);
  1505. strcpy(&strtmp[i],a);
  1506. return strcat(strtmp,&S[i]);
  1507. }
  1508. char *del (char *S, int i, int j)
  1509. {
  1510. int ln = strlen(S);
  1511. if(i<1 || i>ln) return S;
  1512. char *strtmp = BCX_TmpStr(ln);
  1513. memcpy(strtmp,S,--i);
  1514. return strcat(strtmp,&S[i+j]);
  1515. }
  1516. char *str (double d)
  1517. {
  1518. char *strtmp = BCX_TmpStr(16);
  1519. sprintf(strtmp,"% .15G",d);
  1520. return strtmp;
  1521. }
  1522. char *curdir (void)
  1523. {
  1524. char *strtmp = BCX_TmpStr(2048);
  1525. char *res=getcwd(strtmp, 1024);
  1526. return strtmp;
  1527. }
  1528. char *tempdir (void)
  1529. {
  1530. char *strtmp = BCX_TmpStr(2048);
  1531. if(!Exist("/tmp/mbc.compiler")) {
  1532. mkdir ("/tmp/mbc.compiler",0755);
  1533. }
  1534. strcpy(strtmp,"/tmp/mbc.compiler");
  1535. return strtmp;
  1536. }
  1537. char *stringx (int count, int a)
  1538. {
  1539. if(count<1) return BCX_TmpStr(1);
  1540. char *strtmp = BCX_TmpStr(count);
  1541. return (char*)memset(strtmp,a,count);
  1542. }
  1543. void Shell (char *cmd)
  1544. {
  1545. int res=system(cmd);
  1546. }
  1547. char *space (int count)
  1548. {
  1549. if(count<1) return BCX_TmpStr(1);
  1550. char *strtmp = BCX_TmpStr(count);
  1551. return (char*)memset(strtmp,32,count);
  1552. }
  1553. char *enc (char *A, int L, int R)
  1554. {
  1555. char *BCX_RetStr = BCX_TmpStr(strlen(A)+3);
  1556. if(L==0) L=34;
  1557. if(R==0) R=L;
  1558. sprintf(BCX_RetStr,"%c%s%c%s",L,A,R,"");
  1559. return BCX_RetStr;
  1560. }
  1561. char *chr (int a,int b,int c,int d,int e,int f,int g,int h,int i,int j)
  1562. {
  1563. char *strtmp = BCX_TmpStr(11);
  1564. strtmp[0] = a;
  1565. strtmp[1] = b;
  1566. strtmp[2] = c;
  1567. strtmp[3] = d;
  1568. strtmp[4] = e;
  1569. strtmp[5] = f;
  1570. strtmp[6] = g;
  1571. strtmp[7] = h;
  1572. strtmp[8] = i;
  1573. strtmp[9] = j;
  1574. strtmp[10] = 0;
  1575. return strtmp;
  1576. }
  1577. char *vchr(int charcount, ...)
  1578. {
  1579. int c = 0, i = charcount;
  1580. char *s_ = BCX_TmpStr(charcount + 1);
  1581. va_list marker;
  1582. s_[i] = 0;
  1583. va_start(marker, charcount);
  1584. while(i-- > 0) s_[c++] = va_arg(marker,int);
  1585. va_end(marker);
  1586. return s_;
  1587. }
  1588. char * join(int n, ...)
  1589. {
  1590. int i = n, tmplen = 0;
  1591. char *strtmp, *s_;
  1592. va_list marker;
  1593. va_start(marker, n); // Initialize variable arguments
  1594. while(i-- > 0)
  1595. {
  1596. s_ = va_arg(marker, char *);
  1597. if(s_) tmplen += strlen(s_);
  1598. }
  1599. strtmp = BCX_TmpStr(tmplen);
  1600. va_end(marker); // Reset variable arguments
  1601. i = n;
  1602. va_start(marker, n); // Initialize variable arguments
  1603. while(i-- > 0)
  1604. {
  1605. s_ = va_arg(marker, char *);
  1606. if(s_) strcat(strtmp, s_);
  1607. }
  1608. va_end(marker); // Reset variable arguments
  1609. return strtmp;
  1610. }
  1611. char* Environ(char *S)
  1612. {
  1613. char *strtmp, *tmp;
  1614. tmp = getenv(S);
  1615. if(tmp != NULL) {
  1616. strtmp = BCX_TmpStr(strlen(tmp)+1);
  1617. return strcpy(strtmp, tmp);
  1618. }
  1619. return BCX_TmpStr(1);
  1620. }
  1621. char *AppExePath (void)
  1622. {
  1623. char fullpath[MAX_PATH];
  1624. int length;
  1625. length = readlink("/proc/self/exe", fullpath, MAX_PATH);
  1626. if(length < 1) return BCX_TmpStr(1);
  1627. fullpath[length] = 0;
  1628. return BcxSplitPath(fullpath, FDRV|FPATH);
  1629. }
  1630. char *AppExeName (void)
  1631. {
  1632. return BcxSplitPath(G_argv[0], FNAME|FEXT);
  1633. }
  1634. char * TempFileName (char *dr, char *prefix)
  1635. {
  1636. static unsigned int count;
  1637. char *f, *tmpstr = BCX_TmpStr(MAX_PATH);
  1638. int i, length;
  1639. if(!count) srand(time(0));
  1640. if(dr) strcpy(tmpstr, dr);
  1641. length = strlen(tmpstr);
  1642. if(length && (tmpstr[length-1] != '\\' && tmpstr[length-1] != '/'))
  1643. tmpstr[length++] = '/';
  1644. if(prefix) strcpy(&tmpstr[length], prefix);
  1645. f = &tmpstr[strlen(tmpstr)];
  1646. do {
  1647. count++;
  1648. for(i=0; i<5; i+=1)
  1649. {
  1650. do {
  1651. f[i]=(char)(rnd()*122);
  1652. }while((f[i]<65)||(f[i]>90&&f[i]<97));
  1653. }
  1654. snprintf(&f[5],3,"%x", count);
  1655. } while (Exist(tmpstr));
  1656. return tmpstr;
  1657. }
  1658. int InstrRev (char *s, char *p, int os, int sens)
  1659. {
  1660. int sl, pl, ox;
  1661. int (*cmp)(const char *, const char *, size_t );
  1662. if (!s || !p) return 0;
  1663. sl = strlen(s); pl = strlen(p);
  1664. if (os > sl || sl == 0 || pl == 0 || (ox = sl - pl) < 0)
  1665. return 0;
  1666. if (os <= 0)
  1667. os = ox ;
  1668. else if(os >= pl)
  1669. os = os - pl ;
  1670. else
  1671. return 0;
  1672. cmp = (sens ? strncasecmp : strncmp);
  1673. do { if (cmp(s + os , p, pl) == 0)
  1674. return os+1;
  1675. } while (os--);
  1676. return 0;
  1677. }
  1678. int instr_b(char* mane,char* match,int offset,int sensflag)
  1679. {
  1680. char *s;
  1681. if (!mane || !match || ! *match || offset>(int)strlen(mane)) return 0;
  1682. if (sensflag)
  1683. s = _stristr_(offset>0 ? mane+offset-1 : mane,match);
  1684. else
  1685. s = _strstr_(offset>0 ? mane+offset-1 : mane,match);
  1686. return s ? (int)(s-mane)+1 : 0;
  1687. }
  1688. char *MakeLCaseTbl (void)
  1689. {
  1690. static char tbl[256];
  1691. if(!tbl['a'])
  1692. {
  1693. int i; for (i=0; i < 256; i++)
  1694. tbl[i] = (char)(int)tolower(i);
  1695. }
  1696. return tbl;
  1697. }
  1698. char *_stristr_(char *String, char *Pattern)
  1699. {
  1700. int mi=-1;
  1701. char *LowCase = MakeLCaseTbl();
  1702. while(Pattern[++mi])
  1703. {
  1704. if(String[mi]==0) return 0;
  1705. if(LowCase[(unsigned char)String[mi]]!=LowCase[(unsigned char)Pattern[mi]])
  1706. { String++; mi=-1; }
  1707. }
  1708. return String;
  1709. }
  1710. char *_strstr_(char *String, char *Pattern)
  1711. {
  1712. int mi=-1;
  1713. while(Pattern[++mi])
  1714. {
  1715. if(String[mi]==0) return 0;
  1716. if(String[mi]!=Pattern[mi])
  1717. { String++; mi=-1; }
  1718. }
  1719. return String;
  1720. }
  1721. int inchr (char *A, char *B)
  1722. {
  1723. char* C=A;
  1724. while(*C)
  1725. {
  1726. if(*C==*B) return C-A+1;
  1727. C++;
  1728. }
  1729. return 0;
  1730. }
  1731. double Round (double n, int d)
  1732. {
  1733. return (floor((n)*pow(10.0,(d))+0.5)/pow(10.0,(d)));
  1734. }
  1735. bool Exist (char *szFilePath)
  1736. {
  1737. int retstat;
  1738. struct stat sb;
  1739. retstat = stat(szFilePath, &sb);
  1740. if(retstat != -1)
  1741. return TRUE;
  1742. return FALSE;
  1743. }
  1744. int tally (char *szLine, char *szChar, int sensflag)
  1745. {
  1746. if(!*szChar) return 0;
  1747. int mlen = strlen(szChar);
  1748. int iCount = 0;
  1749. char *p = (sensflag == 0 ? _strstr_(szLine, szChar) : _stristr_(szLine, szChar));
  1750. while (p)
  1751. {
  1752. iCount++;
  1753. p+=mlen;
  1754. p = (sensflag == 0 ? _strstr_(p, szChar) : _stristr_(p, szChar));
  1755. }
  1756. return iCount;
  1757. }
  1758. float rnd (void)
  1759. {
  1760. return (float)rand()/RAND_MAX;
  1761. }
  1762. double _MAX_ (double a, double b)
  1763. {
  1764. if(a>b)
  1765. return a;
  1766. return b;
  1767. }
  1768. double _MIN_ (double a, double b)
  1769. {
  1770. if(a<b)
  1771. return a;
  1772. return b;
  1773. }
  1774. void locate (int row,int col,int show,int shape)
  1775. {
  1776. printf("%c%s%u%s%u%s",27,"[",row,";",col,"H");
  1777. // find cursor size/shape function!
  1778. }
  1779. void cls (void)
  1780. {
  1781. printf("%s%s%s%s",ESC,"[2J",ESC,"[H");
  1782. }
  1783. void midstr (char *src, int st, int length, char *rep)
  1784. {
  1785. int srclen = strlen(src);
  1786. if(st>srclen++ || st<1) return;
  1787. int replen = strlen(rep);
  1788. if(replen < length || length==-1) length=replen;
  1789. if((st+length) > srclen) length=srclen-st;
  1790. memcpy(&src[st-1],rep,length);
  1791. }
  1792. DWORD lof (char *FileName)
  1793. {
  1794. int retstat;
  1795. struct stat sb;
  1796. retstat = stat(FileName, &sb);
  1797. if(retstat != -1)
  1798. return sb.st_size;
  1799. return 0;
  1800. }
  1801. char * sziif (bool i, char *a, char *b)
  1802. {
  1803. if(i) return a;
  1804. return b;
  1805. }
  1806. char *BcxSplitPath (char *FPath, int mask)
  1807. {
  1808. if(!FPath) return BCX_TmpStr(1);
  1809. char *BCX_RetStr=BCX_TmpStr(strlen(FPath));
  1810. char tmp[MAX_PATH*4];
  1811. _splitpath_(FPath,tmp,&tmp[MAX_PATH],&tmp[MAX_PATH*2],&tmp[MAX_PATH*3]);
  1812. if(mask & FDRV) strcat(BCX_RetStr,tmp);
  1813. if(mask & FPATH)strcat(BCX_RetStr,&tmp[MAX_PATH]);
  1814. if(mask & FNAME)strcat(BCX_RetStr,&tmp[MAX_PATH*2]);
  1815. if(mask & FEXT) strcat(BCX_RetStr,&tmp[MAX_PATH*3]);
  1816. return BCX_RetStr;
  1817. }
  1818. void _splitpath_(const char* path, char* drv, char* dir, char* name, char* ext)
  1819. {
  1820. const char* pend; /* end of processed string */
  1821. const char* p; /* search pointer */
  1822. const char* s; /* copy pointer */
  1823. /* extract drive name */
  1824. if (path[0] && path[1]==':') {
  1825. if (drv) {
  1826. *drv++ = *path++;
  1827. *drv++ = *path++;
  1828. *drv = 0;
  1829. }
  1830. } else if (drv)
  1831. *drv = 0;
  1832. /* search for end of string or stream separator */
  1833. for(pend=path; *pend && *pend!=':'; )
  1834. pend++;
  1835. /* search for begin of file extension */
  1836. for(p=pend; p > path && *--p != '\\' && *p!='/'; )
  1837. if (*p == '.') {
  1838. pend = p;
  1839. break;
  1840. }
  1841. if (ext)
  1842. {
  1843. s=pend;
  1844. do{ *ext++ = *s; } while(*s++);
  1845. }
  1846. /* search for end of directory name */
  1847. for(p=pend; p > path; )
  1848. if (*--p == '\\' || *p == '/') {
  1849. p++;
  1850. break;
  1851. }
  1852. if (name) {
  1853. for(s=p; s<pend; )
  1854. *name++ = *s++;
  1855. *name = 0;
  1856. }
  1857. if (dir) {
  1858. for(s=path; s<p; )
  1859. *dir++ = *s++;
  1860. *dir = 0;
  1861. }
  1862. }
  1863. char *_strupr_(char *string)
  1864. {
  1865. char *s;
  1866. if (string)
  1867. {
  1868. for(s = string; *s; ++s)
  1869. *s = toupper(*s);
  1870. }
  1871. return string;
  1872. }
  1873. char *_strlwr_(char *string)
  1874. {
  1875. char *s;
  1876. if (string)
  1877. {
  1878. for (s = string; *s; ++s)
  1879. *s = tolower(*s);
  1880. }
  1881. return string;
  1882. }
  1883. char * StrToken (char *Source, char *TokenChar, int n)
  1884. {
  1885. char *BCX_RetStr={0};
  1886. char *RetVal;
  1887. char *Copy;
  1888. int Posn=0;
  1889. int Find=0;
  1890. int LenSrc=strlen(Source);
  1891. RetVal=(char*)calloc(LenSrc+1,1);
  1892. Copy=Source;
  1893. if(tally(Source,TokenChar)==0)
  1894. {
  1895. BCX_RetStr=BCX_TmpStr(1);
  1896. if(RetVal)free(RetVal);
  1897. return BCX_RetStr;
  1898. }
  1899. if(n==1)
  1900. {
  1901. BCX_RetStr=BCX_TmpStr(LenSrc);
  1902. strcpy(BCX_RetStr,(char*)extract(Source,TokenChar));
  1903. if(RetVal)free(RetVal);
  1904. return BCX_RetStr;
  1905. }
  1906. if(n>tally(Source,TokenChar)+1)
  1907. {
  1908. BCX_RetStr=BCX_TmpStr(1);
  1909. if(RetVal)free(RetVal);
  1910. return BCX_RetStr;
  1911. }
  1912. while(*Copy)
  1913. {
  1914. if(*Copy==TokenChar[0]) Find++;
  1915. if(Find==n) break;
  1916. Copy++;
  1917. Posn++;
  1918. }
  1919. if(n==tally(Source,TokenChar)+1)
  1920. {
  1921. Posn=LenSrc;
  1922. Copy=Source+Posn;
  1923. while(*Copy&&Source[Posn]!=TokenChar[0])
  1924. {
  1925. Posn--;
  1926. Copy--;
  1927. }
  1928. }
  1929. strcpy(RetVal,(char*)mid(Source,1,Posn));
  1930. strcpy(RetVal,(char*)mid(RetVal,InstrRev(RetVal,TokenChar)));
  1931. BCX_RetStr=BCX_TmpStr(LenSrc);
  1932. strcpy(BCX_RetStr,(char*)RemoveStr(RetVal,TokenChar));
  1933. if(RetVal)free(RetVal);
  1934. return BCX_RetStr;
  1935. }
  1936. char *iReplace (char *src, char *pat, char *rep)
  1937. {
  1938. size_t patsz, repsz, tmpsz, delta;
  1939. char *strtmp, *p, *q, *r;
  1940. if (!pat || !*pat)
  1941. {
  1942. strtmp = BCX_TmpStr(strlen(src));
  1943. if (!strtmp) return NULL;
  1944. return strcpy(strtmp, src);
  1945. }
  1946. repsz = strlen(rep);
  1947. patsz = strlen(pat);
  1948. for (tmpsz=0, p=src;(q=_stristr_(p,pat))!=0; p=q+patsz)
  1949. tmpsz += (size_t) (q - p) + repsz;
  1950. tmpsz += strlen(p);
  1951. strtmp = BCX_TmpStr(tmpsz);
  1952. if (!strtmp) return NULL;
  1953. for (r=strtmp,p=src;(q=_stristr_(p,pat))!=0;p=q+patsz)
  1954. {
  1955. delta = (size_t) (q-p);
  1956. memcpy(r,p,delta); r += delta;
  1957. strcpy(r,rep); r += repsz;
  1958. }
  1959. strcpy(r,p);
  1960. return strtmp;
  1961. }
  1962. int containedin(char * Token,char **Contain ,int c)
  1963. {
  1964. int i=0;
  1965. while(Contain[i][0])
  1966. {
  1967. if(0 == ((c == 0 || c == 2) ? strcmp(Contain[i],Token) : strcasecmp(Contain[i],Token)))
  1968. {
  1969. return ((c < 2) ? 0 : i);
  1970. }
  1971. i++;
  1972. }
  1973. return -1;
  1974. }
  1975. // ************************************
  1976. // User Subs and Functions
  1977. // ************************************
  1978. int main (int argc, PCHAR* argv)
  1979. {
  1980. G_argc=argc;
  1981. G_argv=argv;
  1982. szTmp=(char*)calloc(256+1048576,1);
  1983. Src=(char*)calloc(256+1048576,1);
  1984. AbortSrc=(char*)calloc(256+1048576,1);
  1985. WarnMsg=(char*)calloc(256+32767,1);
  1986. RmLibs=(char*)calloc(256+32767,1);
  1987. static int bitz;
  1988. memset(&bitz,0,sizeof(bitz));
  1989. ProtoCnt=0;
  1990. TranslateSlash=TRUE;
  1991. OkayToSend=TRUE;
  1992. Use_SingleFile=TRUE;
  1993. Use_StartupCode=FALSE;
  1994. StartNdx=0;
  1995. Use_ExitCode=FALSE;
  1996. ExitNdx=0;
  1997. *HFile=0;
  1998. *CmdLineFileOut=0;
  1999. *RmLibs=0;
  2000. InMain=TRUE;
  2001. TestState=FALSE;
  2002. *CmdLineConst=0;
  2003. bitz=sizeof(long)*8;
  2004. if(command(-1)[0]==0)
  2005. {
  2006. #if defined (__APPLE__)
  2007. printf("%s\n","MBC4: Ported to Mac OSX by Armando Rivera (c) 2009-2018");
  2008. #else
  2009. printf("%s\n","MBC4: Based on Linux BCX by Mike Henning (c) 2009");
  2010. printf("%s%s\n","(c) 2009-2018 Armando Rivera with additional code (c) 2009 John Jacques",LF);
  2011. #endif
  2012. printf("%s%s%s","Version ",Version," Compiled with ");
  2013. // FP3
  2014. #if defined __BCPLUSPLUS__// OUTFILE
  2015. printf("%s\n","Borland C++");
  2016. #elif defined __BORLANDC__
  2017. printf("%s\n","Borland C");
  2018. #elif defined __POCC__
  2019. printf("%s\n","Pelles C");
  2020. #elif defined __GNUG__
  2021. printf("%s\n","GNU G++");
  2022. #else
  2023. printf("%s\n","Unknown");
  2024. #endif // Main
  2025. if(bitz==64)
  2026. {
  2027. printf("\n");
  2028. printf("%s\n","********************");
  2029. printf("%s\n","** 64 BIT VERSION **");
  2030. printf("%s%s\n","********************",LF);
  2031. }
  2032. printf("%s%s%s\n"," Usage: ",AppExeName()," infile [.bas] [options]");
  2033. printf("%s\n"," [-c] Generate C++ Compatible code");
  2034. printf("%s%s%s\n"," [-d] DEFINE a constant ... ex. ",AppExeName()," MyFile -D:MyConst[=SomeValue]");
  2035. printf("%s\n"," [-e] Write ERRORS to BCX.ERR file");
  2036. printf("%s%s%s\n"," [-f] Output FILENAME... ex. ",AppExeName()," MyFile -f:/MyFiles/MyFile.c");
  2037. printf("%s\n"," [-k] KILL the generated BCX generated 'C' file");
  2038. printf("%s\n"," [-o] OUTPUT a copy of the generated C file to STDOUT");
  2039. printf("%s\n"," [-q] QUIET - No output to screen during translation");
  2040. printf("%s\n"," [-s] Show STATUS of translation by line number");
  2041. printf("%s\n"," [-w] Enable WARNINGS during translation");
  2042. printf("%s%s%s\n"," [-t] TURBO Mode ON w/optional size ... ex. ",AppExeName()," MyFile -t[:1024]");
  2043. printf("%s\n"," [-u] Turn UNICODE Support ON");
  2044. FreeGlobals();
  2045. fflush(stdout);
  2046. exit(0);
  2047. }
  2048. Quiet=FALSE;
  2049. {register int i;
  2050. for(i=2; i<=argc-1; i+=1)
  2051. {
  2052. if(instr_b(lcase(argv[i]),"-f"))
  2053. {
  2054. strcpy(CmdLineFileOut,mid(argv[i],4));
  2055. }
  2056. if(instr_b(lcase(argv[i]),"-d"))
  2057. {
  2058. strcpy(CmdLineConst, join(3,CmdLineConst,mid(argv[i],4),chr(1)));
  2059. }
  2060. if(str_cmp(lcase(argv[i]),"-c")==0)
  2061. {
  2062. UseCpp=TRUE;
  2063. }
  2064. if(str_cmp(lcase(argv[i]),"-e")==0)
  2065. {
  2066. ErrFile=TRUE;
  2067. }
  2068. if(str_cmp(lcase(argv[i]),"-q")==0)
  2069. {
  2070. Quiet=TRUE;
  2071. }
  2072. if(str_cmp(lcase(argv[i]),"-k")==0)
  2073. {
  2074. KillCFile=TRUE;
  2075. }
  2076. if(str_cmp(lcase(argv[i]),"-o")==0)
  2077. {
  2078. ReDirect=TRUE;
  2079. }
  2080. if(str_cmp(lcase(argv[i]),"-s")==0)
  2081. {
  2082. ShowStatus=TRUE;
  2083. }
  2084. if(str_cmp(lcase(argv[i]),"-w")==0)
  2085. {
  2086. TestState=TRUE;
  2087. }
  2088. if(instr_b(lcase(argv[i]),"-t"))
  2089. {
  2090. Use_Turbo=TRUE;
  2091. TurboSize=VAL(mid(argv[i],4));
  2092. if(TurboSize!=0)
  2093. {
  2094. if((TurboSize&(TurboSize-1))!=0)
  2095. {
  2096. TurboSize=512;
  2097. Warning("Invalid $Turbo size - defaulting to 512");
  2098. }
  2099. }
  2100. else
  2101. {
  2102. TurboSize=512;
  2103. }
  2104. }
  2105. }
  2106. }
  2107. if(ShowStatus)
  2108. {
  2109. cls();
  2110. }
  2111. if(!Quiet)
  2112. {
  2113. cls();
  2114. printf("%s%s\n","MBC Version ",Version);
  2115. #if defined (__APPLE__)
  2116. IsApple=TRUE;
  2117. printf("%s%s\n","MBC4: Ported to Mac OSX by Armando Rivera (c) 2009-2018",LF);
  2118. #else
  2119. printf("%s\n","MBC4: Based on Linux BCX by Mike Henning (c) 2009");
  2120. printf("%s%s\n","(c) 2009-2018 Armando Rivera with additional code (c) 2009 John Jacques",LF);
  2121. #endif
  2122. if(bitz==64)
  2123. {
  2124. printf("\n");
  2125. printf("%s\n","********************");
  2126. printf("%s\n","** 64 BIT VERSION **");
  2127. printf("%s%s\n","********************",LF);
  2128. }
  2129. }
  2130. if(inchr(command(1),"."))
  2131. {
  2132. strcpy(Cmd,command(1));
  2133. }
  2134. else
  2135. {
  2136. if(Exist(join(2,command(1),".bas")))
  2137. {
  2138. strcpy(Cmd, join(2,command(1),".bas"));
  2139. }
  2140. else if(Exist(join(2,command(1),".BAS")))
  2141. {
  2142. strcpy(Cmd, join(2,command(1),".BAS"));
  2143. }
  2144. }
  2145. if(!Exist(Cmd))
  2146. {
  2147. printf("\n");
  2148. printf("%s%s\n","FILE NOT FOUND: ",command(1));
  2149. FreeGlobals();
  2150. fflush(stdout);
  2151. exit(0);
  2152. }
  2153. strcpy(FileIn,Cmd);
  2154. if(CmdLineFileOut[0]==0)
  2155. {
  2156. strcpy(FileOut, join(2,left(Cmd,InstrRev(Cmd,".",0)-1),".cc"));
  2157. }
  2158. else
  2159. {
  2160. strcpy(FileOut,CmdLineFileOut);
  2161. }
  2162. strcpy(FileErr, join(2,left(Cmd,InstrRev(Cmd,".",0)-1),".ERR"));
  2163. if(Exist(FileErr))
  2164. {
  2165. remove (FileErr);
  2166. }
  2167. strcpy(prcFile,TempFileName(tempdir(),"prc"));
  2168. strcpy(udtFile,TempFileName(tempdir(),"udt"));
  2169. strcpy(datFile,TempFileName(tempdir(),"dat"));
  2170. strcpy(cstFile,TempFileName(tempdir(),"cst"));
  2171. strcpy(ovrFile,TempFileName(tempdir(),"ovr"));
  2172. strcpy(hdrFile,TempFileName(tempdir(),"hdr"));
  2173. strcpy(setFile,TempFileName(tempdir(),"set"));
  2174. strcpy(enuFile,TempFileName(tempdir(),"enu"));
  2175. if((SourceFile=fopen(FileIn,"r"))==0)
  2176. {
  2177. fprintf(stderr,"Can't open file %s\n",FileIn);
  2178. exit(1);
  2179. }
  2180. if((FP2=fopen(FileOut,"w"))==0)
  2181. {
  2182. fprintf(stderr,"Can't open file %s\n",FileOut);
  2183. exit(1);
  2184. }
  2185. Outfile=FP2;
  2186. if((FP3=fopen(prcFile,"w"))==0)
  2187. {
  2188. fprintf(stderr,"Can't open file %s\n",prcFile);
  2189. exit(1);
  2190. }
  2191. if((FP4=fopen(udtFile,"w"))==0)
  2192. {
  2193. fprintf(stderr,"Can't open file %s\n",udtFile);
  2194. exit(1);
  2195. }
  2196. if((FP5=fopen(datFile,"w"))==0)
  2197. {
  2198. fprintf(stderr,"Can't open file %s\n",datFile);
  2199. exit(1);
  2200. }
  2201. if((FP6=fopen(cstFile,"w"))==0)
  2202. {
  2203. fprintf(stderr,"Can't open file %s\n",cstFile);
  2204. exit(1);
  2205. }
  2206. if((FP7=fopen(hdrFile,"w"))==0)
  2207. {
  2208. fprintf(stderr,"Can't open file %s\n",hdrFile);
  2209. exit(1);
  2210. }
  2211. if((FP8=fopen(ovrFile,"w"))==0)
  2212. {
  2213. fprintf(stderr,"Can't open file %s\n",ovrFile);
  2214. exit(1);
  2215. }
  2216. if((FP9=fopen(setFile,"w"))==0)
  2217. {
  2218. fprintf(stderr,"Can't open file %s\n",setFile);
  2219. exit(1);
  2220. }
  2221. if((FP11=fopen(enuFile,"w"))==0)
  2222. {
  2223. fprintf(stderr,"Can't open file %s\n",enuFile);
  2224. exit(1);
  2225. }
  2226. ModuleNdx=1;
  2227. strcpy(Modules[ModuleNdx],FileIn);
  2228. ModuleLineNos[ModuleNdx]=0;
  2229. EmitProlog();
  2230. ClearIfThenStacks();
  2231. EmitCmdLineConst();
  2232. AddGlobal("G_argv",vt_PCHAR,0,"",1,0,0,0);
  2233. AddGlobal("G_argc",vt_INTEGER,0,"",0,0,0,0);
  2234. READSRCLINE:;
  2235. while(!EoF(SourceFile)||SplitCnt)
  2236. {
  2237. if(SplitCnt==0)
  2238. {
  2239. Src[0]=0;
  2240. AR_fgets_retval=fgets(Src,1048576,SourceFile);
  2241. if(Src[strlen(Src)-1]==10)Src[strlen(Src)-1]=0;
  2242. ModuleLineNos[ModuleNdx]++;
  2243. StripCode(Src);
  2244. if(*Src==0)
  2245. {
  2246. continue;
  2247. }
  2248. if(JoinLines(Src)==1)
  2249. {
  2250. continue;
  2251. }
  2252. if(inchr(Src,"["))
  2253. {
  2254. BracketHandler(Src,0);
  2255. }
  2256. if(SplitLines(Src))
  2257. {
  2258. strcpy(Src,SplitStk[++SplitCur]);
  2259. }
  2260. }
  2261. else
  2262. {
  2263. strcpy(Src,SplitStk[++SplitCur]);
  2264. }
  2265. if(SplitCur==SplitCnt)
  2266. {
  2267. SplitCur=SplitCnt=0;
  2268. }
  2269. if(*Src==0)
  2270. {
  2271. continue;
  2272. }
  2273. strcpy(AbortSrc,Src);
  2274. if(TrcFlag&&InFunc)
  2275. {
  2276. if(!iMatchLft(Src,"$trace"))
  2277. {
  2278. if(!iMatchLft(Src,"end ")&&instr_b(Src,"FUNCTION",0,1)==0)
  2279. {
  2280. fprintf(Outfile,"%s%s%s%s%s%s\n","// [",trim(Modules[ModuleNdx])," - ",trim(str(ModuleLineNos[ModuleNdx])),"] ",Src);
  2281. strcpy(Z,trim(Modules[ModuleNdx]));
  2282. strcpy(Z,replace(Z,"\\","\\\\"));
  2283. strcpy(Z, join(5," ",Z," - ",str(ModuleLineNos[ModuleNdx])," \\n"));
  2284. strcpy(Z, join(3,"printf(",enc(Z),");"));
  2285. fprintf(Outfile,"%s\n",Z);
  2286. }
  2287. }
  2288. }
  2289. if(SrcFlag)
  2290. {
  2291. if(!iMatchLft(Src,"$sourc")&&*Src!=33)
  2292. {
  2293. fprintf(Outfile,"%s%s%s%s%s%s\n","// [",trim(Modules[ModuleNdx])," - ",trim(str(ModuleLineNos[ModuleNdx])),"] ",Src);
  2294. }
  2295. }
  2296. if(ShowStatus)
  2297. {
  2298. locate (2,1,0);
  2299. printf("%s%s%s%d\n","Processing Module: ",trim(Modules[ModuleNdx])," - Line:",(int)ModuleLineNos[ModuleNdx]);
  2300. }
  2301. if(Src[0]==33)
  2302. {
  2303. Src[0]=32;
  2304. fprintf(Outfile,"%s\n",Src);
  2305. *Src=0;
  2306. }
  2307. if(*Src==0)
  2308. {
  2309. continue;
  2310. }
  2311. int di;
  2312. di=Directives();
  2313. if(di==0)
  2314. {
  2315. goto READNEXTLINE;
  2316. }
  2317. if(di==1)
  2318. {
  2319. goto READSRCLINE;
  2320. }
  2321. if(iMatchLft(Src,"set "))
  2322. {
  2323. ProcessSetCommand(0);
  2324. }
  2325. if(iMatchLft(Src,"sharedset "))
  2326. {
  2327. ProcessSetCommand(1);
  2328. }
  2329. PassOne=TRUE;
  2330. CheckParQuotes();
  2331. if(SpecialCaseHandler(Src))
  2332. {
  2333. continue;
  2334. }
  2335. Parse(Src);
  2336. PassOne=FALSE;
  2337. if(Ndx)
  2338. {
  2339. Emit();
  2340. }
  2341. READNEXTLINE:;
  2342. }
  2343. if(CmdLineConst[0]>0)
  2344. {
  2345. strcpy(Src, join(2,"CONST ",CmdLineConst));
  2346. Parse(Src);
  2347. Emit();
  2348. *CmdLineConst=0;
  2349. }
  2350. if(TestForBcxIni==FALSE)
  2351. {
  2352. TestForBcxIni=TRUE;
  2353. strcpy(szFile, join(2,curdir(),"\\bcx.ini"));
  2354. if(!Exist(szFile))
  2355. {
  2356. strcpy(szFile, join(2,AppExePath(),"bcx.ini"));
  2357. }
  2358. if(Exist(szFile))
  2359. {
  2360. PushFileIO();
  2361. if((SourceFile=fopen(szFile,"r"))==0)
  2362. {
  2363. fprintf(stderr,"Can't open file %s\n",szFile);
  2364. exit(1);
  2365. }
  2366. strcpy(Modules[++ModuleNdx],szFile);
  2367. ModuleLineNos[ModuleNdx]=0;
  2368. goto READSRCLINE;
  2369. }
  2370. }
  2371. fflush(Outfile);
  2372. if(FPtrNdx)
  2373. {
  2374. PopFileIO();
  2375. goto READSRCLINE;
  2376. }
  2377. if(Use_GenFree&&GlobalDynaCnt)
  2378. {
  2379. MakeFreeGlobals();
  2380. }
  2381. ExportInternalConst();
  2382. EmitEpilog();
  2383. CloseAll();
  2384. AddProtos();
  2385. DeclareVariables();
  2386. AddFuncs();
  2387. CloseAll();
  2388. if(UseCpp&&str_cmp(CmdLineFileOut,"")==0)
  2389. {
  2390. strcpy(szTmp, join(2,extract(FileOut,"."),".cpp"));
  2391. remove (szTmp);
  2392. rename (FileOut,szTmp);
  2393. strcpy(FileOut,szTmp);
  2394. }
  2395. if(Use_Osx&&str_cmp(CmdLineFileOut,"")==0)
  2396. {
  2397. strcpy(szTmp, join(2,extract(FileOut,"."),".mm"));
  2398. remove (szTmp);
  2399. rename (FileOut,szTmp);
  2400. strcpy(FileOut,szTmp);
  2401. }
  2402. if((FP1=fopen(FileOut,"r"))==0)
  2403. {
  2404. fprintf(stderr,"Can't open file %s\n",FileOut);
  2405. exit(1);
  2406. }
  2407. if((FP2=fopen(hdrFile,"r"))==0)
  2408. {
  2409. fprintf(stderr,"Can't open file %s\n",hdrFile);
  2410. exit(1);
  2411. }
  2412. if((FP3=fopen("$temp$","w"))==0)
  2413. {
  2414. fprintf(stderr,"Can't open file %s\n","$temp$");
  2415. exit(1);
  2416. }
  2417. DoCountLines=TRUE;
  2418. fprintf(FP3,"%s\n","// *********************************************************************");
  2419. fprintf(FP3,"%s%s%s\n","// Created with MBC (V) ",Version,"Ported to OSX by Armando Rivera");
  2420. fprintf(FP3,"%s\n","// Ported from BCX32 BASIC To C/C++ Translator (V) 5.12");
  2421. fprintf(FP3,"%s\n","// BCX (c) 1999 - 2018 by Kevin Diggins");
  2422. fprintf(FP3,"%s\n","// LinuxBC (c) 2009 by Mike Henning ");
  2423. fprintf(FP3,"%s\n","// MBC (c) 2009 - 2018 by Armando Rivera");
  2424. fprintf(FP3,"%s\n","// *********************************************************************");
  2425. fprintf(FP3,"%s\n","// Translated for compiling with the g++ Compiler");
  2426. if(UseCpp)
  2427. {
  2428. fprintf(FP3,"%s\n","// g++ -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$.cpp -ldl -o $FILE$");
  2429. }
  2430. else
  2431. {
  2432. fprintf(FP3,"%s\n","// g++ -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$.cc -ldl -o $FILE$");
  2433. }
  2434. fprintf(FP3,"%s\n","// *********************************************************************");
  2435. if(NoRT==FALSE)
  2436. {
  2437. if(Use_Osx)
  2438. {
  2439. fprintf(FP3,"%s\n","#import <Cocoa/Cocoa.h>");
  2440. }
  2441. /*****2010-11-24AddedWxCFORWXCONSOLEApps-AIR*****/;
  2442. if(Use_Wx||Use_WxC)
  2443. {
  2444. fprintf(FP3,"%s\n","// WXWIDGETS HEADER FILES //");
  2445. fprintf(FP3,"%s\n","#include <wx/wx.h>");
  2446. fprintf(FP3,"%s\n","#include <wx/process.h>");
  2447. fprintf(FP3,"%s\n","#include <wx/txtstrm.h>");
  2448. fprintf(FP3,"%s\n","#include <wx/msgdlg.h>");
  2449. fprintf(FP3,"%s\n","#include <wx/stdpaths.h>");
  2450. fprintf(FP3,"%s\n","#include <wx/event.h>");
  2451. fprintf(FP3,"%s\n","// ******************* //");
  2452. fprintf(FP3,"%s\n","");
  2453. }
  2454. if(Use_Gtk)
  2455. {
  2456. fprintf(FP3,"%s\n","#include <gtk/gtk.h>");
  2457. }
  2458. if(Use_Glib)
  2459. {
  2460. fprintf(FP3,"%s\n","#include <glib.h>");
  2461. }
  2462. fprintf(FP3,"%s\n","#include <stdbool.h>");
  2463. fprintf(FP3,"%s\n","#include <ctype.h>");
  2464. fprintf(FP3,"%s\n","#include <math.h>");
  2465. fprintf(FP3,"%s\n","#include <stdio.h>");
  2466. fprintf(FP3,"%s\n","#include <iostream>");
  2467. fprintf(FP3,"%s\n","#include <fstream>");
  2468. fprintf(FP3,"%s\n","#include <string.h>");
  2469. fprintf(FP3,"%s\n","#include <stddef.h>");
  2470. fprintf(FP3,"%s\n","#include <stdlib.h>");
  2471. fprintf(FP3,"%s\n","#include <setjmp.h>");
  2472. fprintf(FP3,"%s\n","#include <time.h>");
  2473. fprintf(FP3,"%s\n","#include <stdarg.h>");
  2474. fprintf(FP3,"%s\n","#include <dirent.h>");
  2475. fprintf(FP3,"%s\n","#include <sys/types.h>");
  2476. fprintf(FP3,"%s\n","#include <sys/stat.h>");
  2477. fprintf(FP3,"%s\n","#include <sys/wait.h>");
  2478. fprintf(FP3,"%s\n","#include <unistd.h>");
  2479. fprintf(FP3,"%s\n","#include <dlfcn.h>");
  2480. #if defined (__APPLE__)
  2481. fprintf(FP3,"%s\n","#include <libproc.h>");
  2482. #endif
  2483. if(UseCpp)
  2484. {
  2485. fprintf(FP3,"%s\n","#include <iostream>");
  2486. fprintf(FP3,"%s\n","#include <fstream>");
  2487. }
  2488. if(Use_Instat)
  2489. {
  2490. Use_Keypress=TRUE;
  2491. fprintf(FP3,"%s\n","#include <fcntl.h>");
  2492. }
  2493. if(Use_Keypress)
  2494. {
  2495. fprintf(FP3,"%s\n","#include <term.h>");
  2496. }
  2497. if(Use_Socket)
  2498. {
  2499. fprintf(FP3,"%s\n","#include <sys/socket.h>");
  2500. fprintf(FP3,"%s\n","#include <netinet/in.h>");
  2501. fprintf(FP3,"%s\n","#include <netdb.h>");
  2502. fprintf(FP3,"%s\n","#include <errno.h>");
  2503. fprintf(FP3,"%s\n","#include <arpa/inet.h>");
  2504. }
  2505. if(Use_RegEx)
  2506. {
  2507. fprintf(FP3,"%s\n","#include <regex.h>");
  2508. }
  2509. fprintf(FP3,"%s\n","");
  2510. EmitCompilerDefines();
  2511. }
  2512. while(!EoF(FP2))
  2513. {
  2514. Z[0]=0;
  2515. AR_fgets_retval=fgets(Z,1048576,FP2);
  2516. if(Z[strlen(Z)-1]==10)Z[strlen(Z)-1]=0;
  2517. fprintf(FP3,"%s\n",Z);
  2518. }
  2519. char Lastlyne[2048];
  2520. *Lastlyne=0;
  2521. while(!EoF(FP1))
  2522. {
  2523. static int bMainOut=0;
  2524. Z[0]=0;
  2525. AR_fgets_retval=fgets(Z,1048576,FP1);
  2526. if(Z[strlen(Z)-1]==10)Z[strlen(Z)-1]=0;
  2527. if(iMatchLft(Lastlyne,"#if"))
  2528. {
  2529. if(iMatchLft(Z,"#endif"))
  2530. {
  2531. *Lastlyne=0;
  2532. continue;
  2533. }
  2534. else
  2535. {
  2536. fprintf(FP3,"%s\n",Lastlyne);
  2537. }
  2538. }
  2539. strcpy(Lastlyne,Z);
  2540. if(iMatchLft(Lastlyne,"#if"))
  2541. {
  2542. continue;
  2543. }
  2544. fprintf(FP3,"%s\n",Z);
  2545. if(bMainOut)
  2546. {
  2547. continue;
  2548. }
  2549. if(str_cmp(left(ltrim(Z),8),"int main")==0)
  2550. {
  2551. while(str_cmp(trim(Z),"{")!=0)
  2552. {
  2553. Z[0]=0;
  2554. AR_fgets_retval=fgets(Z,1048576,FP1);
  2555. if(Z[strlen(Z)-1]==10)Z[strlen(Z)-1]=0;
  2556. fprintf(FP3,"%s\n",Z);
  2557. }
  2558. if(Use_StartupCode)
  2559. {
  2560. fprintf(FP3,"%s%s\n",Scoot,"int BCX_SUCode = BCX_StartupCode_(); // execute user's startup code");
  2561. }
  2562. if(Use_ExitCode)
  2563. {
  2564. fprintf(FP3,"%s%s\n",Scoot,"int BCX_EXCode = BCX_ExitCode_(); // Prepare for user's exit code");
  2565. }
  2566. bMainOut++;
  2567. }
  2568. }
  2569. DoCountLines=FALSE;
  2570. CloseAll();
  2571. remove (hdrFile);
  2572. remove (FileOut);
  2573. rename ("$temp$",FileOut);
  2574. if(ShowStatus)
  2575. {
  2576. locate (2,1,1);
  2577. }
  2578. if(!Quiet)
  2579. {
  2580. LinesRead+=(ModuleLineNos[1]);
  2581. Elapsed=Round((float)clock()/(float)CLOCKS_PER_SEC,2);
  2582. printf("%s%d%s%d%s","[Lines In:",(int)LinesRead,"] [Lines Out:",(int)gLinesWritten,"] ");
  2583. printf("%s%d%s%.7G%s\n","[Statements:",(int)Statements,"] [Time:",(float)Elapsed," sec's]");
  2584. strcpy(Z, join(4,"BCX translated ",RemoveStr(FileIn," ")," to ",RemoveStr(FileOut," ")));
  2585. printf("%s\n",Z);
  2586. }
  2587. PostProcess();
  2588. if(WarnMsg[0]>0)
  2589. {
  2590. printf("%s%s%s\n","Warnings! :",CRLF,WarnMsg);
  2591. }
  2592. if(KillCFile)
  2593. {
  2594. remove (FileOut);
  2595. }
  2596. FreeGlobals();
  2597. return 0;
  2598. }
  2599. void EmitCmdLineConst (void)
  2600. {
  2601. if(CmdLineConst[0]>0)
  2602. {
  2603. static FILE* Ftmp;
  2604. fprintf(FP7,"%s\n","");
  2605. fprintf(FP7,"%s\n","// ***************************************************");
  2606. fprintf(FP7,"%s\n","// Commandline Defines");
  2607. fprintf(FP7,"%s\n","// ***************************************************");
  2608. fprintf(FP7,"%s\n","");
  2609. Ftmp=FP6;
  2610. FP6=FP7;
  2611. {register int i;
  2612. for(i=1; i<=tally(CmdLineConst,chr(1)); i+=1)
  2613. {
  2614. strcpy(Src,StrToken(CmdLineConst,chr(1),i));
  2615. if(Src[0]==0)
  2616. {
  2617. break;
  2618. }
  2619. strcpy(Src, join(2,"CONST ",Src));
  2620. Parse(Src);
  2621. Emit();
  2622. }
  2623. }
  2624. *CmdLineConst=0;
  2625. FP6=Ftmp;
  2626. fprintf(FP7,"%s\n","");
  2627. }
  2628. }
  2629. void EmitCompilerDefines (void)
  2630. {
  2631. fprintf(FP3,"%s\n","");
  2632. fprintf(FP3,"%s\n","// ***************************************************");
  2633. fprintf(FP3,"%s\n","// Compiler Defines");
  2634. fprintf(FP3,"%s\n","// ***************************************************");
  2635. fprintf(FP3,"%s%s\n"," #define C_EXPORT extern ",enc("C"));
  2636. fprintf(FP3,"%s%s\n"," #define C_IMPORT extern ",enc("C"));
  2637. fprintf(FP3,"%s\n","");
  2638. fprintf(FP3,"%s\n","#ifndef stat");
  2639. fprintf(FP3,"%s\n"," #define lstat stat");
  2640. fprintf(FP3,"%s\n","#endif");
  2641. fprintf(FP3,"%s\n","#ifndef _fcloseall");
  2642. fprintf(FP3,"%s\n"," #define _fcloseall _fcloseall");
  2643. fprintf(FP3,"%s\n","#endif");
  2644. fprintf(FP3,"%s\n","#ifndef HWND");
  2645. fprintf(FP3,"%s\n"," #define HWND GHWND");
  2646. fprintf(FP3,"%s\n","#endif");
  2647. fprintf(FP3,"%s\n","#ifndef MAX_PATH");
  2648. fprintf(FP3,"%s\n"," #define MAX_PATH 2048");
  2649. fprintf(FP3,"%s\n","#endif");
  2650. fprintf(FP3,"%s\n","#ifndef CALLBACK");
  2651. fprintf(FP3,"%s\n"," #define CALLBACK");
  2652. fprintf(FP3,"%s\n","#endif");
  2653. fprintf(FP3,"%s\n","typedef unsigned int HINSTANCE;");
  2654. fprintf(FP3,"%s\n","typedef void* LPVOID;");
  2655. fprintf(FP3,"%s\n","typedef char* PCHAR;");
  2656. fprintf(FP3,"%s\n","typedef unsigned char BYTE;");
  2657. fprintf(FP3,"%s\n","typedef unsigned int UINT;");
  2658. fprintf(FP3,"%s\n","typedef unsigned char UCHAR;");
  2659. fprintf(FP3,"%s\n","typedef unsigned char* PUCHAR;");
  2660. fprintf(FP3,"%s\n","typedef unsigned long ULONG;");
  2661. fprintf(FP3,"%s\n","typedef unsigned long* ULONG_PTR;");
  2662. fprintf(FP3,"%s\n","typedef unsigned long DWORD;");
  2663. fprintf(FP3,"%s\n","");
  2664. fprintf(FP3,"%s\n","#ifndef TRUE");
  2665. fprintf(FP3,"%s\n"," #define TRUE 1");
  2666. fprintf(FP3,"%s\n","#endif");
  2667. fprintf(FP3,"%s\n","");
  2668. fprintf(FP3,"%s\n","#ifndef FALSE");
  2669. fprintf(FP3,"%s\n"," #define FALSE 0");
  2670. fprintf(FP3,"%s\n","#endif");
  2671. if(!Use_Osx)
  2672. {
  2673. fprintf(FP3,"%s\n","#define BOOL bool");
  2674. }
  2675. fprintf(FP3,"%s\n","");
  2676. if(UseCpp)
  2677. {
  2678. fprintf(FP3,"%s\n","#define println(a) (std::cout << a << std::endl)");
  2679. fprintf(FP3,"%s\n"," typedef std::string CSTRING;");
  2680. fprintf(FP3,"%s\n"," typedef std::fstream CFILE;");
  2681. }
  2682. }
  2683. void MakeFreeGlobals (void)
  2684. {
  2685. strcpy(Src,"SUB FreeGlobals");
  2686. PassOne=1;
  2687. Parse(Src);
  2688. Emit();
  2689. while(GlobalDynaCnt)
  2690. {
  2691. fprintf(Outfile,"%s%s\n"," ",GlobalDynaStr[GlobalDynaCnt]);
  2692. GlobalDynaCnt--;
  2693. }
  2694. strcpy(Src,"END SUB");
  2695. PassOne=1;
  2696. Parse(Src);
  2697. Emit();
  2698. }
  2699. void ProcessSetCommand (int GS)
  2700. {
  2701. int i;
  2702. int ii;
  2703. int j;
  2704. int SetString=0;
  2705. char CVar[2048];
  2706. int vt;
  2707. static FILE *SaveFP;
  2708. memset(&SaveFP,0,sizeof(SaveFP));
  2709. SaveFP=Outfile;
  2710. if(!InFunc)
  2711. {
  2712. Outfile=FP9;
  2713. }
  2714. if(inchr(Src,"$")&&tally(Src,"[")>1)
  2715. {
  2716. strcpy(Src,strim(Src));
  2717. strcpy(Src,IRemoveStr(Src,"as string"));
  2718. strcpy(Src,IRemoveStr(Src,"as char"));
  2719. strcat(Src," AS char");
  2720. }
  2721. strcat(Src,"=");
  2722. PassOne=1;
  2723. Parse(Src);
  2724. *Tipe=0;
  2725. for(i=1; i<=Ndx; i+=1)
  2726. {
  2727. if(iMatchWrd(Stk[i],"as"))
  2728. {
  2729. strcpy(Tipe,Stk[i+1]);
  2730. *Stk[i]=0;
  2731. *Stk[i+1]=0;
  2732. break;
  2733. }
  2734. }
  2735. if(Tipe[0]==0)
  2736. {
  2737. strcpy(szTmp,Stk[2]);
  2738. SetString=DataType(Stk[2]);
  2739. j=SetString;
  2740. VarCode.Method=mt_ProcessSetCommand;
  2741. strcpy(VarCode.Token,szTmp);
  2742. VarCode.VarNo=j;
  2743. GetVarCode( &VarCode);
  2744. if(GS)
  2745. {
  2746. fprintf(Outfile,"%s%s",Scoot,RemoveStr(VarCode.StaticOut,"static "));
  2747. }
  2748. else
  2749. {
  2750. fprintf(Outfile,"%s%s",Scoot,VarCode.StaticOut);
  2751. }
  2752. char lszTmp[65535];
  2753. *lszTmp=0;
  2754. strcpy(CVar,Clean(Stk[2]));
  2755. ValidVar(CVar);
  2756. vt=DataType(Stk[2]);
  2757. for(i=3; i<=Ndx; i+=1)
  2758. {
  2759. strcat(lszTmp,Stk[i]);
  2760. }
  2761. if(vt==vt_STRVAR&&str_cmp(lszTmp,"")!=0)
  2762. {
  2763. strcat(lszTmp,"[65535]");
  2764. }
  2765. if(!InFunc)
  2766. {
  2767. AddGlobal(CVar,vt,0,lszTmp,0,0,0,1);
  2768. }
  2769. else
  2770. {
  2771. AddLocal(CVar,vt,0,lszTmp,0,0,1);
  2772. }
  2773. }
  2774. else
  2775. {
  2776. strcpy(CVar,Clean(Stk[2]));
  2777. if(GS)
  2778. {
  2779. fprintf(Outfile,"%s%s%s%s",Scoot,Tipe," ",CVar);
  2780. }
  2781. else
  2782. {
  2783. fprintf(Outfile,"%s%s%s%s%s",Scoot,"static ",Tipe," ",CVar);
  2784. }
  2785. char DimType[2048];
  2786. int IsPointer;
  2787. int id;
  2788. strcpy(DimType,RemoveStr(Tipe,"*"));
  2789. GetTypeInfo(Tipe, &IsPointer, &id, &vt);
  2790. if(vt==vt_STRVAR)
  2791. {
  2792. strcat(DimType,"[65535]");
  2793. }
  2794. if(!InFunc)
  2795. {
  2796. AddGlobal(CVar,vt,id,DimType,IsPointer,0,0,1);
  2797. }
  2798. else
  2799. {
  2800. AddLocal(CVar,vt,id,DimType,IsPointer,0,1);
  2801. }
  2802. }
  2803. i=2;
  2804. j=0;
  2805. for(;;)
  2806. {
  2807. i++;
  2808. if(str_cmp(Stk[i],"=")==0)
  2809. {
  2810. j=1;
  2811. }
  2812. if(SetString==vt_STRVAR&&j==1)
  2813. {
  2814. fprintf(Outfile,"%s","[65535]=");
  2815. }
  2816. else
  2817. {
  2818. fprintf(Outfile,"%s",Stk[i]);
  2819. }
  2820. if(str_cmp(Stk[i],"=")==0)
  2821. {
  2822. break;
  2823. }
  2824. if(i==Ndx)
  2825. {
  2826. break;
  2827. }
  2828. }
  2829. fprintf(Outfile,"%s\n","");
  2830. fprintf(Outfile,"%s\n","{");
  2831. while(!EoF(SourceFile))
  2832. {
  2833. Src[0]=0;
  2834. AR_fgets_retval=fgets(Src,1048576,SourceFile);
  2835. if(Src[strlen(Src)-1]==10)Src[strlen(Src)-1]=0;
  2836. ModuleLineNos[ModuleNdx]++;
  2837. StripCode(Src);
  2838. if(JoinLines(Src)==1)
  2839. {
  2840. continue;
  2841. }
  2842. PassOne=TRUE;
  2843. XParse(Src);
  2844. PassOne=FALSE;
  2845. TokenSubstitutions();
  2846. if(iMatchLft(Src,"end "))
  2847. {
  2848. break;
  2849. }
  2850. if(strlen(Src))
  2851. {
  2852. fprintf(Outfile,"%s"," ");
  2853. for(ii=1; ii<=Ndx; ii+=1)
  2854. {
  2855. fprintf(Outfile,"%s",Clean(Stk[ii]));
  2856. }
  2857. fprintf(Outfile,"%s\n","");
  2858. }
  2859. }
  2860. fprintf(Outfile,"%s\n","};\n");
  2861. *Src=0;
  2862. Outfile=SaveFP;
  2863. }
  2864. int Directives (void)
  2865. {
  2866. char lszTmp[2048];
  2867. int i;
  2868. char COutputFile[2048];
  2869. if(*Src==35||*Src==36)
  2870. {
  2871. strcpy(Z,rtrim(lcase(left(Src,6))));
  2872. for(;;)
  2873. {
  2874. if(str_cmp(Z,"$proje")==0)
  2875. {
  2876. NoRT=TRUE;
  2877. *Src=0;
  2878. return 0;
  2879. }
  2880. if(str_cmp(Z,"$accel")==0)
  2881. {
  2882. XParse(Src);
  2883. strcpy(Accelerator,RemoveStr(Stk[2],DQ));
  2884. *Src=0;
  2885. return 0;
  2886. }
  2887. if(str_cmp(Z,"$bcxve")==0)
  2888. {
  2889. strcpy(Src,trim(mid(Src,12)));
  2890. strcpy(Src,RemoveStr(Src,DQ));
  2891. if(str_cmp(lcase(Version),lcase(Src))==-1)
  2892. {
  2893. Abort(join(10,CRLF,"Your Translator needs updating.",CRLF,"This program ",enc(Modules[ModuleNdx])," requires BCX Version: ",Src," or later.",CRLF,CRLF));
  2894. }
  2895. else
  2896. {
  2897. printf("%s\n","");
  2898. printf("%s%s\n","Program written for BCX Version ",Src);
  2899. printf("%s\n","");
  2900. }
  2901. return 0;
  2902. }
  2903. if(str_cmp(Z,"$compi")==0)
  2904. {
  2905. PassOne=1;
  2906. XParse(Src);
  2907. PassOne=0;
  2908. strcpy(Compiler,Stk[2]);
  2909. *Src=0;
  2910. return 0;
  2911. }
  2912. if(str_cmp(Z,"$execo")==0)
  2913. {
  2914. static char SrcExt[2048];
  2915. memset(&SrcExt,0,sizeof(SrcExt));
  2916. PassOne=1;
  2917. XParse(Src);
  2918. PassOne=0;
  2919. XitCount++;
  2920. if(UseCpp)
  2921. {
  2922. strcpy(SrcExt,".cpp");
  2923. }
  2924. else if(Use_Osx)
  2925. {
  2926. strcpy(SrcExt,".mm");
  2927. }
  2928. else
  2929. {
  2930. strcpy(SrcExt,".cc");
  2931. }
  2932. if(MakeDLL)
  2933. {
  2934. strcpy(Xit[XitCount], join(7,"g++ -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$",SrcExt," -ldl ",LD_FLAGS,SPC,Stk[2]," -o lib$FILE$.so"));
  2935. *SrcExt=0;
  2936. *Src=0;
  2937. return 0;
  2938. }
  2939. if(Use_IOS)
  2940. {
  2941. static char IOS_COMPILER[2048];
  2942. memset(&IOS_COMPILER,0,sizeof(IOS_COMPILER));
  2943. strcpy(IOS_COMPILER,"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++");
  2944. if(strlen(Stk[2])>0)
  2945. {
  2946. strcpy(Xit[XitCount], join(8,IOS_COMPILER," -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$",SrcExt," -ldl ",LD_FLAGS,SPC,Stk[2]," -o $FILE$"));
  2947. }
  2948. else
  2949. {
  2950. strcpy(Xit[XitCount], join(6,IOS_COMPILER," -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$",SrcExt," -ldl ",LD_FLAGS," -o $FILE$"));
  2951. }
  2952. *SrcExt=0;
  2953. *Src=0;
  2954. return 0;
  2955. }
  2956. if(strlen(Stk[2])>0)
  2957. {
  2958. strcpy(Xit[XitCount], join(7,"g++ -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$",SrcExt," -ldl ",LD_FLAGS,SPC,Stk[2]," -o $FILE$"));
  2959. }
  2960. else
  2961. {
  2962. strcpy(Xit[XitCount], join(5,"g++ -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$",SrcExt," -ldl ",LD_FLAGS," -o $FILE$"));
  2963. }
  2964. *SrcExt=0;
  2965. *Src=0;
  2966. return 0;
  2967. }
  2968. if(str_cmp(Z,"$exest")==0)
  2969. {
  2970. PassOne=1;
  2971. XParse(Src);
  2972. PassOne=0;
  2973. XitCount++;
  2974. if(IsApple)
  2975. {
  2976. strcpy(Xit[XitCount],"strip $FILE$");
  2977. }
  2978. else
  2979. {
  2980. strcpy(Xit[XitCount],"strip -s -R .comment -R .note -R .note.ABI-tag $FILE$");
  2981. }
  2982. *Src=0;
  2983. return 0;
  2984. }
  2985. if(str_cmp(Z,"$genfr")==0)
  2986. {
  2987. Use_GenFree=TRUE;
  2988. *Src=0;
  2989. return 0;
  2990. }
  2991. if(str_cmp(Z,"$osx")==0)
  2992. {
  2993. Use_Osx=TRUE;
  2994. strcpy(LD_FLAGS,join(2,LD_FLAGS," -fobjc-arc -framework Cocoa"));
  2995. return 0;
  2996. }
  2997. if(str_cmp(Z,"$ios")==0)
  2998. {
  2999. #if !defined __APPLE__
  3000. Abort(join(3,CRLF,"The $IOS Directive REQUIRES an Apple OSX Operating System",CRLF));
  3001. #endif
  3002. Use_IOS=TRUE;
  3003. PassOne=1;
  3004. XParse(Src);
  3005. PassOne=0;
  3006. strcpy(LD_FLAGS,join(2,LD_FLAGS," -arch armv6 -arch armv7 -mthumb -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk -framework Foundation -framework CoreFoundation"));
  3007. return 0;
  3008. }
  3009. if(str_cmp(Z,"$gtk")==0)
  3010. {
  3011. Use_Gtk=TRUE;
  3012. strcpy(LD_FLAGS,join(2,LD_FLAGS," $(pkg-config --libs --cflags gtk+-2.0)"));
  3013. return 0;
  3014. }
  3015. if(str_cmp(Z,"$ldfla")==0)
  3016. {
  3017. strcpy(LD_FLAGS,join(2,LD_FLAGS,remain(Src," ")));
  3018. return 0;
  3019. /*****2010-11-24AddedWxCFORWXCONSOLEApps-AIR*****/;
  3020. break;
  3021. }
  3022. if(str_cmp(Z,"$wxc")==0)
  3023. {
  3024. Use_WxC=UseCpp=NoMain=TRUE;
  3025. strcpy(LD_FLAGS,join(2,LD_FLAGS," $(wx-config --libs --cppflags)"));
  3026. return 0;
  3027. }
  3028. if(str_cmp(Z,"$wx")==0)
  3029. {
  3030. Use_Wx=UseCpp=NoMain=TRUE;
  3031. strcpy(LD_FLAGS,join(2,LD_FLAGS," $(wx-config --libs --cppflags)"));
  3032. return 0;
  3033. }
  3034. if(str_cmp(Z,"$glib")==0)
  3035. {
  3036. Use_Glib=TRUE;
  3037. strcpy(LD_FLAGS,join(2,LD_FLAGS," $(pkg-config --libs --cflags glib-2.0)"));
  3038. return 0;
  3039. }
  3040. if(str_cmp(Z,"$noini")==0)
  3041. {
  3042. *Src=0;
  3043. TestForBcxIni=TRUE;
  3044. return 0;
  3045. }
  3046. if(str_cmp(Z,"$linke")==0)
  3047. {
  3048. PassOne=1;
  3049. XParse(Src);
  3050. PassOne=0;
  3051. strcpy(Linker,Stk[2]);
  3052. *Src=0;
  3053. return 0;
  3054. }
  3055. if(str_cmp(Z,"$onexi")==0)
  3056. {
  3057. PassOne=1;
  3058. XParse(Src);
  3059. PassOne=0;
  3060. XitCount++;
  3061. strcpy(Xit[XitCount],Stk[2]);
  3062. *Src=0;
  3063. return 0;
  3064. }
  3065. if(str_cmp(Z,"$onent")==0)
  3066. {
  3067. PassOne=1;
  3068. XParse(Src);
  3069. PassOne=0;
  3070. EntryCnt++;
  3071. strcpy(Entry[EntryCnt],Stk[2]);
  3072. *Src=0;
  3073. return 0;
  3074. }
  3075. if(str_cmp(Z,"$pack")==0 || str_cmp(Z,"$pack(")==0)
  3076. {
  3077. strcpy(Src,mid(Src,6));
  3078. fprintf(FP4,"%s%s\n","#pragma pack ",ltrim(Src));
  3079. *Src=0;
  3080. return 0;
  3081. }
  3082. if(str_cmp(Z,"$nodll")==0)
  3083. {
  3084. NoDllMain=TRUE;
  3085. *Src=0;
  3086. return 0;
  3087. }
  3088. if(str_cmp(Z,"$pelle")==0)
  3089. {
  3090. *Src=0;
  3091. return 0;
  3092. }
  3093. if(str_cmp(Z,"$stdca")==0)
  3094. {
  3095. UseStdCall=TRUE;
  3096. *Src=0;
  3097. return 0;
  3098. }
  3099. if(str_cmp(Z,"$iprin")==0)
  3100. {
  3101. if(instr_b(lcase(Src),"_on"))
  3102. {
  3103. TranslateSlash=TRUE;
  3104. }
  3105. else
  3106. {
  3107. TranslateSlash=FALSE;
  3108. }
  3109. *Src=0;
  3110. return 0;
  3111. }
  3112. if(str_cmp(Z,"$nomai")==0)
  3113. {
  3114. NoMain=TRUE;
  3115. *Src=0;
  3116. return 0;
  3117. }
  3118. if(str_cmp(Z,"$test")==0)
  3119. {
  3120. TestState=!TestState;
  3121. *Src=0;
  3122. return 0;
  3123. }
  3124. if(str_cmp(Z,"$typed")==0)
  3125. {
  3126. fprintf(FP7,"%s%s%s\n","typedef ",remain(Src," "),";");
  3127. *Src=0;
  3128. return 0;
  3129. }
  3130. if(str_cmp(Z,"$resou")==0)
  3131. {
  3132. static char resAlias[2048];
  3133. memset(&resAlias,0,sizeof(resAlias));
  3134. static char resFile[2048];
  3135. memset(&resFile,0,sizeof(resFile));
  3136. Use_Embed=TRUE;
  3137. PassOne=1;
  3138. XParse(Src);
  3139. PassOne=0;
  3140. EntryCnt++;
  3141. strcpy(Entry[EntryCnt], join(5,"ld -r -b binary ",Stk[2]," -o ",Stk[2],".o"));
  3142. strcpy(Stk[2],replace(Stk[2],".","_"));
  3143. strcpy(resFile,RemoveStr(Stk[2],DQ));
  3144. strcpy(resAlias,RemoveStr(Stk[3],DQ));
  3145. AddGlobal(join(3,"_binary_",resFile,"_start"),vt_INTEGER,0,"",0,0,1,0);
  3146. AddGlobal(join(3,"_binary_",resFile,"_size"),vt_INTEGER,0,"",0,0,1,0);
  3147. strcpy(Src, join(5,"CONST ",resAlias,"= &_binary_",resFile,"_start"));
  3148. Parse(Src);
  3149. Emit();
  3150. strcpy(Src, join(5,"CONST ",resAlias,"_SIZE = (int)&_binary_",resFile,"_size"));
  3151. Parse(Src);
  3152. Emit();
  3153. *Src=0;
  3154. return 0;
  3155. }
  3156. if(str_cmp(Z,"$turbo")==0)
  3157. {
  3158. strcpy(Src,ltrim(mid(Src,7)));
  3159. if(*Src!=0)
  3160. {
  3161. TurboSize=VAL(Src);
  3162. if((TurboSize&(TurboSize-1))!=0)
  3163. {
  3164. TurboSize=512;
  3165. Warning("Invalid $Turbo size - defaulting to 512");
  3166. }
  3167. }
  3168. else
  3169. {
  3170. TurboSize=512;
  3171. }
  3172. Use_Turbo=TRUE;
  3173. *Src=0;
  3174. return 0;
  3175. }
  3176. if(str_cmp(Z,"$sourc")==0)
  3177. {
  3178. SrcFlag=!SrcFlag;
  3179. *Src=0;
  3180. return 0;
  3181. }
  3182. if(str_cmp(Z,"$fssta")==0)
  3183. {
  3184. Use_Static=!Use_Static;
  3185. *Src=0;
  3186. return 0;
  3187. }
  3188. if(str_cmp(Z,"$trace")==0)
  3189. {
  3190. TrcFlag=!TrcFlag;
  3191. *Src=0;
  3192. return 0;
  3193. }
  3194. if(str_cmp(Z,"$inclu")==0 || str_cmp(Z,"$modul")==0)
  3195. {
  3196. char orgfileName[2048];
  3197. strcpy(szFile,trim(RemoveStr(mid(Src,9),DQ)));
  3198. strcpy(orgfileName,szFile);
  3199. if(str_cmp(left(szFile,1),"<")==0)
  3200. {
  3201. strcpy(szFile,mid(szFile,2,strlen(szFile)-2));
  3202. strcpy(szFile, join(2,Environ("BCXLIB"),szFile));
  3203. }
  3204. if(!Exist(szFile))
  3205. {
  3206. strcpy(szFile,BcxSplitPath(szFile,FNAME|FEXT));
  3207. strcpy(szFile, join(2,BcxSplitPath(FileIn,FDRV|FPATH),szFile));
  3208. }
  3209. if(!Exist(szFile))
  3210. {
  3211. Abort(join(2,"Unable to locate ",orgfileName));
  3212. }
  3213. PushFileIO();
  3214. if((SourceFile=fopen(szFile,"r"))==0)
  3215. {
  3216. fprintf(stderr,"Can't open file %s\n",szFile);
  3217. exit(1);
  3218. }
  3219. strcpy(Modules[++ModuleNdx],szFile);
  3220. ModuleLineNos[ModuleNdx]=0;
  3221. return 1;
  3222. }
  3223. if(str_cmp(Z,"$try")==0)
  3224. {
  3225. fprintf(Outfile,"%s\n","try {");
  3226. *Src=0;
  3227. return 0;
  3228. }
  3229. if(str_cmp(Z,"$throw")==0)
  3230. {
  3231. strcpy(szTmp,mid(Src,8));
  3232. if(szTmp[0]==0)
  3233. {
  3234. strcpy(szTmp,enc("An Exception has occured!"));
  3235. }
  3236. fprintf(Outfile,"%s%s%s%s\n",Scoot,"throw ",szTmp,";");
  3237. *Src=0;
  3238. return 0;
  3239. }
  3240. if(str_cmp(Z,"$catch")==0)
  3241. {
  3242. strcpy(szTmp,mid(Src,8));
  3243. if(szTmp[0]==0)
  3244. {
  3245. strcpy(szTmp,"char *str");
  3246. }
  3247. fprintf(Outfile,"%s\n","}");
  3248. fprintf(Outfile,"%s%s%s\n","catch (",szTmp,")");
  3249. fprintf(Outfile,"%s\n","{");
  3250. *Src=0;
  3251. return 0;
  3252. }
  3253. if(str_cmp(Z,"$endtr")==0)
  3254. {
  3255. fprintf(Outfile,"%s\n","}");
  3256. *Src=0;
  3257. return 0;
  3258. }
  3259. if(str_cmp(Z,"$endna")==0)
  3260. {
  3261. InNameSpace--;
  3262. BumpDown();
  3263. fprintf(Outfile,"%s%s\n",Scoot,"}");
  3264. *Src=0;
  3265. return 0;
  3266. }
  3267. if(str_cmp(Z,"$names")==0)
  3268. {
  3269. Abort("$NAMESPACE/$ENDNAMESPACE have been removed from this version. Use NAMESPACE / END NAMESPACE instead.");
  3270. break;
  3271. }
  3272. if(str_cmp(Z,"$usena")==0)
  3273. {
  3274. UseCpp=TRUE;
  3275. strcpy(szTmp,mid(Src,inchr(Src," ")+1));
  3276. if(str_cmp(right(trim(szTmp),1),";")!=0)
  3277. {
  3278. fprintf(Outfile,"%s%s%s\n","using namespace ",szTmp,";");
  3279. }
  3280. else
  3281. {
  3282. fprintf(Outfile,"%s%s\n","using namespace ",szTmp);
  3283. }
  3284. *Src=0;
  3285. return 0;
  3286. }
  3287. if(str_cmp(Z,"$class")==0)
  3288. {
  3289. Abort("$CLASS has been removed from this version. Use CLASS instead.");
  3290. return 0;
  3291. }
  3292. if(str_cmp(Z,"$inter")==0)
  3293. {
  3294. static int BeenHere;
  3295. UseCpp=TRUE;
  3296. strcpy(szTmp,remain(Src,SPC));
  3297. if(!BeenHere)
  3298. {
  3299. BeenHere++;
  3300. fprintf(FP4,"%s\n","#ifndef __cplusplus");
  3301. fprintf(FP4,"%s\n"," #error A C++ compiler is required");
  3302. fprintf(FP4,"%s\n","#endif");
  3303. }
  3304. fprintf(FP4,"%s%s%s\n","interface ",szTmp," {");
  3305. for(;;)
  3306. {
  3307. if(EoF(SourceFile))
  3308. {
  3309. Abort("$Interface Without $EndInterface");
  3310. }
  3311. Src[0]=0;
  3312. AR_fgets_retval=fgets(Src,1048576,SourceFile);
  3313. if(Src[strlen(Src)-1]==10)Src[strlen(Src)-1]=0;
  3314. ModuleLineNos[ModuleNdx]++;
  3315. if(iMatchLft(ltrim(Src),"$endinterface"))
  3316. {
  3317. break;
  3318. }
  3319. fprintf(FP4,"%s\n",Src);
  3320. }
  3321. fprintf(FP4,"%s%s%s\n","}",trim(join(2,Src,13)),";");
  3322. return 0;
  3323. }
  3324. if(str_cmp(Z,"$comme")==0)
  3325. {
  3326. *Src=0;
  3327. for(;;)
  3328. {
  3329. if(EoF(SourceFile))
  3330. {
  3331. Abort("Unbalanced $Comment");
  3332. }
  3333. Src[0]=0;
  3334. AR_fgets_retval=fgets(Src,1048576,SourceFile);
  3335. if(Src[strlen(Src)-1]==10)Src[strlen(Src)-1]=0;
  3336. ModuleLineNos[ModuleNdx]++;
  3337. StripTabs();
  3338. if(iMatchLft(ltrim(Src),"$comment"))
  3339. {
  3340. break;
  3341. }
  3342. fprintf(Outfile,"%s%s\n","// ",Src);
  3343. }
  3344. *Src=0;
  3345. return 0;
  3346. }
  3347. if(str_cmp(Z,"$ccode")==0)
  3348. {
  3349. *Src=0;
  3350. for(;;)
  3351. {
  3352. if(EoF(SourceFile))
  3353. {
  3354. Abort("Unbalanced $Ccode");
  3355. }
  3356. Src[0]=0;
  3357. AR_fgets_retval=fgets(Src,1048576,SourceFile);
  3358. if(Src[strlen(Src)-1]==10)Src[strlen(Src)-1]=0;
  3359. ModuleLineNos[ModuleNdx]++;
  3360. StripTabs();
  3361. if(iMatchLft(ltrim(Src),"$ccode"))
  3362. {
  3363. if(SrcFlag)
  3364. {
  3365. fprintf(Outfile,"%s%s%s%s%s\n","// [",trim(Modules[ModuleNdx])," - ",trim(str(ModuleLineNos[ModuleNdx])),"] End of $CCODE Block");
  3366. }
  3367. break;
  3368. }
  3369. fprintf(Outfile,"%s\n",rtrim(Src));
  3370. }
  3371. *Src=0;
  3372. return 0;
  3373. }
  3374. if(str_cmp(Z,"$cprot")==0)
  3375. {
  3376. FastLexer(Src,SPC,"!");
  3377. if(iMatchWrd(Stk[2],"!"))
  3378. {
  3379. ProtoCnt++;
  3380. strcpy(ProtoType[ProtoCnt].Prototype,remain(Src,"!"));
  3381. *ProtoType[ProtoCnt].Condition=0;
  3382. ProtoType[ProtoCnt].CondLevel=0;
  3383. }
  3384. else
  3385. {
  3386. i=iMatchNQ(Src,"function");
  3387. if(i==0)
  3388. {
  3389. i=iMatchNQ(Src,"sub");
  3390. }
  3391. if(i)
  3392. {
  3393. strcpy(Src, join(2,"c_declare ",mid(Src,i)));
  3394. }
  3395. else
  3396. {
  3397. i=iMatchNQ(Src,"$cproto");
  3398. strcpy(Src, join(2,"c_declare function ",mid(Src,i+7)));
  3399. }
  3400. UseCProto=TRUE;
  3401. return 2;
  3402. }
  3403. *Src=0;
  3404. return 0;
  3405. }
  3406. if(str_cmp(Z,"$heade")==0)
  3407. {
  3408. *Src=0;
  3409. fprintf(FP7,"%s\n","// ***************************************************");
  3410. fprintf(FP7,"%s\n","");
  3411. for(;;)
  3412. {
  3413. if(EoF(SourceFile))
  3414. {
  3415. Abort("Unbalanced $Header");
  3416. }
  3417. Src[0]=0;
  3418. AR_fgets_retval=fgets(Src,1048576,SourceFile);
  3419. if(Src[strlen(Src)-1]==10)Src[strlen(Src)-1]=0;
  3420. ModuleLineNos[ModuleNdx]++;
  3421. StripTabs();
  3422. strcpy(Src,trim(Src));
  3423. if(iMatchLft(Src,"$heade"))
  3424. {
  3425. break;
  3426. }
  3427. fprintf(FP7,"%s\n",Src);
  3428. }
  3429. *Src=0;
  3430. fprintf(FP7,"%s\n","");
  3431. return 0;
  3432. }
  3433. if(str_cmp(Z,"$asm")==0)
  3434. {
  3435. if(!iMatchLft(Src,"$asm"))
  3436. {
  3437. Abort(join(2,"Unknown metastatement: ",Src));
  3438. }
  3439. *Src=0;
  3440. for(;;)
  3441. {
  3442. if(EoF(SourceFile))
  3443. {
  3444. Abort("Unbalanced $Asm");
  3445. }
  3446. Src[0]=0;
  3447. AR_fgets_retval=fgets(Src,1048576,SourceFile);
  3448. if(Src[strlen(Src)-1]==10)Src[strlen(Src)-1]=0;
  3449. ModuleLineNos[ModuleNdx]++;
  3450. if(SrcFlag)
  3451. {
  3452. fprintf(Outfile,"%s%s\n","// ",Src);
  3453. }
  3454. StripTabs();
  3455. strcpy(Src,trim(Src));
  3456. static int meta_asm_loop;
  3457. memset(&meta_asm_loop,0,sizeof(meta_asm_loop));
  3458. static bool meta_asm_comment_present;
  3459. memset(&meta_asm_comment_present,0,sizeof(meta_asm_comment_present));
  3460. static int Src_Len;
  3461. memset(&Src_Len,0,sizeof(Src_Len));
  3462. Src_Len=strlen(Src);
  3463. meta_asm_comment_present=FALSE;
  3464. for(meta_asm_loop=0; meta_asm_loop<=Src_Len; meta_asm_loop+=1)
  3465. {
  3466. if(Src[meta_asm_loop]==39||Src[meta_asm_loop]==59)
  3467. {
  3468. strcpy(lszTmp,right(Src,Src_Len-meta_asm_loop-1));
  3469. Src[meta_asm_loop]=0;
  3470. meta_asm_comment_present=TRUE;
  3471. break;
  3472. }
  3473. }
  3474. strcpy(Src,trim(Src));
  3475. if(iMatchLft(Src,"$asm"))
  3476. {
  3477. break;
  3478. }
  3479. strcpy(Src,replace(Src,"$","0x"));
  3480. strcpy(Src,iReplace(Src,"&h","0x"));
  3481. if(Src[0]!=0)
  3482. {
  3483. strcpy(Src, join(3,"_asm(",enc(Src),chr(1)));
  3484. if(meta_asm_comment_present)
  3485. {
  3486. strcpy(Src, join(4,Src,TAB,"//",lszTmp));
  3487. }
  3488. strcpy(SrcTmp,Src);
  3489. fprintf(Outfile,"%s\n","#if !defined( __POCC__ ) && !defined (__cplusplus )");
  3490. strcpy(Src,replace(Src,chr(1),")"));
  3491. fprintf(Outfile,"%s\n",Src);
  3492. fprintf(Outfile,"%s\n","#else");
  3493. strcpy(SrcTmp,replace(SrcTmp,"_asm(","__asm{"));
  3494. strcpy(SrcTmp,replace(SrcTmp,chr(1),"}"));
  3495. fprintf(Outfile,"%s\n",RemoveStr(SrcTmp,DQ));
  3496. fprintf(Outfile,"%s\n","#endif");
  3497. }
  3498. }
  3499. *Src=0;
  3500. return 0;
  3501. }
  3502. if(str_cmp(Z,"#inclu")==0)
  3503. {
  3504. strcpy(Src,RemoveStr(lcase(Src),"#include"));
  3505. strcpy(Src,trim(Src));
  3506. fprintf(FP7,"%s%s\n","#include ",Src);
  3507. *Src=0;
  3508. return 0;
  3509. }
  3510. if(str_cmp(Z,"$libra")==0)
  3511. {
  3512. strcpy(Src,replace(Src,"\\","\\\\"));
  3513. strcpy(Src,RemoveStr(lcase(Src),"$library"));
  3514. strcpy(Src,trim(Src));
  3515. AddLibrary(Src);
  3516. *Src=0;
  3517. return 0;
  3518. }
  3519. if(str_cmp(Z,"$nolib")==0)
  3520. {
  3521. strcpy(Src,replace(Src,"\\","\\\\"));
  3522. strcpy(Src,RemoveStr(lcase(Src),"$nolibrary"));
  3523. RemoveLibrary(Src);
  3524. *Src=0;
  3525. return 0;
  3526. }
  3527. break;
  3528. }
  3529. }
  3530. return 2;
  3531. }
  3532. int SubVarType (int TokenNum)
  3533. {
  3534. int k;
  3535. int j=0;
  3536. k=CheckLocal(Stk[TokenNum], &j);
  3537. if(k==vt_CHAR)
  3538. {
  3539. if(*LocalVars[j].VarDim!=91&&LocalVars[j].VarPntr==0)
  3540. {
  3541. k=vt_INTEGER;
  3542. }
  3543. }
  3544. else if(k==vt_UNKNOWN)
  3545. {
  3546. k=CheckGlobal(Stk[TokenNum], &j);
  3547. if(k==vt_CHAR)
  3548. {
  3549. if(*GlobalVars[j].VarDim!=91&&GlobalVars[j].VarPntr==0)
  3550. {
  3551. k=vt_INTEGER;
  3552. }
  3553. }
  3554. }
  3555. j=(UCHAR)*(right(Stk[TokenNum],1));
  3556. for(;;)
  3557. {
  3558. if(k==vt_STRVAR||k==vt_CHAR)
  3559. {
  3560. if(j!=36)
  3561. {
  3562. strcat(Stk[TokenNum],"$");
  3563. }
  3564. break;
  3565. }
  3566. if(k==vt_INTEGER)
  3567. {
  3568. if(j!=37)
  3569. {
  3570. strcat(Stk[TokenNum],"%");
  3571. }
  3572. break;
  3573. }
  3574. if(k==vt_SINGLE)
  3575. {
  3576. if(j!=33)
  3577. {
  3578. strcat(Stk[TokenNum],"!");
  3579. }
  3580. break;
  3581. }
  3582. if(k==vt_DOUBLE)
  3583. {
  3584. if(j!=35)
  3585. {
  3586. strcat(Stk[TokenNum],"#");
  3587. }
  3588. break;
  3589. }
  3590. if(k==vt_LDOUBLE)
  3591. {
  3592. if(j!=166)
  3593. {
  3594. strcat(Stk[TokenNum],"¦");
  3595. }
  3596. }
  3597. break;
  3598. }
  3599. return k;
  3600. }
  3601. char * PrintWriteFormat (int DoWrite)
  3602. {
  3603. char *BCX_RetStr={0};
  3604. ARGTYPE Stak[128];
  3605. char Frmat[2048];
  3606. char Arg[2048];
  3607. char ZZ[2048];
  3608. char Cast[2048];
  3609. int NewLineFlag=0;
  3610. int Argcount=0;
  3611. int i=0;
  3612. int j=0;
  3613. int k=0;
  3614. *Frmat=0;
  3615. *Arg=0;
  3616. *ZZ=0;
  3617. if(str_cmp(Stk[Ndx],";")==0)
  3618. {
  3619. NewLineFlag=TRUE;
  3620. Ndx--;
  3621. }
  3622. if(Ndx==1)
  3623. {
  3624. goto PRINTWRITELABEL;
  3625. }
  3626. Stak[1].ArgType=-1;
  3627. j=2;
  3628. while(j<=Ndx)
  3629. {
  3630. if(str_cmp(Clean(Stk[j]),"BCX_DynaCall")!=0)
  3631. {
  3632. i=SubVarType(j);
  3633. if(Stak[Argcount+1].ArgType==-1)
  3634. {
  3635. if(i==vt_CHAR||i==vt_STRVAR||i==vt_INTEGER||i==vt_SINGLE||i==vt_DOUBLE||i==vt_LDOUBLE)
  3636. {
  3637. Stak[Argcount+1].ArgType=i;
  3638. }
  3639. }
  3640. if(str_cmp(Stk[j],"(")==0)
  3641. {
  3642. i=0;
  3643. for(;;)
  3644. {
  3645. if(str_cmp(Stk[j],"(")==0)
  3646. {
  3647. i++;
  3648. }
  3649. if(str_cmp(Stk[j],")")==0)
  3650. {
  3651. i--;
  3652. }
  3653. strcat(Arg,Stk[j]);
  3654. j++;
  3655. if(i<=0||j>=Ndx)
  3656. {
  3657. break;
  3658. }
  3659. }
  3660. }
  3661. if(str_cmp(Stk[j],"[")==0)
  3662. {
  3663. i=0;
  3664. for(;;)
  3665. {
  3666. if(str_cmp(Stk[j],"[")==0)
  3667. {
  3668. i++;
  3669. }
  3670. if(str_cmp(Stk[j],"]")==0)
  3671. {
  3672. i--;
  3673. }
  3674. strcat(Arg,Stk[j]);
  3675. j++;
  3676. if(str_cmp(Stk[j],"[")==0 && i==0)
  3677. {
  3678. continue;
  3679. }
  3680. if(i<=0||j>=Ndx)
  3681. {
  3682. break;
  3683. }
  3684. }
  3685. }
  3686. if(str_cmp(Stk[j],";")==0 || str_cmp(Stk[j],",")==0 || str_cmp(Stk[j],"&")==0)
  3687. {
  3688. Argcount++;
  3689. strcpy(Stak[Argcount].Arg,Arg);
  3690. Stak[Argcount+1].ArgType=-1;
  3691. *Arg=0;
  3692. j++;
  3693. }
  3694. else
  3695. {
  3696. strcat(Arg,Stk[j]);
  3697. j++;
  3698. }
  3699. }
  3700. else
  3701. {
  3702. strcat(Arg,Stk[j]);
  3703. j++;
  3704. }
  3705. }
  3706. Argcount++;
  3707. strcpy(Stak[Argcount].Arg,Arg);
  3708. *Arg=0;
  3709. for(i=1; i<=Argcount; i+=1)
  3710. {
  3711. j=Stak[i].ArgType;
  3712. if(j==-1)
  3713. {
  3714. strcpy(ZZ,extract(Stak[i].Arg,"("));
  3715. j=DataType(ZZ);
  3716. }
  3717. for(;;)
  3718. {
  3719. if(j==vt_STRLIT||j==vt_STRVAR||j==vt_CHAR)
  3720. {
  3721. if(DoWrite)
  3722. {
  3723. strcpy(Frmat, join(7,Frmat,"\\",DQ,"%s","\\",DQ,","));
  3724. }
  3725. else
  3726. {
  3727. strcat(Frmat,"%s");
  3728. }
  3729. if(str_cmp(left(ZZ,12),"BCX_DynaCall")==0)
  3730. {
  3731. strcpy(Arg, join(3,Arg,",(char*)",Stak[i].Arg));
  3732. }
  3733. else
  3734. {
  3735. strcpy(Arg, join(3,Arg,",",Stak[i].Arg));
  3736. }
  3737. break;
  3738. }
  3739. if(j==vt_INTEGER||j==vt_DECFUNC)
  3740. {
  3741. if(DoWrite)
  3742. {
  3743. strcpy(Frmat, join(3,Frmat,"%d",","));
  3744. }
  3745. else
  3746. {
  3747. strcat(Frmat,"%d");
  3748. }
  3749. strcpy(Arg, join(3,Arg,",(int)",Stak[i].Arg));
  3750. break;
  3751. }
  3752. if(j==vt_SINGLE)
  3753. {
  3754. if(DoWrite)
  3755. {
  3756. strcpy(Frmat, join(3,Frmat,"%.7G",","));
  3757. }
  3758. else
  3759. {
  3760. strcat(Frmat,"%.7G");
  3761. }
  3762. strcpy(Arg, join(3,Arg,",(float)",Stak[i].Arg));
  3763. break;
  3764. }
  3765. if(j==vt_DOUBLE||j==vt_NUMBER)
  3766. {
  3767. if(DoWrite)
  3768. {
  3769. strcpy(Frmat, join(3,Frmat,"%.15G",","));
  3770. }
  3771. else
  3772. {
  3773. strcat(Frmat,"%.15G");
  3774. }
  3775. strcpy(Arg, join(3,Arg,",(double)",Stak[i].Arg));
  3776. break;
  3777. }
  3778. if(j==vt_LDOUBLE)
  3779. {
  3780. if(DoWrite)
  3781. {
  3782. strcpy(Frmat, join(3,Frmat,"%.19LG",","));
  3783. }
  3784. else
  3785. {
  3786. strcat(Frmat,"%.19LG");
  3787. }
  3788. strcpy(Arg, join(3,Arg,",(LDOUBLE)",Stak[i].Arg));
  3789. break;
  3790. }
  3791. // case else
  3792. {
  3793. if((UCHAR)*(Stak[i].Arg)==40)
  3794. {
  3795. *ZZ=0;
  3796. strcat(Arg,",");
  3797. for(;;)
  3798. {
  3799. k=instr_b(Stak[i].Arg,")");
  3800. strcpy(Cast,mid(Stak[i].Arg,1,k));
  3801. strcpy(Stak[i].Arg,trim(mid(Stak[i].Arg,k+1)));
  3802. strcpy(Cast,iReplace(Cast,"char*","char *"));
  3803. strcpy(Cast,iReplace(Cast,"integer","int"));
  3804. strcpy(Cast,iReplace(Cast,"single","float"));
  3805. strcpy(Cast,iReplace(Cast,"ldouble","LDOUBLE"));
  3806. if(ZZ[0]==0)
  3807. {
  3808. if(str_cmp(Cast,"(char *)")==0 || str_cmp(Cast,"(int)")==0 || str_cmp(Cast,"(float)")==0 || str_cmp(Cast,"(double)")==0 || str_cmp(Cast,"(LDOUBLE)")==0)
  3809. {
  3810. strcpy(ZZ,Cast);
  3811. }
  3812. else
  3813. {
  3814. strcpy(ZZ,"(double)");
  3815. strcpy(Cast, join(2,ZZ,Cast));
  3816. }
  3817. RemoveAll(ZZ,"()");
  3818. strcpy(ZZ,iReplace(ZZ,"char *","%s"));
  3819. strcpy(ZZ,iReplace(ZZ,"int","%d"));
  3820. strcpy(ZZ,iReplace(ZZ,"float","%.7G"));
  3821. strcpy(ZZ,iReplace(ZZ,"ldouble","%.19LG"));
  3822. strcpy(ZZ,iReplace(ZZ,"double","%.15G"));
  3823. }
  3824. strcat(Arg,Cast);
  3825. if(!((UCHAR)*(Stak[i].Arg)==40))
  3826. {
  3827. break;
  3828. }
  3829. }
  3830. strcat(Arg,Stak[i].Arg);
  3831. strcat(Frmat,ZZ);
  3832. if(DoWrite)
  3833. {
  3834. strcat(Frmat,",");
  3835. }
  3836. }
  3837. else
  3838. {
  3839. if(DoWrite)
  3840. {
  3841. strcpy(Frmat, join(3,Frmat,"%G",","));
  3842. }
  3843. else
  3844. {
  3845. strcat(Frmat,"%G");
  3846. strcpy(Arg, join(3,Arg,",(float)",Stak[i].Arg));
  3847. }
  3848. }
  3849. }
  3850. break;
  3851. }
  3852. }
  3853. if(DoWrite)
  3854. {
  3855. strcpy(Frmat,left(Frmat,strlen(Frmat)-1));
  3856. }
  3857. PRINTWRITELABEL:;
  3858. if(NewLineFlag==0)
  3859. {
  3860. strcat(Frmat,"\\n");
  3861. }
  3862. BCX_RetStr=join(4,"printf(",enc(Frmat),Clean(Arg),");");
  3863. return BCX_RetStr;
  3864. }
  3865. void EmitInputCode (void)
  3866. {
  3867. int Argcount=0;
  3868. int VarCnt=0;
  3869. int i=0;
  3870. int j=0;
  3871. int l=0;
  3872. char Arg[2048];
  3873. char Tmp[2048];
  3874. char Frmat[2048];
  3875. static char Stak[128][2048];
  3876. memset(&Stak,0,sizeof(Stak));
  3877. char Y[2048];
  3878. char ZZ[2048];
  3879. Use_Inputbuffer=TRUE;
  3880. Use_Scan=TRUE;
  3881. Use_Split=TRUE;
  3882. Use_Remove=TRUE;
  3883. Use_StrStr=TRUE;
  3884. Use_Mid=TRUE;
  3885. Use_Left=TRUE;
  3886. Use_Instr=TRUE;
  3887. Use_Stristr=TRUE;
  3888. UseLCaseTbl=TRUE;
  3889. UseFlag=TRUE;
  3890. Use_Lineinput=TRUE;
  3891. *Arg=0;
  3892. *ZZ=0;
  3893. *Frmat=0;
  3894. strcpy(Tmp, join(7,DQ,",",DQ,",",DQ," ",DQ));
  3895. if(DataType(Stk[2])==vt_STRLIT)
  3896. {
  3897. fprintf(Outfile,"%s%s%s%s\n",Scoot,"printf(",Clean(Stk[2]),");");
  3898. }
  3899. if(DataType(Stk[2])==vt_STRLIT)
  3900. {
  3901. j=4;
  3902. }
  3903. else
  3904. {
  3905. j=2;
  3906. }
  3907. l=j;
  3908. while(j<=Ndx)
  3909. {
  3910. if(j==l)
  3911. {
  3912. i=SubVarType(j);
  3913. }
  3914. if(str_cmp(Stk[j],",")==0)
  3915. {
  3916. l=j+1;
  3917. }
  3918. strcat(ZZ,Stk[j]);
  3919. j++;
  3920. }
  3921. FastLexer(ZZ,"",",");
  3922. j=1;
  3923. while(j<=Ndx)
  3924. {
  3925. if(str_cmp(Stk[j],",")==0)
  3926. {
  3927. Argcount++;
  3928. strcpy(Stak[Argcount],Arg);
  3929. *Arg=0;
  3930. j++;
  3931. }
  3932. else
  3933. {
  3934. strcat(Arg,Stk[j]);
  3935. j++;
  3936. if(j<Ndx)
  3937. {
  3938. if(str_cmp(Stk[j],"[")==0)
  3939. {
  3940. i=0;
  3941. for(;;)
  3942. {
  3943. DOAGAIN:;
  3944. if(str_cmp(Stk[j],"[")==0)
  3945. {
  3946. i++;
  3947. }
  3948. if(str_cmp(Stk[j],"]")==0)
  3949. {
  3950. i--;
  3951. }
  3952. strcat(Arg,Stk[j]);
  3953. j++;
  3954. if(str_cmp(Stk[j],"[")==0 && i==0)
  3955. {
  3956. goto DOAGAIN;
  3957. }
  3958. if(i<=0||j>=Ndx)
  3959. {
  3960. break;
  3961. }
  3962. }
  3963. }
  3964. }
  3965. }
  3966. }
  3967. Argcount++;
  3968. strcpy(Stak[Argcount],Arg);
  3969. *Arg=0;
  3970. for(i=1; i<=Argcount; i+=1)
  3971. {
  3972. strcpy(Y,Stak[i]);
  3973. j=DataType(Y);
  3974. for(;;)
  3975. {
  3976. if(j==vt_STRVAR)
  3977. {
  3978. strcat(Frmat,"%s");
  3979. strcpy(Arg, join(3,Arg,",",Clean(Stak[i])));
  3980. fprintf(Outfile,"%s%s%s%s\n",Scoot,"*",trim(Clean(Stak[i])),"=0;");
  3981. VarCnt++;
  3982. break;
  3983. }
  3984. if(j==vt_INTEGER)
  3985. {
  3986. strcat(Frmat,"%d");
  3987. strcpy(Arg, join(3,Arg,",&",Clean(Stak[i])));
  3988. fprintf(Outfile,"%s%s%s\n",Scoot,Clean(Stak[i]),"=0;");
  3989. VarCnt++;
  3990. break;
  3991. }
  3992. if(j==vt_SINGLE)
  3993. {
  3994. strcat(Frmat,"%g");
  3995. strcpy(Arg, join(3,Arg,",&",Clean(Stak[i])));
  3996. fprintf(Outfile,"%s%s%s\n",Scoot,Clean(Stak[i]),"=0;");
  3997. VarCnt++;
  3998. break;
  3999. }
  4000. if(j==vt_DOUBLE)
  4001. {
  4002. strcat(Frmat,"%lG");
  4003. strcpy(Arg, join(3,Arg,",&",Clean(Stak[i])));
  4004. fprintf(Outfile,"%s%s%s\n",Scoot,Clean(Stak[i]),"=0;");
  4005. VarCnt++;
  4006. break;
  4007. }
  4008. if(j==vt_LDOUBLE)
  4009. {
  4010. strcat(Frmat,"%lG");
  4011. strcpy(Arg, join(3,Arg,",&",Clean(Stak[i])));
  4012. fprintf(Outfile,"%s%s%s\n",Scoot,Clean(Stak[i]),"=0;");
  4013. VarCnt++;
  4014. break;
  4015. }
  4016. // case else
  4017. {
  4018. strcat(Frmat,"%d");
  4019. strcpy(Arg, join(3,Arg,",&",Clean(Stak[i])));
  4020. fprintf(Outfile,"%s%s%s\n",Scoot,Clean(Stak[i]),"=0;");
  4021. VarCnt++;
  4022. }
  4023. break;
  4024. }
  4025. }
  4026. fprintf(Outfile,"%s%s\n",Scoot,"AR_fgets_retval=fgets(InputBuffer,sizeof(InputBuffer),stdin);");
  4027. fprintf(Outfile,"%s%s\n",Scoot,"InputBuffer[strlen(InputBuffer)-1]=0;");
  4028. fprintf(Outfile,"%s%s%s%s%s\n",Scoot,"ScanError = scan(InputBuffer,",enc(Frmat),Arg,");\n");
  4029. fprintf(Outfile,"%s%s\n",Scoot,"*InputBuffer=0;");
  4030. }
  4031. void EmitFileInputCode (void)
  4032. {
  4033. int Argcount=0;
  4034. int VarCnt=0;
  4035. int i;
  4036. int j;
  4037. char Arg[2048];
  4038. char Frmat[2048];
  4039. char FHandle[2048];
  4040. char Y[2048];
  4041. char ZZ[2048];
  4042. static char Stak[128][2048];
  4043. memset(&Stak,0,sizeof(Stak));
  4044. *Arg=0;
  4045. *Frmat=0;
  4046. *ZZ=0;
  4047. *FHandle=0;
  4048. Use_Inputbuffer=TRUE;
  4049. Use_Scan=TRUE;
  4050. Use_Split=TRUE;
  4051. Use_Remove=TRUE;
  4052. Use_StrStr=TRUE;
  4053. Use_Mid=TRUE;
  4054. Use_Left=TRUE;
  4055. Use_Instr=TRUE;
  4056. Use_Stristr=TRUE;
  4057. UseLCaseTbl=TRUE;
  4058. i=4;
  4059. for(j=2; j<=Ndx; j+=1)
  4060. {
  4061. if(*Stk[j]==44)
  4062. {
  4063. i=j+1;
  4064. break;
  4065. }
  4066. strcat(FHandle,Stk[j]);
  4067. }
  4068. for(j=i; j<=Ndx; j+=1)
  4069. {
  4070. if(j==i)
  4071. {
  4072. SubVarType(j);
  4073. }
  4074. if(str_cmp(Stk[j],",")==0)
  4075. {
  4076. SubVarType(j+1);
  4077. }
  4078. strcat(ZZ,Stk[j]);
  4079. }
  4080. FastLexer(ZZ,"",",");
  4081. j=1;
  4082. while(j<=Ndx)
  4083. {
  4084. if(str_cmp(Stk[j],",")==0)
  4085. {
  4086. Argcount++;
  4087. strcpy(Stak[Argcount],Arg);
  4088. *Arg=0;
  4089. j++;
  4090. }
  4091. else
  4092. {
  4093. strcat(Arg,Stk[j]);
  4094. j++;
  4095. if(j<Ndx)
  4096. {
  4097. if(str_cmp(Stk[j],"[")==0)
  4098. {
  4099. i=0;
  4100. for(;;)
  4101. {
  4102. DOAGAIN:;
  4103. if(str_cmp(Stk[j],"[")==0)
  4104. {
  4105. i++;
  4106. }
  4107. if(str_cmp(Stk[j],"]")==0)
  4108. {
  4109. i--;
  4110. }
  4111. strcat(Arg,Stk[j]);
  4112. j++;
  4113. if(str_cmp(Stk[j],"[")==0 && i==0)
  4114. {
  4115. goto DOAGAIN;
  4116. }
  4117. if(i<=0||j>=Ndx)
  4118. {
  4119. break;
  4120. }
  4121. }
  4122. }
  4123. }
  4124. }
  4125. }
  4126. Argcount++;
  4127. strcpy(Stak[Argcount],Arg);
  4128. *Arg=0;
  4129. for(i=1; i<=Argcount; i+=1)
  4130. {
  4131. strcpy(Y,Stak[i]);
  4132. j=DataType(Y);
  4133. for(;;)
  4134. {
  4135. if(j==vt_STRVAR)
  4136. {
  4137. strcat(Frmat,"%s");
  4138. strcpy(Arg, join(3,Arg,",",Clean(Stak[i])));
  4139. fprintf(Outfile,"%s%s%s%s\n",Scoot,"*",trim(Clean(Stak[i])),"=0;");
  4140. VarCnt++;
  4141. break;
  4142. }
  4143. if(j==vt_INTEGER)
  4144. {
  4145. strcat(Frmat,"%d");
  4146. strcpy(Arg, join(3,Arg,",&",Clean(Stak[i])));
  4147. fprintf(Outfile,"%s%s%s\n",Scoot,Clean(Stak[i]),"=0;");
  4148. VarCnt++;
  4149. break;
  4150. }
  4151. if(j==vt_SINGLE)
  4152. {
  4153. strcat(Frmat,"%g");
  4154. strcpy(Arg, join(3,Arg,",&",Clean(Stak[i])));
  4155. fprintf(Outfile,"%s%s%s\n",Scoot,Clean(Stak[i]),"=0;");
  4156. VarCnt++;
  4157. break;
  4158. }
  4159. if(j==vt_DOUBLE)
  4160. {
  4161. strcat(Frmat,"%lG");
  4162. strcpy(Arg, join(3,Arg,",&",Clean(Stak[i])));
  4163. fprintf(Outfile,"%s%s%s\n",Scoot,Clean(Stak[i]),"=0;");
  4164. VarCnt++;
  4165. break;
  4166. }
  4167. if(j==vt_LDOUBLE)
  4168. {
  4169. strcat(Frmat,"%lG");
  4170. strcpy(Arg, join(3,Arg,",&",Clean(Stak[i])));
  4171. fprintf(Outfile,"%s%s%s\n",Scoot,Clean(Stak[i]),"=0;");
  4172. VarCnt++;
  4173. break;
  4174. }
  4175. // case else
  4176. {
  4177. strcat(Frmat,"%d");
  4178. strcpy(Arg, join(3,Arg,",&",Clean(Stak[i])));
  4179. fprintf(Outfile,"%s%s%s\n",Scoot,Clean(Stak[i]),"=0;");
  4180. VarCnt++;
  4181. }
  4182. break;
  4183. }
  4184. }
  4185. fprintf(Outfile,"%s%s%s%s\n",Scoot,"AR_fgets_retval=fgets(InputBuffer,1048576,",FHandle,");");
  4186. fprintf(Outfile,"%s%s\n",Scoot,"if(InputBuffer[strlen(InputBuffer)-1]== 10)");
  4187. fprintf(Outfile,"%s%s\n",Scoot," InputBuffer[strlen(InputBuffer)-1]=0;");
  4188. fprintf(Outfile,"%s%s%s%s%s\n",Scoot,"ScanError = scan(InputBuffer,",enc(Frmat),Arg,");\n");
  4189. fprintf(Outfile,"%s%s\n",Scoot,"*InputBuffer=0;");
  4190. }
  4191. void AddFuncs (void)
  4192. {
  4193. char ZZ[2048];
  4194. char Last[2048];
  4195. *Last=0;
  4196. CloseAll();
  4197. if((FP1=fopen(prcFile,"r"))==0)
  4198. {
  4199. fprintf(stderr,"Can't open file %s\n",prcFile);
  4200. exit(1);
  4201. }
  4202. if((Outfile=fopen(FileOut,"a"))==0)
  4203. {
  4204. fprintf(stderr,"Can't open file %s\n",FileOut);
  4205. exit(1);
  4206. }
  4207. if(ProtoType[1].Prototype[0]>0)
  4208. {
  4209. fprintf(Outfile,"%s\n","");
  4210. fprintf(Outfile,"%s\n","// ************************************");
  4211. fprintf(Outfile,"%s%s\n","// ",BCX_STR_USR_PROCS);
  4212. fprintf(Outfile,"%s\n","// ************************************");
  4213. fprintf(Outfile,"%s\n","\n");
  4214. }
  4215. while(!EoF(FP1))
  4216. {
  4217. ZZ[0]=0;
  4218. AR_fgets_retval=fgets(ZZ,1048576,FP1);
  4219. if(ZZ[strlen(ZZ)-1]==10)ZZ[strlen(ZZ)-1]=0;
  4220. if(instr_b(ZZ,"DefWindowProc"))
  4221. {
  4222. if(instr_b(Last,"return ")||instr_b(Last,"CallWindowProc")||instr_b(Last,"DefWindowProc")||instr_b(Last,"DefMDIChildProc")||instr_b(Last,"DefFrameProc"))
  4223. {
  4224. *Last=0;
  4225. continue;
  4226. }
  4227. }
  4228. fprintf(Outfile,"%s\n",ZZ);
  4229. if(str_cmp(left(ZZ,2),"//")!=0)
  4230. {
  4231. strcpy(Last,ZZ);
  4232. }
  4233. }
  4234. CloseAll();
  4235. remove (prcFile);
  4236. remove (udtFile);
  4237. remove (datFile);
  4238. remove (cstFile);
  4239. remove (ovrFile);
  4240. remove (setFile);
  4241. remove (enuFile);
  4242. }
  4243. int CheckLocal (char *ZZ, int* varidx)
  4244. {
  4245. char TT[2048];
  4246. if(LocalVarCnt)
  4247. {
  4248. strcpy(TT,Clean(ZZ));
  4249. RemoveAll(TT," &*()",1);
  4250. if(instr_b(TT,"["))
  4251. {
  4252. strcpy(TT,left(TT,instr_b(TT,"[")-1));
  4253. }
  4254. {register int i;
  4255. for(i=1; i<=LocalVarCnt; i+=1)
  4256. {
  4257. if(str_cmp(TT,LocalVars[i].VarName)==0)
  4258. {
  4259. (*varidx)=i;
  4260. return LocalVars[i].VarType;
  4261. }
  4262. }
  4263. }
  4264. }
  4265. return vt_UNKNOWN;
  4266. }
  4267. int CheckGlobal (char *ZZ, int* varidx)
  4268. {
  4269. int hn;
  4270. int s;
  4271. char TT[2048];
  4272. strcpy(TT,Clean(ZZ));
  4273. RemoveAll(TT," &*()",1);
  4274. if(instr_b(TT,"["))
  4275. {
  4276. strcpy(TT,left(TT,instr_b(TT,"[")-1));
  4277. }
  4278. hn=HashNumber(TT);
  4279. while(GlobalVarHash[hn])
  4280. {
  4281. s=GlobalVarHash[hn];
  4282. if(str_cmp(TT,GlobalVars[s].VarName)==0)
  4283. {
  4284. (*varidx)=s;
  4285. return GlobalVars[s].VarType;
  4286. }
  4287. hn=imod(hn+1,MaxGlobalVars);
  4288. }
  4289. return vt_UNKNOWN;
  4290. }
  4291. int CheckType (char *ZZ)
  4292. {
  4293. char Keyword[2048];
  4294. int varid=0;
  4295. int i;
  4296. strcpy(Keyword,lcase(ZZ));
  4297. for(;;)
  4298. {
  4299. if(str_cmp(Keyword,"int")==0)
  4300. {
  4301. return vt_INTEGER;
  4302. }
  4303. if(str_cmp(Keyword,"string")==0)
  4304. {
  4305. return vt_STRVAR;
  4306. }
  4307. if(str_cmp(Keyword,"char")==0)
  4308. {
  4309. return vt_CHAR;
  4310. }
  4311. if(str_cmp(Keyword,"pchar")==0)
  4312. {
  4313. return vt_PCHAR;
  4314. }
  4315. if(str_cmp(Keyword,"byte")==0)
  4316. {
  4317. return vt_BYTE;
  4318. }
  4319. if(str_cmp(Keyword,"double")==0)
  4320. {
  4321. return vt_DOUBLE;
  4322. }
  4323. if(str_cmp(Keyword,"ldouble")==0)
  4324. {
  4325. return vt_LDOUBLE;
  4326. }
  4327. if(str_cmp(Keyword,"file")==0)
  4328. {
  4329. return vt_FILEPTR;
  4330. }
  4331. if(str_cmp(Keyword,"float")==0)
  4332. {
  4333. return vt_SINGLE;
  4334. }
  4335. if(str_cmp(Keyword,"bool")==0 || str_cmp(Keyword,"boolean")==0)
  4336. {
  4337. return vt_BOOL;
  4338. }
  4339. if(str_cmp(Keyword,"long")==0)
  4340. {
  4341. return vt_LONG;
  4342. }
  4343. if(str_cmp(Keyword,"dword")==0)
  4344. {
  4345. return vt_DWORD;
  4346. }
  4347. if(str_cmp(Keyword,"farproc")==0)
  4348. {
  4349. return vt_FARPROC;
  4350. }
  4351. if(str_cmp(Keyword,"void")==0)
  4352. {
  4353. return vt_VOID;
  4354. }
  4355. if(str_cmp(Keyword,"lpbyte")==0)
  4356. {
  4357. return vt_LPBYTE;
  4358. }
  4359. if(str_cmp(Keyword,"lresult")==0)
  4360. {
  4361. return vt_LRESULT;
  4362. }
  4363. if(str_cmp(Keyword,"short")==0)
  4364. {
  4365. return vt_SHORT;
  4366. }
  4367. if(str_cmp(Keyword,"ushort")==0)
  4368. {
  4369. return vt_USHORT;
  4370. }
  4371. if(str_cmp(Keyword,"uint")==0)
  4372. {
  4373. return vt_UINT;
  4374. }
  4375. if(str_cmp(Keyword,"ulong")==0)
  4376. {
  4377. return vt_ULONG;
  4378. }
  4379. if(str_cmp(Keyword,"colorref")==0)
  4380. {
  4381. return vt_COLORREF;
  4382. }
  4383. if(str_cmp(Keyword,"handle")==0)
  4384. {
  4385. return vt_HANDLE;
  4386. }
  4387. if(str_cmp(Keyword,"hdc")==0)
  4388. {
  4389. return vt_HDC;
  4390. }
  4391. if(str_cmp(Keyword,"variant")==0)
  4392. {
  4393. return vt_VARIANT;
  4394. }
  4395. break;
  4396. }
  4397. i=CheckLocal(ZZ, &varid);
  4398. if(i==vt_UNKNOWN)
  4399. {
  4400. i=DefsID(ZZ);
  4401. if(i)
  4402. {
  4403. return TypeDefs[i].TypeofDef;
  4404. }
  4405. }
  4406. else
  4407. {
  4408. return i;
  4409. }
  4410. return CheckGlobal(ZZ, &varid);
  4411. }
  4412. void ExportInternalConst (void)
  4413. {
  4414. if(Use_FillArray)
  4415. {
  4416. strcpy(Src,"CONST vt_INTEGER = 2");
  4417. PassOne=1;
  4418. Parse(Src);
  4419. Emit();
  4420. strcpy(Src,"CONST vt_SINGLE = 3");
  4421. PassOne=1;
  4422. Parse(Src);
  4423. Emit();
  4424. strcpy(Src,"CONST vt_DOUBLE = 4");
  4425. PassOne=1;
  4426. Parse(Src);
  4427. Emit();
  4428. strcpy(Src,"CONST vt_LDOUBLE = 5");
  4429. PassOne=1;
  4430. Parse(Src);
  4431. Emit();
  4432. }
  4433. }
  4434. int RestrictedWords (char *ZZ)
  4435. {
  4436. if(str_cmp(ZZ,"CmdLine")==0)
  4437. {
  4438. return 1;
  4439. }
  4440. if(str_cmp(ZZ,"CmdShow")==0)
  4441. {
  4442. return 1;
  4443. }
  4444. if(str_cmp(ZZ,"hInst")==0)
  4445. {
  4446. return 1;
  4447. }
  4448. if(str_cmp(ZZ,"hPrev")==0)
  4449. {
  4450. return 1;
  4451. }
  4452. if(str_cmp(ZZ,"hWnd")==0)
  4453. {
  4454. return 1;
  4455. }
  4456. if(str_cmp(ZZ,"lParam")==0)
  4457. {
  4458. return 1;
  4459. }
  4460. if(str_cmp(ZZ,"Msg")==0)
  4461. {
  4462. return 1;
  4463. }
  4464. if(str_cmp(ZZ,"wParam")==0)
  4465. {
  4466. return 1;
  4467. }
  4468. if(str_cmp(ZZ,"vt_INTEGER")==0)
  4469. {
  4470. return 1;
  4471. }
  4472. if(str_cmp(ZZ,"vt_SINGLE")==0)
  4473. {
  4474. return 1;
  4475. }
  4476. if(str_cmp(ZZ,"vt_DOUBLE")==0)
  4477. {
  4478. return 1;
  4479. }
  4480. if(str_cmp(ZZ,"vt_LDOUBLE")==0)
  4481. {
  4482. return 1;
  4483. }
  4484. return 0;
  4485. }
  4486. int DataType (char *ZZ)
  4487. {
  4488. char Keyword[2048];
  4489. int i;
  4490. if(ZZ[0]==34)
  4491. {
  4492. return vt_STRLIT;
  4493. }
  4494. if(inchr(ZZ,"$"))
  4495. {
  4496. return vt_STRVAR;
  4497. }
  4498. if(IsNumber(ZZ))
  4499. {
  4500. return vt_NUMBER;
  4501. }
  4502. i=DefsID(ZZ);
  4503. if(i)
  4504. {
  4505. return TypeDefs[i].TypeofDef;
  4506. }
  4507. strcpy(Keyword,lcase(ZZ));
  4508. if(str_cmp(Keyword,"strlen")==0)
  4509. {
  4510. return vt_DECFUNC;
  4511. }
  4512. if(str_cmp(Keyword,"instr")==0)
  4513. {
  4514. return vt_DECFUNC;
  4515. }
  4516. if(str_cmp(Keyword,"inchr")==0)
  4517. {
  4518. return vt_DECFUNC;
  4519. }
  4520. if(str_cmp(Keyword,"sizeof")==0)
  4521. {
  4522. return vt_DECFUNC;
  4523. }
  4524. if(str_cmp(Keyword,"tally")==0)
  4525. {
  4526. return vt_DECFUNC;
  4527. }
  4528. if(str_cmp(Keyword,"band")==0)
  4529. {
  4530. return vt_DECFUNC;
  4531. }
  4532. if(str_cmp(Keyword,"bor")==0)
  4533. {
  4534. return vt_DECFUNC;
  4535. }
  4536. if(str_cmp(Keyword,"lof")==0)
  4537. {
  4538. return vt_DOUBLE;
  4539. }
  4540. if(str_cmp(Keyword,"pos")==0)
  4541. {
  4542. return vt_DECFUNC;
  4543. }
  4544. if(str_cmp(Keyword,"qbcolor")==0)
  4545. {
  4546. return vt_DECFUNC;
  4547. }
  4548. if(str_cmp(Keyword,"split")==0)
  4549. {
  4550. return vt_DECFUNC;
  4551. }
  4552. if(str_cmp(Keyword,"dsplit")==0)
  4553. {
  4554. return vt_DECFUNC;
  4555. }
  4556. if(str_cmp(Keyword,"sgn")==0)
  4557. {
  4558. return vt_DECFUNC;
  4559. }
  4560. if(str_cmp(Keyword,"timer")==0)
  4561. {
  4562. return vt_SINGLE;
  4563. }
  4564. if(str_cmp(Keyword,"keypress()")==0)
  4565. {
  4566. return vt_DECFUNC;
  4567. }
  4568. if(str_cmp(Keyword,"getattr")==0)
  4569. {
  4570. return vt_DECFUNC;
  4571. }
  4572. if(str_cmp(Keyword,"fix")==0)
  4573. {
  4574. return vt_DECFUNC;
  4575. }
  4576. if(str_cmp(Keyword,"instrrev")==0)
  4577. {
  4578. return vt_DECFUNC;
  4579. }
  4580. if(str_cmp(Keyword,"kbhit")==0)
  4581. {
  4582. return vt_DECFUNC;
  4583. }
  4584. if(str_cmp(Keyword,"exp")==0)
  4585. {
  4586. return vt_DOUBLE;
  4587. }
  4588. if(str_cmp(Keyword,"expl")==0)
  4589. {
  4590. return vt_LDOUBLE;
  4591. }
  4592. if(str_cmp(Keyword,"sinh")==0)
  4593. {
  4594. return vt_DOUBLE;
  4595. }
  4596. if(str_cmp(Keyword,"cosh")==0)
  4597. {
  4598. return vt_DOUBLE;
  4599. }
  4600. if(str_cmp(Keyword,"tanh")==0)
  4601. {
  4602. return vt_DOUBLE;
  4603. }
  4604. if(str_cmp(Keyword,"asinh")==0)
  4605. {
  4606. return vt_DOUBLE;
  4607. }
  4608. if(str_cmp(Keyword,"acosh")==0)
  4609. {
  4610. return vt_DOUBLE;
  4611. }
  4612. if(str_cmp(Keyword,"atanh")==0)
  4613. {
  4614. return vt_DOUBLE;
  4615. }
  4616. if(str_cmp(Keyword,"round")==0)
  4617. {
  4618. return vt_DOUBLE;
  4619. }
  4620. if(str_cmp(Keyword,"val")==0)
  4621. {
  4622. return vt_DOUBLE;
  4623. }
  4624. if(str_cmp(Keyword,"vall")==0)
  4625. {
  4626. return vt_LDOUBLE;
  4627. }
  4628. if(str_cmp(Keyword,"iif")==0)
  4629. {
  4630. return vt_DOUBLE;
  4631. }
  4632. if(str_cmp(Keyword,"bin2dec")==0)
  4633. {
  4634. return vt_INTEGER;
  4635. }
  4636. if(str_cmp(Keyword,"hex2dec")==0)
  4637. {
  4638. return vt_INTEGER;
  4639. }
  4640. if(str_cmp(Keyword,"rnd")==0)
  4641. {
  4642. return vt_SINGLE;
  4643. }
  4644. if(str_cmp(Keyword,"frac")==0)
  4645. {
  4646. return vt_DOUBLE;
  4647. }
  4648. if(str_cmp(Keyword,"fracl")==0)
  4649. {
  4650. return vt_LDOUBLE;
  4651. }
  4652. if(str_cmp(Keyword,"asin")==0)
  4653. {
  4654. return vt_DOUBLE;
  4655. }
  4656. if(str_cmp(Keyword,"asinl")==0)
  4657. {
  4658. return vt_LDOUBLE;
  4659. }
  4660. if(str_cmp(Keyword,"hypot")==0)
  4661. {
  4662. return vt_DOUBLE;
  4663. }
  4664. if(str_cmp(Keyword,"hypotl")==0)
  4665. {
  4666. return vt_LDOUBLE;
  4667. }
  4668. if(str_cmp(Keyword,"log")==0)
  4669. {
  4670. return vt_DOUBLE;
  4671. }
  4672. if(str_cmp(Keyword,"logl")==0)
  4673. {
  4674. return vt_LDOUBLE;
  4675. }
  4676. if(str_cmp(Keyword,"log10")==0)
  4677. {
  4678. return vt_DOUBLE;
  4679. }
  4680. if(str_cmp(Keyword,"log10l")==0)
  4681. {
  4682. return vt_LDOUBLE;
  4683. }
  4684. if(str_cmp(Keyword,"acos")==0)
  4685. {
  4686. return vt_DOUBLE;
  4687. }
  4688. if(str_cmp(Keyword,"acosl")==0)
  4689. {
  4690. return vt_LDOUBLE;
  4691. }
  4692. if(str_cmp(Keyword,"atan")==0)
  4693. {
  4694. return vt_DOUBLE;
  4695. }
  4696. if(str_cmp(Keyword,"atanl")==0)
  4697. {
  4698. return vt_DOUBLE;
  4699. }
  4700. if(str_cmp(Keyword,"sin")==0)
  4701. {
  4702. return vt_DOUBLE;
  4703. }
  4704. if(str_cmp(Keyword,"sinl")==0)
  4705. {
  4706. return vt_LDOUBLE;
  4707. }
  4708. if(str_cmp(Keyword,"cos")==0)
  4709. {
  4710. return vt_DOUBLE;
  4711. }
  4712. if(str_cmp(Keyword,"cosl")==0)
  4713. {
  4714. return vt_LDOUBLE;
  4715. }
  4716. if(str_cmp(Keyword,"tan")==0)
  4717. {
  4718. return vt_DOUBLE;
  4719. }
  4720. if(str_cmp(Keyword,"tanl")==0)
  4721. {
  4722. return vt_LDOUBLE;
  4723. }
  4724. if(str_cmp(Keyword,"pow")==0)
  4725. {
  4726. return vt_DOUBLE;
  4727. }
  4728. if(str_cmp(Keyword,"powl")==0)
  4729. {
  4730. return vt_LDOUBLE;
  4731. }
  4732. if(str_cmp(Keyword,"sqrt")==0)
  4733. {
  4734. return vt_DOUBLE;
  4735. }
  4736. if(str_cmp(Keyword,"sqrtl")==0)
  4737. {
  4738. return vt_LDOUBLE;
  4739. }
  4740. if(str_cmp(Keyword,"min")==0)
  4741. {
  4742. return vt_DOUBLE;
  4743. }
  4744. if(str_cmp(Keyword,"max")==0)
  4745. {
  4746. return vt_DOUBLE;
  4747. }
  4748. if(str_cmp(Keyword,"exist")==0)
  4749. {
  4750. return vt_DECFUNC;
  4751. }
  4752. if(str_cmp(Keyword,"abs")==0)
  4753. {
  4754. return vt_DOUBLE;
  4755. }
  4756. if(str_cmp(Keyword,"absl")==0)
  4757. {
  4758. return vt_LDOUBLE;
  4759. }
  4760. if(str_cmp(Keyword,"freefile")==0)
  4761. {
  4762. return vt_FILEPTR;
  4763. }
  4764. if(str_cmp(Keyword,"fint")==0)
  4765. {
  4766. return vt_INTEGER;
  4767. }
  4768. if(inchr(ZZ,"%"))
  4769. {
  4770. return vt_INTEGER;
  4771. }
  4772. if(inchr(ZZ,"!"))
  4773. {
  4774. return vt_SINGLE;
  4775. }
  4776. if(inchr(ZZ,"#"))
  4777. {
  4778. return vt_DOUBLE;
  4779. }
  4780. if(inchr(ZZ,"^"))
  4781. {
  4782. return vt_DOUBLE;
  4783. }
  4784. if(inchr(ZZ,"¦"))
  4785. {
  4786. return vt_LDOUBLE;
  4787. }
  4788. if(iMatchRgt(ZZ,"@"))
  4789. {
  4790. return vt_FILEPTR;
  4791. }
  4792. if(inchr(ZZ," "))
  4793. {
  4794. return vt_UDT;
  4795. }
  4796. if(isalpha(*ZZ))
  4797. {
  4798. return vt_INTEGER;
  4799. }
  4800. return vt_UNKNOWN;
  4801. }
  4802. void CloseAll (void)
  4803. {
  4804. #if defined (__APPLE__)
  4805. if(SourceFile)
  4806. {
  4807. fclose(SourceFile);
  4808. SourceFile=NULL;
  4809. }
  4810. if(FP2)
  4811. {
  4812. fclose(FP2);
  4813. FP2=NULL;
  4814. }
  4815. if(FP3)
  4816. {
  4817. fclose(FP3);
  4818. FP3=NULL;
  4819. }
  4820. if(FP4)
  4821. {
  4822. fclose(FP4);
  4823. FP4=NULL;
  4824. }
  4825. if(FP5)
  4826. {
  4827. fclose(FP5);
  4828. FP5=NULL;
  4829. }
  4830. if(FP6)
  4831. {
  4832. fclose(FP6);
  4833. FP6=NULL;
  4834. }
  4835. if(FP7)
  4836. {
  4837. fclose(FP7);
  4838. FP7=NULL;
  4839. }
  4840. if(FP8)
  4841. {
  4842. fclose(FP8);
  4843. FP8=NULL;
  4844. }
  4845. if(FP9)
  4846. {
  4847. fclose(FP9);
  4848. FP9=NULL;
  4849. }
  4850. if(FP10)
  4851. {
  4852. fclose(FP10);
  4853. FP10=NULL;
  4854. }
  4855. if(FP11)
  4856. {
  4857. fclose(FP11);
  4858. FP11=NULL;
  4859. }
  4860. if(Outfile)
  4861. {
  4862. fclose(Outfile);
  4863. Outfile=NULL;
  4864. }
  4865. if(FP1)
  4866. {
  4867. fclose(FP1);
  4868. FP1=NULL;
  4869. }
  4870. if(ResIn)
  4871. {
  4872. fclose(ResIn);
  4873. ResIn=NULL;
  4874. }
  4875. if(ResOut)
  4876. {
  4877. fclose(ResOut);
  4878. ResOut=NULL;
  4879. }
  4880. if(UserResIn)
  4881. {
  4882. fclose(UserResIn);
  4883. UserResIn=NULL;
  4884. }
  4885. if(fpErr)
  4886. {
  4887. fclose(fpErr);
  4888. fpErr=NULL;
  4889. }
  4890. if(fpHFile)
  4891. {
  4892. fclose(fpHFile);
  4893. fpHFile=NULL;
  4894. }
  4895. if(FP68)
  4896. {
  4897. fclose(FP68);
  4898. FP68=NULL;
  4899. }
  4900. if(fpdef)
  4901. {
  4902. fclose(fpdef);
  4903. fpdef=NULL;
  4904. }
  4905. if(SaveOutfileNum)
  4906. {
  4907. fclose(SaveOutfileNum);
  4908. SaveOutfileNum=NULL;
  4909. }
  4910. #else
  4911. fcloseall();
  4912. #endif
  4913. }
  4914. char * Clean (char *ZZ)
  4915. {
  4916. char *BCX_RetStr={0};
  4917. char Tmp[2048];
  4918. if(inchr(ZZ,"%"))
  4919. {
  4920. if(str_cmp(trim(ZZ),"%")==0)
  4921. {
  4922. BCX_RetStr=BCX_TmpStr(strlen(" % "));
  4923. strcpy(BCX_RetStr," % ");
  4924. return BCX_RetStr;
  4925. }
  4926. }
  4927. if(iMatchNQ(ZZ,"!="))
  4928. {
  4929. BCX_RetStr=BCX_TmpStr(strlen(ZZ));
  4930. strcpy(BCX_RetStr,ZZ);
  4931. return BCX_RetStr;
  4932. }
  4933. strcpy(Tmp,ZZ);
  4934. RemoveAll(Tmp,"%$#!@¦",1);
  4935. BCX_RetStr=BCX_TmpStr(strlen(Tmp));
  4936. strcpy(BCX_RetStr,Tmp);
  4937. return BCX_RetStr;
  4938. }
  4939. void RemoveAll (char * Arg,char * MatchChars,int qtflag)
  4940. {
  4941. PCHAR C=Arg;
  4942. PCHAR pmc;
  4943. while(*Arg)
  4944. {
  4945. if(qtflag)
  4946. {
  4947. if(*Arg==34)
  4948. {
  4949. *(C++)=*Arg;
  4950. while(*(++Arg)!=34)
  4951. {
  4952. *(C++)=*Arg;
  4953. if(*Arg==0)
  4954. {
  4955. return;
  4956. }
  4957. }
  4958. *(C++)=*(Arg++);
  4959. continue;
  4960. }
  4961. }
  4962. pmc=MatchChars;
  4963. while(*pmc)
  4964. {
  4965. if(*(pmc++)==*Arg)
  4966. {
  4967. goto SKIP;
  4968. }
  4969. }
  4970. *(C++)=*Arg;
  4971. SKIP:;
  4972. Arg++;
  4973. }
  4974. *C=0;
  4975. }
  4976. void Warning (char * ZZ,int WarnLvl)
  4977. {
  4978. static FILE *fErr;
  4979. memset(&fErr,0,sizeof(fErr));
  4980. if(WarnLvl)
  4981. {
  4982. strcpy(WarnMsg, join(7,WarnMsg," Line",str(ModuleLineNos[ModuleNdx])," in Module: ",trim(Modules[ModuleNdx])," - ",ZZ));
  4983. }
  4984. else
  4985. {
  4986. strcat(WarnMsg,ZZ);
  4987. }
  4988. strcat(WarnMsg,CRLF);
  4989. if(ErrFile)
  4990. {
  4991. if((fErr=fopen(FileErr,"a"))==0)
  4992. {
  4993. fprintf(stderr,"Can't open file %s\n",FileErr);
  4994. exit(1);
  4995. }
  4996. fprintf(fErr,"%s%s\n","WARNING ",ZZ);
  4997. if(fErr)
  4998. {
  4999. fclose(fErr);
  5000. fErr=NULL;
  5001. }
  5002. }
  5003. }
  5004. PCHAR GetVarTypeName (int i)
  5005. {
  5006. static char A[2048];
  5007. for(;;)
  5008. {
  5009. if(i==vt_INTEGER)
  5010. {
  5011. strcpy(A,"int");
  5012. break;
  5013. }
  5014. if(i==vt_STRVAR)
  5015. {
  5016. strcpy(A,"char *");
  5017. break;
  5018. }
  5019. if(i==vt_STRLIT)
  5020. {
  5021. strcpy(A,"STRLIT");
  5022. break;
  5023. }
  5024. if(i==vt_UNKNOWN)
  5025. {
  5026. strcpy(A,"UNKNOWN");
  5027. break;
  5028. }
  5029. if(i==vt_SINGLE)
  5030. {
  5031. strcpy(A,"float");
  5032. break;
  5033. }
  5034. if(i==vt_DOUBLE)
  5035. {
  5036. strcpy(A,"double");
  5037. break;
  5038. }
  5039. if(i==vt_LDOUBLE)
  5040. {
  5041. strcpy(A,"LDOUBLE");
  5042. break;
  5043. }
  5044. if(i==vt_DECFUNC)
  5045. {
  5046. strcpy(A,"DECFUNC");
  5047. break;
  5048. }
  5049. if(i==vt_NUMBER)
  5050. {
  5051. strcpy(A,"NUMBER");
  5052. break;
  5053. }
  5054. if(i==vt_FILEPTR)
  5055. {
  5056. strcpy(A,"FILE*");
  5057. break;
  5058. }
  5059. if(i==vt_UDT)
  5060. {
  5061. strcpy(A,"struct");
  5062. break;
  5063. }
  5064. if(i==vt_STRUCT)
  5065. {
  5066. strcpy(A,"struct");
  5067. break;
  5068. }
  5069. if(i==vt_UNION)
  5070. {
  5071. strcpy(A,"union");
  5072. break;
  5073. }
  5074. if(i==vt_BOOL)
  5075. {
  5076. strcpy(A,"bool");
  5077. break;
  5078. }
  5079. if(i==vt_CHAR)
  5080. {
  5081. strcpy(A,"char");
  5082. break;
  5083. }
  5084. if(i==vt_CHARPTR)
  5085. {
  5086. strcpy(A,"char");
  5087. break;
  5088. }
  5089. if(i==vt_PCHAR)
  5090. {
  5091. strcpy(A,"PCHAR");
  5092. break;
  5093. }
  5094. if(i==vt_VOID)
  5095. {
  5096. strcpy(A,"void");
  5097. break;
  5098. }
  5099. if(i==vt_LONG)
  5100. {
  5101. strcpy(A,"long");
  5102. break;
  5103. }
  5104. if(i==vt_DWORD)
  5105. {
  5106. strcpy(A,"DWORD");
  5107. break;
  5108. }
  5109. if(i==vt_FARPROC)
  5110. {
  5111. strcpy(A,"FARPROC");
  5112. break;
  5113. }
  5114. if(i==vt_LPBYTE)
  5115. {
  5116. strcpy(A,"LPBYTE");
  5117. break;
  5118. }
  5119. if(i==vt_LRESULT)
  5120. {
  5121. strcpy(A,"LRESULT");
  5122. break;
  5123. }
  5124. if(i==vt_BYTE)
  5125. {
  5126. strcpy(A,"BYTE");
  5127. break;
  5128. }
  5129. if(i==vt_SHORT)
  5130. {
  5131. strcpy(A,"short");
  5132. break;
  5133. }
  5134. if(i==vt_USHORT)
  5135. {
  5136. strcpy(A,"USHORT");
  5137. break;
  5138. }
  5139. if(i==vt_COLORREF)
  5140. {
  5141. strcpy(A,"COLORREF");
  5142. break;
  5143. }
  5144. if(i==vt_UINT)
  5145. {
  5146. strcpy(A,"UINT");
  5147. break;
  5148. }
  5149. if(i==vt_ULONG)
  5150. {
  5151. strcpy(A,"ULONG");
  5152. break;
  5153. }
  5154. if(i==vt_HANDLE)
  5155. {
  5156. strcpy(A,"HANDLE");
  5157. break;
  5158. }
  5159. if(i==vt_HINSTANCE)
  5160. {
  5161. strcpy(A,"HINSTANCE");
  5162. break;
  5163. }
  5164. if(i==vt_HDC)
  5165. {
  5166. strcpy(A,"HDC");
  5167. break;
  5168. }
  5169. if(i==vt_VARIANT)
  5170. {
  5171. strcpy(A,"VARIANT");
  5172. break;
  5173. }
  5174. // case else
  5175. {
  5176. *A=0;
  5177. }
  5178. break;
  5179. }
  5180. return A;
  5181. }
  5182. int HashNumber (char *HT)
  5183. {
  5184. char* TT;
  5185. ULONG i=0;
  5186. TT=HT;
  5187. while(*TT)
  5188. {
  5189. i<<=1;
  5190. i ^= *TT;
  5191. TT++;
  5192. }
  5193. return imod(i,MaxGlobalVars);
  5194. }
  5195. void AddLibrary (char *LibName)
  5196. {
  5197. static int nTimes;
  5198. static int nLibNdx;
  5199. memset(&nLibNdx,0,sizeof(nLibNdx));
  5200. char TempLibName[2048];
  5201. strcpy(TempLibName,lcase(LibName));
  5202. if(!inchr(TempLibName,DQ)&&!inchr(TempLibName,"<"))
  5203. {
  5204. strcpy(TempLibName,enc(TempLibName,60,62));
  5205. }
  5206. if(nTimes==0)
  5207. {
  5208. {register int i;
  5209. for(i=0; i<=MaxLib-1; i+=1)
  5210. {
  5211. *Library[i]=0;
  5212. }
  5213. }
  5214. nTimes++;
  5215. strcpy(Library[0],TempLibName);
  5216. return;
  5217. }
  5218. nLibNdx=0;
  5219. while(Library[nLibNdx][0]!=0)
  5220. {
  5221. if(str_cmp(Library[nLibNdx],TempLibName)==0)
  5222. {
  5223. return;
  5224. }
  5225. nLibNdx++;
  5226. }
  5227. if(nLibNdx<MaxLib-1)
  5228. {
  5229. strcpy(Library[nLibNdx],TempLibName);
  5230. }
  5231. }
  5232. void RemoveLibrary (char *LibName)
  5233. {
  5234. if(!instr_b(RmLibs,LibName,1,1))
  5235. {
  5236. strcpy(RmLibs, join(3,RmLibs,",",lcase(LibName)));
  5237. }
  5238. }
  5239. void EmitLibs (void)
  5240. {
  5241. static int nTimes;
  5242. static int nCount;
  5243. char ltmp[2048];
  5244. if(nTimes>0)
  5245. {
  5246. return;
  5247. }
  5248. nTimes++;
  5249. if(Library[0][0]==0)
  5250. {
  5251. return;
  5252. }
  5253. fprintf(FP7,"%s\n","");
  5254. fprintf(FP7,"%s\n","#ifndef LINUXBCX");
  5255. fprintf(FP7,"%s\n","#if !defined( __LCC__ )");
  5256. {register int i;
  5257. for(i=0; i<=MaxLib-1; i+=1)
  5258. {
  5259. if(Library[i][0]==0&&nCount>0)
  5260. {
  5261. goto NEXTLIB;
  5262. }
  5263. else if(Library[i][0]==0)
  5264. {
  5265. goto NEXTLIB;
  5266. }
  5267. strcpy(ltmp,Library[i]);
  5268. RemoveAll(ltmp,join(2,"<>",DQ));
  5269. if(instr_b(RmLibs,ltmp))
  5270. {
  5271. continue;
  5272. }
  5273. if(nCount==0)
  5274. {
  5275. nCount++;
  5276. fprintf(FP7,"%s\n","// *************************************************");
  5277. fprintf(FP7,"%s\n","// Instruct Linker to Search Object/Import Libraries");
  5278. fprintf(FP7,"%s\n","// *************************************************");
  5279. }
  5280. fprintf(FP7,"%s%s%s\n","#pragma comment(lib,",enc(ltmp),")");
  5281. }
  5282. }
  5283. NEXTLIB:;
  5284. fprintf(FP7,"%s\n","#else");
  5285. strcat(RmLibs,",<libc.lib>,<kernel32.lib>,<comdlg32.lib>,<user32.lib>,<gdi32.lib>,<advapi32.lib>,<comctl32.lib>,<crtdll.lib>");
  5286. {register int i;
  5287. for(i=0; i<=MaxLib-1; i+=1)
  5288. {
  5289. if(Library[i][0]==0&&nCount>0)
  5290. {
  5291. fprintf(FP7,"%s\n","// *************************************************");
  5292. fprintf(FP7,"%s\n","// End of Object/Import Libraries To Search");
  5293. fprintf(FP7,"%s\n","// *************************************************");
  5294. goto LIBEND;
  5295. }
  5296. else if(Library[i][0]==0)
  5297. {
  5298. goto LIBEND;
  5299. }
  5300. if(instr_b(RmLibs,Library[i]))
  5301. {
  5302. continue;
  5303. }
  5304. if(nCount==0)
  5305. {
  5306. nCount++;
  5307. fprintf(FP7,"%s\n","");
  5308. fprintf(FP7,"%s\n","// *************************************************");
  5309. fprintf(FP7,"%s\n","// Instruct Linker to Search Object/Import Libraries");
  5310. fprintf(FP7,"%s\n","// *************************************************");
  5311. }
  5312. fprintf(FP7,"%s%s\n","#pragma lib ",Library[i]);
  5313. }
  5314. }
  5315. LIBEND:;
  5316. fprintf(FP7,"%s\n","#endif");
  5317. fprintf(FP7,"%s\n","#endif // LINUXBCX not defined");
  5318. }
  5319. void AddGlobal (char * GlobalName,int GlobalType,int GlobalDef,char * GlobalDim,int GlobalPtr,int GlobalFS,int GlobalExtn,int iEmitted,int iConst)
  5320. {
  5321. char FirstVar[2048];
  5322. char SecondVar[2048];
  5323. char Warn[2048];
  5324. int ss;
  5325. int s;
  5326. if(RestrictedWords(GlobalName)&&TestState)
  5327. {
  5328. strcpy(Warn, join(3,"Restricted Word ",GlobalName," on Line"));
  5329. strcpy(Warn, join(4,Warn,str(ModuleLineNos[ModuleNdx])," in Module: ",trim(Modules[ModuleNdx])));
  5330. Warning(Warn);
  5331. }
  5332. ss=HashNumber(GlobalName);
  5333. while(GlobalVarHash[ss])
  5334. {
  5335. s=GlobalVarHash[ss];
  5336. if(str_cmp(GlobalName,GlobalVars[s].VarName)==0)
  5337. {
  5338. if(InConditional==0||(InConditional>0&&str_cmp(InIfDef,GlobalVars[s].VarCondDef)==0))
  5339. {
  5340. if(GlobalVars[s].VarType!=GlobalType||str_cmp(GlobalDim,GlobalVars[s].VarDim)!=0 || GlobalVars[s].VarDef!=GlobalDef)
  5341. {
  5342. strcpy(FirstVar, join(11,"Line",str(ModuleLineNos[ModuleNdx])," in Module: ",trim(Modules[ModuleNdx])," : ",GlobalName,GlobalDim," as ",GetVarTypeName(GlobalType)," ",TypeDefs[GlobalDef].VarName));
  5343. strcpy(SecondVar, join(11,"Line",str(GlobalVars[s].VarLine)," in Module: ",GlobalVars[s].VarModule," : ",GlobalName,GlobalVars[s].VarDim," as ",GetVarTypeName(GlobalVars[s].VarType)," ",TypeDefs[GlobalVars[s].VarDef].VarName));
  5344. strcpy(Warn, join(4,"Two Variables ",FirstVar," previously defined at ",SecondVar));
  5345. Warning(Warn);
  5346. }
  5347. return;
  5348. }
  5349. }
  5350. ss=imod(ss+1,MaxGlobalVars);
  5351. }
  5352. GlobalVarCnt++;
  5353. if(GlobalVarCnt==MaxGlobalVars)
  5354. {
  5355. Abort("Maximum Global Variables reached.");
  5356. }
  5357. strcpy(GlobalVars[GlobalVarCnt].VarName,GlobalName);
  5358. GlobalVars[GlobalVarCnt].VarType=GlobalType;
  5359. GlobalVars[GlobalVarCnt].VarDef=GlobalDef;
  5360. strcpy(GlobalVars[GlobalVarCnt].VarDim,GlobalDim);
  5361. GlobalVars[GlobalVarCnt].VarLine=ModuleLineNos[ModuleNdx];
  5362. GlobalVars[GlobalVarCnt].VarPntr=GlobalPtr;
  5363. GlobalVars[GlobalVarCnt].VarSF=GlobalFS;
  5364. GlobalVars[GlobalVarCnt].VarEmitFlag=iEmitted;
  5365. strcpy(GlobalVars[GlobalVarCnt].VarModule,trim(Modules[ModuleNdx]));
  5366. GlobalVars[GlobalVarCnt].VarExtn=GlobalExtn;
  5367. GlobalVars[GlobalVarCnt].VarCondLevel=InConditional;
  5368. GlobalVars[GlobalVarCnt].VarConstant=iConst;
  5369. strcpy(GlobalVars[GlobalVarCnt].VarCondDef,InIfDef);
  5370. GlobalVarHash[ss]=GlobalVarCnt;
  5371. }
  5372. void AddLocal (char * LocalName,int LocalType,int LocalDef,char * LocalDim,int LocalPtr,int LocalFS,int iEmitted,int iConst)
  5373. {
  5374. int varid=0;
  5375. char FirstVar[2048];
  5376. char SecondVar[2048];
  5377. char Warn[2048];
  5378. int s;
  5379. if(LocalVarCnt&&TestState)
  5380. {
  5381. if(CheckGlobal(LocalName, &varid)!=vt_UNKNOWN)
  5382. {
  5383. if(LocalDef)
  5384. {
  5385. strcpy(FirstVar, join(9,"Line",str(ModuleLineNos[ModuleNdx])," in Module: ",trim(Modules[ModuleNdx])," : ",LocalName,LocalDim," as ",TypeDefs[LocalDef].VarName));
  5386. }
  5387. else
  5388. {
  5389. strcpy(FirstVar, join(9,"Line",str(ModuleLineNos[ModuleNdx])," in Module: ",trim(Modules[ModuleNdx])," : ",LocalName,LocalDim," as ",GetVarTypeName(LocalType)));
  5390. }
  5391. if(GlobalVars[varid].VarDef)
  5392. {
  5393. strcpy(SecondVar, join(9,"Line",str(GlobalVars[varid].VarLine)," in Module: ",GlobalVars[varid].VarModule," : ",LocalName,GlobalVars[varid].VarDim," as ",TypeDefs[GlobalVars[varid].VarDef].VarName));
  5394. }
  5395. else
  5396. {
  5397. strcpy(SecondVar, join(9,"Line",str(GlobalVars[varid].VarLine)," in Module: ",GlobalVars[varid].VarModule," : ",LocalName,GlobalVars[varid].VarDim," as ",GetVarTypeName(GlobalVars[varid].VarType)));
  5398. }
  5399. strcpy(Warn, join(5,"Local Variable ",FirstVar,CRLF,"Has Same Name as Global ",SecondVar));
  5400. Warning(Warn);
  5401. }
  5402. for(s=1; s<=LocalVarCnt; s+=1)
  5403. {
  5404. if(str_cmp(LocalName,LocalVars[s].VarName)==0)
  5405. {
  5406. if(LocalVars[s].VarType!=LocalType||str_cmp(LocalDim,LocalVars[s].VarDim)!=0 || LocalVars[s].VarDef!=LocalDef)
  5407. {
  5408. strcpy(FirstVar, join(11,"Line",str(ModuleLineNos[ModuleNdx])," in Module: ",trim(Modules[ModuleNdx])," : ",LocalName,LocalDim," as ",GetVarTypeName(LocalType)," ",TypeDefs[LocalDef].VarName));
  5409. strcpy(SecondVar, join(11,"Line",str(LocalVars[s].VarLine)," in Module: ",LocalVars[s].VarModule," : ",LocalName,LocalVars[s].VarDim," as ",GetVarTypeName(LocalVars[s].VarType)," ",TypeDefs[LocalVars[s].VarDef].VarName));
  5410. strcpy(Warn, join(4,"Two Variables ",FirstVar," previously defined at ",SecondVar));
  5411. Warning(Warn);
  5412. }
  5413. return;
  5414. }
  5415. }
  5416. }
  5417. LocalVarCnt++;
  5418. if(LocalVarCnt==MaxLocalVars)
  5419. {
  5420. strcpy(Warn,"Maximum Local Variables reached.");
  5421. Abort(Warn);
  5422. }
  5423. strcpy(LocalVars[LocalVarCnt].VarName,LocalName);
  5424. LocalVars[LocalVarCnt].VarType=LocalType;
  5425. LocalVars[LocalVarCnt].VarDef=LocalDef;
  5426. strcpy(LocalVars[LocalVarCnt].VarDim,LocalDim);
  5427. LocalVars[LocalVarCnt].VarLine=ModuleLineNos[ModuleNdx];
  5428. LocalVars[LocalVarCnt].VarPntr=LocalPtr;
  5429. LocalVars[LocalVarCnt].VarSF=LocalFS;
  5430. LocalVars[LocalVarCnt].VarEmitFlag=iEmitted;
  5431. LocalVars[LocalVarCnt].VarConstant=iConst;
  5432. strcpy(LocalVars[LocalVarCnt].VarModule,trim(Modules[ModuleNdx]));
  5433. }
  5434. int IsNumber (char *a)
  5435. {
  5436. int i=0;
  5437. if(!*a)
  5438. {
  5439. return FALSE;
  5440. }
  5441. while(a[i])
  5442. {
  5443. if(a[i]>47&&a[i]<58)
  5444. {
  5445. i++;
  5446. }
  5447. else
  5448. {
  5449. return FALSE;
  5450. }
  5451. }
  5452. return TRUE;
  5453. }
  5454. int IsNumberEx (char *a)
  5455. {
  5456. int i=0;
  5457. if(!*a)
  5458. {
  5459. return FALSE;
  5460. }
  5461. while(a[i])
  5462. {
  5463. if(a[i]>44&&a[i]<58)
  5464. {
  5465. i++;
  5466. }
  5467. else
  5468. {
  5469. return FALSE;
  5470. }
  5471. }
  5472. return TRUE;
  5473. }
  5474. void StripTabs (void)
  5475. {
  5476. int i=0;
  5477. while(Src[i])
  5478. {
  5479. if(Src[i]==9)
  5480. {
  5481. Src[i]=32;
  5482. }
  5483. i++;
  5484. }
  5485. }
  5486. void PushFileIO (void)
  5487. {
  5488. FPtr[++FPtrNdx]=SourceFile;
  5489. }
  5490. void PopFileIO (void)
  5491. {
  5492. if(FPtrNdx==0)
  5493. {
  5494. return;
  5495. }
  5496. if(SourceFile)
  5497. {
  5498. fclose(SourceFile);
  5499. SourceFile=NULL;
  5500. }
  5501. LinesRead+=(ModuleLineNos[ModuleNdx--]);
  5502. SourceFile=FPtr[FPtrNdx--];
  5503. }
  5504. int Inset (char *Mane, char *Match)
  5505. {
  5506. int i=-1;
  5507. int j=-1;
  5508. while(Match[++i])
  5509. {
  5510. while(Mane[++j])
  5511. {
  5512. if(Match[i]==Mane[j])
  5513. {
  5514. return TRUE;
  5515. }
  5516. }
  5517. j=-1;
  5518. }
  5519. return FALSE;
  5520. }
  5521. void CheckParQuotes (void)
  5522. {
  5523. int CountR=0;
  5524. int CountS=0;
  5525. int i=0;
  5526. bool DoCount=TRUE;
  5527. while(Src[i])
  5528. {
  5529. if(Src[i]==34)
  5530. {
  5531. DoCount=!DoCount;
  5532. }
  5533. if(DoCount)
  5534. {
  5535. if(Src[i]==40)
  5536. {
  5537. CountR++;
  5538. }
  5539. else if(Src[i]==41)
  5540. {
  5541. CountR--;
  5542. }
  5543. else if(Src[i]==91)
  5544. {
  5545. CountS++;
  5546. }
  5547. else if(Src[i]==93)
  5548. {
  5549. CountS--;
  5550. }
  5551. }
  5552. i++;
  5553. }
  5554. if(!DoCount)
  5555. {
  5556. Abort("Unmatched Quotes");
  5557. }
  5558. else if(CountS)
  5559. {
  5560. Abort("Unmatched []");
  5561. }
  5562. else if(CountR)
  5563. {
  5564. Abort("Unmatched ()");
  5565. }
  5566. }
  5567. void ClearIfThenStacks (void)
  5568. {
  5569. {register int i;
  5570. for(i=0; i<=127; i+=1)
  5571. {
  5572. *SrcStk[i]=0;
  5573. }
  5574. }
  5575. SrcCnt=0;
  5576. }
  5577. int IsQuoted (char *ZZ)
  5578. {
  5579. if(!iMatchLft(ltrim(ZZ),DQ))
  5580. {
  5581. return 0;
  5582. }
  5583. if(!iMatchRgt(rtrim(ZZ),DQ))
  5584. {
  5585. return 0;
  5586. }
  5587. return TRUE;
  5588. }
  5589. void PostProcess (void)
  5590. {
  5591. int A;
  5592. if(ReDirect==TRUE)
  5593. {
  5594. if((FP1=fopen(FileOut,"r"))==0)
  5595. {
  5596. fprintf(stderr,"Can't open file %s\n",FileOut);
  5597. exit(1);
  5598. }
  5599. while(!EoF(FP1))
  5600. {
  5601. Z[0]=0;
  5602. AR_fgets_retval=fgets(Z,1048576,FP1);
  5603. if(Z[strlen(Z)-1]==10)Z[strlen(Z)-1]=0;
  5604. printf("%s\n",Z);
  5605. }
  5606. CloseAll();
  5607. }
  5608. strcpy(OutfileClone,FileOut);
  5609. for(A=1; A<=EntryCnt; A+=1)
  5610. {
  5611. strcpy(OutfileClone,extract(OutfileClone,"."));
  5612. strcpy(Cmd,RemoveStr(Entry[A],DQ));
  5613. strcpy(Cmd,replace(Cmd,"\\\\","\\"));
  5614. strcpy(Cmd,iReplace(Cmd,"$file$",extract(OutfileClone,".")));
  5615. printf("%s%s\n","Shelling Out To: ",Cmd);
  5616. Shell(Cmd);
  5617. }
  5618. if(Compiler[0]>0)
  5619. {
  5620. strcpy(Compiler,trim(RemoveStr(Compiler,DQ)));
  5621. if(inchr(Compiler," "))
  5622. {
  5623. strcpy(Compiler, join(3,enc(extract(Compiler," "))," ",remain(Compiler," ")));
  5624. }
  5625. else
  5626. {
  5627. strcpy(Compiler,enc(Compiler));
  5628. }
  5629. strcpy(FileOut, join(2,extract(FileOut,"."),".cc"));
  5630. strcpy(Compiler, join(3,Compiler," ",FileOut));
  5631. strcpy(Compiler,iReplace(Compiler,"$FILE$",extract(OutfileClone,".")));
  5632. strcpy(Compiler,replace(Compiler,"\\\\","\\"));
  5633. strcpy(Compiler,replace(Compiler,DDQ,DQ));
  5634. printf("%s%s\n","Shelling Out To: ",Compiler);
  5635. Shell(Compiler);
  5636. }
  5637. if(Linker[0]>0)
  5638. {
  5639. strcpy(Linker,trim(RemoveStr(Linker,DQ)));
  5640. if(inchr(Linker," "))
  5641. {
  5642. strcpy(Linker, join(5,DQ,extract(Linker," "),DQ," ",remain(Linker," ")));
  5643. }
  5644. else
  5645. {
  5646. strcpy(Linker,enc(Linker));
  5647. }
  5648. strcpy(FileOut, join(2,extract(FileOut,"."),".obj"));
  5649. strcpy(Linker, join(3,Linker," ",FileOut));
  5650. strcpy(Linker,iReplace(Linker,"$FILE$",extract(OutfileClone,".")));
  5651. strcpy(Linker,replace(Linker,"\\\\","\\"));
  5652. strcpy(Linker,replace(Linker,DDQ,DQ));
  5653. printf("%s%s\n","Shelling Out To:",Linker);
  5654. Shell(Linker);
  5655. }
  5656. for(A=1; A<=XitCount; A+=1)
  5657. {
  5658. strcpy(FileOut,extract(FileOut,"."));
  5659. strcpy(Cmd,RemoveStr(Xit[A],DQ));
  5660. strcpy(Cmd,iReplace(Cmd,"$FILE$",extract(OutfileClone,".")));
  5661. strcpy(Cmd,replace(Cmd,"\\\\","\\"));
  5662. strcpy(Cmd,replace(Cmd,DDQ,DQ));
  5663. printf("%s%s\n","Shelling Out To: ",Cmd);
  5664. Shell(Cmd);
  5665. }
  5666. }
  5667. void XParse (char *Arg)
  5668. {
  5669. char lszTmp[2048];
  5670. int j;
  5671. int i=0;
  5672. int Gapflag=0;
  5673. int InIF=0;
  5674. if(str_cmp(trim(Arg),"")==0)
  5675. {
  5676. Ndx=0;
  5677. return;
  5678. }
  5679. i=iMatchNQ(Arg,"&&");
  5680. while(i)
  5681. {
  5682. strcpy(Arg,del(Arg,i,2));
  5683. strcpy(Arg,ins(Arg,i," and "));
  5684. i=iMatchNQ(Arg,"&&");
  5685. }
  5686. FastLexer(Arg,SPC,"=&()[]{}',+-*/<>?;.|:^");
  5687. while(++i<17)
  5688. {
  5689. *Stk[i+Ndx]=0;
  5690. }
  5691. for(i=1; i<=Ndx; i+=1)
  5692. {
  5693. strcpy(Keyword1,lcase(Stk[i]));
  5694. if(Keyword1[1]!=0)
  5695. {
  5696. for(;;)
  5697. {
  5698. if(str_cmp(Keyword1,"and")==0)
  5699. {
  5700. strcpy(Stk[i],"&&");
  5701. break;
  5702. }
  5703. if(str_cmp(Keyword1,"or")==0)
  5704. {
  5705. strcpy(Stk[i],"||");
  5706. break;
  5707. }
  5708. if(str_cmp(Keyword1,"not")==0)
  5709. {
  5710. strcpy(Stk[i],"!");
  5711. break;
  5712. }
  5713. if(str_cmp(Keyword1,"is")==0)
  5714. {
  5715. strcpy(Stk[i],"=");
  5716. break;
  5717. }
  5718. if(str_cmp(Keyword1,"xor")==0)
  5719. {
  5720. strcpy(Stk[i],"xor");
  5721. break;
  5722. }
  5723. if(str_cmp(Keyword1,"if")==0 || str_cmp(Keyword1,"iif")==0 || str_cmp(Keyword1,"iif$")==0 || str_cmp(Keyword1,"case")==0 || str_cmp(Keyword1,"elseif")==0 || str_cmp(Keyword1,"while")==0)
  5724. {
  5725. InIF=1;
  5726. break;
  5727. }
  5728. if(str_cmp(Keyword1,"then")==0)
  5729. {
  5730. InIF=0;
  5731. break;
  5732. }
  5733. if(str_cmp(Keyword1,"byval")==0)
  5734. {
  5735. *Stk[i]=0;
  5736. Gapflag=TRUE;
  5737. break;
  5738. }
  5739. if(str_cmp(Keyword1,"byref")==0)
  5740. {
  5741. if(!iMatchWrd(Stk[1],"declare")&&!iMatchWrd(Stk[1],"c_declare"))
  5742. {
  5743. strcpy(ByrefVars[++ByrefCnt],Stk[i+1]);
  5744. }
  5745. for(j=i; j<=Ndx; j+=1)
  5746. {
  5747. if(str_cmp(Stk[j+1],",")==0 || str_cmp(Stk[j+1],")")==0)
  5748. {
  5749. strcpy(Stk[j],"PTR");
  5750. break;
  5751. }
  5752. strcpy(Stk[j],Stk[j+1]);
  5753. }
  5754. break;
  5755. }
  5756. // case else
  5757. {
  5758. if(PassOne)
  5759. {
  5760. if(str_cmp(Keyword1,enc(chr(92)))==0)
  5761. {
  5762. strcpy(Stk[i],"chr$");
  5763. InsertTokens(i,3,"(","92",")");
  5764. i+=(3);
  5765. }
  5766. else if(TranslateSlash)
  5767. {
  5768. strcpy(Stk[i],replace(Stk[i],"\\","\\\\"));
  5769. }
  5770. }
  5771. }
  5772. break;
  5773. }
  5774. if(!InIF)
  5775. {
  5776. if(str_cmp(Stk[i],"&&")==0)
  5777. {
  5778. strcpy(Stk[i],"BAND");
  5779. }
  5780. else if(str_cmp(Stk[i],"||")==0)
  5781. {
  5782. strcpy(Stk[i],"BOR");
  5783. }
  5784. }
  5785. }
  5786. else
  5787. {
  5788. for(;;)
  5789. {
  5790. if((UCHAR)*(Keyword1)==38)
  5791. {
  5792. if(i<3||inchr("+&,(=",Stk[i-1]))
  5793. {
  5794. strcpy(Stk[i+1], join(2," &",Stk[i+1]));
  5795. *Stk[i]=0;
  5796. Gapflag=TRUE;
  5797. }
  5798. break;
  5799. }
  5800. if((UCHAR)*(Keyword1)==63)
  5801. {
  5802. strcpy(Stk[i],"print");
  5803. break;
  5804. }
  5805. if((UCHAR)*(Keyword1)==45)
  5806. {
  5807. if((UCHAR)*(Stk[i+1])==62)
  5808. {
  5809. strcpy(Stk[i], join(2,"->",Stk[i+2]));
  5810. *Stk[++i]=0;
  5811. *Stk[++i]=0;
  5812. Gapflag=TRUE;
  5813. }
  5814. break;
  5815. }
  5816. if((UCHAR)*(Keyword1)==46)
  5817. {
  5818. if(IsNumber(Stk[i-1]))
  5819. {
  5820. strcpy(Stk[i], join(2,Stk[i-1],"."));
  5821. *Stk[i-1]=0;
  5822. Gapflag=TRUE;
  5823. }
  5824. if(!inchr(",)=<>*/+-^",Stk[i+1]))
  5825. {
  5826. strcpy(Stk[i], join(2,Stk[i],Stk[i+1]));
  5827. *Stk[++i]=0;
  5828. Gapflag=TRUE;
  5829. }
  5830. }
  5831. break;
  5832. }
  5833. }
  5834. }
  5835. if(Gapflag)
  5836. {
  5837. for(i=1; i<=Ndx; i+=1)
  5838. {
  5839. if(!*Stk[i])
  5840. {
  5841. j=i+1;
  5842. while(!*Stk[j]&&(j<Ndx))
  5843. {
  5844. j++;
  5845. }
  5846. if(!*Stk[j])
  5847. {
  5848. break;
  5849. }
  5850. strcpy(Stk[i],Stk[j]);
  5851. *Stk[j]=0;
  5852. }
  5853. }
  5854. Ndx=i-1;
  5855. }
  5856. if(PassOne==1)
  5857. {
  5858. if(InFunc)
  5859. {
  5860. for(i=1; i<=Ndx; i+=1)
  5861. {
  5862. for(j=1; j<=ByrefCnt; j+=1)
  5863. {
  5864. if(iMatchLft(Stk[i]," &"))
  5865. {
  5866. strcpy(lszTmp,Stk[i]+2);
  5867. }
  5868. else
  5869. {
  5870. strcpy(lszTmp,Stk[i]);
  5871. }
  5872. if(str_cmp(Clean(lszTmp),Clean(ByrefVars[j]))==0)
  5873. {
  5874. if(i>2)
  5875. {
  5876. if(inchr("+-^%*/|&<=>,",Stk[i-2])&&str_cmp(Stk[i-1],"*")==0)
  5877. {
  5878. *Stk[i-1]=0;
  5879. }
  5880. if(iMatchLft(Stk[i]," &"))
  5881. {
  5882. strcpy(Stk[i],Stk[i]+2);
  5883. break;
  5884. }
  5885. }
  5886. else if(i==2)
  5887. {
  5888. if(str_cmp(Stk[i-1],"*")==0)
  5889. {
  5890. *Stk[i-1]=0;
  5891. }
  5892. }
  5893. strcpy(Stk[i], join(2,"*",Stk[i]));
  5894. if(str_cmp(Stk[i-1],"(")!=0 || str_cmp(Stk[i+1],")")!=0)
  5895. {
  5896. strcpy(Stk[i],enc(Stk[i],40,41));
  5897. }
  5898. break;
  5899. }
  5900. }
  5901. }
  5902. }
  5903. }
  5904. if(iMatchWrd(Stk[1],"dim"))
  5905. {
  5906. if(iMatchWrd(Stk[Ndx-1],"static"))
  5907. {
  5908. strcpy(Stk[1],"static");
  5909. strcpy(Stk[Ndx-1],Stk[Ndx]);
  5910. Ndx--;
  5911. }
  5912. }
  5913. strcpy(Keyword1,lcase(Stk[1]));
  5914. if(InTypeDef)
  5915. {
  5916. if(str_cmp(Keyword1,"end")!=0 && str_cmp(Keyword1,"dim")!=0 && str_cmp(Keyword1,"declare")!=0 && str_cmp(Keyword1,"type")!=0 && str_cmp(Keyword1,"union")!=0)
  5917. {
  5918. InsertTokens(0,1,"dim");
  5919. }
  5920. }
  5921. if(!InTypeDef)
  5922. {
  5923. char lsz[2048];
  5924. int Res=1;
  5925. strcpy(lsz, join(3,SPC,Keyword1,SPC));
  5926. if(iMatchNQ(" dim , local , global , raw , static , shared , dynamic , auto , register , extern ",lsz))
  5927. {
  5928. Res=1;
  5929. }
  5930. strcpy(lsz, join(3,SPC,lcase(Stk[2]),SPC));
  5931. if(iMatchNQ(" dim , local , global , raw , static , shared , dynamic , auto , register , extern ",lsz))
  5932. {
  5933. Res=2;
  5934. }
  5935. if(Res>0)
  5936. {
  5937. i=Ndx;
  5938. while(i>1&&str_cmp(Stk[i],")")!=0)
  5939. {
  5940. if(iMatchWrd(Stk[i],"as"))
  5941. {
  5942. if(iMatchWrd(Stk[i+1],"function"))
  5943. {
  5944. if(i+1==Ndx)
  5945. {
  5946. *Stk[i]=0;
  5947. }
  5948. *Stk[i+1]=0;
  5949. InsertTokens(Res,1,"function");
  5950. }
  5951. else if(iMatchWrd(Stk[i+1],"sub"))
  5952. {
  5953. if(i+1==Ndx)
  5954. {
  5955. *Stk[i]=0;
  5956. }
  5957. *Stk[i+1]=0;
  5958. InsertTokens(Res,1,"sub");
  5959. }
  5960. RemEmptyTokens();
  5961. break;
  5962. }
  5963. i--;
  5964. }
  5965. }
  5966. }
  5967. if(InTypeDef||iMatchWrd(Stk[1],"declare")||iMatchWrd(Stk[1],"c_declare"))
  5968. {
  5969. if(iMatchWrd(Stk[2],"sub")||iMatchWrd(Stk[2],"function"))
  5970. {
  5971. {register int i;
  5972. for(i=2; i<=Ndx; i+=1)
  5973. {
  5974. if(iMatchLft(Stk[i],"as")&&iMatchWrd(Stk[i+1],"string"))
  5975. {
  5976. if(*Stk[i+2]!=42)
  5977. {
  5978. strcpy(Stk[i+1],"char *");
  5979. }
  5980. }
  5981. }
  5982. }
  5983. }
  5984. }
  5985. }
  5986. void TokenSubstitutions (void)
  5987. {
  5988. int A;
  5989. int CompPtr;
  5990. int CompToken;
  5991. char Keyword[2048];
  5992. int a;
  5993. int i;
  5994. int j;
  5995. int Tmp;
  5996. for(i=1; i<=Ndx; i+=1)
  5997. {
  5998. if(iMatchWrd(Stk[i],"as"))
  5999. {
  6000. if(iMatchWrd(Stk[i+1],"string"))
  6001. {
  6002. if(str_cmp(Stk[i+2],"*")==0)
  6003. {
  6004. strcpy(Stk[i],"[");
  6005. strcpy(Stk[i+1],Stk[i+3]);
  6006. strcpy(Stk[i+2],"]");
  6007. strcpy(Stk[i+3],"as");
  6008. Ndx++;
  6009. strcpy(Stk[Ndx],"char");
  6010. break;
  6011. }
  6012. }
  6013. }
  6014. }
  6015. for(i=1; i<=Ndx; i+=1)
  6016. {
  6017. if(!InFunc)
  6018. {
  6019. if(iMatchWrd(Stk[i],"global"))
  6020. {
  6021. strcpy(Stk[i],"dim");
  6022. }
  6023. }
  6024. }
  6025. A=FALSE;
  6026. for(Tmp=1; Tmp<=Ndx; Tmp+=1)
  6027. {
  6028. if(*Stk[Tmp]==48&&Stk[Tmp][1]!=120&&Stk[Tmp][1]!=108)
  6029. {
  6030. strcpy(Stk[Tmp],ltrim(Stk[Tmp],48));
  6031. if(Stk[Tmp][0]==0)
  6032. {
  6033. strcpy(Stk[Tmp],"0");
  6034. }
  6035. }
  6036. if(iMatchWrd(Stk[Tmp],"xor"))
  6037. {
  6038. strcpy(Stk[Tmp],"^");
  6039. }
  6040. else if(str_cmp(Stk[Tmp],"=")==0 && str_cmp(Stk[Tmp+1],">")==0)
  6041. {
  6042. strcpy(Stk[Tmp],">");
  6043. strcpy(Stk[Tmp+1],"=");
  6044. }
  6045. else if(str_cmp(Stk[Tmp],"=")==0 && str_cmp(Stk[Tmp+1],"<")==0)
  6046. {
  6047. strcpy(Stk[Tmp],"<");
  6048. strcpy(Stk[Tmp+1],"=");
  6049. }
  6050. else if(str_cmp(Stk[Tmp],"<")==0 && str_cmp(Stk[Tmp+1],">")==0)
  6051. {
  6052. strcpy(Stk[Tmp],"!=");
  6053. *Stk[Tmp+1]=0;
  6054. A=TRUE;
  6055. }
  6056. else if(str_cmp(Stk[Tmp],">")==0 && str_cmp(Stk[Tmp+1],"<")==0)
  6057. {
  6058. strcpy(Stk[Tmp],"!=");
  6059. *Stk[Tmp+1]=0;
  6060. A=TRUE;
  6061. }
  6062. else if(str_cmp(Stk[Tmp],"!")==0 && str_cmp(Stk[Tmp+1],"=")==0)
  6063. {
  6064. strcpy(Stk[Tmp],"!=");
  6065. *Stk[Tmp+1]=0;
  6066. A=TRUE;
  6067. }
  6068. }
  6069. if(A==TRUE)
  6070. {
  6071. RemEmptyTokens();
  6072. }
  6073. CompToken=0;
  6074. for(Tmp=1; Tmp<=Ndx; Tmp+=1)
  6075. {
  6076. A=CheckLocal(Stk[Tmp], &i);
  6077. if(A==vt_UNKNOWN)
  6078. {
  6079. A=CheckGlobal(Stk[Tmp], &i);
  6080. }
  6081. if(A==vt_STRUCT||A==vt_UDT||A==vt_UNION)
  6082. {
  6083. CompToken=1;
  6084. }
  6085. if(iMatchWrd(Stk[Tmp],"int")&&str_cmp(Stk[Tmp+1],"(")==0)
  6086. {
  6087. strcpy(Stk[Tmp],"fint");
  6088. }
  6089. else if(iMatchWrd(Stk[Tmp],"integer"))
  6090. {
  6091. strcpy(Stk[Tmp],"int");
  6092. }
  6093. else if(iMatchWrd(Stk[Tmp],"fint")&&str_cmp(Stk[Tmp+1],")")==0)
  6094. {
  6095. strcpy(Stk[Tmp],"int");
  6096. }
  6097. }
  6098. CompPtr=0;
  6099. for(Tmp=1; Tmp<=Ndx; Tmp+=1)
  6100. {
  6101. strcpy(Keyword,lcase(Stk[Tmp]));
  6102. a=inchr("abcdefghijklmnopqrstuvwxyz",Keyword);
  6103. for(;;)
  6104. {
  6105. if(a==1)
  6106. {
  6107. for(;;)
  6108. {
  6109. if(str_cmp(Keyword,"abs")==0)
  6110. {
  6111. strcpy(Stk[Tmp],"abs");
  6112. break;
  6113. }
  6114. if(str_cmp(Keyword,"acos")==0)
  6115. {
  6116. strcpy(Stk[Tmp],"acos");
  6117. break;
  6118. }
  6119. if(str_cmp(Keyword,"acosl")==0)
  6120. {
  6121. strcpy(Stk[Tmp],"acosl");
  6122. break;
  6123. }
  6124. if(str_cmp(Keyword,"acosh")==0)
  6125. {
  6126. strcpy(Stk[Tmp],"acosh");
  6127. break;
  6128. }
  6129. if(str_cmp(Keyword,"appexename$")==0)
  6130. {
  6131. strcpy(Stk[Tmp],"AppExeName$()");
  6132. Use_AppExeName=Use_BcxSplitPath=UseFlag=TRUE;
  6133. break;
  6134. }
  6135. if(str_cmp(Keyword,"appexepath$")==0)
  6136. {
  6137. strcpy(Stk[Tmp],"AppExePath$()");
  6138. if(str_cmp(Stk[Tmp+1],"(")==0 && str_cmp(Stk[Tmp+2],")")==0)
  6139. {
  6140. *Stk[Tmp+1]=0;
  6141. *Stk[Tmp+2]=0;
  6142. }
  6143. Use_AppExePath=Use_BcxSplitPath=UseFlag=TRUE;
  6144. break;
  6145. }
  6146. if(str_cmp(Keyword,"ansitowide")==0)
  6147. {
  6148. strcpy(Stk[Tmp],"AnsiToWide");
  6149. Use_AnsiToWide=UseFlag=TRUE;
  6150. break;
  6151. }
  6152. if(str_cmp(Keyword,"argc")==0)
  6153. {
  6154. strcpy(Stk[Tmp],"argc");
  6155. break;
  6156. }
  6157. if(str_cmp(Keyword,"argv")==0)
  6158. {
  6159. strcpy(Stk[Tmp],"argv");
  6160. break;
  6161. }
  6162. if(str_cmp(Keyword,"argv$")==0)
  6163. {
  6164. strcpy(Stk[Tmp],"argv$");
  6165. break;
  6166. }
  6167. if(str_cmp(Keyword,"asc")==0)
  6168. {
  6169. i=0;
  6170. j=GetNumArgs(Tmp+2, &i);
  6171. if(*Stk[Tmp+2]==*DQ)
  6172. {
  6173. if(j>0||*Stk[Tmp+3]!=41)
  6174. {
  6175. strcpy(Stk[Tmp],"asc");
  6176. Use_Asc=TRUE;
  6177. }
  6178. else
  6179. {
  6180. if(str_cmp(Stk[Tmp+2],DDQ)==0)
  6181. {
  6182. strcpy(Stk[Tmp],"0");
  6183. }
  6184. else
  6185. {
  6186. strcpy(Stk[Tmp],ltrim(str((UCHAR)*(Stk[Tmp+2]+1))));
  6187. }
  6188. *Stk[Tmp+1]=0;
  6189. *Stk[Tmp+2]=0;
  6190. *Stk[Tmp+3]=0;
  6191. }
  6192. }
  6193. else
  6194. {
  6195. if(j>0)
  6196. {
  6197. strcpy(Stk[i],"+");
  6198. }
  6199. strcpy(Stk[Tmp],"(UCHAR)*");
  6200. }
  6201. break;
  6202. }
  6203. if(str_cmp(Keyword,"asin")==0)
  6204. {
  6205. strcpy(Stk[Tmp],"asin");
  6206. break;
  6207. }
  6208. if(str_cmp(Keyword,"asinl")==0)
  6209. {
  6210. strcpy(Stk[Tmp],"asinl");
  6211. break;
  6212. }
  6213. if(str_cmp(Keyword,"asinh")==0)
  6214. {
  6215. strcpy(Stk[Tmp],"asinh");
  6216. break;
  6217. }
  6218. if(str_cmp(Keyword,"atanh")==0)
  6219. {
  6220. strcpy(Stk[Tmp],"atanh");
  6221. break;
  6222. }
  6223. if(str_cmp(Keyword,"atn")==0 || str_cmp(Keyword,"atan")==0)
  6224. {
  6225. strcpy(Stk[Tmp],"atan");
  6226. break;
  6227. }
  6228. if(str_cmp(Keyword,"atnl")==0 || str_cmp(Keyword,"atanl")==0)
  6229. {
  6230. strcpy(Stk[Tmp],"atanl");
  6231. break;
  6232. }
  6233. if(str_cmp(Keyword,"auto")==0)
  6234. {
  6235. if(iMatchWrd(Stk[Tmp+1],"local"))
  6236. {
  6237. strcpy(Stk[Tmp],"dim");
  6238. strcpy(Stk[Tmp+1],"raw");
  6239. }
  6240. else
  6241. {
  6242. strcpy(Stk[Tmp],"auto");
  6243. }
  6244. }
  6245. break;
  6246. }
  6247. break;
  6248. }
  6249. if(a==2)
  6250. {
  6251. for(;;)
  6252. {
  6253. if(str_cmp(Keyword,"bcopy")==0)
  6254. {
  6255. *Stk[1]=0;
  6256. for(i=Tmp+1; i<=Ndx; i+=1)
  6257. {
  6258. if(iMatchWrd(Stk[i],"to"))
  6259. {
  6260. break;
  6261. }
  6262. strcat(Stk[1],Stk[i]);
  6263. }
  6264. *Stk[2]=0;
  6265. for(i=i+1; i<=Ndx; i+=1)
  6266. {
  6267. strcat(Stk[2],Stk[i]);
  6268. }
  6269. strcpy(Src, join(7,"memmove(&",Stk[2],",&",Stk[1],",sizeof(",Stk[2],"))"));
  6270. strcpy(Src,RemoveStr(Src,"&*"));
  6271. Ndx=0;
  6272. XParse(Src);
  6273. break;
  6274. }
  6275. if(str_cmp(Keyword,"bel$")==0)
  6276. {
  6277. strcpy(Stk[Tmp],"BEL$");
  6278. Use_BEL=UseFlag=TRUE;
  6279. break;
  6280. }
  6281. if(str_cmp(Keyword,"bs$")==0)
  6282. {
  6283. strcpy(Stk[Tmp],"BS$");
  6284. Use_BS=UseFlag=TRUE;
  6285. break;
  6286. }
  6287. if(str_cmp(Keyword,"bool")==0 || str_cmp(Keyword,"boolean")==0)
  6288. {
  6289. strcpy(Stk[Tmp],"bool");
  6290. break;
  6291. }
  6292. if(str_cmp(Keyword,"band")==0)
  6293. {
  6294. strcpy(Stk[Tmp]," BAND ");
  6295. Use_Band=TRUE;
  6296. break;
  6297. }
  6298. if(str_cmp(Keyword,"bnot")==0)
  6299. {
  6300. strcpy(Stk[Tmp]," BNOT ");
  6301. Use_Bnot=TRUE;
  6302. break;
  6303. }
  6304. if(str_cmp(Keyword,"bcx_font")==0)
  6305. {
  6306. strcpy(Stk[Tmp],ucase(Stk[Tmp]));
  6307. char tmp[2048];
  6308. strcpy(tmp,Clean(ucase(Stk[Tmp+1])));
  6309. for(;;)
  6310. {
  6311. if(str_cmp(tmp,".NAME")==0)
  6312. {
  6313. strcpy(Stk[Tmp+1],".lf.lfFaceName$");
  6314. break;
  6315. }
  6316. if(str_cmp(tmp,".BOLD")==0)
  6317. {
  6318. strcpy(Stk[Tmp+1],".lf.lfWeight");
  6319. break;
  6320. }
  6321. if(str_cmp(tmp,".UNDERLINE")==0)
  6322. {
  6323. strcpy(Stk[Tmp+1],".lf.lfUnderline");
  6324. break;
  6325. }
  6326. if(str_cmp(tmp,".STRIKEOUT")==0)
  6327. {
  6328. strcpy(Stk[Tmp+1],".lf.lfStrikeOut");
  6329. break;
  6330. }
  6331. if(str_cmp(tmp,".ITALIC")==0)
  6332. {
  6333. strcpy(Stk[Tmp+1],".lf.lfItalic");
  6334. break;
  6335. }
  6336. if(str_cmp(tmp,".CHARSET")==0)
  6337. {
  6338. strcpy(Stk[Tmp+1],".lf.lfCharSet");
  6339. break;
  6340. }
  6341. if(str_cmp(tmp,".SIZE")==0 || str_cmp(tmp,".RGB")==0)
  6342. {
  6343. strcpy(Stk[Tmp+1],tmp);
  6344. break;
  6345. }
  6346. // case else
  6347. {
  6348. strcpy(Stk[Tmp+1],Clean(Stk[Tmp+1]));
  6349. }
  6350. break;
  6351. }
  6352. break;
  6353. }
  6354. if(str_cmp(Keyword,"bcxsplitpath$")==0)
  6355. {
  6356. strcpy(Stk[Tmp],"$$BcxSplitPath$");
  6357. Use_BcxSplitPath=UseFlag=TRUE;
  6358. break;
  6359. }
  6360. if(str_cmp(Keyword,"bcxpath$")==0)
  6361. {
  6362. UseFlag=TRUE;
  6363. strcpy(Stk[Tmp],"BcxPath$()");
  6364. if(str_cmp(Stk[Tmp+1],"(")==0 && str_cmp(Stk[Tmp+2],")")==0)
  6365. {
  6366. *Stk[Tmp+1]=0;
  6367. *Stk[Tmp+2]=0;
  6368. }
  6369. break;
  6370. }
  6371. if(str_cmp(Keyword,"bcxfont")==0)
  6372. {
  6373. strcpy(Stk[Tmp],"BcxFont");
  6374. break;
  6375. }
  6376. if(str_cmp(Keyword,"bcxsocket")==0)
  6377. {
  6378. strcpy(Stk[Tmp],"BcxSocket");
  6379. Use_Socket=TRUE;
  6380. break;
  6381. }
  6382. if(str_cmp(Keyword,"bcxsocketsend")==0)
  6383. {
  6384. strcpy(Stk[Tmp],"BcxSocketSend");
  6385. break;
  6386. }
  6387. if(str_cmp(Keyword,"bcxsocketread")==0)
  6388. {
  6389. strcpy(Stk[Tmp],"BcxSocketRead");
  6390. break;
  6391. }
  6392. if(str_cmp(Keyword,"bcxsocketclose")==0)
  6393. {
  6394. strcpy(Stk[Tmp],"BcxSocketClose");
  6395. break;
  6396. }
  6397. if(str_cmp(Keyword,"bcx_thread")==0 || str_cmp(Keyword,"bcx_threadwait")==0 || str_cmp(Keyword,"bcx_threadsuspend")==0 || str_cmp(Keyword,"bcx_threadresume")==0 || str_cmp(Keyword,"bcx_threadkill")==0 || str_cmp(Keyword,"bcx_threadend")==0)
  6398. {
  6399. strcpy(Stk[Tmp],ucase(Stk[Tmp]));
  6400. Use_Threads=TRUE;
  6401. break;
  6402. }
  6403. if(str_cmp(Keyword,"bin$")==0)
  6404. {
  6405. strcpy(Stk[Tmp],"$$Bin$");
  6406. Use_Bin=UseFlag=TRUE;
  6407. break;
  6408. }
  6409. if(str_cmp(Keyword,"bool$")==0)
  6410. {
  6411. strcpy(Stk[Tmp],"$$BoolStr$");
  6412. Use_Boolstr=UseFlag=TRUE;
  6413. break;
  6414. }
  6415. if(str_cmp(Keyword,"bin2dec")==0)
  6416. {
  6417. strcpy(Stk[Tmp],"Bin2Dec");
  6418. Use_Bin2dec=TRUE;
  6419. break;
  6420. }
  6421. if(str_cmp(Keyword,"boolean")==0)
  6422. {
  6423. strcpy(Stk[Tmp],"BOOLEAN");
  6424. break;
  6425. }
  6426. if(str_cmp(Keyword,"bor")==0)
  6427. {
  6428. strcpy(Stk[Tmp]," BOR ");
  6429. Use_Bor=TRUE;
  6430. break;
  6431. }
  6432. if(str_cmp(Keyword,"byte")==0)
  6433. {
  6434. strcpy(Stk[Tmp],"BYTE");
  6435. }
  6436. break;
  6437. }
  6438. break;
  6439. }
  6440. if(a==3)
  6441. {
  6442. for(;;)
  6443. {
  6444. if(str_cmp(Keyword,"containedin")==0)
  6445. {
  6446. strcpy(Stk[Tmp],"containedin");
  6447. Use_ContainedIn=TRUE;
  6448. break;
  6449. }
  6450. if(str_cmp(Keyword,"copyfile")==0)
  6451. {
  6452. Use_CopyFile=TRUE;
  6453. Use_Exist=Use_Lof=TRUE;
  6454. break;
  6455. }
  6456. if(str_cmp(Keyword,"cr$")==0)
  6457. {
  6458. strcpy(Stk[Tmp],"CR$");
  6459. Use_CR=UseFlag=TRUE;
  6460. break;
  6461. }
  6462. if(str_cmp(Keyword,"close#")==0)
  6463. {
  6464. strcpy(Stk[Tmp],"close");
  6465. break;
  6466. }
  6467. if(str_cmp(Keyword,"close")==0)
  6468. {
  6469. if(str_cmp(left(Stk[Tmp+1],1),"#")==0)
  6470. {
  6471. strcpy(Stk[Tmp+1],mid(Stk[Tmp+1],2));
  6472. }
  6473. break;
  6474. }
  6475. if(str_cmp(Keyword,"cvd")==0)
  6476. {
  6477. strcpy(Stk[Tmp],"CVD");
  6478. Use_Cvd=TRUE;
  6479. break;
  6480. }
  6481. if(str_cmp(Keyword,"cvi")==0)
  6482. {
  6483. strcpy(Stk[Tmp],"CVI");
  6484. Use_Cvi=TRUE;
  6485. break;
  6486. }
  6487. if(str_cmp(Keyword,"cvl")==0)
  6488. {
  6489. strcpy(Stk[Tmp],"CVL");
  6490. Use_Cvl=TRUE;
  6491. break;
  6492. }
  6493. if(str_cmp(Keyword,"cvld")==0)
  6494. {
  6495. strcpy(Stk[Tmp],"CVLD");
  6496. Use_Cvld=TRUE;
  6497. break;
  6498. }
  6499. if(str_cmp(Keyword,"cvs")==0)
  6500. {
  6501. strcpy(Stk[Tmp],"CVS");
  6502. Use_Cvs=TRUE;
  6503. break;
  6504. }
  6505. if(str_cmp(Keyword,"concat")==0)
  6506. {
  6507. strcpy(Stk[Tmp],"strcat");
  6508. break;
  6509. }
  6510. if(str_cmp(Keyword,"chr$")==0)
  6511. {
  6512. strcpy(Stk[Tmp],"$$chr$");
  6513. Use_Chr=UseFlag=TRUE;
  6514. break;
  6515. }
  6516. if(str_cmp(Keyword,"char")==0)
  6517. {
  6518. strcpy(Stk[Tmp],"char");
  6519. break;
  6520. }
  6521. if(str_cmp(Keyword,"crlf$")==0)
  6522. {
  6523. strcpy(Stk[Tmp],"CRLF$");
  6524. Use_Crlf=UseFlag=TRUE;
  6525. break;
  6526. }
  6527. if(str_cmp(Keyword,"cbctl")==0)
  6528. {
  6529. strcpy(Stk[Tmp],"LOWORD(wParam)");
  6530. break;
  6531. }
  6532. if(str_cmp(Keyword,"cbctlmsg")==0)
  6533. {
  6534. strcpy(Stk[Tmp],"HIWORD(wParam)");
  6535. break;
  6536. }
  6537. if(str_cmp(Keyword,"cblparam")==0)
  6538. {
  6539. strcpy(Stk[Tmp],"lParam");
  6540. break;
  6541. }
  6542. if(str_cmp(Keyword,"cbmsg")==0)
  6543. {
  6544. strcpy(Stk[Tmp],"Msg");
  6545. break;
  6546. }
  6547. if(str_cmp(Keyword,"cbwparam")==0)
  6548. {
  6549. strcpy(Stk[Tmp],"wParam");
  6550. break;
  6551. }
  6552. if(str_cmp(Keyword,"cdbl")==0)
  6553. {
  6554. strcpy(Stk[Tmp],"CDBL");
  6555. Use_Cdbl=TRUE;
  6556. break;
  6557. }
  6558. if(str_cmp(Keyword,"chdrive")==0 || str_cmp(Keyword,"chdir")==0)
  6559. {
  6560. strcpy(Stk[Tmp],"chdir");
  6561. break;
  6562. }
  6563. if(str_cmp(Keyword,"cint")==0)
  6564. {
  6565. strcpy(Stk[Tmp],"Cint");
  6566. Use_Cint=TRUE;
  6567. break;
  6568. }
  6569. if(str_cmp(Keyword,"cldbl")==0)
  6570. {
  6571. strcpy(Stk[Tmp],"CLDBL");
  6572. Use_Cldbl=TRUE;
  6573. break;
  6574. }
  6575. if(str_cmp(Keyword,"clng")==0)
  6576. {
  6577. strcpy(Stk[Tmp],"CLNG");
  6578. Use_Clng=TRUE;
  6579. break;
  6580. }
  6581. if(str_cmp(Keyword,"cls")==0)
  6582. {
  6583. strcpy(Stk[Tmp],"cls");
  6584. Use_Cls=Use_ESC=TRUE;
  6585. break;
  6586. }
  6587. if(str_cmp(Keyword,"color")==0 || str_cmp(Keyword,"color_fg")==0 || str_cmp(Keyword,"color_bg")==0)
  6588. {
  6589. strcpy(Stk[Tmp],lcase(Stk[Tmp]));
  6590. Use_Color=Use_Console=TRUE;
  6591. break;
  6592. }
  6593. if(str_cmp(Keyword,"command$")==0)
  6594. {
  6595. Use_Command=Use_SPC=UseFlag=TRUE;
  6596. strcpy(Stk[Tmp],"command$(-1)");
  6597. if(str_cmp(Stk[Tmp+1],"(")==0)
  6598. {
  6599. strcpy(Stk[Tmp],"command$");
  6600. }
  6601. break;
  6602. }
  6603. if(str_cmp(Keyword,"colorref")==0)
  6604. {
  6605. strcpy(Stk[Tmp],"COLORREF");
  6606. break;
  6607. }
  6608. if(str_cmp(Keyword,"cos")==0)
  6609. {
  6610. strcpy(Stk[Tmp],"cos");
  6611. break;
  6612. }
  6613. if(str_cmp(Keyword,"cosl")==0)
  6614. {
  6615. strcpy(Stk[Tmp],"cosl");
  6616. break;
  6617. }
  6618. if(str_cmp(Keyword,"cosh")==0)
  6619. {
  6620. strcpy(Stk[Tmp],"cosh");
  6621. break;
  6622. }
  6623. if(str_cmp(Keyword,"cbool")==0)
  6624. {
  6625. strcpy(Stk[Tmp],"CBOOL");
  6626. static struct _functionParse fp;
  6627. memset(&fp,0,sizeof(fp));
  6628. static int i;
  6629. memset(&i,0,sizeof(i));
  6630. static int t;
  6631. memset(&t,0,sizeof(t));
  6632. static int expos=0;
  6633. memset(&expos,0,sizeof(expos));
  6634. if(SepFuncArgs(Tmp+1, &fp,TRUE)==0)
  6635. {
  6636. Abort("No argument specified in CBOOL");
  6637. }
  6638. for(i=fp.CommaPos[0]; i<=fp.CommaPos[1]; i+=1)
  6639. {
  6640. t=inchr("!<>=",Stk[i]);
  6641. if(t)
  6642. {
  6643. if(t<4)
  6644. {
  6645. if(str_cmp(Stk[i+1],"=")==0)
  6646. {
  6647. strcpy(Stk[i], join(2,Stk[i],Stk[i+1]));
  6648. *Stk[i+1]=0;
  6649. }
  6650. else if(t==1&&str_cmp(Stk[i],"!=")!=0)
  6651. {
  6652. continue;
  6653. }
  6654. }
  6655. else
  6656. {
  6657. if(str_cmp(Stk[i+1],"=")!=0)
  6658. {
  6659. strcpy(Stk[i],"==");
  6660. }
  6661. }
  6662. expos=i;
  6663. break;
  6664. }
  6665. }
  6666. t=DataType(Stk[expos-1]);
  6667. if(t==vt_STRLIT||t==vt_STRVAR)
  6668. {
  6669. if(expos)
  6670. {
  6671. strcpy(Stk[Tmp+1], join(2,Stk[Tmp+1],"strcmp("));
  6672. strcpy(Stk[fp.CommaPos[1]], join(3,")",Stk[expos],"0)"));
  6673. strcpy(Stk[expos],",");
  6674. *Src=0;
  6675. for(i=1; i<=Ndx; i+=1)
  6676. {
  6677. strcpy(Src, join(3,Src,Stk[i],SPC));
  6678. }
  6679. FastLexer(Src," ","(),");
  6680. }
  6681. }
  6682. break;
  6683. }
  6684. if(str_cmp(Keyword,"csng")==0)
  6685. {
  6686. strcpy(Stk[Tmp],"CSNG");
  6687. Use_Csng=TRUE;
  6688. break;
  6689. }
  6690. if(str_cmp(Keyword,"curdir$")==0)
  6691. {
  6692. strcpy(Stk[Tmp],"curdir$()");
  6693. if(str_cmp(Stk[Tmp+1],"(")==0 && str_cmp(Stk[Tmp+2],")")==0)
  6694. {
  6695. *Stk[Tmp+1]=0;
  6696. *Stk[Tmp+2]=0;
  6697. }
  6698. Use_Curdir=UseFlag=TRUE;
  6699. break;
  6700. }
  6701. if(str_cmp(Keyword,"currency")==0)
  6702. {
  6703. strcpy(Stk[Tmp],"CURRENCY");
  6704. break;
  6705. }
  6706. if(str_cmp(Keyword,"c_declare")==0)
  6707. {
  6708. strcpy(CallType,"__attribute__((cdecl)) ");
  6709. strcpy(Stk[Tmp],"declare");
  6710. if(iMatchWrd(Stk[4],"lib"))
  6711. {
  6712. NoTypeDeclare=FALSE;
  6713. }
  6714. else
  6715. {
  6716. NoTypeDeclare=TRUE;
  6717. }
  6718. }
  6719. break;
  6720. }
  6721. break;
  6722. }
  6723. if(a==4)
  6724. {
  6725. for(;;)
  6726. {
  6727. if(str_cmp(Keyword,"declare")==0)
  6728. {
  6729. strcpy(CallType,"__attribute__((stdcall)) ");
  6730. strcpy(Stk[Tmp],"declare");
  6731. if(!iMatchWrd(Stk[4],"lib"))
  6732. {
  6733. NoTypeDeclare=TRUE;
  6734. }
  6735. else
  6736. {
  6737. NoTypeDeclare=FALSE;
  6738. }
  6739. break;
  6740. }
  6741. if(str_cmp(Keyword,"dq$")==0)
  6742. {
  6743. strcpy(Stk[Tmp],"DQ$");
  6744. Use_DQ=UseFlag=TRUE;
  6745. break;
  6746. }
  6747. if(str_cmp(Keyword,"ddq$")==0)
  6748. {
  6749. strcpy(Stk[Tmp],"DDQ$");
  6750. Use_DDQ=UseFlag=TRUE;
  6751. break;
  6752. }
  6753. if(str_cmp(Keyword,"data$")==0)
  6754. {
  6755. strcpy(Stk[Tmp],"DATA$");
  6756. break;
  6757. }
  6758. if(str_cmp(Keyword,"date$")==0)
  6759. {
  6760. strcpy(Stk[Tmp],"$$timef$(12)");
  6761. Use_Time=UseFlag=TRUE;
  6762. break;
  6763. }