12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819 |
- (eval-when-compile
- (let ((load-path
- (if (and (boundp 'byte-compile-dest-file)
- (stringp byte-compile-dest-file))
- (cons (file-name-directory byte-compile-dest-file) load-path)
- load-path)))
- (load "cc-bytecomp" nil t)))
- (cc-require 'cc-defs)
- (cc-require-when-compile 'cc-langs)
- (cc-require 'cc-vars)
- (cc-bytecomp-defun buffer-syntactic-context)
- (defmacro c-declare-lang-variables ()
- `(progn
- ,@(apply 'nconc
- (mapcar (lambda (init)
- `(,(if (elt init 2)
- `(defvar ,(car init) nil ,(elt init 2))
- `(defvar ,(car init) nil))
- (make-variable-buffer-local ',(car init))))
- (cdr c-lang-variable-inits)))))
- (c-declare-lang-variables)
- (defvar c-hungry-delete-key nil)
- (make-variable-buffer-local 'c-hungry-delete-key)
- (defvar c-electric-flag t)
- (make-variable-buffer-local 'c-electric-flag)
- (defvar c-auto-newline nil)
- (make-variable-buffer-local 'c-auto-newline)
- (defun c-calculate-state (arg prevstate)
-
-
-
- (if (or (not arg)
- (zerop (setq arg (prefix-numeric-value arg))))
- (not prevstate)
- (> arg 0)))
- (defvar c-macro-start 'unknown)
- (defsubst c-query-and-set-macro-start ()
- (if (symbolp c-macro-start)
- (setq c-macro-start (save-excursion
- (c-save-buffer-state ()
- (and (c-beginning-of-macro)
- (point)))))
- c-macro-start))
- (defsubst c-query-macro-start ()
- (if (symbolp c-macro-start)
- (save-excursion
- (c-save-buffer-state ()
- (and (c-beginning-of-macro)
- (point))))
- c-macro-start))
- (defvar c-macro-cache nil)
- (make-variable-buffer-local 'c-macro-cache)
- (defvar c-macro-cache-start-pos nil)
- (make-variable-buffer-local 'c-macro-cache-start-pos)
- (defvar c-macro-cache-syntactic nil)
- (make-variable-buffer-local 'c-macro-cache-syntactic)
- (defun c-invalidate-macro-cache (beg end)
-
-
-
-
- (cond
- ((null c-macro-cache))
- ((< beg (car c-macro-cache))
- (setq c-macro-cache nil
- c-macro-cache-start-pos nil
- c-macro-cache-syntactic nil))
- ((and (cdr c-macro-cache)
- (< beg (cdr c-macro-cache)))
- (setcdr c-macro-cache nil)
- (setq c-macro-cache-start-pos beg
- c-macro-cache-syntactic nil))))
- (defun c-beginning-of-macro (&optional lim)
- "Go to the beginning of a preprocessor directive.
- Leave point at the beginning of the directive and return t if in one,
- otherwise return nil and leave point unchanged.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (let ((here (point)))
- (when c-opt-cpp-prefix
- (if (and (car c-macro-cache)
- (>= (point) (car c-macro-cache))
- (or (and (cdr c-macro-cache)
- (<= (point) (cdr c-macro-cache)))
- (<= (point) c-macro-cache-start-pos)))
- (unless (< (car c-macro-cache) (or lim (point-min)))
- (progn (goto-char (max (or lim (point-min)) (car c-macro-cache)))
- (setq c-macro-cache-start-pos
- (max c-macro-cache-start-pos here))
- t))
- (setq c-macro-cache nil
- c-macro-cache-start-pos nil
- c-macro-cache-syntactic nil)
- (save-restriction
- (if lim (narrow-to-region lim (point-max)))
- (beginning-of-line)
- (while (eq (char-before (1- (point))) ?\\)
- (forward-line -1))
- (back-to-indentation)
- (if (and (<= (point) here)
- (looking-at c-opt-cpp-start))
- (progn
- (setq c-macro-cache (cons (point) nil)
- c-macro-cache-start-pos here)
- t)
- (goto-char here)
- nil))))))
- (defun c-end-of-macro ()
- "Go to the end of a preprocessor directive.
- More accurately, move the point to the end of the closest following
- line that doesn't end with a line continuation backslash - no check is
- done that the point is inside a cpp directive to begin with.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (if (and (cdr c-macro-cache)
- (<= (point) (cdr c-macro-cache))
- (>= (point) (car c-macro-cache)))
- (goto-char (cdr c-macro-cache))
- (unless (and (car c-macro-cache)
- (<= (point) c-macro-cache-start-pos)
- (>= (point) (car c-macro-cache)))
- (setq c-macro-cache nil
- c-macro-cache-start-pos nil
- c-macro-cache-syntactic nil))
- (while (progn
- (end-of-line)
- (when (and (eq (char-before) ?\\)
- (not (eobp)))
- (forward-char)
- t)))
- (when (car c-macro-cache)
- (setcdr c-macro-cache (point)))))
- (defun c-syntactic-end-of-macro ()
-
-
-
-
-
-
-
-
-
-
- (let* ((here (point))
- (there (progn (c-end-of-macro) (point)))
- s)
- (unless c-macro-cache-syntactic
- (setq s (parse-partial-sexp here there))
- (while (and (or (nth 3 s)
- (nth 4 s))
- (> there here))
- (setq there (1- (nth 8 s)))
- (setq s (parse-partial-sexp here there)))
- (setq c-macro-cache-syntactic (car c-macro-cache)))
- (point)))
- (defun c-forward-over-cpp-define-id ()
-
-
-
-
-
-
-
- (when (and c-opt-cpp-macro-define-id
- (looking-at c-opt-cpp-macro-define-id))
- (goto-char (match-end 0))))
- (defun c-forward-to-cpp-define-body ()
-
-
-
-
-
-
-
- (when (and c-opt-cpp-macro-define-start
- (looking-at c-opt-cpp-macro-define-start)
- (not (= (match-end 0) (c-point 'eol))))
- (goto-char (match-end 0))))
- (defun c-syntactic-content (from to paren-level)
-
-
-
-
-
-
- (save-excursion
- (save-restriction
- (narrow-to-region from to)
- (goto-char from)
- (let* ((parts (list nil)) (tail parts) pos in-paren)
- (while (re-search-forward c-syntactic-ws-start to t)
- (goto-char (setq pos (match-beginning 0)))
- (c-forward-syntactic-ws)
- (if (= (point) pos)
- (forward-char)
- (when paren-level
- (save-excursion
- (setq in-paren (= (car (parse-partial-sexp from pos 1)) 1)
- pos (point))))
- (if (and (> pos from)
- (< (point) to)
- (looking-at "\\w\\|\\s_")
- (save-excursion
- (goto-char (1- pos))
- (looking-at "\\w\\|\\s_")))
- (progn
- (setcdr tail (list (buffer-substring-no-properties from pos)
- " "))
- (setq tail (cddr tail)))
- (setcdr tail (list (buffer-substring-no-properties from pos)))
- (setq tail (cdr tail)))
- (when in-paren
- (when (= (car (parse-partial-sexp pos to -1)) -1)
- (setcdr tail (list (buffer-substring-no-properties
- (1- (point)) (point))))
- (setq tail (cdr tail))))
- (setq from (point))))
- (setcdr tail (list (buffer-substring-no-properties from to)))
- (apply 'concat (cdr parts))))))
- (defun c-shift-line-indentation (shift-amt)
-
-
-
- (let ((pos (- (point-max) (point)))
- (c-macro-start c-macro-start)
- tmp-char-inserted)
- (if (zerop shift-amt)
- nil
-
-
-
-
- (when (and (c-query-and-set-macro-start)
- (looking-at "[ \t]*\\\\$")
- (save-excursion
- (skip-chars-backward " \t")
- (bolp)))
- (insert ?x)
- (backward-char)
- (setq tmp-char-inserted t))
- (unwind-protect
- (let ((col (current-indentation)))
- (delete-region (c-point 'bol) (c-point 'boi))
- (beginning-of-line)
- (indent-to (+ col shift-amt)))
- (when tmp-char-inserted
- (delete-char 1))))
-
-
-
- (if (and (< (point) (c-point 'boi))
- (not tmp-char-inserted))
- (back-to-indentation)
- (if (> (- (point-max) pos) (point))
- (goto-char (- (point-max) pos))))))
- (defsubst c-keyword-sym (keyword)
-
-
-
- (intern-soft keyword c-keywords-obarray))
- (defsubst c-keyword-member (keyword-sym lang-constant)
-
-
-
-
- (get keyword-sym lang-constant))
- (defconst c-string-syntax (if (memq 'gen-string-delim c-emacs-features)
- "\"|"
- "\""))
- (defconst c-string-limit-regexp (if (memq 'gen-string-delim c-emacs-features)
- "\\s\"\\|\\s|"
- "\\s\""))
- (defconst c-ws*-string-limit-regexp
- (concat "[ \t]*\\(" c-string-limit-regexp "\\)"))
- (defvar c-parsing-error nil)
- (make-variable-buffer-local 'c-parsing-error)
- (defun c-echo-parsing-error (&optional quiet)
- (when (and c-report-syntactic-errors c-parsing-error (not quiet))
- (c-benign-error "%s" c-parsing-error))
- c-parsing-error)
- (defvar c-literal-faces
- (append '(font-lock-comment-face font-lock-string-face)
- (when (facep 'font-lock-comment-delimiter-face)
-
- '(font-lock-comment-delimiter-face))))
- (defsubst c-put-c-type-property (pos value)
-
- (c-put-char-property pos 'c-type value))
- (defun c-clear-c-type-property (from to value)
-
-
-
-
-
-
- (save-excursion
- (goto-char from)
- (while (progn
- (when (eq (get-text-property (point) 'c-type) value)
- (c-clear-char-property (point) 'c-type))
- (goto-char (next-single-property-change (point) 'c-type nil to))
- (< (point) to)))))
- (cc-bytecomp-defun overlays-in)
- (cc-bytecomp-defun overlay-get)
- (cc-bytecomp-defun overlay-start)
- (cc-bytecomp-defun overlay-end)
- (cc-bytecomp-defun delete-overlay)
- (cc-bytecomp-defun overlay-put)
- (cc-bytecomp-defun make-overlay)
- (defun c-debug-add-face (beg end face)
- (c-save-buffer-state ((overlays (overlays-in beg end)) overlay)
- (while overlays
- (setq overlay (car overlays)
- overlays (cdr overlays))
- (when (eq (overlay-get overlay 'face) face)
- (setq beg (min beg (overlay-start overlay))
- end (max end (overlay-end overlay)))
- (delete-overlay overlay)))
- (overlay-put (make-overlay beg end) 'face face)))
- (defun c-debug-remove-face (beg end face)
- (c-save-buffer-state ((overlays (overlays-in beg end)) overlay
- (ol-beg beg) (ol-end end))
- (while overlays
- (setq overlay (car overlays)
- overlays (cdr overlays))
- (when (eq (overlay-get overlay 'face) face)
- (setq ol-beg (min ol-beg (overlay-start overlay))
- ol-end (max ol-end (overlay-end overlay)))
- (delete-overlay overlay)))
- (when (< ol-beg beg)
- (overlay-put (make-overlay ol-beg beg) 'face face))
- (when (> ol-end end)
- (overlay-put (make-overlay end ol-end) 'face face))))
- (defvar c-maybe-labelp)
- (defmacro c-bos-push-state ()
- '(setq stack (cons (cons state saved-pos)
- stack)))
- (defmacro c-bos-pop-state (&optional do-if-done)
- `(if (setq state (car (car stack))
- saved-pos (cdr (car stack))
- stack (cdr stack))
- t
- ,do-if-done
- (throw 'loop nil)))
- (defmacro c-bos-pop-state-and-retry ()
- '(throw 'loop (setq state (car (car stack))
- saved-pos (cdr (car stack))
-
- stack (cdr stack))))
- (defmacro c-bos-save-pos ()
- '(setq saved-pos (vector pos tok ptok pptok)))
- (defmacro c-bos-restore-pos ()
- '(unless (eq (elt saved-pos 0) start)
- (setq pos (elt saved-pos 0)
- tok (elt saved-pos 1)
- ptok (elt saved-pos 2)
- pptok (elt saved-pos 3))
- (goto-char pos)
- (setq sym nil)))
- (defmacro c-bos-save-error-info (missing got)
- `(setq saved-pos (vector pos ,missing ,got)))
- (defmacro c-bos-report-error ()
- '(unless noerror
- (setq c-parsing-error
- (format "No matching `%s' found for `%s' on line %d"
- (elt saved-pos 1)
- (elt saved-pos 2)
- (1+ (count-lines (point-min)
- (c-point 'bol (elt saved-pos 0))))))))
- (defun c-beginning-of-statement-1 (&optional lim ignore-labels
- noerror comma-delim)
- "Move to the start of the current statement or declaration, or to
- the previous one if already at the beginning of one. Only
- statements/declarations on the same level are considered, i.e. don't
- move into or out of sexps (not even normal expression parentheses).
- If point is already at the earliest statement within braces or parens,
- this function doesn't move back into any whitespace preceding it; it
- returns 'same in this case.
- Stop at statement continuation tokens like \"else\", \"catch\",
- \"finally\" and the \"while\" in \"do ... while\" if the start point
- is within the continuation. If starting at such a token, move to the
- corresponding statement start. If at the beginning of a statement,
- move to the closest containing statement if there is any. This might
- also stop at a continuation clause.
- Labels are treated as part of the following statements if
- IGNORE-LABELS is non-nil. (FIXME: Doesn't work if we stop at a known
- statement start keyword.) Otherwise, each label is treated as a
- separate statement.
- Macros are ignored \(i.e. skipped over) unless point is within one, in
- which case the content of the macro is treated as normal code. Aside
- from any normal statement starts found in it, stop at the first token
- of the content in the macro, i.e. the expression of an \"#if\" or the
- start of the definition in a \"#define\". Also stop at start of
- macros before leaving them.
- Return:
- 'label if stopped at a label or \"case...:\" or \"default:\";
- 'same if stopped at the beginning of the current statement;
- 'up if stepped to a containing statement;
- 'previous if stepped to a preceding statement;
- 'beginning if stepped from a statement continuation clause to
- its start clause; or
- 'macro if stepped to a macro start.
- Note that 'same and not 'label is returned if stopped at the same
- label without crossing the colon character.
- LIM may be given to limit the search. If the search hits the limit,
- point will be left at the closest following token, or at the start
- position if that is less ('same is returned in this case).
- NOERROR turns off error logging to `c-parsing-error'.
- Normally only ';' and virtual semicolons are considered to delimit
- statements, but if COMMA-DELIM is non-nil then ',' is treated
- as a delimiter too.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((case-fold-search nil)
- (start (point))
- macro-start
- (delims (if comma-delim '(?\
- (c-stmt-delim-chars (if comma-delim
- c-stmt-delim-chars-with-comma
- c-stmt-delim-chars))
- c-in-literal-cache c-maybe-labelp after-case:-pos saved
-
- pos
-
- boundary-pos
-
-
-
-
- after-labels-pos
-
-
-
- last-label-pos
-
-
-
-
-
-
- label-good-pos
-
-
- bitfield-type-pos bitfield-id-pos bitfield-size-pos
-
-
- sym
-
- state
-
- saved-pos
-
- stack
-
- (cond-key (or c-opt-block-stmt-key
- "\\<\\>"))
-
- (ret 'same)
-
- tok ptok pptok)
- (save-restriction
- (if lim (narrow-to-region lim (point-max)))
- (if (save-excursion
- (and (c-beginning-of-macro)
- (/= (point) start)))
- (setq macro-start (point)))
-
-
- (while (progn
- (setq pos (point))
- (c-backward-syntactic-ws)
-
- (and (not (c-at-vsemi-p))
- (/= (skip-chars-backward "-+!*&~@`#") 0))))
-
-
-
-
- (if (and (memq (char-before) delims)
- (progn (forward-char -1)
- (setq saved (point))
- (c-backward-syntactic-ws)
- (or (memq (char-before) delims)
- (memq (char-before) '(?: nil))
- (eq (char-syntax (char-before)) ?\()
- (c-at-vsemi-p))))
- (setq ret 'previous
- pos saved)
-
-
- (goto-char start)
- (if (looking-at "\\<\\|\\W")
-
- (setq tok start))
-
-
-
-
-
-
-
-
-
-
-
- (while
- (catch 'loop
- (cond
-
- ((save-excursion
- (and macro-start
- (progn (skip-chars-backward " \t")
- (eq (char-before) ?#))
- (progn (setq saved (1- (point)))
- (beginning-of-line)
- (not (eq (char-before (1- (point))) ?\\)))
- (looking-at c-opt-cpp-start)
- (progn (skip-chars-forward " \t")
- (eq (point) saved))))
- (goto-char saved)
- (if (and (c-forward-to-cpp-define-body)
- (progn (c-forward-syntactic-ws start)
- (< (point) start)))
-
- (setq pos (point)
- ignore-labels t)
- (setq pos saved
- ret 'macro
- ignore-labels t))
- (throw 'loop nil))
-
-
- ((or sym
- (and (looking-at cond-key)
- (setq sym (intern (match-string 1)))))
- (when (and (< pos start) (null stack))
- (throw 'loop nil))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (or (cond
- ((eq state 'else)
- (if (eq sym 'boundary)
- (setq state 'else-boundary)
- (c-bos-report-error)
- (c-bos-pop-state-and-retry)))
- ((eq state 'else-boundary)
- (cond ((eq sym 'if)
- (c-bos-pop-state (setq ret 'beginning)))
- ((eq sym 'boundary)
- (c-bos-report-error)
- (c-bos-pop-state))))
- ((eq state 'while)
- (if (and (eq sym 'boundary)
-
-
-
-
- (not after-labels-pos))
- (progn (c-bos-save-pos)
- (setq state 'while-boundary))
- (c-bos-pop-state-and-retry)))
- ((eq state 'while-boundary)
- (cond ((eq sym 'do)
- (c-bos-pop-state (setq ret 'beginning)))
- ((eq sym 'boundary)
- (c-bos-restore-pos)
- (c-bos-pop-state))))
- ((eq state 'catch)
- (if (eq sym 'boundary)
- (setq state 'catch-boundary)
- (c-bos-report-error)
- (c-bos-pop-state-and-retry)))
- ((eq state 'catch-boundary)
- (cond
- ((eq sym 'try)
- (c-bos-pop-state (setq ret 'beginning)))
- ((eq sym 'catch)
- (setq state 'catch))
- ((eq sym 'boundary)
- (c-bos-report-error)
- (c-bos-pop-state)))))
-
-
- (cond ((eq sym 'boundary)
-
-
-
- (if (>= pos start)
- (c-bos-push-state)
- (c-bos-pop-state)))
- ((eq sym 'else)
- (c-bos-push-state)
- (c-bos-save-error-info 'if 'else)
- (setq state 'else))
- ((eq sym 'while)
-
-
-
- (when (or (not pptok)
- (memq (char-after pptok) delims)
-
-
-
-
- (and (eq (point) start)
- (c-vsemi-status-unknown-p))
- (c-at-vsemi-p pptok))
-
-
-
-
- (c-bos-push-state)
- (setq state 'while)))
- ((memq sym '(catch finally))
- (c-bos-push-state)
- (c-bos-save-error-info 'try sym)
- (setq state 'catch))))
- (when c-maybe-labelp
-
-
-
- (setq after-labels-pos nil
- last-label-pos nil
- c-maybe-labelp nil))))
-
-
- (if (eq sym 'boundary)
- (setq ret 'previous)
-
-
- (c-backward-syntactic-ws)
- (let ((before-sws-pos (point))
-
-
- (maybe-after-boundary-pos pos))
-
-
- (while
- (progn
- (unless (c-safe (c-backward-sexp) t)
-
-
-
- (throw 'loop nil))
- (cond
-
- ((and (not macro-start)
- (c-beginning-of-macro))
-
-
- (and
- (save-excursion
- (c-end-of-macro)
- (not (c-crosses-statement-barrier-p
- (point) maybe-after-boundary-pos)))
- (setq maybe-after-boundary-pos (point))))
-
-
- ((looking-at "\\\\$")))))
-
- (setq boundary-pos
- (cond
-
- ((and (not macro-start)
- c-opt-cpp-prefix
- (looking-at c-opt-cpp-prefix))
- (save-excursion
- (c-end-of-macro)
- (c-crosses-statement-barrier-p
- (point) maybe-after-boundary-pos)))
-
- ((and
- (eq (char-after) ?{)
- (not (c-looking-at-inexpr-block lim nil t)))
- (save-excursion
- (c-forward-sexp) (point)))
-
- ((looking-at "\\s\(")
- (save-excursion
- (goto-char (1+ (c-down-list-backward
- before-sws-pos)))
- (c-crosses-statement-barrier-p
- (point) maybe-after-boundary-pos)))
-
- (t (c-crosses-statement-barrier-p
- (point) maybe-after-boundary-pos))))
- (when boundary-pos
- (setq pptok ptok
- ptok tok
- tok boundary-pos
- sym 'boundary)
-
- (throw 'loop t))))
-
- (when (and c-opt-method-key
- (setq saved (c-in-method-def-p)))
- (setq pos saved
- ignore-labels t)
- (throw 'loop nil))
-
- (if c-has-bitfields
- (cond
-
- ((and (numberp c-maybe-labelp)
- (not bitfield-size-pos)
- (save-excursion
- (goto-char (or tok start))
- (not (looking-at c-keywords-regexp)))
- (not (looking-at c-keywords-regexp))
- (not (c-punctuation-in (point) c-maybe-labelp)))
- (setq bitfield-size-pos (or tok start)
- bitfield-id-pos (point)))
-
- ((and bitfield-id-pos
- (not bitfield-type-pos))
- (if (and (looking-at c-symbol-key)
- (not (looking-at c-not-primitive-type-keywords-regexp))
- (not (c-punctuation-in (point) tok)))
- (setq bitfield-type-pos (point))
- (setq bitfield-size-pos nil
- bitfield-id-pos nil)))))
-
- (unless (eq ignore-labels t)
- (when (numberp c-maybe-labelp)
-
-
-
-
- (setq after-case:-pos (or tok start))
- (if (or (looking-at c-nonlabel-token-key)
-
- (save-excursion
- (and
- (c-safe (c-backward-sexp) t)
- (looking-at c-nonlabel-token-2-key))))
- (setq c-maybe-labelp nil)
- (if after-labels-pos
- (if (not last-label-pos)
- (setq last-label-pos (or tok start)))
- (setq after-labels-pos (or tok start)))
- (setq c-maybe-labelp t
- label-good-pos nil)))
- (when (and (not label-good-pos)
-
- (looking-at c-nonlabel-token-key))
-
-
-
- (setq label-good-pos (or tok start))))
-
- (setq sym nil
- pptok ptok
- ptok tok
- tok (point)
- pos tok)
- )
- )
-
- (while stack
- (if (and (vectorp saved-pos) (eq (length saved-pos) 3))
- (c-bos-report-error))
- (setq saved-pos (cdr (car stack))
- stack (cdr stack)))
- (when (and (eq ret 'same)
- (not (memq sym '(boundary ignore nil))))
-
-
- (if (setq saved (if (looking-at c-block-stmt-1-key)
- ptok
- pptok))
- (cond ((> start saved) (setq pos saved))
- ((= start saved) (setq ret 'up)))))
- (when (and (not ignore-labels)
- (eq c-maybe-labelp t)
- (not (eq ret 'beginning))
- after-labels-pos
- (not bitfield-type-pos)
- (or (not label-good-pos)
- (<= label-good-pos pos)
- (progn
- (goto-char (if (and last-label-pos
- (< last-label-pos start))
- last-label-pos
- pos))
- (looking-at c-label-kwds-regexp))))
-
-
- (if (< after-labels-pos start)
- (setq pos after-labels-pos)
- (setq ret 'label)
- (if (and last-label-pos (< last-label-pos start))
-
- (setq pos last-label-pos)))))
-
- (goto-char pos)
- (when (and after-case:-pos
- (not (eq ret 'beginning))
- (looking-at c-case-kwds-regexp))
- (if (< after-case:-pos start)
- (setq pos after-case:-pos))
- (if (eq ret 'same)
- (setq ret 'label)))
-
- (while (progn
- (c-backward-syntactic-ws)
-
- (and (not (c-at-vsemi-p (point)))
- (/= (skip-chars-backward "-+!*&~@`#") 0)))
- (setq pos (point)))
- (goto-char pos)
- ret)))
- (defun c-punctuation-in (from to)
- "Return non-nil if there is a non-comment non-macro punctuation character
- between FROM and TO. FROM must not be in a string or comment. The returned
- value is the position of the first such character."
- (save-excursion
- (goto-char from)
- (let ((pos (point)))
- (while (progn (skip-chars-forward c-symbol-chars to)
- (c-forward-syntactic-ws to)
- (> (point) pos))
- (setq pos (point))))
- (and (< (point) to) (point))))
- (defun c-crosses-statement-barrier-p (from to)
- "Return non-nil if buffer positions FROM to TO cross one or more
- statement or declaration boundaries. The returned value is actually
- the position of the earliest boundary char. FROM must not be within
- a string or comment.
- The variable `c-maybe-labelp' is set to the position of the first `:' that
- might start a label (i.e. not part of `::' and not preceded by `?'). If a
- single `?' is found, then `c-maybe-labelp' is cleared.
- For AWK, a statement which is terminated by an EOL (not a \; or a }) is
- regarded as having a \"virtual semicolon\" immediately after the last token on
- the line. If this virtual semicolon is _at_ from, the function recognizes it.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (let* ((skip-chars
-
- (if c-opt-cpp-symbol
- (concat (substring c-stmt-delim-chars 0 1)
- c-opt-cpp-symbol
- (substring c-stmt-delim-chars 1))
- c-stmt-delim-chars))
- (non-skip-list
- (append (substring skip-chars 1) nil))
- lit-range vsemi-pos)
- (save-restriction
- (widen)
- (save-excursion
- (catch 'done
- (goto-char from)
- (while (progn (skip-chars-forward
- skip-chars
- (min to (c-point 'bonl)))
- (< (point) to))
- (cond
-
- ((and (bolp)
- (save-excursion
- (progn
- (if (setq lit-range (c-literal-limits from))
- (goto-char (car lit-range)))
- (c-backward-syntactic-ws)
- (setq vsemi-pos (point))
- (c-at-vsemi-p))))
- (throw 'done vsemi-pos))
-
- ((setq lit-range (c-literal-limits from))
- (goto-char (cdr lit-range)))
- ((eq (char-after) ?:)
- (forward-char)
- (if (and (eq (char-after) ?:)
- (< (point) to))
-
- (forward-char)
- (setq c-maybe-labelp (1- (point)))))
- ((eq (char-after) ??)
-
-
- (setq c-maybe-labelp nil
- skip-chars (substring c-stmt-delim-chars 0 -2)))
-
- ((and c-opt-cpp-symbol (looking-at c-opt-cpp-symbol)
- (save-excursion
- (forward-line 0)
- (looking-at c-opt-cpp-prefix)))
- (c-end-of-macro))
- ((memq (char-after) non-skip-list)
- (throw 'done (point)))))
-
- (c-backward-syntactic-ws from)
- (if (and (< (point) to)
- (c-at-vsemi-p))
- (point)
- nil))))))
- (defun c-at-statement-start-p ()
- "Return non-nil if the point is at the first token in a statement
- or somewhere in the syntactic whitespace before it.
- A \"statement\" here is not restricted to those inside code blocks.
- Any kind of declaration-like construct that occur outside function
- bodies is also considered a \"statement\".
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (save-excursion
- (let ((end (point))
- c-maybe-labelp)
- (c-syntactic-skip-backward (substring c-stmt-delim-chars 1) nil t)
- (or (bobp)
- (eq (char-before) ?})
- (and (eq (char-before) ?{)
- (not (and c-special-brace-lists
- (progn (backward-char)
- (c-looking-at-special-brace-list)))))
- (c-crosses-statement-barrier-p (point) end)))))
- (defun c-at-expression-start-p ()
- "Return non-nil if the point is at the first token in an expression or
- statement, or somewhere in the syntactic whitespace before it.
- An \"expression\" here is a bit different from the normal language
- grammar sense: It's any sequence of expression tokens except commas,
- unless they are enclosed inside parentheses of some kind. Also, an
- expression never continues past an enclosing parenthesis, but it might
- contain parenthesis pairs of any sort except braces.
- Since expressions never cross statement boundaries, this function also
- recognizes statement beginnings, just like `c-at-statement-start-p'.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (save-excursion
- (let ((end (point))
- (c-stmt-delim-chars c-stmt-delim-chars-with-comma)
- c-maybe-labelp)
- (c-syntactic-skip-backward (substring c-stmt-delim-chars 1) nil t)
- (or (bobp)
- (memq (char-before) '(?{ ?}))
- (save-excursion (backward-char)
- (looking-at "\\s("))
- (c-crosses-statement-barrier-p (point) end)))))
- (defun c-forward-single-comment ()
- "Move forward past whitespace and the closest following comment, if any.
- Return t if a comment was found, nil otherwise. In either case, the
- point is moved past the following whitespace. Line continuations,
- i.e. a backslashes followed by line breaks, are treated as whitespace.
- The line breaks that end line comments are considered to be the
- comment enders, so the point will be put on the beginning of the next
- line if it moved past a line comment.
- This function does not do any hidden buffer changes."
- (let ((start (point)))
- (when (looking-at "\\([ \t\n\r\f\v]\\|\\\\[\n\r]\\)+")
- (goto-char (match-end 0)))
- (when (forward-comment 1)
- (if (eobp)
-
-
- nil
-
-
-
- (if (and (eolp) (elt (parse-partial-sexp start (point)) 7))
- (condition-case nil (forward-char 1)))
- t))))
- (defsubst c-forward-comments ()
- "Move forward past all following whitespace and comments.
- Line continuations, i.e. a backslashes followed by line breaks, are
- treated as whitespace.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (while (or
-
-
-
- (and (forward-comment 5)
-
-
- (not (eobp)))
- (when (looking-at "\\\\[\n\r]")
- (forward-char 2)
- t))))
- (defun c-backward-single-comment ()
- "Move backward past whitespace and the closest preceding comment, if any.
- Return t if a comment was found, nil otherwise. In either case, the
- point is moved past the preceding whitespace. Line continuations,
- i.e. a backslashes followed by line breaks, are treated as whitespace.
- The line breaks that end line comments are considered to be the
- comment enders, so the point cannot be at the end of the same line to
- move over a line comment.
- This function does not do any hidden buffer changes."
- (let ((start (point)))
-
-
-
-
- (while (progn
- (skip-chars-backward " \t\n\r\f\v")
- (and (looking-at "[\n\r]")
- (eq (char-before) ?\\)))
- (backward-char))
- (if (bobp)
-
-
- nil
-
-
-
-
- (re-search-forward "\\=\\s *[\n\r]" start t)
- (if (if (let (open-paren-in-column-0-is-defun-start) (forward-comment -1))
- (if (eolp)
-
-
-
- (let (open-paren-in-column-0-is-defun-start)
- (forward-comment -1))
- t))
-
-
- (if (looking-at "\\*/")
- (progn (forward-char 2) nil)
- t)))))
- (defsubst c-backward-comments ()
- "Move backward past all preceding whitespace and comments.
- Line continuations, i.e. a backslashes followed by line breaks, are
- treated as whitespace. The line breaks that end line comments are
- considered to be the comment enders, so the point cannot be at the end
- of the same line to move over a line comment. Unlike
- c-backward-syntactic-ws, this function doesn't move back over
- preprocessor directives.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (let ((start (point)))
- (while (and
-
-
- (not (bobp))
- (if (let (open-paren-in-column-0-is-defun-start)
- (forward-comment -1))
- (if (looking-at "\\*/")
-
-
- (progn (forward-char 2) nil)
- t)
-
-
-
- (when (and (looking-at "[\n\r]")
- (eq (char-before) ?\\)
- (< (point) start))
- (backward-char)
- t))))))
- (defmacro c-debug-sws-msg (&rest args)
-
- )
- (defmacro c-put-is-sws (beg end)
-
- `(let ((beg ,beg) (end ,end))
- (put-text-property beg end 'c-is-sws t)
- ,@(when (facep 'c-debug-is-sws-face)
- `((c-debug-add-face beg end 'c-debug-is-sws-face)))))
- (defmacro c-put-in-sws (beg end)
-
- `(let ((beg ,beg) (end ,end))
- (put-text-property beg end 'c-in-sws t)
- ,@(when (facep 'c-debug-is-sws-face)
- `((c-debug-add-face beg end 'c-debug-in-sws-face)))))
- (defmacro c-remove-is-sws (beg end)
-
- `(let ((beg ,beg) (end ,end))
- (remove-text-properties beg end '(c-is-sws nil))
- ,@(when (facep 'c-debug-is-sws-face)
- `((c-debug-remove-face beg end 'c-debug-is-sws-face)))))
- (defmacro c-remove-in-sws (beg end)
-
- `(let ((beg ,beg) (end ,end))
- (remove-text-properties beg end '(c-in-sws nil))
- ,@(when (facep 'c-debug-is-sws-face)
- `((c-debug-remove-face beg end 'c-debug-in-sws-face)))))
- (defmacro c-remove-is-and-in-sws (beg end)
-
- `(let ((beg ,beg) (end ,end))
- (remove-text-properties beg end '(c-is-sws nil c-in-sws nil))
- ,@(when (facep 'c-debug-is-sws-face)
- `((c-debug-remove-face beg end 'c-debug-is-sws-face)
- (c-debug-remove-face beg end 'c-debug-in-sws-face)))))
- (defsubst c-invalidate-sws-region-after (beg end)
-
-
-
-
-
-
- (save-excursion
-
-
-
-
-
-
-
- (goto-char end)
- (skip-chars-forward " \t\f\v")
- (when (and (eolp) (not (eobp)))
- (setq end (1+ (point)))))
- (when (and (= beg end)
- (get-text-property beg 'c-in-sws)
- (> beg (point-min))
- (get-text-property (1- beg) 'c-in-sws))
-
-
-
-
-
-
-
-
-
-
-
- (setq beg (1- beg)))
- (c-debug-sws-msg "c-invalidate-sws-region-after [%s..%s]" beg end)
- (c-remove-is-and-in-sws beg end))
- (defun c-forward-sws ()
-
-
-
- (let (
-
- (rung-pos (point)) next-rung-pos rung-end-pos last-put-in-sws-pos
- rung-is-marked next-rung-is-marked simple-ws-end
-
-
-
-
-
-
- safe-start)
-
-
-
- (skip-chars-forward " \t\n\r\f\v")
- (when (looking-at c-syntactic-ws-start)
- (setq rung-end-pos (min (1+ (point)) (point-max)))
- (if (setq rung-is-marked (text-property-any rung-pos rung-end-pos
- 'c-is-sws t))
-
-
-
-
- (setq rung-pos (1- (next-single-property-change
- rung-is-marked 'c-is-sws nil rung-end-pos)))
-
-
-
- (setq rung-pos (point)))
- (while
- (progn
- (while
- (when (and rung-is-marked
- (get-text-property (point) 'c-in-sws))
-
-
- (goto-char (next-single-property-change
- (point) 'c-in-sws nil (point-max)))
- (unless (get-text-property (point) 'c-is-sws)
-
-
- (or (get-text-property (1- (point)) 'c-is-sws)
- (goto-char (previous-single-property-change
- (point) 'c-is-sws)))
- (backward-char))
- (c-debug-sws-msg
- "c-forward-sws cached move %s -> %s (max %s)"
- rung-pos (point) (point-max))
- (setq rung-pos (point))
- (and (> (skip-chars-forward " \t\n\r\f\v") 0)
- (not (eobp))))
-
-
-
-
-
- (c-debug-sws-msg
- "c-forward-sws extending rung with [%s..%s] (max %s)"
- (1+ rung-pos) (1+ (point)) (point-max))
- (unless (get-text-property (point) 'c-is-sws)
-
-
-
- (c-remove-in-sws (point) (1+ (point))))
- (c-put-is-sws (1+ rung-pos)
- (1+ (point)))
- (c-put-in-sws rung-pos
- (setq rung-pos (point)
- last-put-in-sws-pos rung-pos)))
- (setq simple-ws-end (point))
- (c-forward-comments)
- (cond
- ((/= (point) simple-ws-end)
-
-
- (not (eobp)))
- ((save-excursion
- (and c-opt-cpp-prefix
- (looking-at c-opt-cpp-start)
- (progn (skip-chars-backward " \t")
- (bolp))
- (or (bobp)
- (progn (backward-char)
- (not (eq (char-before) ?\\))))))
-
- (end-of-line)
- (while (and (eq (char-before) ?\\)
- (= (forward-line 1) 0))
- (end-of-line))
- (forward-line 1)
- (setq safe-start t)
-
- (not (eobp)))))
-
-
- (setq next-rung-pos (point))
- (skip-chars-forward " \t\n\r\f\v")
- (setq rung-end-pos (min (1+ (point)) (point-max)))
- (if (or
-
-
-
- (and safe-start
- (or rung-is-marked
- (not (get-text-property simple-ws-end 'c-in-sws))))
-
-
-
-
- (and (setq next-rung-is-marked
- (text-property-any next-rung-pos rung-end-pos
- 'c-is-sws t))
- safe-start))
- (progn
- (c-debug-sws-msg
- "c-forward-sws caching [%s..%s] - [%s..%s] (max %s)"
- rung-pos (1+ simple-ws-end) next-rung-pos rung-end-pos
- (point-max))
-
-
-
- (c-remove-is-sws (1+ simple-ws-end) next-rung-pos)
- (unless (and rung-is-marked (= rung-pos simple-ws-end))
- (c-put-is-sws rung-pos
- (1+ simple-ws-end))
- (setq rung-is-marked t))
- (c-put-in-sws rung-pos
- (setq rung-pos (point)
- last-put-in-sws-pos rung-pos))
- (unless (get-text-property (1- rung-end-pos) 'c-is-sws)
-
-
-
- (c-remove-in-sws (1- rung-end-pos) rung-end-pos))
- (c-put-is-sws next-rung-pos
- rung-end-pos))
- (c-debug-sws-msg
- "c-forward-sws not caching [%s..%s] - [%s..%s] (max %s)"
- rung-pos (1+ simple-ws-end) next-rung-pos rung-end-pos
- (point-max))
-
-
-
-
- (if (setq rung-is-marked next-rung-is-marked)
- (setq rung-pos (1- (next-single-property-change
- rung-is-marked 'c-is-sws nil rung-end-pos)))
- (setq rung-pos next-rung-pos))
- (setq safe-start t)))
-
-
-
- (when (eq last-put-in-sws-pos (point))
- (cond ((< last-put-in-sws-pos (point-max))
- (c-debug-sws-msg
- "c-forward-sws clearing at %s for cache separation"
- last-put-in-sws-pos)
- (c-remove-in-sws last-put-in-sws-pos
- (1+ last-put-in-sws-pos)))
- (t
-
-
-
-
- (c-debug-sws-msg
- "c-forward-sws clearing thoroughly at %s for cache separation"
- (1- last-put-in-sws-pos))
- (c-remove-is-and-in-sws (1- last-put-in-sws-pos)
- last-put-in-sws-pos))))
- )))
- (defun c-backward-sws ()
-
-
-
- (let (
-
- (rung-pos (point)) next-rung-pos last-put-in-sws-pos
- rung-is-marked simple-ws-beg cmt-skip-pos)
-
-
-
-
-
- (skip-chars-backward " \t\f")
- (when (and (not (bobp))
- (save-excursion
- (backward-char)
- (looking-at c-syntactic-ws-end)))
-
-
-
- (setq simple-ws-beg (point))
- (skip-chars-backward " \t\n\r\f\v")
- (if (setq rung-is-marked (text-property-any
- (point) (min (1+ rung-pos) (point-max))
- 'c-is-sws t))
-
-
-
-
- (goto-char (setq rung-pos rung-is-marked))
- (goto-char simple-ws-beg))
- (while
- (progn
- (while
- (when (and rung-is-marked
- (not (bobp))
- (get-text-property (1- (point)) 'c-in-sws))
-
-
- (goto-char (previous-single-property-change
- (point) 'c-in-sws nil (point-min)))
- (unless (get-text-property (point) 'c-is-sws)
-
-
- (goto-char (next-single-property-change
- (point) 'c-is-sws)))
- (c-debug-sws-msg
- "c-backward-sws cached move %s <- %s (min %s)"
- (point) rung-pos (point-min))
- (setq rung-pos (point))
- (if (and (< (min (skip-chars-backward " \t\f\v")
- (progn
- (setq simple-ws-beg (point))
- (skip-chars-backward " \t\n\r\f\v")))
- 0)
- (setq rung-is-marked
- (text-property-any (point) rung-pos
- 'c-is-sws t)))
- t
- (goto-char simple-ws-beg)
- nil))
-
-
-
-
-
- (c-debug-sws-msg
- "c-backward-sws extending rung with [%s..%s] (min %s)"
- rung-is-marked rung-pos (point-min))
- (unless (get-text-property (1- rung-pos) 'c-is-sws)
-
-
-
- (c-remove-in-sws (1- rung-pos) rung-pos))
- (c-put-is-sws rung-is-marked
- rung-pos)
- (c-put-in-sws rung-is-marked
- (1- rung-pos))
- (setq rung-pos rung-is-marked
- last-put-in-sws-pos rung-pos))
- (c-backward-comments)
- (setq cmt-skip-pos (point))
- (cond
- ((and c-opt-cpp-prefix
- (/= cmt-skip-pos simple-ws-beg)
- (c-beginning-of-macro))
-
- (let ((cpp-beg (point)))
-
-
-
- (goto-char simple-ws-beg)
- (beginning-of-line)
- (while (and (> (point) cmt-skip-pos)
- (progn (backward-char)
- (eq (char-before) ?\\)))
- (beginning-of-line))
- (if (< (point) cmt-skip-pos)
-
-
-
- (progn (goto-char cmt-skip-pos)
- nil)
-
-
-
-
-
-
- (goto-char simple-ws-beg)
- (skip-chars-backward " \t\n\r\f\v")
- (if (eq (char-before) ?\\)
- (forward-char))
- (forward-line 1)
- (if (< (point) simple-ws-beg)
-
-
- (setq simple-ws-beg (point)))
- (goto-char cpp-beg)
- t)))
- ((/= (save-excursion
- (skip-chars-forward " \t\n\r\f\v" simple-ws-beg)
- (setq next-rung-pos (point)))
- simple-ws-beg)
-
-
-
-
-
- (goto-char next-rung-pos)
- t)))
-
-
- (setq next-rung-pos (point))
- (skip-chars-backward " \t\f\v")
- (if (or
-
-
- rung-is-marked
- (not (get-text-property (1- simple-ws-beg) 'c-in-sws))
-
- (save-excursion
- (skip-chars-backward " \t\n\r\f\v")
- (text-property-any (point) (min (1+ next-rung-pos) (point-max))
- 'c-is-sws t)))
- (progn
- (c-debug-sws-msg
- "c-backward-sws caching [%s..%s] - [%s..%s] (min %s)"
- (point) (1+ next-rung-pos)
- simple-ws-beg (min (1+ rung-pos) (point-max))
- (point-min))
-
-
-
- (c-remove-is-sws (1+ next-rung-pos) simple-ws-beg)
- (unless (and rung-is-marked (= simple-ws-beg rung-pos))
- (let ((rung-end-pos (min (1+ rung-pos) (point-max))))
- (unless (get-text-property (1- rung-end-pos) 'c-is-sws)
-
-
-
- (c-remove-in-sws (1- rung-end-pos) rung-end-pos))
- (c-put-is-sws simple-ws-beg
- rung-end-pos)
- (setq rung-is-marked t)))
- (c-put-in-sws (setq simple-ws-beg (point)
- last-put-in-sws-pos simple-ws-beg)
- rung-pos)
- (c-put-is-sws (setq rung-pos simple-ws-beg)
- (1+ next-rung-pos)))
- (c-debug-sws-msg
- "c-backward-sws not caching [%s..%s] - [%s..%s] (min %s)"
- (point) (1+ next-rung-pos)
- simple-ws-beg (min (1+ rung-pos) (point-max))
- (point-min))
- (setq rung-pos next-rung-pos
- simple-ws-beg (point))
- ))
-
-
-
- (when (eq last-put-in-sws-pos (point))
- (cond ((< (point-min) last-put-in-sws-pos)
- (c-debug-sws-msg
- "c-backward-sws clearing at %s for cache separation"
- (1- last-put-in-sws-pos))
- (c-remove-in-sws (1- last-put-in-sws-pos)
- last-put-in-sws-pos))
- ((> (point-min) 1)
-
-
-
-
- (c-debug-sws-msg
- "c-backward-sws clearing thoroughly at %s for cache separation"
- last-put-in-sws-pos)
- (c-remove-is-and-in-sws last-put-in-sws-pos
- (1+ last-put-in-sws-pos)))))
- )))
- (defun c-partial-ws-p (beg end)
-
-
-
-
-
-
-
-
- (save-excursion
- (let ((end+1 (min (1+ end) (point-max))))
- (or (progn (goto-char (max (point-min) (1- beg)))
- (c-skip-ws-forward end)
- (eq (point) end))
- (progn (goto-char beg)
- (c-skip-ws-forward end+1)
- (eq (point) end+1))))))
- (defconst c-state-cache-too-far 5000)
- (defvar c-state-cache nil)
- (make-variable-buffer-local 'c-state-cache)
- (defvar c-state-cache-good-pos 1)
- (make-variable-buffer-local 'c-state-cache-good-pos)
- (defconst c-state-nonlit-pos-interval 3000)
- (defvar c-state-nonlit-pos-cache nil)
- (make-variable-buffer-local 'c-state-nonlit-pos-cache)
- (defvar c-state-nonlit-pos-cache-limit 1)
- (make-variable-buffer-local 'c-state-nonlit-pos-cache-limit)
- (defvar c-state-semi-nonlit-pos-cache nil)
- (make-variable-buffer-local 'c-state-semi-nonlit-pos-cache)
- (defvar c-state-semi-nonlit-pos-cache-limit 1)
- (make-variable-buffer-local 'c-state-semi-nonlit-pos-cache-limit)
- (defsubst c-state-pp-to-literal (from to)
-
-
-
-
-
-
-
-
-
- (save-excursion
- (let ((s (parse-partial-sexp from to))
- ty)
- (when (or (nth 3 s) (nth 4 s))
- (setq ty (cond
- ((nth 3 s) 'string)
- ((eq (nth 7 s) t) 'c++)
- (t 'c)))
- (parse-partial-sexp (point) (point-max)
- nil
- nil
- s
- 'syntax-table))
- (if ty
- `(,s ,ty (,(nth 8 s) . ,(point)))
- `(,s)))))
- (defun c-state-safe-place (here)
-
-
-
-
-
-
-
-
- (save-restriction
- (widen)
- (save-excursion
- (let ((c c-state-nonlit-pos-cache)
- pos npos high-pos lit macro-beg macro-end)
-
- (while (and c (> (car c) c-state-nonlit-pos-cache-limit))
- (setq c (cdr c)))
- (setq c-state-nonlit-pos-cache c)
- (while (and c (> (car c) here))
- (setq high-pos (car c))
- (setq c (cdr c)))
- (setq pos (or (car c) (point-min)))
- (unless high-pos
- (while
-
- (and
- (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here)
-
- (progn
- (setq lit (car (cddr (c-state-pp-to-literal pos npos))))
- (or (null lit)
- (prog1 (<= (cdr lit) here)
- (setq npos (cdr lit)))))
-
- (progn
- (goto-char npos)
- (setq macro-beg
- (and (c-beginning-of-macro) (/= (point) npos) (point)))
- (when macro-beg
- (c-syntactic-end-of-macro)
- (or (eobp) (forward-char))
- (setq macro-end (point)))
- (or (null macro-beg)
- (prog1 (<= macro-end here)
- (setq npos macro-end)))))
- (setq pos npos)
- (setq c-state-nonlit-pos-cache (cons pos c-state-nonlit-pos-cache)))
-
-
-
- (setq c-state-nonlit-pos-cache (cons npos c-state-nonlit-pos-cache)))
- (if (> pos c-state-nonlit-pos-cache-limit)
- (setq c-state-nonlit-pos-cache-limit pos))
- pos))))
- (defun c-state-semi-safe-place (here)
-
-
- (save-restriction
- (widen)
- (save-excursion
- (let ((c c-state-semi-nonlit-pos-cache)
- pos npos high-pos lit macro-beg macro-end)
-
- (while (and c (> (car c) c-state-semi-nonlit-pos-cache-limit))
- (setq c (cdr c)))
- (setq c-state-semi-nonlit-pos-cache c)
-
- (while (and c (> (car c) here))
- (setq high-pos (car c))
- (setq c (cdr c)))
- (setq pos (or (car c) (point-min)))
-
- (unless high-pos
- (while
-
- (and
- (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here)
-
-
- (progn
- (setq lit (car (cddr (c-state-pp-to-literal pos npos))))
- (or (null lit)
- (prog1 (<= (cdr lit) here)
- (setq npos (cdr lit))))))
-
- (setq pos npos)
- (setq c-state-semi-nonlit-pos-cache
- (cons pos c-state-semi-nonlit-pos-cache))))
- (if (> pos c-state-semi-nonlit-pos-cache-limit)
- (setq c-state-semi-nonlit-pos-cache-limit pos))
- pos))))
- (defun c-state-literal-at (here)
-
-
-
-
-
-
-
-
- (save-restriction
- (widen)
- (save-excursion
- (let ((pos (c-state-safe-place here)))
- (car (cddr (c-state-pp-to-literal pos here)))))))
- (defsubst c-state-lit-beg (pos)
-
- (or (car (c-state-literal-at pos))
- pos))
- (defsubst c-state-cache-non-literal-place (pos state)
-
-
- (let ((res (if (or (nth 3 state)
- (nth 4 state))
- (nth 8 state)
- pos)))
- (save-excursion
- (goto-char res)
- (if (c-beginning-of-macro)
- (point)
- res))))
- (defvar c-state-point-min 1)
- (make-variable-buffer-local 'c-state-point-min)
- (defvar c-state-point-min-lit-type nil)
- (make-variable-buffer-local 'c-state-point-min-lit-type)
- (defvar c-state-point-min-lit-start nil)
- (make-variable-buffer-local 'c-state-point-min-lit-start)
- (defvar c-state-min-scan-pos 1)
- (make-variable-buffer-local 'c-state-min-scan-pos)
- (defun c-state-get-min-scan-pos ()
-
-
- (or c-state-min-scan-pos
- (save-restriction
- (save-excursion
- (widen)
- (goto-char c-state-point-min-lit-start)
- (if (eq c-state-point-min-lit-type 'string)
- (forward-sexp)
- (forward-comment 1))
- (setq c-state-min-scan-pos (point))))))
- (defun c-state-mark-point-min-literal ()
-
-
-
- (let ((p-min (point-min))
- lit)
- (save-restriction
- (widen)
- (setq lit (c-state-literal-at p-min))
- (if lit
- (setq c-state-point-min-lit-type
- (save-excursion
- (goto-char (car lit))
- (cond
- ((looking-at c-block-comment-start-regexp) 'c)
- ((looking-at c-line-comment-starter) 'c++)
- (t 'string)))
- c-state-point-min-lit-start (car lit)
- c-state-min-scan-pos (cdr lit))
- (setq c-state-point-min-lit-type nil
- c-state-point-min-lit-start nil
- c-state-min-scan-pos p-min)))))
- (defvar c-state-brace-pair-desert nil)
- (make-variable-buffer-local 'c-state-brace-pair-desert)
- (defmacro c-state-cache-top-lparen (&optional cache)
-
-
- (let ((cash (or cache 'c-state-cache)))
- `(if (consp (car ,cash))
- (caar ,cash)
- (car ,cash))))
- (defmacro c-state-cache-top-paren (&optional cache)
-
-
- (let ((cash (or cache 'c-state-cache)))
- `(if (consp (car ,cash))
- (cdar ,cash)
- (car ,cash))))
- (defmacro c-state-cache-after-top-paren (&optional cache)
-
-
- (let ((cash (or cache 'c-state-cache)))
- `(if (consp (car ,cash))
- (cdar ,cash)
- (and (car ,cash)
- (1+ (car ,cash))))))
- (defun c-get-cache-scan-pos (here)
-
-
-
-
-
-
- (let ((c c-state-cache) elt)
-
- (while (and c
- (>= (c-state-cache-top-lparen c) here))
- (setq c (cdr c)))
- (setq elt (car c))
- (cond
- ((consp elt)
- (if (> (cdr elt) here)
- (1+ (car elt))
- (cdr elt)))
- (elt (1+ elt))
- ((<= (c-state-get-min-scan-pos) here)
- (c-state-get-min-scan-pos))
- (t nil))))
- (defvar c-state-old-cpp-beg nil)
- (make-variable-buffer-local 'c-state-old-cpp-beg)
- (defvar c-state-old-cpp-end nil)
- (make-variable-buffer-local 'c-state-old-cpp-end)
- (defun c-get-fallback-scan-pos (here)
-
-
- (save-excursion
-
-
- (goto-char here)
- (let ((cnt 2))
- (while (not (or (bobp) (zerop cnt)))
- (c-beginning-of-defun-1)
- (if (eq (char-after) ?\{)
- (setq cnt (1- cnt)))))
- (point)))
- (defun c-state-balance-parens-backwards (here- here+ top)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let (pos pa ren+1 lonely-rens)
- (save-excursion
- (save-restriction
- (narrow-to-region (point-min) top)
- (setq pos here+)
- (c-safe
- (while
- (setq ren+1 (scan-lists pos 1 1))
- (setq lonely-rens (cons ren+1 lonely-rens)
- pos ren+1)))))
-
-
-
- (setq pos here-)
- (when lonely-rens
- (c-safe
- (while
- (and lonely-rens
- (setq pa (scan-lists pos -1 1)))
- (setq pos pa)
- (setq lonely-rens (cdr lonely-rens)))))
- pos))
- (defun c-parse-state-get-strategy (here good-pos)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((cache-pos (c-get-cache-scan-pos here))
- BOD-pos
- strategy
- start-point
- how-far)
- (setq good-pos (or good-pos (c-state-get-min-scan-pos)))
- (cond
- ((< here (c-state-get-min-scan-pos))
- (setq strategy 'IN-LIT
- start-point nil
- cache-pos nil
- how-far 0))
- ((<= good-pos here)
- (setq strategy 'forward
- start-point (max good-pos cache-pos)
- how-far (- here start-point)))
- ((< (- good-pos here) (- here cache-pos))
- (setq strategy 'backward
- how-far (- good-pos here)))
- (t
- (setq strategy 'forward
- how-far (- here cache-pos)
- start-point cache-pos)))
-
-
- (when (> how-far c-state-cache-too-far)
- (setq BOD-pos (c-get-fallback-scan-pos here))
- (if (< (- here BOD-pos) how-far)
- (setq strategy 'BOD
- start-point BOD-pos)))
- (list
- strategy
- (and (memq strategy '(forward backward)) cache-pos)
- (and (memq strategy '(forward BOD)) start-point))))
- (defun c-renarrow-state-cache ()
-
-
- (if (< (point-min) c-state-point-min)
-
-
-
- (progn
- (c-state-mark-point-min-literal)
- (setq c-state-cache nil
- c-state-cache-good-pos c-state-min-scan-pos
- c-state-brace-pair-desert nil))
-
-
- (unless (and c-state-point-min-lit-start
- (< (point-min) (c-state-get-min-scan-pos)))
- (c-state-mark-point-min-literal))
-
- (let ((ptr (cons nil c-state-cache))
- pa)
- (while (and (setq pa (c-state-cache-top-lparen (cdr ptr)))
- (>= pa (point-min)))
- (setq ptr (cdr ptr)))
- (when (consp ptr)
- (if (eq (cdr ptr) c-state-cache)
- (setq c-state-cache nil
- c-state-cache-good-pos c-state-min-scan-pos)
- (setcdr ptr nil)
- (setq c-state-cache-good-pos (1+ (c-state-cache-top-lparen))))
- )))
- (setq c-state-point-min (point-min)))
- (defun c-append-lower-brace-pair-to-state-cache (from &optional upper-lim)
-
-
-
-
-
-
-
-
-
-
- (save-excursion
- (save-restriction
- (let ((bra from) ce
- new-cons
- (cache-pos (c-state-cache-top-lparen))
- (macro-start-or-from
- (progn (goto-char from)
- (c-beginning-of-macro)
- (point))))
- (or upper-lim (setq upper-lim from))
-
- (unless (and c-state-brace-pair-desert
- (eq cache-pos (car c-state-brace-pair-desert))
- (<= from (cdr c-state-brace-pair-desert)))
-
- (if (and c-state-brace-pair-desert
- (eq cache-pos (car c-state-brace-pair-desert)))
- (narrow-to-region (cdr c-state-brace-pair-desert) (point-max)))
-
-
-
-
- (while
- (progn
- (c-safe
- (while
- (and (setq ce (scan-lists bra -1 -1))
- (setq bra (scan-lists ce -1 1))
- (or (> ce upper-lim)
- (not (eq (char-after bra) ?\{))
- (and (goto-char bra)
- (c-beginning-of-macro)
- (< (point) macro-start-or-from))))))
- (and ce (< ce bra)))
- (setq bra ce))
-
- (if (and ce (< bra ce) (eq (char-after bra) ?\{))
-
- (progn
- (setq new-cons (cons bra (1+ ce)))
- (cond
- ((consp (car c-state-cache))
- (setcar c-state-cache new-cons))
- ((and (numberp (car c-state-cache))
- (< ce (car c-state-cache)))
- (setcdr c-state-cache
- (cons new-cons (cdr c-state-cache))))
- (t (setq c-state-cache (cons new-cons c-state-cache)))))
-
- (setq c-state-brace-pair-desert (cons cache-pos from))))))))
- (defsubst c-state-push-any-brace-pair (bra+1 macro-start-or-here)
-
-
-
-
-
-
-
-
-
-
-
-
-
- (if bra+1
- (if (or (> bra+1 macro-start-or-here)
- (progn (goto-char bra+1)
- (not (c-beginning-of-macro))))
- (setq c-state-cache
- (cons (cons (1- bra+1)
- (scan-lists bra+1 1 1))
- (if (consp (car c-state-cache))
- (cdr c-state-cache)
- c-state-cache)))
-
-
-
- (c-append-lower-brace-pair-to-state-cache (1- bra+1)))))
- (defun c-append-to-state-cache (from)
-
-
-
-
-
-
-
- (let ((here-bol (c-point 'bol (point-max)))
- (macro-start-or-here
- (save-excursion (goto-char (point-max))
- (if (c-beginning-of-macro)
- (point)
- (point-max))))
- pa+1
- (ren+1 from)
-
-
- paren+1
- paren+1s
-
- bra+1 ce+1
- bra+1s
- mstart)
- (save-excursion
-
-
-
-
- (while
- (progn
-
-
-
-
-
-
- (c-safe
- (while t
- (setq pa+1 (scan-lists ren+1 1 -1)
- paren+1s (cons pa+1 paren+1s))
- (setq ren+1 (scan-lists pa+1 1 1))
- (if (and (eq (char-before pa+1) ?{))
- (setq bra+1 pa+1))
- (setcar paren+1s ren+1)))
- (if (and pa+1 (> pa+1 ren+1))
-
- (progn
-
-
-
-
- (c-state-push-any-brace-pair bra+1 macro-start-or-here)
-
- (setq c-state-cache (cons (1- pa+1) c-state-cache))
-
- (setq ren+1 pa+1 pa+1 nil bra+1 nil bra+1s nil)
- t)
-
-
-
-
-
- (c-safe (setq ren+1 (scan-lists ren+1 1 1))))))
-
- (c-state-push-any-brace-pair bra+1 macro-start-or-here)
-
- (while (and (setq paren+1 (car paren+1s))
- (> (if (> paren+1 macro-start-or-here)
- paren+1
- (goto-char paren+1)
- (setq mstart (and (c-beginning-of-macro)
- (point)))
- (or mstart paren+1))
- here-bol))
- (setq paren+1s (cdr paren+1s)))
- (cond
- ((and paren+1 mstart)
- (min paren+1 mstart))
- (paren+1)
- (t from)))))
- (defun c-remove-stale-state-cache (good-pos pps-point)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (save-restriction
- (narrow-to-region 1 (point-max))
- (save-excursion
- (let* ((in-macro-start
- (save-excursion
- (goto-char (point-max))
- (and (c-beginning-of-macro)
- (point))))
- (good-pos-actual-macro-start
-
- (and (< good-pos (point-max))
- (save-excursion
- (goto-char good-pos)
- (and (c-beginning-of-macro)
- (point)))))
- (good-pos-actual-macro-end
-
- (and good-pos-actual-macro-start
- (save-excursion
- (goto-char good-pos-actual-macro-start)
- (c-end-of-macro)
- (point))))
- pps-state
- pos
- upper-lim
- scan-back-pos
- pair-beg pps-point-state target-depth)
-
-
- (setq upper-lim
- (if (or (null c-state-old-cpp-beg)
- (and (> (point-max) c-state-old-cpp-beg)
- (< (point-max) c-state-old-cpp-end)))
- (point-max)
- (min (point-max) c-state-old-cpp-beg)))
- (while (and c-state-cache (>= (c-state-cache-top-lparen) upper-lim))
- (setq c-state-cache (cdr c-state-cache)))
-
-
-
- (when (and c-state-cache
- (consp (car c-state-cache))
- (> (cdar c-state-cache) upper-lim))
- (setcar c-state-cache (caar c-state-cache))
- (setq scan-back-pos (car c-state-cache)))
-
-
-
-
-
-
- (setq pos (if (and good-pos-actual-macro-end
- (not (eq good-pos-actual-macro-start
- in-macro-start)))
- (1+ good-pos-actual-macro-end)
-
- good-pos))
- (goto-char pos)
- (while (and c-state-cache
- (< (point) (point-max)))
- (cond
- ((null pps-state)
- (setq target-depth -1))
- ((eq (car pps-state) target-depth)
- (setq target-depth (1- (car pps-state))))
-
- )
-
- (setq pps-state
- (parse-partial-sexp
- (point) (if (< (point) pps-point) pps-point (point-max))
- target-depth
- nil pps-state))
- (if (= (point) pps-point)
- (setq pps-point-state pps-state))
- (when (eq (car pps-state) target-depth)
- (setq pos (point))
- (cond
- ((and (consp (car c-state-cache))
- (eq (point) (cdar c-state-cache)))
-
-
-
-
- (setq pair-beg (car-safe (cdr c-state-cache))
- c-state-cache (cdr-safe (cdr c-state-cache))))
- ((numberp (car c-state-cache))
- (setq pair-beg (car c-state-cache)
- c-state-cache (cdr c-state-cache)))
-
- ((numberp (cadr c-state-cache))
- (setq pair-beg (cadr c-state-cache)
- c-state-cache (cddr c-state-cache)))
-
-
- )))
- (if (< (point) pps-point)
- (setq pps-state (parse-partial-sexp (point) pps-point
- nil nil
- pps-state)))
-
-
- (when (and pair-beg (eq (char-after pair-beg) ?{))
- (if (consp (car-safe c-state-cache))
- (setq c-state-cache (cdr c-state-cache)))
- (setq c-state-cache (cons (cons pair-beg pos)
- c-state-cache)))
- (list pos scan-back-pos pps-state)))))
- (defun c-remove-stale-state-cache-backwards (here cache-pos)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((pos c-state-cache-good-pos)
- pa ren
- dropped-cons
-
- good-pos
- lit
- here-lit-start here-lit-end
-
- here- here+
- (here-bol (c-point 'bol here))
- (too-far-back (max (- here c-state-cache-too-far) (point-min))))
-
- (while (and c-state-cache
- (>= (setq pa (c-state-cache-top-lparen)) here))
- (setq dropped-cons (consp (car c-state-cache)))
- (setq c-state-cache (cdr c-state-cache))
- (setq pos pa))
-
-
- (cond
- ((and (consp (car c-state-cache))
- (> (cdar c-state-cache) here))
-
-
-
-
- (setq pos (caar c-state-cache))
- (setcar c-state-cache pos)
- (list (1+ pos) pos t))
-
-
-
- ((progn
- (setq lit (c-state-literal-at here)
- here-lit-start (or (car lit) here)
- here-lit-end (or (cdr lit) here))
-
- (save-excursion
- (goto-char here-lit-start)
- (if (and (c-beginning-of-macro)
- (or (null c-state-old-cpp-beg)
- (not (= (point) c-state-old-cpp-beg))))
- (progn
- (setq here- (point))
- (c-end-of-macro)
- (setq here+ (point)))
- (setq here- here-lit-start
- here+ here-lit-end)))
-
-
-
- (save-restriction
- (narrow-to-region cache-pos (point-max))
- (setq pos (c-state-balance-parens-backwards here- here+ pos)))
- nil))
- ((< pos here-lit-start)
-
-
-
-
-
- (list pos (and dropped-cons pos) t))
-
-
-
- ((progn
- (save-restriction
- (narrow-to-region here-bol (point-max))
- (setq pos here-lit-start)
- (c-safe (while (setq pa (scan-lists pos -1 1))
- (setq pos pa))))
- nil))
- ((setq ren (c-safe-scan-lists pos -1 -1 too-far-back))
-
- (list (1+ ren) (and dropped-cons pos) nil))
- (t
-
-
- (setq good-pos (c-state-lit-beg (c-point 'bopl here-bol)))
- (list good-pos (and dropped-cons good-pos) nil)))))
- (defun c-state-cache-init ()
- (setq c-state-cache nil
- c-state-cache-good-pos 1
- c-state-nonlit-pos-cache nil
- c-state-nonlit-pos-cache-limit 1
- c-state-brace-pair-desert nil
- c-state-point-min 1
- c-state-point-min-lit-type nil
- c-state-point-min-lit-start nil
- c-state-min-scan-pos 1
- c-state-old-cpp-beg nil
- c-state-old-cpp-end nil)
- (c-state-mark-point-min-literal))
- (defun c-invalidate-state-cache-1 (here)
-
-
-
-
-
-
-
-
-
-
- (if (< here c-state-nonlit-pos-cache-limit)
- (setq c-state-nonlit-pos-cache-limit here))
- (if (< here c-state-semi-nonlit-pos-cache-limit)
- (setq c-state-semi-nonlit-pos-cache-limit here))
-
-
-
- (if (or (null c-state-cache-good-pos)
- (< here (c-state-get-min-scan-pos)))
- (setq c-state-cache nil
- c-state-cache-good-pos nil
- c-state-min-scan-pos nil)
-
-
-
- (let ((here-bol (c-point 'bol here))
- too-high-pa
- dropped-cons
- pa)
-
- (while (and c-state-cache
- (>= (setq pa (c-state-cache-top-paren)) here))
- (setq dropped-cons (consp (car c-state-cache))
- too-high-pa (c-state-cache-top-lparen)
- c-state-cache (cdr c-state-cache)))
-
- (if (and dropped-cons
- (< too-high-pa (+ here c-state-cache-too-far)))
- (c-append-lower-brace-pair-to-state-cache too-high-pa here-bol))
- (setq c-state-cache-good-pos (or (c-state-cache-after-top-paren)
- (c-state-get-min-scan-pos)))))
-
- (when (car c-state-brace-pair-desert)
- (if (< here (car c-state-brace-pair-desert))
- (setq c-state-brace-pair-desert nil)
- (if (< here (cdr c-state-brace-pair-desert))
- (setcdr c-state-brace-pair-desert here)))))
- (defun c-parse-state-1 ()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let* ((here (point))
- (here-bopl (c-point 'bopl))
- strategy
-
- cache-pos
-
- good-pos
- start-point
- bopl-state
- res
- scan-backward-pos scan-forward-p)
-
- (unless (= (point-min) c-state-point-min)
- (c-renarrow-state-cache))
-
- (setq res (c-parse-state-get-strategy here c-state-cache-good-pos)
- strategy (car res)
- cache-pos (cadr res)
- start-point (nth 2 res))
- (when (eq strategy 'BOD)
- (setq c-state-cache nil
- c-state-cache-good-pos start-point))
-
- (save-restriction
- (cond
- ((memq strategy '(forward BOD))
- (narrow-to-region (point-min) here)
- (setq res (c-remove-stale-state-cache start-point here-bopl))
- (setq cache-pos (car res)
- scan-backward-pos (cadr res)
- bopl-state (car (cddr res)))
-
- (if scan-backward-pos
- (c-append-lower-brace-pair-to-state-cache scan-backward-pos))
- (setq good-pos
- (c-append-to-state-cache cache-pos))
- (setq c-state-cache-good-pos
- (if (and bopl-state
- (< good-pos (- here c-state-cache-too-far)))
- (c-state-cache-non-literal-place here-bopl bopl-state)
- good-pos)))
- ((eq strategy 'backward)
- (setq res (c-remove-stale-state-cache-backwards here cache-pos)
- good-pos (car res)
- scan-backward-pos (cadr res)
- scan-forward-p (car (cddr res)))
- (if scan-backward-pos
- (c-append-lower-brace-pair-to-state-cache
- scan-backward-pos))
- (setq c-state-cache-good-pos
- (if scan-forward-p
- (progn (narrow-to-region (point-min) here)
- (c-append-to-state-cache good-pos))
- good-pos)))
- (t
- (setq c-state-cache nil
- c-state-cache-good-pos nil)))))
- c-state-cache)
- (defun c-invalidate-state-cache (here)
-
-
-
-
-
-
- (c-with-<->-as-parens-suppressed
- (if (and c-state-old-cpp-beg
- (< c-state-old-cpp-beg here))
- (c-with-all-but-one-cpps-commented-out
- c-state-old-cpp-beg
- (min c-state-old-cpp-end here)
- (c-invalidate-state-cache-1 here))
- (c-with-cpps-commented-out
- (c-invalidate-state-cache-1 here)))))
- (defun c-parse-state ()
-
-
-
-
-
-
-
- (let (here-cpp-beg here-cpp-end)
- (save-excursion
- (when (c-beginning-of-macro)
- (setq here-cpp-beg (point))
- (unless
- (> (setq here-cpp-end (c-syntactic-end-of-macro))
- here-cpp-beg)
- (setq here-cpp-beg nil here-cpp-end nil))))
-
-
- (prog1
- (c-with-<->-as-parens-suppressed
- (if (and here-cpp-beg (> here-cpp-end here-cpp-beg))
- (c-with-all-but-one-cpps-commented-out
- here-cpp-beg here-cpp-end
- (c-parse-state-1))
- (c-with-cpps-commented-out
- (c-parse-state-1))))
- (setq c-state-old-cpp-beg (and here-cpp-beg (copy-marker here-cpp-beg t))
- c-state-old-cpp-end (and here-cpp-end (copy-marker here-cpp-end t)))
- )))
- (defvar c-debug-parse-state nil)
- (unless (fboundp 'c-real-parse-state)
- (fset 'c-real-parse-state (symbol-function 'c-parse-state)))
- (cc-bytecomp-defun c-real-parse-state)
- (defvar c-parse-state-state nil)
- (defun c-record-parse-state-state ()
- (setq c-parse-state-state
- (mapcar
- (lambda (arg)
- (cons arg (symbol-value arg)))
- '(c-state-cache
- c-state-cache-good-pos
- c-state-nonlit-pos-cache
- c-state-nonlit-pos-cache-limit
- c-state-brace-pair-desert
- c-state-point-min
- c-state-point-min-lit-type
- c-state-point-min-lit-start
- c-state-min-scan-pos
- c-state-old-cpp-beg
- c-state-old-cpp-end))))
- (defun c-replay-parse-state-state ()
- (message
- (concat "(setq "
- (mapconcat
- (lambda (arg)
- (format "%s %s%s" (car arg) (if (atom (cdr arg)) "" "'") (cdr arg)))
- c-parse-state-state " ")
- ")")))
- (defun c-debug-parse-state ()
- (let ((here (point)) (res1 (c-real-parse-state)) res2)
- (let ((c-state-cache nil)
- (c-state-cache-good-pos 1)
- (c-state-nonlit-pos-cache nil)
- (c-state-nonlit-pos-cache-limit 1)
- (c-state-brace-pair-desert nil)
- (c-state-point-min 1)
- (c-state-point-min-lit-type nil)
- (c-state-point-min-lit-start nil)
- (c-state-min-scan-pos 1)
- (c-state-old-cpp-beg nil)
- (c-state-old-cpp-end nil))
- (setq res2 (c-real-parse-state)))
- (unless (equal res1 res2)
-
-
-
-
-
-
-
-
-
-
-
-
- (message (concat "c-parse-state inconsistency at %s: "
- "using cache: %s, from scratch: %s")
- here res1 res2)
- (message "Old state:")
- (c-replay-parse-state-state))
- (c-record-parse-state-state)
- res1))
- (defun c-toggle-parse-state-debug (&optional arg)
- (interactive "P")
- (setq c-debug-parse-state (c-calculate-state arg c-debug-parse-state))
- (fset 'c-parse-state (symbol-function (if c-debug-parse-state
- 'c-debug-parse-state
- 'c-real-parse-state)))
- (c-keep-region-active))
- (when c-debug-parse-state
- (c-toggle-parse-state-debug 1))
- (defun c-whack-state-before (bufpos paren-state)
-
-
- (let* ((newstate (list nil))
- (ptr newstate)
- car)
- (while paren-state
- (setq car (car paren-state)
- paren-state (cdr paren-state))
- (if (< (if (consp car) (car car) car) bufpos)
- (setq paren-state nil)
- (setcdr ptr (list car))
- (setq ptr (cdr ptr))))
- (cdr newstate)))
- (defun c-whack-state-after (bufpos paren-state)
-
-
- (catch 'done
- (while paren-state
- (let ((car (car paren-state)))
- (if (consp car)
-
-
-
-
- (if (<= bufpos (car car))
- nil
- (if (< bufpos (cdr car))
-
-
-
-
-
- (throw 'done (cons (car car) (cdr paren-state)))
-
-
-
- (throw 'done paren-state)))
- (if (<= bufpos car)
- nil
-
- (throw 'done paren-state)))
- (setq paren-state (cdr paren-state)))
- nil)))
- (defun c-most-enclosing-brace (paren-state &optional bufpos)
-
-
- (let (enclosingp)
- (or bufpos (setq bufpos 134217727))
- (while paren-state
- (setq enclosingp (car paren-state)
- paren-state (cdr paren-state))
- (if (or (consp enclosingp)
- (>= enclosingp bufpos))
- (setq enclosingp nil)
- (setq paren-state nil)))
- enclosingp))
- (defun c-least-enclosing-brace (paren-state)
-
-
- (let (pos elem)
- (while paren-state
- (setq elem (car paren-state)
- paren-state (cdr paren-state))
- (if (integerp elem)
- (setq pos elem)))
- pos))
- (defun c-safe-position (bufpos paren-state)
-
-
-
-
-
-
-
-
-
-
- (when bufpos
- (let (elem)
- (catch 'done
- (while paren-state
- (setq elem (car paren-state))
- (if (consp elem)
- (cond ((< (cdr elem) bufpos)
- (throw 'done (cdr elem)))
- ((< (car elem) bufpos)
-
- (throw 'done (min (1+ (car elem)) bufpos))))
- (if (< elem bufpos)
-
-
-
-
- (throw 'done (min (1+ elem) bufpos))))
- (setq paren-state (cdr paren-state)))))))
- (defun c-beginning-of-syntax ()
-
-
-
-
- (let* ((paren-state c-state-cache)
- elem
- (pos (catch 'done
-
-
-
-
- (while paren-state
- (setq elem (car paren-state))
- (if (consp elem)
- (cond ((<= (cdr elem) (point))
- (throw 'done (cdr elem)))
- ((<= (car elem) (point))
- (throw 'done (car elem))))
- (if (<= elem (point))
- (throw 'done elem)))
- (setq paren-state (cdr paren-state)))
- (point-min))))
- (if (> pos (- (point) 4000))
- (goto-char pos)
-
-
-
-
- (c-beginning-of-defun-1)
- (if (< (point) pos)
- (goto-char pos)))))
- (defun c-on-identifier ()
- "Return non-nil if the point is on or directly after an identifier.
- Keywords are recognized and not considered identifiers. If an
- identifier is detected, the returned value is its starting position.
- If an identifier ends at the point and another begins at it \(can only
- happen in Pike) then the point for the preceding one is returned.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
-
- (save-excursion
- (skip-syntax-backward "w_")
- (or
-
- (and (looking-at c-symbol-start)
- (not (looking-at c-keywords-regexp))
- (point))
- (when (c-major-mode-is 'pike-mode)
-
- (let ((pos (point)))
- (skip-chars-backward "-!%&*+/<=>^|~[]()")
- (and (if (< (skip-chars-backward "`") 0)
- t
- (goto-char pos)
- (eq (char-after) ?\`))
- (looking-at c-symbol-key)
- (>= (match-end 0) pos)
- (point))))
-
- (when (and c-overloadable-operators-regexp
- (= (c-backward-token-2 0) 0))
- (cond ((and (looking-at c-overloadable-operators-regexp)
- (or (not c-opt-op-identifier-prefix)
- (and (= (c-backward-token-2 1) 0)
- (looking-at c-opt-op-identifier-prefix))))
- (point))
- ((save-excursion
- (and c-opt-op-identifier-prefix
- (looking-at c-opt-op-identifier-prefix)
- (= (c-forward-token-2 1) 0)
- (looking-at c-overloadable-operators-regexp)))
- (point))))
- )))
- (defsubst c-simple-skip-symbol-backward ()
-
-
-
-
-
- (or (< (skip-syntax-backward "w_") 0)
- (and (c-major-mode-is 'pike-mode)
-
- (let ((pos (point)))
- (if (and (< (skip-chars-backward "-!%&*+/<=>^|~[]()") 0)
- (< (skip-chars-backward "`") 0)
- (looking-at c-symbol-key)
- (>= (match-end 0) pos))
- t
- (goto-char pos)
- nil)))))
- (defun c-beginning-of-current-token (&optional back-limit)
-
-
-
-
-
-
-
- (let ((start (point)))
- (if (looking-at "\\w\\|\\s_")
- (skip-syntax-backward "w_" back-limit)
- (when (< (skip-syntax-backward ".()" back-limit) 0)
- (while (let ((pos (or (and (looking-at c-nonsymbol-token-regexp)
- (match-end 0))
-
-
-
-
-
- (1+ (point)))))
- (if (<= pos start)
- (goto-char pos))))))
- (< (point) start)))
- (defun c-end-of-current-token (&optional back-limit)
-
-
-
-
-
-
- (let ((start (point)))
- (cond ((< (skip-syntax-backward "w_" (1- start)) 0)
- (skip-syntax-forward "w_"))
- ((< (skip-syntax-backward ".()" back-limit) 0)
- (while (progn
- (if (looking-at c-nonsymbol-token-regexp)
- (goto-char (match-end 0))
-
-
-
-
- (forward-char))
- (< (point) start)))))
- (> (point) start)))
- (defconst c-jump-syntax-balanced
- (if (memq 'gen-string-delim c-emacs-features)
- "\\w\\|\\s_\\|\\s\(\\|\\s\)\\|\\s\"\\|\\s|"
- "\\w\\|\\s_\\|\\s\(\\|\\s\)\\|\\s\""))
- (defconst c-jump-syntax-unbalanced
- (if (memq 'gen-string-delim c-emacs-features)
- "\\w\\|\\s_\\|\\s\"\\|\\s|"
- "\\w\\|\\s_\\|\\s\""))
- (defun c-forward-token-2 (&optional count balanced limit)
- "Move forward by tokens.
- A token is defined as all symbols and identifiers which aren't
- syntactic whitespace \(note that multicharacter tokens like \"==\" are
- treated properly). Point is always either left at the beginning of a
- token or not moved at all. COUNT specifies the number of tokens to
- move; a negative COUNT moves in the opposite direction. A COUNT of 0
- moves to the next token beginning only if not already at one. If
- BALANCED is true, move over balanced parens, otherwise move into them.
- Also, if BALANCED is true, never move out of an enclosing paren.
- LIMIT sets the limit for the movement and defaults to the point limit.
- The case when LIMIT is set in the middle of a token, comment or macro
- is handled correctly, i.e. the point won't be left there.
- Return the number of tokens left to move \(positive or negative). If
- BALANCED is true, a move over a balanced paren counts as one. Note
- that if COUNT is 0 and no appropriate token beginning is found, 1 will
- be returned. Thus, a return value of 0 guarantees that point is at
- the requested position and a return value less \(without signs) than
- COUNT guarantees that point is at the beginning of some token.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (or count (setq count 1))
- (if (< count 0)
- (- (c-backward-token-2 (- count) balanced limit))
- (let ((jump-syntax (if balanced
- c-jump-syntax-balanced
- c-jump-syntax-unbalanced))
- (last (point))
- (prev (point)))
- (if (zerop count)
-
- (c-end-of-current-token))
- (save-restriction
- (if limit (narrow-to-region (point-min) limit))
- (if (/= (point)
- (progn (c-forward-syntactic-ws) (point)))
-
-
- (setq count (max (1- count) 0)))
- (if (eobp)
-
- (progn
- (if (zerop count) (setq count 1))
- (goto-char last))
-
-
- (condition-case nil
- (while (and
- (> count 0)
- (progn
- (setq last (point))
- (cond ((looking-at jump-syntax)
- (goto-char (scan-sexps (point) 1))
- t)
- ((looking-at c-nonsymbol-token-regexp)
- (goto-char (match-end 0))
- t)
-
-
-
-
-
- ((and limit
- (save-restriction
- (widen)
- (looking-at c-nonsymbol-token-regexp)))
- nil)
- (t
- (forward-char)
- t))))
- (c-forward-syntactic-ws)
- (setq prev last
- count (1- count)))
- (error (goto-char last)))
- (when (eobp)
- (goto-char prev)
- (setq count (1+ count)))))
- count)))
- (defun c-backward-token-2 (&optional count balanced limit)
- "Move backward by tokens.
- See `c-forward-token-2' for details."
- (or count (setq count 1))
- (if (< count 0)
- (- (c-forward-token-2 (- count) balanced limit))
- (or limit (setq limit (point-min)))
- (let ((jump-syntax (if balanced
- c-jump-syntax-balanced
- c-jump-syntax-unbalanced))
- (last (point)))
- (if (zerop count)
-
-
- (if (> (point)
- (progn (c-beginning-of-current-token) (point)))
- (if (< (point) limit)
-
- (setq count 1))
-
-
-
- (and (looking-at c-syntactic-ws-start)
-
-
- (or (/= (char-after) ?#)
- (not c-opt-cpp-prefix)
- (save-excursion
- (and (= (point)
- (progn (beginning-of-line)
- (looking-at "[ \t]*")
- (match-end 0)))
- (or (bobp)
- (progn (backward-char)
- (not (eq (char-before) ?\\)))))))
- (setq count 1))))
-
-
- (condition-case nil
- (while (and
- (> count 0)
- (progn
- (c-backward-syntactic-ws)
- (backward-char)
- (if (looking-at jump-syntax)
- (goto-char (scan-sexps (1+ (point)) -1))
-
-
-
- (c-beginning-of-current-token))
- (>= (point) limit)))
- (setq last (point)
- count (1- count)))
- (error (goto-char last)))
- (if (< (point) limit)
- (goto-char last))
- count)))
- (defun c-forward-token-1 (&optional count balanced limit)
- "Like `c-forward-token-2' but doesn't treat multicharacter operator
- tokens like \"==\" as single tokens, i.e. all sequences of symbol
- characters are jumped over character by character. This function is
- for compatibility only; it's only a wrapper over `c-forward-token-2'."
- (let ((c-nonsymbol-token-regexp "\\s.\\|\\s\(\\|\\s\)"))
- (c-forward-token-2 count balanced limit)))
- (defun c-backward-token-1 (&optional count balanced limit)
- "Like `c-backward-token-2' but doesn't treat multicharacter operator
- tokens like \"==\" as single tokens, i.e. all sequences of symbol
- characters are jumped over character by character. This function is
- for compatibility only; it's only a wrapper over `c-backward-token-2'."
- (let ((c-nonsymbol-token-regexp "\\s.\\|\\s\(\\|\\s\)"))
- (c-backward-token-2 count balanced limit)))
- (defun c-syntactic-re-search-forward (regexp &optional bound noerror
- paren-level not-inside-token
- lookbehind-submatch)
- "Like `re-search-forward', but only report matches that are found
- in syntactically significant text. I.e. matches in comments, macros
- or string literals are ignored. The start point is assumed to be
- outside any comment, macro or string literal, or else the content of
- that region is taken as syntactically significant text.
- If PAREN-LEVEL is non-nil, an additional restriction is added to
- ignore matches in nested paren sexps. The search will also not go
- outside the current list sexp, which has the effect that if the point
- should be moved to BOUND when no match is found \(i.e. NOERROR is
- neither nil nor t), then it will be at the closing paren if the end of
- the current list sexp is encountered first.
- If NOT-INSIDE-TOKEN is non-nil, matches in the middle of tokens are
- ignored. Things like multicharacter operators and special symbols
- \(e.g. \"`()\" in Pike) are handled but currently not floating point
- constants.
- If LOOKBEHIND-SUBMATCH is non-nil, it's taken as a number of a
- subexpression in REGEXP. The end of that submatch is used as the
- position to check for syntactic significance. If LOOKBEHIND-SUBMATCH
- isn't used or if that subexpression didn't match then the start
- position of the whole match is used instead. The \"look behind\"
- subexpression is never tested before the starting position, so it
- might be a good idea to include \\=\\= as a match alternative in it.
- Optimization note: Matches might be missed if the \"look behind\"
- subexpression can match the end of nonwhite syntactic whitespace,
- i.e. the end of comments or cpp directives. This since the function
- skips over such things before resuming the search. It's on the other
- hand not safe to assume that the \"look behind\" subexpression never
- matches syntactic whitespace.
- Bug: Unbalanced parens inside cpp directives are currently not handled
- correctly \(i.e. they don't get ignored as they should) when
- PAREN-LEVEL is set.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (or bound (setq bound (point-max)))
- (if paren-level (setq paren-level -1))
-
- (let ((start (point))
- tmp
-
- search-pos
-
-
- state
-
-
- (state-pos (point))
-
-
-
- check-pos check-state
-
- (last-token-end-pos (point-min))
-
- found)
- (condition-case err
- (while
- (and
- (progn
- (setq search-pos (point))
- (re-search-forward regexp bound noerror))
- (progn
- (setq state (parse-partial-sexp
- state-pos (match-beginning 0) paren-level nil state)
- state-pos (point))
- (if (setq check-pos (and lookbehind-submatch
- (or (not paren-level)
- (>= (car state) 0))
- (match-end lookbehind-submatch)))
- (setq check-state (parse-partial-sexp
- state-pos check-pos paren-level nil state))
- (setq check-pos state-pos
- check-state state))
-
-
-
-
-
-
-
-
-
- (cond
- ((elt check-state 7)
-
-
-
- (re-search-forward "[\n\r]" bound noerror))
- ((elt check-state 4)
-
- (search-forward "*/" bound noerror))
- ((and (not (elt check-state 5))
- (eq (char-before check-pos) ?/)
- (not (c-get-char-property (1- check-pos) 'syntax-table))
- (memq (char-after check-pos) '(?/ ?*)))
-
-
- (if (= (char-after check-pos) ?/)
- (re-search-forward "[\n\r]" bound noerror)
- (search-forward "*/" bound noerror)))
-
-
-
-
-
-
-
- ((and paren-level
- (/= (setq tmp (car check-state)) 0))
-
-
-
- (if (> tmp 0)
-
- (if lookbehind-submatch
-
- (progn (goto-char state-pos) t)
-
- (setq state (parse-partial-sexp state-pos bound 0 nil state)
- state-pos (point)))
-
- (if noerror
- (progn
-
-
-
-
-
- (setq bound (1- (point)))
- nil)
- (signal 'search-failed (list regexp)))))
- ((setq tmp (elt check-state 3))
-
- (if (or lookbehind-submatch
- (not (integerp tmp)))
-
- (progn (goto-char state-pos) t)
-
- (let ((ender (make-string 1 tmp)) (continue t))
- (while (if (search-forward ender bound noerror)
- (progn
- (setq state (parse-partial-sexp
- state-pos (point) nil nil state)
- state-pos (point))
- (elt state 3))
- (setq continue nil)))
- continue)))
- ((save-excursion
- (save-match-data
- (c-beginning-of-macro start)))
-
- (c-end-of-macro)
- (cond ((<= (point) bound) t)
- (noerror nil)
- (t (signal 'search-failed (list regexp)))))
- ((and not-inside-token
- (or (< check-pos last-token-end-pos)
- (< check-pos
- (save-excursion
- (goto-char check-pos)
- (save-match-data
- (c-end-of-current-token last-token-end-pos))
- (setq last-token-end-pos (point))))))
-
- (if lookbehind-submatch
-
- (goto-char state-pos)
- (goto-char (min last-token-end-pos bound))))
- (t
-
- (setq found t)
- nil)))
-
-
- (or (/= search-pos (point))
- (if (= (point) bound)
- (if noerror
- nil
- (signal 'search-failed (list regexp)))
- (forward-char)
- t))))
- (error
- (goto-char start)
- (signal (car err) (cdr err))))
-
- (if found
- (progn
- (goto-char (match-end 0))
- (match-end 0))
-
- (if (eq noerror t)
- (goto-char start)
- (goto-char bound))
- nil)))
- (defvar safe-pos-list)
- (defsubst c-ssb-lit-begin ()
-
-
-
-
-
- (save-excursion
- (let ((pos (point)) safe-pos state pps-end-pos)
-
-
-
-
- (while (and safe-pos-list
- (> (car safe-pos-list) (point)))
- (setq safe-pos-list (cdr safe-pos-list)))
- (unless (setq safe-pos (car-safe safe-pos-list))
- (setq safe-pos (max (or (c-safe-position
- (point) (or c-state-cache
- (c-parse-state)))
- 0)
- (point-min))
- safe-pos-list (list safe-pos)))
-
-
-
-
-
-
- (while (progn
- (setq state (parse-partial-sexp
- safe-pos pos 0))
- (< (point) pos))
- (setq safe-pos (point)
- safe-pos-list (cons safe-pos safe-pos-list)))
-
-
-
-
- (if (elt state 1)
- (setq safe-pos (1+ (elt state 1))
- safe-pos-list (cons safe-pos safe-pos-list)))
- (if (or (elt state 3) (elt state 4))
-
-
- (elt state 8)))))
- (defun c-syntactic-skip-backward (skip-chars &optional limit paren-level)
- "Like `skip-chars-backward' but only look at syntactically relevant chars,
- i.e. don't stop at positions inside syntactic whitespace or string
- literals. Preprocessor directives are also ignored, with the exception
- of the one that the point starts within, if any. If LIMIT is given,
- it's assumed to be at a syntactically relevant position.
- If PAREN-LEVEL is non-nil, the function won't stop in nested paren
- sexps, and the search will also not go outside the current paren sexp.
- However, if LIMIT or the buffer limit is reached inside a nested paren
- then the point will be left at the limit.
- Non-nil is returned if the point moved, nil otherwise.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (let ((start (point))
- state-2
-
-
-
-
- safe-pos-list
-
-
-
- start-macro-beg
-
-
- lit-beg
- (paren-level-pos (point)))
- (while
- (progn
-
-
- (while
- (and
- (< (skip-chars-backward skip-chars limit) 0)
- (let ((pos (point)) state-2 pps-end-pos)
- (cond
-
- ((setq lit-beg (c-ssb-lit-begin))
- (goto-char lit-beg)
- t)
- ((and paren-level
- (save-excursion
- (setq state-2 (parse-partial-sexp
- pos paren-level-pos -1)
- pps-end-pos (point))
- (/= (car state-2) 0)))
-
- (if (and (< (car state-2) 0)
-
-
-
- (save-excursion
- (setq state-2
- (parse-partial-sexp
- pps-end-pos paren-level-pos
- nil nil state-2))
- (< (car state-2) 0)))
-
-
-
- (condition-case nil
- (progn
- (goto-char (scan-lists pos -1
- (- (car state-2))))
- (setq paren-level-pos (point))
- (if (and limit (>= limit paren-level-pos))
- (progn
- (goto-char limit)
- nil)
- t))
- (error
- (goto-char (or limit (point-min)))
- nil))
-
-
- (goto-char (1+ (elt state-2 1)))
- nil))
- ((c-beginning-of-macro limit)
-
- (if (< (point)
- (or start-macro-beg
- (setq start-macro-beg
- (save-excursion
- (goto-char start)
- (c-beginning-of-macro limit)
- (point)))))
- t
-
-
- (goto-char pos)
- nil))))))
- (> (point)
- (progn
-
-
- (c-backward-syntactic-ws)
- (point)))))
-
-
- (/= (point) start)))
- (defun c-in-literal (&optional lim detect-cpp)
- "Return the type of literal point is in, if any.
- The return value is `c' if in a C-style comment, `c++' if in a C++
- style comment, `string' if in a string literal, `pound' if DETECT-CPP
- is non-nil and in a preprocessor line, or nil if somewhere else.
- Optional LIM is used as the backward limit of the search. If omitted,
- or nil, `c-beginning-of-defun' is used.
- The last point calculated is cached if the cache is enabled, i.e. if
- `c-in-literal-cache' is bound to a two element vector.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (save-restriction
- (widen)
- (let* ((safe-place (c-state-semi-safe-place (point)))
- (lit (c-state-pp-to-literal safe-place (point))))
- (or (cadr lit)
- (and detect-cpp
- (save-excursion (c-beginning-of-macro))
- 'pound)))))
- (defun c-literal-limits (&optional lim near not-in-delimiter)
- "Return a cons of the beginning and end positions of the comment or
- string surrounding point (including both delimiters), or nil if point
- isn't in one. If LIM is non-nil, it's used as the \"safe\" position
- to start parsing from. If NEAR is non-nil, then the limits of any
- literal next to point is returned. \"Next to\" means there's only
- spaces and tabs between point and the literal. The search for such a
- literal is done first in forward direction. If NOT-IN-DELIMITER is
- non-nil, the case when point is inside a starting delimiter won't be
- recognized. This only has effect for comments which have starting
- delimiters with more than one character.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (save-excursion
- (let* ((pos (point))
- (lim (or lim (c-state-semi-safe-place pos)))
- (pp-to-lit (save-restriction
- (widen)
- (c-state-pp-to-literal lim pos)))
- (state (car pp-to-lit))
- (lit-limits (car (cddr pp-to-lit))))
- (cond
- (lit-limits)
- ((and (not not-in-delimiter)
- (not (elt state 5))
- (eq (char-before) ?/)
- (looking-at "[/*]"))
-
- (backward-char 1)
- (cons (point) (progn (c-forward-single-comment) (point))))
- (near
- (goto-char pos)
-
- (skip-chars-forward " \t")
- (cond
- ((looking-at c-string-limit-regexp)
- (cons (point) (or (c-safe (c-forward-sexp 1) (point))
- (point-max))))
- ((looking-at c-comment-start-regexp)
- (cons (point) (progn (c-forward-single-comment) (point))))
- (t
-
- (skip-chars-backward " \t")
- (let ((end (point)) beg)
- (cond
- ((save-excursion
- (< (skip-syntax-backward c-string-syntax) 0))
- (setq beg (c-safe (c-backward-sexp 1) (point))))
- ((and (c-safe (forward-char -2) t)
- (looking-at "*/"))
-
-
-
- (goto-char end)
- (c-backward-single-comment)
-
- (setq beg (point))))
- (if beg (cons beg end))))))
- ))))
- (defalias 'c-literal-limits-fast 'c-literal-limits)
- (defun c-collect-line-comments (range)
- "If the argument is a cons of two buffer positions (such as returned by
- `c-literal-limits'), and that range contains a C++ style line comment,
- then an extended range is returned that contains all adjacent line
- comments (i.e. all comments that starts in the same column with no
- empty lines or non-whitespace characters between them). Otherwise the
- argument is returned.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (save-excursion
- (condition-case nil
- (if (and (consp range) (progn
- (goto-char (car range))
- (looking-at c-line-comment-starter)))
- (let ((col (current-column))
- (beg (point))
- (bopl (c-point 'bopl))
- (end (cdr range)))
-
-
- (while (and (c-backward-single-comment)
- (>= (point) bopl)
- (looking-at c-line-comment-starter)
- (= col (current-column)))
- (setq beg (point)
- bopl (c-point 'bopl)))
- (goto-char end)
- (while (and (progn (skip-chars-forward " \t")
- (looking-at c-line-comment-starter))
- (= col (current-column))
- (prog1 (zerop (forward-line 1))
- (setq end (point)))))
- (cons beg end))
- range)
- (error range))))
- (defun c-literal-type (range)
- "Convenience function that given the result of `c-literal-limits',
- returns nil or the type of literal that the range surrounds, one
- of the symbols 'c, 'c++ or 'string. It's much faster than using
- `c-in-literal' and is intended to be used when you need both the
- type of a literal and its limits.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (if (consp range)
- (save-excursion
- (goto-char (car range))
- (cond ((looking-at c-string-limit-regexp) 'string)
- ((or (looking-at "//")
- (and (looking-at "\\s<")
- (looking-at "#")))
- 'c++)
- (t 'c)))
- range))
- (defsubst c-determine-limit-get-base (start try-size)
-
-
- (let* ((pos (max (- start try-size) (point-min)))
- (base (c-state-semi-safe-place pos))
- (s (parse-partial-sexp base pos)))
- (if (or (nth 4 s) (nth 3 s))
- (nth 8 s)
- (point))))
- (defun c-determine-limit (how-far-back &optional start try-size)
-
-
-
-
-
-
- (save-excursion
- (let* ((start (or start (point)))
- (try-size (or try-size (* 2 how-far-back)))
- (base (c-determine-limit-get-base start try-size))
- (pos base)
- (s (parse-partial-sexp pos pos))
- stack elt size
- (count 0))
- (while (< pos start)
-
-
- (setq s (parse-partial-sexp
- pos
- start
- nil
- nil
- s
- 'syntax-table))
-
- (setq size (- (if (or (nth 4 s) (nth 3 s))
- (nth 8 s)
- (point))
- pos))
- (if (> size 0)
- (setq stack (cons (cons pos size) stack)))
-
- (if (or (nth 4 s) (nth 3 s))
- (setq s (parse-partial-sexp
- (point)
- start
- nil
- nil
- s
- 'syntax-table)))
- (setq pos (point)))
-
-
-
- (while (and (< count how-far-back)
- stack)
- (setq elt (car stack)
- stack (cdr stack))
- (setq count (+ count (cdr elt))))
-
- (cond
- ((>= count how-far-back)
- (+ (car elt) (- count how-far-back)))
- ((eq base (point-min))
- (point-min))
- (t
- (c-determine-limit (- how-far-back count) base try-size))))))
- (defun c-determine-+ve-limit (how-far &optional start-pos)
-
-
- (save-excursion
- (let ((pos (or start-pos (point)))
- (count how-far)
- (s (parse-partial-sexp (point) (point))))
- (while (and (not (eobp))
- (> count 0))
-
- (setq s (parse-partial-sexp
- pos
- (min (+ pos count) (point-max))
- nil
- nil
- s
- 'syntax-table))
- (setq count (- count (- (point) pos) 1)
- pos (point))
-
- (if (nth 8 s)
- (setq s (parse-partial-sexp
- pos
- (point-max)
- nil
- nil
- s
- 'syntax-table)
- pos (point))))
- (point))))
- (defvar c-find-decl-syntactic-pos nil)
- (make-variable-buffer-local 'c-find-decl-syntactic-pos)
- (defvar c-find-decl-match-pos nil)
- (make-variable-buffer-local 'c-find-decl-match-pos)
- (defsubst c-invalidate-find-decl-cache (change-min-pos)
- (and c-find-decl-syntactic-pos
- (< change-min-pos c-find-decl-syntactic-pos)
- (setq c-find-decl-syntactic-pos nil)))
- (defmacro c-debug-put-decl-spot-faces (match-pos decl-pos)
- (when (facep 'c-debug-decl-spot-face)
- `(c-save-buffer-state ((match-pos ,match-pos) (decl-pos ,decl-pos))
- (c-debug-add-face (max match-pos (point-min)) decl-pos
- 'c-debug-decl-sws-face)
- (c-debug-add-face decl-pos (min (1+ decl-pos) (point-max))
- 'c-debug-decl-spot-face))))
- (defmacro c-debug-remove-decl-spot-faces (beg end)
- (when (facep 'c-debug-decl-spot-face)
- `(c-save-buffer-state ()
- (c-debug-remove-face ,beg ,end 'c-debug-decl-spot-face)
- (c-debug-remove-face ,beg ,end 'c-debug-decl-sws-face))))
- (defmacro c-find-decl-prefix-search ()
-
-
-
-
-
-
- '(progn
-
- (unless cfd-prop-match
- (save-excursion
- (while (progn
- (goto-char (next-single-property-change
- (point) 'c-type nil cfd-limit))
- (and (< (point) cfd-limit)
- (not (eq (c-get-char-property (1- (point)) 'c-type)
- 'c-decl-end)))))
- (setq cfd-prop-match (point))))
-
-
- (unless cfd-re-match
- (if (> cfd-re-match-end (point))
- (goto-char cfd-re-match-end))
- (while (if (setq cfd-re-match-end
- (re-search-forward c-decl-prefix-or-start-re
- cfd-limit 'move))
-
- (c-got-face-at
- (if (setq cfd-re-match (match-end 1))
-
- (progn
- (goto-char cfd-re-match)
- (1- cfd-re-match))
-
- (goto-char (match-beginning 0))
- (point))
- c-literal-faces)
-
- (setq cfd-re-match cfd-limit)
- nil)
-
- (while (progn
- (goto-char (next-single-property-change
- (point) 'face nil cfd-limit))
- (and (< (point) cfd-limit)
- (c-got-face-at (point) c-literal-faces)))))
-
-
-
- (unless cfd-re-match
- (c-backward-syntactic-ws)
- (setq cfd-re-match (point))))
-
- (if (< cfd-re-match cfd-prop-match)
- (setq cfd-match-pos cfd-re-match
- cfd-re-match nil)
- (setq cfd-match-pos cfd-prop-match
- cfd-prop-match nil))
- (goto-char cfd-match-pos)
- (when (< cfd-match-pos cfd-limit)
-
- (c-forward-comments)
-
-
-
-
- (setq cfd-continue-pos (if cfd-prop-match
- (min cfd-prop-match (point))
- (point))))))
- (defun c-find-decl-spots (cfd-limit cfd-decl-re cfd-face-checklist cfd-fun)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((cfd-start-pos (point))
- (cfd-buffer-end (point-max))
-
-
-
- cfd-re-match
-
-
-
- (cfd-re-match-end (point-min))
-
-
-
-
- (cfd-prop-match (unless c-type-decl-end-used cfd-limit))
-
-
-
-
- (cfd-match-pos cfd-limit)
-
- cfd-continue-pos
-
-
-
-
- (cfd-token-pos 0)
-
- (cfd-macro-end 0))
-
-
-
- (let (start-in-literal start-in-macro syntactic-pos)
-
-
-
- (cond
-
-
- ((and
- (when (c-got-face-at (point) c-literal-faces)
-
-
-
- (while (and (not (bobp))
- (c-got-face-at (1- (point)) c-literal-faces))
- (goto-char (previous-single-property-change
- (point) 'face nil (point-min))))
-
-
- (and (featurep 'xemacs)
- (eq (get-text-property (point) 'face)
- 'font-lock-string-face)
- (not (bobp))
- (progn (backward-char)
- (not (looking-at c-string-limit-regexp)))
- (forward-char))
-
-
-
-
-
- (unless (looking-at c-literal-start-regexp)
- (let ((range (c-literal-limits)))
- (if range (goto-char (car range)))))
- (setq start-in-literal (point)))
-
-
-
-
-
- (<= cfd-limit (c-point 'bonl cfd-start-pos))
- (save-excursion
- (goto-char cfd-start-pos)
- (while (progn
- (goto-char (next-single-property-change
- (point) 'face nil cfd-limit))
- (and (< (point) cfd-limit)
- (c-got-face-at (point) c-literal-faces))))
- (= (point) cfd-limit)))
-
-
-
- (setq cfd-continue-pos start-in-literal))
-
-
- ((save-excursion
- (and (= (forward-line 1) 0)
- (bolp)
- (>= (point) cfd-limit)
- (progn (backward-char)
- (eq (char-before) ?\\))))
-
-
-
- (setq cfd-continue-pos (1- cfd-start-pos)
- start-in-macro t))
- (t
-
-
- (when (c-beginning-of-macro)
- (setq start-in-macro t))
-
-
-
- (c-invalidate-find-decl-cache cfd-start-pos)
- (setq syntactic-pos (point))
- (unless (eq syntactic-pos c-find-decl-syntactic-pos)
-
-
-
-
- (c-backward-syntactic-ws c-find-decl-syntactic-pos))
-
-
-
-
-
-
-
-
- (if (and (eq (point) c-find-decl-syntactic-pos)
- c-find-decl-match-pos)
- (setq cfd-match-pos c-find-decl-match-pos
- cfd-continue-pos syntactic-pos)
- (setq c-find-decl-syntactic-pos syntactic-pos)
- (when (if (bobp)
-
-
-
-
-
- (setq cfd-re-match 0)
- (backward-char)
- (c-beginning-of-current-token)
- (< (point) cfd-limit))
-
-
- (c-find-decl-prefix-search))
- (setq c-find-decl-match-pos (and (< cfd-match-pos cfd-start-pos)
- cfd-match-pos)))))
-
-
-
-
-
- (when (and cfd-continue-pos (< cfd-continue-pos cfd-start-pos))
- (cond
- (start-in-macro
-
-
-
-
-
- (goto-char (or start-in-literal cfd-start-pos))
-
- (c-backward-comments)
- (backward-char)
- (c-beginning-of-current-token))
- (start-in-literal
-
-
-
-
-
-
-
-
-
-
-
- (if (not c-type-decl-end-used)
- (goto-char start-in-literal)
- (goto-char cfd-start-pos)
- (while (progn
- (goto-char (previous-single-property-change
- (point) 'c-type nil start-in-literal))
- (and (> (point) start-in-literal)
- (not (eq (c-get-char-property (point) 'c-type)
- 'c-decl-end))))))
- (when (= (point) start-in-literal)
-
-
-
-
- (c-forward-single-comment)
- (if (> (point) cfd-limit)
- (goto-char cfd-limit))))
- (t
-
-
-
-
-
- (goto-char cfd-start-pos)))
-
-
-
- (setq cfd-continue-pos (point))
- (when (and cfd-re-match (< cfd-re-match cfd-continue-pos))
- (setq cfd-re-match nil))
- (when (and cfd-prop-match (< cfd-prop-match cfd-continue-pos))
- (setq cfd-prop-match nil)))
- (if syntactic-pos
-
-
-
-
-
-
- (when (and cfd-match-pos (< cfd-match-pos syntactic-pos))
- (goto-char syntactic-pos)
- (c-forward-syntactic-ws)
- (and cfd-continue-pos
- (< cfd-continue-pos (point))
- (setq cfd-token-pos (point))))
-
-
-
- (c-find-decl-prefix-search)))
-
- (while (progn
- (while (and
- (< cfd-match-pos cfd-limit)
- (or
-
-
-
- (and (eq (char-before cfd-match-pos) ?<)
- (not (c-get-char-property (1- cfd-match-pos)
- 'syntax-table)))
-
-
-
-
-
-
- (= cfd-continue-pos cfd-token-pos)
- (progn
-
-
-
-
-
-
- (when (> cfd-continue-pos cfd-token-pos)
- (c-forward-syntactic-ws)
- (setq cfd-token-pos (point)))
-
-
- (when (or (>= (point) cfd-limit)
- (not (looking-at cfd-decl-re))
- (and cfd-face-checklist
- (not (c-got-face-at
- (point) cfd-face-checklist))))
- (goto-char cfd-continue-pos)
- t)))
- (< (point) cfd-limit))
- (c-find-decl-prefix-search))
- (< (point) cfd-limit))
- (when (and
- (>= (point) cfd-start-pos)
- (progn
-
-
-
- (when (> cfd-match-pos cfd-macro-end)
-
- (save-excursion
- (goto-char cfd-match-pos)
- (setq cfd-macro-end
- (if (save-excursion (and (c-beginning-of-macro)
- (< (point) cfd-match-pos)))
- (progn (c-end-of-macro)
- (point))
- 0))))
- (if (zerop cfd-macro-end)
- t
- (if (> cfd-macro-end (point))
- (progn (narrow-to-region (point-min) cfd-macro-end)
- t)
-
-
- (setq cfd-macro-end 0)
- nil))))
- (c-debug-put-decl-spot-faces cfd-match-pos (point))
- (if (funcall cfd-fun cfd-match-pos (/= cfd-macro-end 0))
- (setq cfd-prop-match nil))
- (when (/= cfd-macro-end 0)
-
- (narrow-to-region (point-min) cfd-buffer-end)))
- (goto-char cfd-continue-pos)
- (if (= cfd-continue-pos cfd-limit)
- (setq cfd-match-pos cfd-limit)
- (c-find-decl-prefix-search)))))
-
- (defvar c-found-types nil)
- (make-variable-buffer-local 'c-found-types)
- (defsubst c-clear-found-types ()
-
- (setq c-found-types (make-vector 53 0)))
- (defun c-add-type (from to)
-
-
-
-
-
-
-
-
-
-
- (let ((type (c-syntactic-content from to c-recognize-<>-arglists)))
- (unless (intern-soft type c-found-types)
- (unintern (substring type 0 -1) c-found-types)
- (intern type c-found-types))))
- (defun c-unfind-type (name)
-
- (unintern name c-found-types))
- (defsubst c-check-type (from to)
-
-
-
-
- (intern-soft (c-syntactic-content from to c-recognize-<>-arglists)
- c-found-types))
- (defun c-list-found-types ()
-
-
- (let (type-list)
- (mapatoms (lambda (type)
- (setq type-list (cons (symbol-name type)
- type-list)))
- c-found-types)
- (sort type-list 'string-lessp)))
- (defvar c-maybe-stale-found-type)
- (defun c-trim-found-types (beg end old-len)
-
-
-
-
-
-
-
-
-
- (when (> end beg)
- (save-excursion
- (when (< end (point-max))
- (goto-char end)
- (if (and (c-beginning-of-current-token)
- (progn (goto-char end)
- (c-end-of-current-token)))
- (c-unfind-type (buffer-substring-no-properties
- end (point)))))
- (when (> beg (point-min))
- (goto-char beg)
- (if (and (c-end-of-current-token)
- (progn (goto-char beg)
- (c-beginning-of-current-token)))
- (c-unfind-type (buffer-substring-no-properties
- (point) beg))))))
- (if c-maybe-stale-found-type
- (cond
-
- ((and (c-partial-ws-p beg end)
- (or (= beg end)
- (string-match "^[ \t\n\r\f\v]*$" (nth 5 c-maybe-stale-found-type)))))
-
-
- ((eq (car c-maybe-stale-found-type) 'c-decl-id-start)
- (c-unfind-type (cadr c-maybe-stale-found-type)))
- )))
- (defun c-clear-<-pair-props (&optional pos)
-
-
-
-
- (save-excursion
- (if pos
- (goto-char pos)
- (setq pos (point)))
- (when (equal (c-get-char-property (point) 'syntax-table)
- c-<-as-paren-syntax)
- (with-syntax-table c-no-parens-syntax-table
- (c-go-list-forward))
- (when (equal (c-get-char-property (1- (point)) 'syntax-table)
- c->-as-paren-syntax)
- (c-clear-char-property (1- (point)) 'category))
- (c-clear-char-property pos 'category))))
- (defun c-clear->-pair-props (&optional pos)
-
-
-
- (save-excursion
- (if pos
- (goto-char pos)
- (setq pos (point)))
- (when (equal (c-get-char-property (point) 'syntax-table)
- c->-as-paren-syntax)
- (with-syntax-table c-no-parens-syntax-table
- (c-go-up-list-backward))
- (when (equal (c-get-char-property (point) 'syntax-table)
- c-<-as-paren-syntax)
- (c-clear-char-property (point) 'category))
- (c-clear-char-property pos 'category))))
- (defun c-clear-<>-pair-props (&optional pos)
-
-
-
-
- (cond
- ((eq (char-after) ?\<)
- (c-clear-<-pair-props pos))
- ((eq (char-after) ?\>)
- (c-clear->-pair-props pos))
- (t (c-benign-error
- "c-clear-<>-pair-props called from wrong position"))))
- (defun c-clear-<-pair-props-if-match-after (lim &optional pos)
-
-
-
-
-
- (save-excursion
- (if pos
- (goto-char pos)
- (setq pos (point)))
- (when (equal (c-get-char-property (point) 'syntax-table)
- c-<-as-paren-syntax)
- (with-syntax-table c-no-parens-syntax-table
- (c-go-list-forward))
- (when (and (>= (point) lim)
- (equal (c-get-char-property (1- (point)) 'syntax-table)
- c->-as-paren-syntax))
- (c-unmark-<->-as-paren (1- (point)))
- (c-unmark-<->-as-paren pos))
- t)))
- (defun c-clear->-pair-props-if-match-before (lim &optional pos)
-
-
-
-
-
- (save-excursion
- (if pos
- (goto-char pos)
- (setq pos (point)))
- (when (equal (c-get-char-property (point) 'syntax-table)
- c->-as-paren-syntax)
- (with-syntax-table c-no-parens-syntax-table
- (c-go-up-list-backward))
- (when (and (<= (point) lim)
- (equal (c-get-char-property (point) 'syntax-table)
- c-<-as-paren-syntax))
- (c-unmark-<->-as-paren (point))
- (c-unmark-<->-as-paren pos))
- t)))
- (defvar c-new-BEG)
- (defvar c-new-END)
- (defun c-before-change-check-<>-operators (beg end)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (save-excursion
- (let ((beg-lit-limits (progn (goto-char beg) (c-literal-limits)))
- (end-lit-limits (progn (goto-char end) (c-literal-limits)))
- new-beg new-end need-new-beg need-new-end)
-
- (goto-char (if beg-lit-limits (car beg-lit-limits) beg))
- (c-syntactic-skip-backward "^;{}" (c-determine-limit 512))
- (setq new-beg (point))
-
-
- (while (c-search-forward-char-property 'category 'c-<-as-paren-syntax beg)
- (if (c-clear-<-pair-props-if-match-after beg (1- (point)))
- (setq need-new-beg t)))
-
- (goto-char (if end-lit-limits (cdr end-lit-limits) end))
- (c-syntactic-re-search-forward "[;{}]" (c-determine-+ve-limit 512) 'end)
- (setq new-end (point))
-
-
- (while (c-search-backward-char-property 'category 'c->-as-paren-syntax end)
- (if (c-clear->-pair-props-if-match-before end)
- (setq need-new-end t)))
-
- (when need-new-beg
- (goto-char new-beg)
- (c-forward-syntactic-ws)
- (and (< (point) c-new-BEG) (setq c-new-BEG (point))))
- (when need-new-end
- (and (> new-end c-new-END) (setq c-new-END new-end))))))
- (defun c-after-change-check-<>-operators (beg end)
-
-
-
-
-
-
- (save-excursion
- (goto-char beg)
- (when (or (looking-at "[<>]")
- (< (skip-chars-backward "<>") 0))
- (goto-char beg)
- (c-beginning-of-current-token)
- (when (and (< (point) beg)
- (looking-at c-<>-multichar-token-regexp)
- (< beg (setq beg (match-end 0))))
- (while (progn (skip-chars-forward "^<>" beg)
- (< (point) beg))
- (c-clear-<>-pair-props)
- (forward-char))))
- (when (< beg end)
- (goto-char end)
- (when (or (looking-at "[<>]")
- (< (skip-chars-backward "<>") 0))
- (goto-char end)
- (c-beginning-of-current-token)
- (when (and (< (point) end)
- (looking-at c-<>-multichar-token-regexp)
- (< end (setq end (match-end 0))))
- (while (progn (skip-chars-forward "^<>" end)
- (< (point) end))
- (c-clear-<>-pair-props)
- (forward-char)))))))
- (defvar c-promote-possible-types nil)
- (defvar c-parse-and-markup-<>-arglists nil)
- (defvar c-restricted-<>-arglists nil)
- (defvar c-record-type-identifiers nil)
- (defvar c-record-ref-identifiers nil)
- (defvar c-last-identifier-range nil)
- (defmacro c-record-type-id (range)
- (if (eq (car-safe range) 'cons)
-
- `(setq c-record-type-identifiers
- (cons ,range c-record-type-identifiers))
- `(let ((range ,range))
- (if range
- (setq c-record-type-identifiers
- (cons range c-record-type-identifiers))))))
- (defmacro c-record-ref-id (range)
- (if (eq (car-safe range) 'cons)
-
- `(setq c-record-ref-identifiers
- (cons ,range c-record-ref-identifiers))
- `(let ((range ,range))
- (if range
- (setq c-record-ref-identifiers
- (cons range c-record-ref-identifiers))))))
- (defvar c-record-found-types nil)
- (defmacro c-forward-keyword-prefixed-id (type)
-
-
-
-
-
-
-
-
-
-
- `(let (res)
- (while (if (setq res ,(if (eq type 'type)
- `(c-forward-type)
- `(c-forward-name)))
- nil
- (and (looking-at c-keywords-regexp)
- (c-forward-keyword-clause 1))))
- (when (memq res '(t known found prefix))
- ,(when (eq type 'ref)
- `(when c-record-type-identifiers
- (c-record-ref-id c-last-identifier-range)))
- t)))
- (defmacro c-forward-id-comma-list (type update-safe-pos)
-
-
-
-
-
- `(while (and (progn
- ,(when update-safe-pos
- `(setq safe-pos (point)))
- (eq (char-after) ?,))
- (progn
- (forward-char)
- (c-forward-syntactic-ws)
- (c-forward-keyword-prefixed-id ,type)))))
- (defun c-forward-keyword-clause (match)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((kwd-sym (c-keyword-sym (match-string match))) safe-pos pos
-
-
-
-
- (c-parse-and-markup-<>-arglists t)
- c-restricted-<>-arglists)
- (when kwd-sym
- (goto-char (match-end match))
- (c-forward-syntactic-ws)
- (setq safe-pos (point))
- (cond
- ((and (c-keyword-member kwd-sym 'c-type-list-kwds)
- (c-forward-keyword-prefixed-id type))
-
- (c-forward-id-comma-list type t))
- ((and (c-keyword-member kwd-sym 'c-ref-list-kwds)
- (c-forward-keyword-prefixed-id ref))
-
- (c-forward-id-comma-list ref t))
- ((and (c-keyword-member kwd-sym 'c-paren-any-kwds)
- (eq (char-after) ?\())
-
- (forward-char)
- (when (and (setq pos (c-up-list-forward))
- (eq (char-before pos) ?\)))
- (when (and c-record-type-identifiers
- (c-keyword-member kwd-sym 'c-paren-type-kwds))
-
-
- (while (c-syntactic-re-search-forward c-symbol-start pos t)
- (goto-char (match-beginning 0))
- (unless (c-forward-type)
- (looking-at c-symbol-key)
- (goto-char (match-end 0)))))
- (goto-char pos)
- (c-forward-syntactic-ws)
- (setq safe-pos (point))))
- ((and (c-keyword-member kwd-sym 'c-<>-sexp-kwds)
- (eq (char-after) ?<)
- (c-forward-<>-arglist (c-keyword-member kwd-sym 'c-<>-type-kwds)))
- (c-forward-syntactic-ws)
- (setq safe-pos (point)))
- ((and (c-keyword-member kwd-sym 'c-nonsymbol-sexp-kwds)
- (not (looking-at c-symbol-start))
- (c-safe (c-forward-sexp) t))
- (c-forward-syntactic-ws)
- (setq safe-pos (point))))
- (when (c-keyword-member kwd-sym 'c-colon-type-list-kwds)
- (if (eq (char-after) ?:)
-
-
- (progn
- (forward-char)
- (c-forward-syntactic-ws)
- (when (c-forward-keyword-prefixed-id type)
- (c-forward-id-comma-list type t)))
-
-
-
- (and c-record-type-identifiers
- (progn
-
-
-
- (goto-char safe-pos)
- (looking-at c-colon-type-list-re))
- (progn
- (goto-char (match-end 0))
- (c-forward-syntactic-ws)
- (c-forward-keyword-prefixed-id type))
-
-
- (c-forward-id-comma-list type nil))))
- (goto-char safe-pos)
- t)))
- (declare-function c-fontify-recorded-types-and-refs "cc-fonts" ())
- (defun c-forward-<>-arglist (all-types)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((start (point))
-
-
-
- (c-record-found-types (if c-record-type-identifiers t)))
- (if (catch 'angle-bracket-arglist-escape
- (setq c-record-found-types
- (c-forward-<>-arglist-recur all-types)))
- (progn
- (when (consp c-record-found-types)
- (setq c-record-type-identifiers
-
-
- (nconc c-record-found-types c-record-type-identifiers)))
- (if (c-major-mode-is 'java-mode) (c-fontify-recorded-types-and-refs))
- t)
- (goto-char start)
- nil)))
- (defun c-forward-<>-arglist-recur (all-types)
-
-
-
- (let ((start (point)) res pos tmp
-
-
-
-
- (c-record-found-types c-record-found-types)
-
-
- arg-start-pos)
-
-
- (if (and (not c-parse-and-markup-<>-arglists)
- (c-get-char-property (point) 'syntax-table))
- (progn
- (forward-char)
- (if (and (c-go-up-list-forward)
- (eq (char-before) ?>))
- t
-
-
-
-
-
- (goto-char start)
- nil))
- (forward-char)
- (unless (looking-at c-<-op-cont-regexp)
-
-
- (while (and
- (progn
- (c-forward-syntactic-ws)
- (let ((orig-record-found-types c-record-found-types))
- (when (or (and c-record-type-identifiers all-types)
- (c-major-mode-is 'java-mode))
-
-
- (progn
- (c-forward-syntactic-ws)
- (if (looking-at "\\?")
- (forward-char)
- (when (looking-at c-identifier-start)
- (let ((c-promote-possible-types t)
- (c-record-found-types t))
- (c-forward-type))))
- (c-forward-syntactic-ws)
- (when (or (looking-at "extends")
- (looking-at "super"))
- (forward-word)
- (c-forward-syntactic-ws)
- (let ((c-promote-possible-types t)
- (c-record-found-types t))
- (c-forward-type)
- (c-forward-syntactic-ws))))))
- (setq pos (point))
-
-
- (c-syntactic-re-search-forward
-
-
-
- "[<;{},|+&-]\\|[>)]"
- nil t t))
- (cond
- ((eq (char-before) ?>)
-
-
- (if (looking-at c->-op-cont-regexp)
- (progn
- (goto-char (match-end 0))
- t)
-
- (when c-parse-and-markup-<>-arglists
- (while arg-start-pos
- (c-put-c-type-property (1- (car arg-start-pos))
- 'c-<>-arg-sep)
- (setq arg-start-pos (cdr arg-start-pos)))
- (c-mark-<-as-paren start)
- (c-mark->-as-paren (1- (point))))
- (setq res t)
- nil))
- ((eq (char-before) ?<)
-
- (setq pos (point))
- (let (id-start id-end subres keyword-match)
- (cond
-
- ((looking-at c-<-op-cont-regexp)
- (setq tmp (match-end 0))
- (goto-char (match-end 0)))
-
- ((progn
- (setq tmp pos)
- (backward-char)
- (and
- (save-excursion
-
-
-
- (c-backward-syntactic-ws)
- (setq id-end (point))
- (c-simple-skip-symbol-backward)
- (when (or (setq keyword-match
- (looking-at c-opt-<>-sexp-key))
- (not (looking-at c-keywords-regexp)))
- (setq id-start (point))))
- (setq subres
- (let ((c-promote-possible-types t)
- (c-record-found-types t))
- (c-forward-<>-arglist-recur
- (and keyword-match
- (c-keyword-member
- (c-keyword-sym (match-string 1))
- 'c-<>-type-kwds)))))))
-
- (setq c-record-found-types subres)
-
-
-
- (when (and c-record-type-identifiers
- (not keyword-match))
- (if (and c-opt-identifier-concat-key
- (progn
- (c-forward-syntactic-ws)
- (looking-at c-opt-identifier-concat-key)))
- (c-record-ref-id (cons id-start id-end))
- (c-record-type-id (cons id-start id-end)))))
-
- (t
- (forward-char)
- )))
- t)
- ((and (not c-restricted-<>-arglists)
- (or (and (eq (char-before) ?&)
- (not (eq (char-after) ?&)))
- (eq (char-before) ?,)))
-
-
-
- (setq arg-start-pos (cons (point) arg-start-pos)))
- (t
-
-
-
-
- (throw 'angle-bracket-arglist-escape nil))))))
- (if res
- (or c-record-found-types t)))))
- (defun c-backward-<>-arglist (all-types &optional limit)
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((start (point)))
- (backward-char)
- (if (and (not c-parse-and-markup-<>-arglists)
- (c-get-char-property (point) 'syntax-table))
- (if (and (c-go-up-list-backward)
- (eq (char-after) ?<))
- t
-
- (goto-char start)
- nil)
- (while (progn
- (c-syntactic-skip-backward "^<;{}" limit t)
- (and
- (if (eq (char-before) ?<)
- t
-
-
- (goto-char start)
- nil)
- (if (> (point)
- (progn (c-beginning-of-current-token)
- (point)))
-
-
- t
- (backward-char)
- (let ((beg-pos (point)))
- (if (c-forward-<>-arglist all-types)
- (cond ((= (point) start)
-
- (goto-char beg-pos)
- nil)
- ((> (point) start)
-
-
- (goto-char start)
- nil)
- (t
-
-
- (goto-char beg-pos)
- t))
- t))))))
- (/= (point) start))))
- (defun c-forward-name ()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((pos (point)) (start (point)) res id-start id-end
-
-
-
-
-
-
- c-promote-possible-types)
- (while
- (and
- (looking-at c-identifier-key)
- (progn
-
-
- (goto-char (setq id-end (match-end 0)))
- (c-simple-skip-symbol-backward)
- (setq id-start (point))
- (if (looking-at c-keywords-regexp)
- (when (and (c-major-mode-is 'c++-mode)
- (looking-at
- (cc-eval-when-compile
- (concat "\\(operator\\|\\(template\\)\\)"
- "\\(" (c-lang-const c-nonsymbol-key c++)
- "\\|$\\)")))
- (if (match-beginning 2)
-
-
- (save-excursion
- (c-backward-syntactic-ws)
- (and (c-safe (backward-char 2) t)
- (looking-at "::")))
- t))
-
- (goto-char id-end)
- (c-forward-syntactic-ws)
- (cond ((eq (char-before id-end) ?e)
-
- (let ((subres (c-forward-name)))
- (when subres
- (setq pos (point)
- res subres))))
- ((looking-at c-identifier-start)
-
- (when (c-forward-type)
- (setq pos (point)
- res 'operator)
-
-
-
-
- (while (cond ((looking-at "[*&]")
- (goto-char (match-end 0))
- t)
- ((looking-at c-identifier-start)
- (and (c-forward-name)
- (looking-at "::")
- (progn
- (goto-char (match-end 0))
- (c-forward-syntactic-ws)
- (eq (char-after) ?*))
- (progn
- (forward-char)
- t))))
- (while (progn
- (c-forward-syntactic-ws)
- (setq pos (point))
- (looking-at c-opt-type-modifier-key))
- (goto-char (match-end 1))))))
- ((looking-at c-overloadable-operators-regexp)
-
- (setq c-last-identifier-range
- (cons (point) (match-end 0)))
- (goto-char (match-end 0))
- (c-forward-syntactic-ws)
- (setq pos (point)
- res 'operator)))
- nil)
-
-
-
-
- (when (and id-start (/= id-start id-end))
- (setq c-last-identifier-range
- (cons id-start id-end)))
- (goto-char id-end)
- (c-forward-syntactic-ws)
- (setq pos (point)
- res t)))
- (progn
- (goto-char pos)
- (when (or c-opt-identifier-concat-key
- c-recognize-<>-arglists)
- (cond
- ((and c-opt-identifier-concat-key
- (looking-at c-opt-identifier-concat-key))
-
-
-
- (goto-char (match-end 0))
- (c-forward-syntactic-ws)
- t)
- ((and c-recognize-<>-arglists
- (eq (char-after) ?<))
-
- (when (let ((c-record-type-identifiers t)
- (c-record-found-types t))
- (c-forward-<>-arglist nil))
- (c-add-type start (1+ pos))
- (c-forward-syntactic-ws)
- (setq pos (point)
- c-last-identifier-range nil)
- (if (and c-opt-identifier-concat-key
- (looking-at c-opt-identifier-concat-key))
-
-
- (progn
- (when (and c-record-type-identifiers id-start)
- (c-record-ref-id (cons id-start id-end)))
- (forward-char 2)
- (c-forward-syntactic-ws)
- t)
- (when (and c-record-type-identifiers id-start)
- (c-record-type-id (cons id-start id-end)))
- (setq res 'template)
- nil)))
- )))))
- (goto-char pos)
- res))
- (defun c-forward-type (&optional brace-block-too)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (when (and c-recognize-<>-arglists
- (looking-at "<"))
- (c-forward-<>-arglist t)
- (c-forward-syntactic-ws))
- (let ((start (point)) pos res name-res id-start id-end id-range)
-
-
- (when c-opt-type-modifier-key
- (while (looking-at c-opt-type-modifier-key)
- (goto-char (match-end 1))
- (c-forward-syntactic-ws)
- (setq res 'prefix)))
- (cond
- ((looking-at c-type-prefix-key)
-
- (goto-char (match-end 1))
- (c-forward-syntactic-ws)
- (setq pos (point))
- (setq name-res (c-forward-name))
- (setq res (not (null name-res)))
- (when (eq name-res t)
-
-
- (c-add-type pos (point))
- (when (and c-record-type-identifiers
- c-last-identifier-range)
- (c-record-type-id c-last-identifier-range)))
- (when (and brace-block-too
- (memq res '(t nil))
- (eq (char-after) ?\{)
- (save-excursion
- (c-safe
- (progn (c-forward-sexp)
- (c-forward-syntactic-ws)
- (setq pos (point))))))
- (goto-char pos)
- (setq res t))
- (unless res (goto-char start)))
- ((progn
- (setq pos nil)
- (if (looking-at c-identifier-start)
- (save-excursion
- (setq id-start (point)
- name-res (c-forward-name))
- (when name-res
- (setq id-end (point)
- id-range c-last-identifier-range))))
- (and (cond ((looking-at c-primitive-type-key)
- (setq res t))
- ((c-with-syntax-table c-identifier-syntax-table
- (looking-at c-known-type-key))
- (setq res 'known)))
- (or (not id-end)
- (>= (save-excursion
- (save-match-data
- (goto-char (match-end 1))
- (c-forward-syntactic-ws)
- (setq pos (point))))
- id-end)
- (setq res nil))))
-
-
-
- (setq id-end (match-end 1))
- (when (and c-record-type-identifiers
- (or c-promote-possible-types (eq res t)))
- (c-record-type-id (cons (match-beginning 1) (match-end 1))))
- (if (and c-opt-type-component-key
- (save-match-data
- (looking-at c-opt-type-component-key)))
-
- (let (safe-pos)
- (c-forward-keyword-clause 1)
- (while (progn
- (setq safe-pos (point))
- (looking-at c-opt-type-component-key))
- (when (and c-record-type-identifiers
- (looking-at c-primitive-type-key))
- (c-record-type-id (cons (match-beginning 1)
- (match-end 1))))
- (c-forward-keyword-clause 1))
- (if (looking-at c-primitive-type-key)
- (progn
- (when c-record-type-identifiers
- (c-record-type-id (cons (match-beginning 1)
- (match-end 1))))
- (c-forward-keyword-clause 1)
- (setq res t))
- (goto-char safe-pos)
- (setq res 'prefix)))
- (unless (save-match-data (c-forward-keyword-clause 1))
- (if pos
- (goto-char pos)
- (goto-char (match-end 1))
- (c-forward-syntactic-ws)))))
- (name-res
- (cond ((eq name-res t)
-
- (goto-char id-end)
- (if (or res c-promote-possible-types)
- (progn
- (c-add-type id-start id-end)
- (when (and c-record-type-identifiers id-range)
- (c-record-type-id id-range))
- (unless res
- (setq res 'found)))
- (setq res (if (c-check-type id-start id-end)
-
-
- 'found
-
- 'maybe))))
- ((eq name-res 'template)
-
- (goto-char id-end)
- (setq res t))
- (t
-
- (goto-char start)
- (setq res nil)))))
- (when res
-
-
- (when c-opt-type-modifier-key
- (while (looking-at c-opt-type-modifier-key)
- (goto-char (match-end 1))
- (c-forward-syntactic-ws)
- (setq res t)))
-
-
-
-
- (when c-opt-type-suffix-key
- (while (looking-at c-opt-type-suffix-key)
- (goto-char (match-end 1))
- (c-forward-syntactic-ws)))
- (when c-opt-type-concat-key
-
-
-
-
-
- (setq pos (point))
- (let* ((c-promote-possible-types (or (memq res '(t known))
- c-promote-possible-types))
-
-
-
- (c-record-found-types (and c-record-type-identifiers
- (not c-promote-possible-types)))
- subres)
- (if (and (looking-at c-opt-type-concat-key)
- (progn
- (goto-char (match-end 1))
- (c-forward-syntactic-ws)
- (setq subres (c-forward-type))))
- (progn
-
-
-
- (cond ((eq res t))
- ((eq subres t)
- (unless (eq name-res 'template)
- (c-add-type id-start id-end))
- (when (and c-record-type-identifiers id-range)
- (c-record-type-id id-range))
- (setq res t))
- ((eq res 'known))
- ((eq subres 'known)
- (setq res 'known))
- ((eq res 'found))
- ((eq subres 'found)
- (setq res 'found))
- (t
- (setq res 'maybe)))
- (when (and (eq res t)
- (consp c-record-found-types))
-
-
- (setq c-record-type-identifiers
-
-
- (nconc c-record-found-types
- c-record-type-identifiers))))
- (goto-char pos))))
- (when (and c-record-found-types (memq res '(known found)) id-range)
- (setq c-record-found-types
- (cons id-range c-record-found-types))))
-
- res))
- (defun c-forward-annotation ()
-
-
-
- (and (looking-at "@")
- (progn (forward-char) t)
- (c-forward-type)
- (progn (c-forward-syntactic-ws) t)
- (if (looking-at "(")
- (c-go-list-forward)
- t)))
- (defmacro c-fdoc-shift-type-backward (&optional short)
-
-
-
-
-
- `(progn
- ,(unless short
-
- '(setq identifier-type at-type
- identifier-start type-start
- got-parens nil
- got-identifier t
- got-suffix t
- got-suffix-after-parens id-start
- paren-depth 0))
- (if (setq at-type (if (eq backup-at-type 'prefix)
- t
- backup-at-type))
- (setq type-start backup-type-start
- id-start backup-id-start)
- (setq type-start start-pos
- id-start start-pos))
-
-
-
- (or at-type-decl
- (setq at-type-decl backup-at-type-decl))
- (or maybe-typeless
- (setq maybe-typeless backup-maybe-typeless))
- ,(unless short
-
- '(setq start id-start))))
- (defun c-forward-decl-or-cast-1 (preceding-token-end context last-cast-end)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let (
-
-
-
- (start-pos (point))
-
- at-type
-
-
-
- type-start
-
-
-
-
-
- id-start
-
-
-
-
-
-
- backup-at-type backup-type-start backup-id-start
-
-
- at-type-decl
-
- at-typedef
-
-
- maybe-typeless
-
-
-
-
-
- backup-at-type-decl backup-maybe-typeless
-
-
-
-
-
- at-decl-or-cast
-
-
- backup-if-not-cast
-
- cast-end
-
-
-
-
- (save-rec-type-ids c-record-type-identifiers)
- (save-rec-ref-ids c-record-ref-identifiers))
- (while (c-forward-annotation)
- (c-forward-syntactic-ws))
-
-
-
-
- (while
- (let* ((start (point)) kwd-sym kwd-clause-end found-type)
-
- (when (or (looking-at c-prefix-spec-kwds-re)
- (and (c-major-mode-is 'java-mode)
- (looking-at "@[A-Za-z0-9]+")))
- (if (looking-at c-typedef-key)
- (setq at-typedef t))
- (setq kwd-sym (c-keyword-sym (match-string 1)))
- (save-excursion
- (c-forward-keyword-clause 1)
- (setq kwd-clause-end (point))))
- (when (setq found-type (c-forward-type t))
-
- (when at-type
-
-
- (setq at-decl-or-cast 'ids)
- (when (eq at-type 'found)
-
-
-
- (save-excursion
- (goto-char type-start)
- (let ((c-promote-possible-types t))
- (c-forward-type)))))
- (setq backup-at-type at-type
- backup-type-start type-start
- backup-id-start id-start
- at-type found-type
- type-start start
- id-start (point)
-
-
-
- backup-at-type-decl nil
- backup-maybe-typeless nil))
- (if kwd-sym
- (progn
-
-
-
- (if (c-keyword-member kwd-sym 'c-decl-hangon-kwds)
-
- (progn
- (setq at-decl-or-cast t)
- (if at-type
-
-
- (setq id-start kwd-clause-end)
-
-
- (setq start-pos kwd-clause-end))
- (goto-char kwd-clause-end))
-
-
- (setq backup-at-type nil
- start-pos kwd-clause-end)
- (if found-type
-
-
-
-
- (progn
- (when (c-keyword-member kwd-sym 'c-typedef-decl-kwds)
- (setq backup-at-type-decl t))
- (when (c-keyword-member kwd-sym 'c-typeless-decl-kwds)
- (setq backup-maybe-typeless t)))
- (when (c-keyword-member kwd-sym 'c-typedef-decl-kwds)
-
-
- (setq at-type-decl t))
- (when (c-keyword-member kwd-sym 'c-typeless-decl-kwds)
- (setq maybe-typeless t))
-
-
-
- (setq at-decl-or-cast t)
- (goto-char kwd-clause-end))))
-
-
-
-
- (and found-type (not (eq found-type t))))))
- (cond
- ((eq at-type t)
-
-
-
- (while (looking-at c-decl-hangon-key)
- (c-forward-keyword-clause 1))
- (setq id-start (point)))
- ((eq at-type 'prefix)
-
-
- (setq at-type t))
- ((not at-type)
-
-
-
- (setq id-start start-pos))
- ((and (eq at-type 'maybe)
- (c-major-mode-is 'c++-mode))
-
-
-
- (save-excursion
- (let (name end-2 end-1)
- (goto-char id-start)
- (c-backward-syntactic-ws)
- (setq end-2 (point))
- (when (and
- (c-simple-skip-symbol-backward)
- (progn
- (setq name
- (buffer-substring-no-properties (point) end-2))
-
- (< (skip-chars-backward ":~ \t\n\r\v\f") 0))
- (progn
- (setq end-1 (point))
- (c-simple-skip-symbol-backward))
- (>= (point) type-start)
- (equal (buffer-substring-no-properties (point) end-1)
- name))
-
-
-
- (goto-char type-start)
- (setq at-type nil
- backup-at-type nil
- id-start type-start))))))
-
-
-
-
- (let ((start (point)) (paren-depth 0) pos
-
-
- got-prefix
-
- got-parens
-
- got-identifier
-
-
- got-suffix
-
-
- got-prefix-before-parens
-
-
-
- got-suffix-after-parens
-
-
- at-decl-end
-
-
- identifier-type identifier-start
-
-
-
-
-
-
- c-parse-and-markup-<>-arglists)
- (goto-char id-start)
-
-
- (while (and (looking-at c-type-decl-prefix-key)
- (if (and (c-major-mode-is 'c++-mode)
- (match-beginning 3))
-
-
-
- (when (setq got-identifier (c-forward-name))
- (if (looking-at "\\(::\\)")
-
-
-
- (progn (setq got-identifier nil) t)
-
-
- nil))
- t))
- (if (eq (char-after) ?\()
- (progn
- (setq paren-depth (1+ paren-depth))
- (forward-char))
- (unless got-prefix-before-parens
- (setq got-prefix-before-parens (= paren-depth 0)))
- (setq got-prefix t)
- (goto-char (match-end 1)))
- (c-forward-syntactic-ws))
- (setq got-parens (> paren-depth 0))
-
- (or got-identifier
- (and (looking-at c-identifier-start)
- (setq got-identifier (c-forward-name))))
-
- (while (if (looking-at c-type-decl-suffix-key)
- (if (eq (char-after) ?\))
- (when (> paren-depth 0)
- (setq paren-depth (1- paren-depth))
- (forward-char)
- t)
- (when (if (save-match-data (looking-at "\\s\("))
- (c-safe (c-forward-sexp 1) t)
- (goto-char (match-end 1))
- t)
- (when (and (not got-suffix-after-parens)
- (= paren-depth 0))
- (setq got-suffix-after-parens (match-beginning 0)))
- (setq got-suffix t)))
-
-
-
-
-
-
-
-
-
-
-
-
- (when (and (= paren-depth 1)
- (not got-prefix-before-parens)
- (not (eq at-type t))
- (or backup-at-type
- maybe-typeless
- backup-maybe-typeless
- (when c-recognize-typeless-decls
- (not context)))
- (setq pos (c-up-list-forward (point)))
- (eq (char-before pos) ?\)))
- (c-fdoc-shift-type-backward)
- (goto-char pos)
- t))
- (c-forward-syntactic-ws))
- (when (and (or maybe-typeless backup-maybe-typeless)
- (not got-identifier)
- (not got-prefix)
- at-type)
-
-
-
- (c-fdoc-shift-type-backward))
- (setq
- at-decl-or-cast
- (catch 'at-decl-or-cast
-
- (when (> paren-depth 0)
-
-
-
-
- (c-safe (goto-char (scan-lists (point) 1 paren-depth)))
-
-
- (throw 'at-decl-or-cast (eq at-decl-or-cast t)))
- (setq at-decl-end
- (looking-at (cond ((eq context '<>) "[,>]")
- (context "[,\)]")
- (t "[,;]"))))
-
-
-
-
- (if got-identifier
- (progn
-
- (when (and (or at-type maybe-typeless)
- (not (or got-prefix got-parens)))
-
-
- (throw 'at-decl-or-cast t))
- (when (and got-parens
- (not got-prefix)
- (not got-suffix-after-parens)
- (or backup-at-type
- maybe-typeless
- backup-maybe-typeless))
-
-
-
-
-
-
-
- (c-fdoc-shift-type-backward)))
-
- (if backup-at-type
- (progn
-
- (when (= (point) start)
-
-
-
-
- (if (and (eq (char-after) ?:)
- (not (c-major-mode-is 'java-mode)))
- (cond
-
-
- ((eq at-decl-or-cast t)
- (throw 'at-decl-or-cast t))
- ((and c-has-bitfields
- (eq at-decl-or-cast 'ids))
- (setq backup-if-not-cast t)
- (throw 'at-decl-or-cast t)))
- (setq backup-if-not-cast t)
- (throw 'at-decl-or-cast t)))
-
- (when (and got-suffix
- (not got-prefix)
- (not got-parens))
-
-
-
-
- (setq backup-if-not-cast t)
- (throw 'at-decl-or-cast t)))
-
- (when (eq at-type t)
-
-
-
-
- (throw 'at-decl-or-cast t))
- (when (= (point) start)
-
-
- (if (and
-
-
- at-decl-end
- (cond
- ((eq context 'decl)
-
-
-
-
-
- (or (and (not c-recognize-knr-p)
- (not c-recognize-paren-inits))
- (memq at-type '(known found))))
- ((eq context '<>)
-
-
-
- (memq at-type '(known found)))))
- (throw 'at-decl-or-cast t)
-
-
-
-
- (throw 'at-decl-or-cast at-decl-or-cast))))
- (if (and got-parens
- (not got-prefix)
- (not context)
- (not (eq at-type t))
- (or backup-at-type
- maybe-typeless
- backup-maybe-typeless
- (when c-recognize-typeless-decls
- (or (not got-suffix)
- (not (looking-at
- c-after-suffixed-type-maybe-decl-key))))))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (c-fdoc-shift-type-backward)
-
-
- (when (and got-prefix (or got-parens got-suffix))
-
-
-
-
-
-
-
-
-
- (throw 'at-decl-or-cast t))
-
- (when (and at-type
- (not got-prefix)
- (not got-parens)
- got-suffix-after-parens
- (eq (char-after got-suffix-after-parens) ?\())
-
-
-
- (throw 'at-decl-or-cast nil))))
-
- (when at-decl-or-cast
-
-
- (throw 'at-decl-or-cast t))
-
- (when (and got-identifier
- (not context)
- (looking-at c-after-suffixed-type-decl-key)
- (if (and got-parens
- (not got-prefix)
- (not got-suffix)
- (not (eq at-type t)))
-
-
-
-
-
-
- (progn (c-fdoc-shift-type-backward) t)
- got-suffix-after-parens))
-
- (throw 'at-decl-or-cast t))
-
- (when (and (or got-prefix (not got-parens))
- (memq at-type '(t known)))
-
-
- (throw 'at-decl-or-cast t))
-
-
-
-
-
-
- (unless (or at-decl-end (looking-at "=[^=]"))
-
-
-
-
-
-
-
-
-
-
-
- (throw 'at-decl-or-cast at-decl-or-cast))
-
-
-
- (when (memq at-type '(t known))
-
-
- (throw 'at-decl-or-cast t))
-
- (when (and (c-major-mode-is 'c++-mode)
-
-
-
-
- identifier-type
- (or (memq identifier-type '(found known))
- (and (eq (char-after identifier-start) ?~)
-
-
-
-
-
- (or (save-excursion
- (goto-char (1+ identifier-start))
- (c-forward-syntactic-ws)
- (c-with-syntax-table
- c-identifier-syntax-table
- (looking-at c-known-type-key)))
- (save-excursion
- (goto-char (1+ identifier-start))
-
-
-
-
-
- (c-check-type (point)
- (progn (c-forward-type)
- (point))))))))
- (throw 'at-decl-or-cast t))
- (if got-identifier
- (progn
-
- (when (and got-prefix-before-parens
- at-type
- (or at-decl-end (looking-at "=[^=]"))
- (not context)
- (not got-suffix))
-
-
-
-
-
- (throw 'at-decl-or-cast t))
-
- (when (and (or got-suffix-after-parens
- (looking-at "=[^=]"))
- (eq at-type 'found)
- (not (eq context 'arglist)))
-
-
-
-
- (throw 'at-decl-or-cast t)))
-
- (when (and context
- (or got-prefix
- (and (eq context 'decl)
- (not c-recognize-paren-inits)
- (or got-parens got-suffix))))
-
-
-
-
-
- (throw 'at-decl-or-cast t)))
-
-
-
-
-
-
- (eq context 'decl))))
-
- (cond
-
- ((save-excursion
- (and
- c-cast-parens
-
- (> preceding-token-end (point-min))
- (memq (char-before preceding-token-end) c-cast-parens)
-
- (progn
- (c-forward-syntactic-ws)
- (looking-at "\\s\)"))
-
- (let (pos)
- (forward-char)
- (c-forward-syntactic-ws)
- (setq cast-end (point))
- (and (looking-at c-primary-expr-regexp)
- (progn
- (setq pos (match-end 0))
- (or
-
- (match-beginning 2)
- (if (match-beginning 1)
-
-
-
- (or at-decl-or-cast
- (memq at-type '(t known found)))
-
-
- (not (looking-at c-keywords-regexp)))))
-
-
-
-
-
- (or (not (looking-at c-nonsymbol-token-regexp))
- (<= (match-end 0) pos))))
-
-
- (> preceding-token-end (point-min))
- (progn
- (goto-char (1- preceding-token-end))
- (or (eq (point) last-cast-end)
- (progn
- (c-backward-syntactic-ws)
- (if (< (skip-syntax-backward "w_") 0)
-
-
-
- (looking-at c-simple-stmt-key)
- (and
-
-
- (not (memq (char-before) '(?\) ?\])))
-
- (not (c-on-identifier)))))))))
-
- (when (and c-record-type-identifiers at-type (not (eq at-type t)))
- (let ((c-promote-possible-types t))
- (goto-char type-start)
- (c-forward-type)))
- (goto-char cast-end)
- 'cast)
- (at-decl-or-cast
-
-
- (when backup-if-not-cast
- (c-fdoc-shift-type-backward t))
- (when (and (eq context 'decl) (looking-at ","))
-
-
-
- (c-put-c-type-property (point) 'c-decl-arg-start))
- (when (and c-record-type-identifiers at-type (not (eq at-type t)))
- (let ((c-promote-possible-types t))
- (save-excursion
- (goto-char type-start)
- (c-forward-type))))
- (cons id-start
- (and (or at-type-decl at-typedef)
- (cons at-type-decl at-typedef))))
- (t
-
- (setq c-record-type-identifiers save-rec-type-ids
- c-record-ref-identifiers save-rec-ref-ids)
- nil))))
- (defun c-forward-label (&optional assume-markup preceding-token-end limit)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((start (point))
- label-end
- qt-symbol-idx
- macro-start
- label-type
- kwd)
- (cond
-
- ((looking-at c-label-kwds-regexp)
- (let ((kwd-end (match-end 1)))
-
-
-
- (when c-record-type-identifiers
- (c-record-ref-id (cons (match-beginning 1) kwd-end)))
-
- (goto-char kwd-end)
- (setq label-type
- (if (and (c-syntactic-re-search-forward
-
-
-
- "[;{=,@]\\|\\(\\=\\|[^:]\\):\\([^:]\\|\\'\\)"
- limit t t nil 1)
- (match-beginning 2))
- (progn
- (goto-char (match-beginning 2))
- (c-put-c-type-property (1- (point)) 'c-decl-end)
- t)
-
-
-
-
- (goto-char kwd-end)
- t))))
-
- ((and c-opt-extra-label-key
- (looking-at c-opt-extra-label-key))
-
-
-
- (goto-char (match-end 1))
- (when c-record-type-identifiers
- (c-record-ref-id (cons (match-beginning 1) (point))))
- (c-put-c-type-property (1- (point)) 'c-decl-end)
- (setq label-type t))
-
- ((and c-recognize-colon-labels
-
- (not (eq (char-after) ?:))
-
- (or
-
-
- (if preceding-token-end
- (<= preceding-token-end (point-min))
- (save-excursion
- (c-backward-syntactic-ws)
- (setq preceding-token-end (point))
- (or (bobp)
- (c-at-vsemi-p))))
-
-
-
-
-
- (if assume-markup
- (or
- (eq (c-get-char-property (1- preceding-token-end) 'c-type)
- 'c-decl-end)
- (save-excursion
- (goto-char (1- preceding-token-end))
- (c-beginning-of-current-token)
- (or (looking-at c-label-prefix-re)
- (looking-at c-block-stmt-1-key)))
- (and (eq (char-before preceding-token-end) ?\))
- (c-after-conditional)))
- (or
- (save-excursion
- (goto-char (1- preceding-token-end))
- (c-beginning-of-current-token)
- (or (looking-at c-label-prefix-re)
- (looking-at c-block-stmt-1-key)))
- (cond
- ((eq (char-before preceding-token-end) ?\))
- (c-after-conditional))
- ((eq (char-before preceding-token-end) ?:)
-
- (save-restriction
- (save-excursion
- (goto-char (1- preceding-token-end))
-
-
- (setq macro-start
- (save-excursion (and (c-beginning-of-macro)
- (point))))
- (if macro-start (narrow-to-region macro-start (point-max)))
- (c-syntactic-skip-backward "^-]:?;}=*/%&|,<>!@+" nil t)
-
-
-
-
-
- (let ((pte (point))
-
-
-
- c-record-type-identifiers)
-
-
- (unless (and c-opt-cpp-prefix (looking-at c-opt-cpp-prefix))
- (c-forward-syntactic-ws)
- (c-forward-label nil pte start))))))))))
-
-
-
-
-
-
- (cond
-
- ((and
- (c-major-mode-is 'c++-mode)
- (search-forward-regexp
- "\\=p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\>[^_]" nil t)
- (progn (backward-char)
- (c-forward-syntactic-ws limit)
- (looking-at ":\\([^:]\\|\\'\\)")))
- (forward-char)
- (setq label-type t))
-
- ((progn (goto-char start) nil))
- ((when (c-syntactic-re-search-forward
- "[ \t\n[:?;{=*/%&|,<>!@+-]" limit t t)
- (backward-char)
- (setq label-end (point))
- (setq qt-symbol-idx
- (and (c-major-mode-is 'c++-mode)
- (string-match
- "\\(p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\|more\\)\\>"
- (buffer-substring start (point)))))
- (c-forward-syntactic-ws limit)
- (cond
- ((looking-at ":\\([^:]\\|\\'\\)")
- (forward-char)
- (setq label-type
- (if (or (string= "signals"
- (setq kwd (buffer-substring-no-properties start label-end)))
- (string= "Q_SIGNALS" kwd))
- 'qt-1kwd-colon
- 'goto-target)))
- ((and qt-symbol-idx
- (search-forward-regexp "\\=\\(slots\\|Q_SLOTS\\)\\>" limit t)
- (progn (c-forward-syntactic-ws limit)
- (looking-at ":\\([^:]\\|\\'\\)")))
- (forward-char)
- (setq label-type 'qt-2kwds-colon)))))))
- (save-restriction
- (narrow-to-region start (point))
-
- (catch 'check-label
- (goto-char start)
- (while (progn
- (when (looking-at c-nonlabel-token-key)
- (goto-char start)
- (setq label-type nil)
- (throw 'check-label nil))
- (and (c-safe (c-forward-sexp)
- (c-forward-syntactic-ws)
- t)
- (not (eobp)))))
-
-
-
-
- (when (and c-record-type-identifiers
- (progn (goto-char start)
- (not (looking-at c-label-kwds-regexp))))
- (while (c-syntactic-re-search-forward c-symbol-key nil t)
- (c-record-ref-id (cons (match-beginning 0)
- (match-end 0)))))
- (c-put-c-type-property (1- (point-max)) 'c-decl-end)
- (goto-char (point-max)))))
- (t
-
- (goto-char start)))
- label-type))
- (defun c-forward-objc-directive ()
-
-
-
-
-
-
-
-
-
-
-
- (let ((start (point))
- start-char
- (c-promote-possible-types t)
- lim
-
-
-
- c-recognize-<>-arglists)
- (if (or
- (when (looking-at
- (eval-when-compile
- (c-make-keywords-re t
- (append (c-lang-const c-protection-kwds objc)
- '("@end"))
- 'objc-mode)))
- (goto-char (match-end 1))
- t)
- (and
- (looking-at
- (eval-when-compile
- (c-make-keywords-re t
- '("@interface" "@implementation" "@protocol")
- 'objc-mode)))
-
- (progn
- (goto-char (match-end 0))
- (setq lim (point))
- (c-skip-ws-forward)
- (c-forward-type))
- (catch 'break
-
- (when (looking-at "[:\(]")
- (setq start-char (char-after))
- (forward-char)
- (c-forward-syntactic-ws)
- (unless (c-forward-type) (throw 'break nil))
- (when (eq start-char ?\()
- (unless (eq (char-after) ?\)) (throw 'break nil))
- (forward-char)
- (c-forward-syntactic-ws)))
-
- (if (eq (char-after) ?<)
- (let ((c-recognize-<>-arglists t)
- (c-parse-and-markup-<>-arglists t)
- c-restricted-<>-arglists)
- (c-forward-<>-arglist t))
- t))))
- (progn
- (c-backward-syntactic-ws lim)
- (c-clear-c-type-property start (1- (point)) 'c-decl-end)
- (c-put-c-type-property (1- (point)) 'c-decl-end)
- t)
- (c-clear-c-type-property start (point) 'c-decl-end)
- nil)))
- (defun c-beginning-of-inheritance-list (&optional lim)
-
-
-
-
-
- (c-with-syntax-table c++-template-syntax-table
- (c-backward-token-2 0 t lim)
- (while (and (or (looking-at c-symbol-start)
- (looking-at "[<,]\\|::"))
- (zerop (c-backward-token-2 1 t lim))))))
- (defun c-in-method-def-p ()
-
-
-
-
- (save-excursion
- (beginning-of-line)
- (and c-opt-method-key
- (looking-at c-opt-method-key)
- (point))
- ))
- (defun c-in-gcc-asm-p ()
-
-
-
-
-
-
-
-
-
- (and c-opt-asm-stmt-key
- (save-excursion
- (beginning-of-line)
- (backward-up-list 1)
- (c-beginning-of-statement-1 (point-min) nil t)
- (looking-at c-opt-asm-stmt-key))))
- (defun c-at-toplevel-p ()
- "Return a determination as to whether point is \"at the top level\".
- Informally, \"at the top level\" is anywhere where you can write
- a function.
- More precisely, being at the top-level means that point is either
- outside any enclosing block (such as a function definition), or
- directly inside a class, namespace or other block that contains
- another declaration level.
- If point is not at the top-level (e.g. it is inside a method
- definition), then nil is returned. Otherwise, if point is at a
- top-level not enclosed within a class definition, t is returned.
- Otherwise, a 2-vector is returned where the zeroth element is the
- buffer position of the start of the class declaration, and the first
- element is the buffer position of the enclosing class's opening
- brace.
- Note that this function might do hidden buffer changes. See the
- comment at the start of cc-engine.el for more info."
- (let ((paren-state (c-parse-state)))
- (or (not (c-most-enclosing-brace paren-state))
- (c-search-uplist-for-classkey paren-state))))
- (defun c-just-after-func-arglist-p (&optional lim)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((beg (point)) end id-start)
- (and
- (eq (c-beginning-of-statement-1 lim) 'same)
- (not (and (c-major-mode-is 'objc-mode)
- (c-forward-objc-directive)))
- (setq id-start
- (car-safe (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))
- (< id-start beg)
-
-
-
- (or (> (point) beg)
- (not (looking-at "[=,]")))
- (save-excursion
-
-
- (goto-char id-start)
- (cond ((eq (char-after) ?\()
-
-
-
- (c-forward-sexp))
- ((and c-opt-op-identifier-prefix
- (looking-at c-opt-op-identifier-prefix))
-
- (c-forward-token-2 2 t)))
- (and (< (point) beg)
- (c-syntactic-re-search-forward "(" beg t t)
- (1- (point)))))))
- (defun c-in-knr-argdecl (&optional lim)
-
-
-
-
-
-
-
-
-
-
- (save-excursion
- (save-restriction
-
-
- (let* ((macro-start (save-excursion (and (c-beginning-of-macro) (point))))
- (macro-end (save-excursion (and macro-start (c-end-of-macro) (point))))
- (low-lim (max (or lim (point-min)) (or macro-start (point-min))))
- before-lparen after-rparen
- (pp-count-out 20))
-
- (narrow-to-region low-lim (or macro-end (point-max)))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (catch 'knr
- (while (> pp-count-out 0)
- (setq pp-count-out (1- pp-count-out))
- (c-syntactic-skip-backward "^)]}=")
- (cond ((eq (char-before) ?\))
- (setq after-rparen (point)))
- ((eq (char-before) ?\])
- (setq after-rparen nil))
- (t
-
- (throw 'knr nil)))
- (if after-rparen
-
- (if
- (and
- (progn
- (goto-char after-rparen)
- (unless (c-go-list-backward) (throw 'knr nil))
-
- (setq before-lparen (point)))
-
- (progn (goto-char after-rparen)
- (c-forward-syntactic-ws)
- (not (memq (char-after) '(?\
-
-
- (progn
- (goto-char before-lparen)
- (eq (c-backward-token-2) 0)
- (or (eq (c-on-identifier) (point))
- (and (eq (char-after) ?\))
- (c-go-up-list-backward)
- (eq (c-backward-token-2) 0)
- (eq (c-on-identifier) (point)))))
-
-
- (progn
- (goto-char before-lparen)
- (c-forward-token-2)
- (and
- (c-on-identifier)
- (c-forward-token-2)
- (catch 'id-list
- (while (eq (char-after) ?\,)
- (c-forward-token-2)
- (unless (c-on-identifier) (throw 'id-list nil))
- (c-forward-token-2))
- (eq (char-after) ?\))))))
-
- (throw 'knr
- (progn (goto-char after-rparen)
- (c-forward-syntactic-ws)
- (point)))
-
- (goto-char before-lparen))
- (or (c-go-list-backward)
- (throw 'knr nil)))))))))
- (defun c-skip-conditional ()
-
-
-
-
- (c-forward-sexp (cond
-
- ((looking-at (concat "\\<else"
- "\\([ \t\n]\\|\\\\\n\\)+"
- "if\\>\\([^_]\\|$\\)"))
- 3)
-
- ((looking-at (concat "\\<\\("
- "do\\|else\\|try\\|finally"
- "\\)\\>\\([^_]\\|$\\)"))
- 1)
-
- (t 2))))
- (defun c-after-conditional (&optional lim)
-
-
-
-
- (save-excursion
- (and (zerop (c-backward-token-2 1 t lim))
- (or (looking-at c-block-stmt-1-key)
- (and (eq (char-after) ?\()
- (zerop (c-backward-token-2 1 t lim))
- (looking-at c-block-stmt-2-key)))
- (point))))
- (defun c-after-special-operator-id (&optional lim)
-
-
-
-
-
-
-
- (save-excursion
- (and c-overloadable-operators-regexp
- (zerop (c-backward-token-2 1 nil lim))
- (looking-at c-overloadable-operators-regexp)
- (or (not c-opt-op-identifier-prefix)
- (and
- (zerop (c-backward-token-2 1 nil lim))
- (looking-at c-opt-op-identifier-prefix)))
- (point))))
- (defsubst c-backward-to-block-anchor (&optional lim)
-
-
-
-
-
-
-
- (unless (= (point) (c-point 'boi))
- (let ((start (c-after-conditional lim)))
- (if start
- (goto-char start)))))
- (defsubst c-backward-to-decl-anchor (&optional lim)
-
-
-
-
-
- (unless (= (point) (c-point 'boi))
- (c-beginning-of-statement-1 lim)))
- (defun c-search-decl-header-end ()
-
-
-
-
-
-
-
-
- (let ((base (point)))
- (if (c-major-mode-is 'c++-mode)
-
-
- (while (and
- (c-syntactic-re-search-forward "[;{<=]" nil 'move t t)
- (or
- (c-end-of-current-token base)
-
-
- (save-excursion
- (and (c-safe (c-backward-sexp) t)
- (looking-at c-opt-op-identifier-prefix)))
- (and (eq (char-before) ?<)
- (c-with-syntax-table c++-template-syntax-table
- (if (c-safe (goto-char (c-up-list-forward (point))))
- t
- (goto-char (point-max))
- nil)))))
- (setq base (point)))
- (while (and
- (c-syntactic-re-search-forward "[;{=]" nil 'move t t)
- (c-end-of-current-token base))
- (setq base (point))))))
- (defun c-beginning-of-decl-1 (&optional lim)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (catch 'return
- (let* ((start (point))
- (last-stmt-start (point))
- (move (c-beginning-of-statement-1 lim nil t)))
-
-
-
-
- (let ((beg (point)) tentative-move)
-
-
-
-
- (while (and
-
- (not (and c-opt-method-key
- (looking-at c-opt-method-key)))
- (/= last-stmt-start (point))
- (progn
- (c-backward-syntactic-ws lim)
- (not (memq (char-before) '(?\
- (save-excursion
- (backward-char)
- (not (looking-at "\\s(")))
-
-
- (not (eq (setq tentative-move
- (c-beginning-of-statement-1 lim nil t))
- 'macro)))
- (setq last-stmt-start beg
- beg (point)
- move tentative-move))
- (goto-char beg))
- (when c-recognize-knr-p
- (let ((fallback-pos (point)) knr-argdecl-start)
-
-
-
-
-
-
- (unless (eq (char-after) ?{)
- (goto-char last-stmt-start))
- (if (and (setq knr-argdecl-start (c-in-knr-argdecl lim))
- (< knr-argdecl-start start)
- (progn
- (goto-char knr-argdecl-start)
- (not (eq (c-beginning-of-statement-1 lim nil t) 'macro))))
- (throw 'return
- (cons (if (eq (char-after fallback-pos) ?{)
- 'previous
- 'same)
- knr-argdecl-start))
- (goto-char fallback-pos))))
-
-
-
-
-
-
-
-
-
-
- (if (and (eq move 'previous)
- (c-with-syntax-table (if (c-major-mode-is 'c++-mode)
- c++-template-syntax-table
- (syntax-table))
- (save-excursion
- (and
- (progn
- (while
-
- (and (c-syntactic-re-search-forward "[;={]" start t t t)
- (eq (char-before) ?=)
- c-overloadable-operators-regexp
- c-opt-op-identifier-prefix
- (save-excursion
- (eq (c-backward-token-2) 0)
- (looking-at c-overloadable-operators-regexp)
- (eq (c-backward-token-2) 0)
- (looking-at c-opt-op-identifier-prefix))))
- (eq (char-before) ?=))
- (c-syntactic-re-search-forward "[;{]" start t t)
- (eq (char-before) ?{)
- (c-safe (goto-char (c-up-list-forward (point))) t)
- (not (c-syntactic-re-search-forward ";" start t t))))))
- (cons 'same nil)
- (cons move nil)))))
- (defun c-end-of-decl-1 ()
-
-
-
-
-
-
-
-
-
-
- (let ((start (point))
- (decl-syntax-table (if (c-major-mode-is 'c++-mode)
- c++-template-syntax-table
- (syntax-table))))
- (catch 'return
- (c-search-decl-header-end)
- (when (and c-recognize-knr-p
- (eq (char-before) ?\
- (c-in-knr-argdecl start))
-
-
-
-
- (c-syntactic-re-search-forward "{" nil 'move t))
- (when (eq (char-before) ?{)
-
- (condition-case nil
- (goto-char (c-up-list-forward (point)))
- (error (goto-char (point-max))
- (throw 'return nil)))
- (if (or (not c-opt-block-decls-with-vars-key)
- (save-excursion
- (c-with-syntax-table decl-syntax-table
- (let ((lim (point)))
- (goto-char start)
- (not (and
-
-
- (c-syntactic-re-search-forward
- (concat "[;=\(\[{]\\|\\("
- c-opt-block-decls-with-vars-key
- "\\)")
- lim t t t)
- (match-beginning 1)
- (not (eq (char-before) ?_))
-
-
- (c-syntactic-re-search-forward "[;=\(\[{]"
- lim t t t)
- (eq (char-before) ?{)))))))
-
-
-
- (throw 'return t)))
- (c-with-syntax-table decl-syntax-table
- (while (progn
- (if (eq (char-before) ?\
- (throw 'return t))
- (c-syntactic-re-search-forward ";" nil 'move t))))
- nil)))
- (defun c-looking-at-decl-block (containing-sexp goto-start &optional limit)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (let ((open-brace (point)) kwd-start first-specifier-pos)
- (c-syntactic-skip-backward c-block-prefix-charset limit t)
- (when (and c-recognize-<>-arglists
- (eq (char-before) ?>))
-
- (let ((c-parse-and-markup-<>-arglists t)
- (c-disallow-comma-in-<>-arglists
- (and containing-sexp
- (not (eq (char-after containing-sexp) ?{)))))
- (while (and
- (c-backward-<>-arglist nil limit)
- (progn
- (c-syntactic-skip-backward c-block-prefix-charset limit t)
- (eq (char-before) ?>))))))
-
-
- (when (and
-
-
-
-
- (if goto-start
- (when (c-syntactic-re-search-forward c-symbol-start
- open-brace t t)
- (goto-char (setq first-specifier-pos (match-beginning 0)))
- t)
- t)
- (cond
- ((c-syntactic-re-search-forward c-decl-block-key open-brace t t t)
- (goto-char (setq kwd-start (match-beginning 0)))
- (or
-
- (match-beginning 1)
-
-
-
- (not (c-forward-type))
-
-
-
-
-
-
-
-
-
-
- (not (or (looking-at c-symbol-start)
- (looking-at c-type-decl-prefix-key)))))
-
-
-
- ((and (c-major-mode-is 'pike-mode)
- (progn
- (goto-char open-brace)
- (= (c-backward-token-2) 0))
- (looking-at c-specifier-key)
-
- (c-keyword-member (c-keyword-sym (match-string 1))
- 'c-modifier-kwds))
- (setq kwd-start (point))
- t)))
-
- (if goto-start
-
-
-
-
- (progn
- (goto-char first-specifier-pos)
- (while (< (point) kwd-start)
- (if (looking-at c-symbol-key)
-
-
-
-
-
-
-
-
- (let ((end (match-end 0)))
- (unless (c-forward-keyword-clause 0)
- (goto-char end)
- (c-forward-syntactic-ws)))
-
-
-
- (if (c-syntactic-re-search-forward c-symbol-start
- kwd-start 'move t)
- (goto-char (setq first-specifier-pos (match-beginning 0)))
-
- (setq first-specifier-pos kwd-start))))
- (goto-char first-specifier-pos))
- (goto-char kwd-start))
- kwd-start)))
- (defun c-search-uplist-for-classkey (paren-state)
-
-
-
-
-
-
-
- (let ((open-paren-pos (c-most-enclosing-brace paren-state)))
- (when open-paren-pos
- (save-excursion
- (goto-char open-paren-pos)
- (when (and (eq (char-after) ?{)
- (c-looking-at-decl-block
- (c-safe-position open-paren-pos paren-state)
- nil))
- (back-to-indentation)
- (vector (point) open-paren-pos))))))
- (defmacro c-pull-open-brace (ps)
-
-
- `(progn
- (while (consp (car ,ps))
- (setq ,ps (cdr ,ps)))
- (prog1 (car ,ps)
- (setq ,ps (cdr ,ps)))))
- (defun c-most-enclosing-decl-block (paren-state)
-
-
-
- (let* ((open-brace (c-pull-open-brace paren-state))
- (next-open-brace (c-pull-open-brace paren-state)))
- (while (and open-brace
- (save-excursion
- (goto-char open-brace)
- (not (c-looking-at-decl-block next-open-brace nil))))
- (setq open-brace next-open-brace
- next-open-brace (c-pull-open-brace paren-state)))
- open-brace))
- (defun c-cheap-inside-bracelist-p (paren-state)
-
-
-
-
-
-
- (let (b-pos)
- (save-excursion
- (while
- (and (setq b-pos (c-pull-open-brace paren-state))
- (progn (goto-char b-pos)
- (c-backward-sws)
- (c-backward-token-2)
- (not (looking-at "=")))))
- b-pos)))
- (defun c-inside-bracelist-p (containing-sexp paren-state)
-
-
-
-
-
-
-
-
-
-
-
- (or
-
- (c-safe
- (save-excursion
- (goto-char containing-sexp)
- (c-forward-sexp -1)
- (let (bracepos)
- (if (and (or (looking-at c-brace-list-key)
- (progn (c-forward-sexp -1)
- (looking-at c-brace-list-key)))
- (setq bracepos (c-down-list-forward (point)))
- (not (c-crosses-statement-barrier-p (point)
- (- bracepos 2))))
- (point)))))
-
- (save-excursion
- (let ((class-key
-
-
- (and (c-major-mode-is 'pike-mode)
- c-decl-block-key))
- bufpos braceassignp lim next-containing)
- (while (and (not bufpos)
- containing-sexp)
- (when paren-state
- (if (consp (car paren-state))
- (setq lim (cdr (car paren-state))
- paren-state (cdr paren-state))
- (setq lim (car paren-state)))
- (when paren-state
- (setq next-containing (car paren-state)
- paren-state (cdr paren-state))))
- (goto-char containing-sexp)
- (if (c-looking-at-inexpr-block next-containing next-containing)
-
-
-
-
- (setq containing-sexp nil)
-
-
- (setq braceassignp 'dontknow)
- (c-backward-token-2 1 t lim)
-
- (when (and c-opt-inexpr-brace-list-key
- (eq (char-after) ?\[))
-
-
-
- (while (eq braceassignp 'dontknow)
- (setq braceassignp
- (cond ((/= (c-backward-token-2 1 t lim) 0) nil)
- ((looking-at c-opt-inexpr-brace-list-key) t)
- ((looking-at "\\sw\\|\\s_\\|[.[]")
-
-
-
- 'dontknow)
- (t nil)))))
-
-
- (while (eq braceassignp 'dontknow)
- (cond ((eq (char-after) ?\
- (setq braceassignp nil))
- ((and class-key
- (looking-at class-key))
- (setq braceassignp nil))
- ((eq (char-after) ?=)
-
-
- (setq braceassignp 'maybe)
- (while (and (eq braceassignp 'maybe)
- (zerop (c-backward-token-2 1 t lim)))
- (setq braceassignp
- (cond
-
- ((and c-opt-op-identifier-prefix
- (looking-at c-opt-op-identifier-prefix))
- nil)
-
- ((and (c-major-mode-is 'pike-mode)
- (or (eq (char-after) ?`)
-
-
-
- (and (eq (char-after) ?\[)
- (eq (char-before) ?`))))
- nil)
- ((looking-at "\\s.") 'maybe)
-
-
- ((and
- (c-major-mode-is 'c++-mode)
- (save-excursion
- (let ((here (point))
- (pos< (progn
- (skip-chars-backward "^<>")
- (point))))
- (and (eq (char-before) ?<)
- (not (c-crosses-statement-barrier-p
- pos< here))
- (not (c-in-literal))
- ))))
- nil)
- (t t))))))
- (if (and (eq braceassignp 'dontknow)
- (/= (c-backward-token-2 1 t lim) 0))
- (setq braceassignp nil)))
- (if (not braceassignp)
- (if (eq (char-after) ?\
-
- (setq containing-sexp nil)
-
- (setq containing-sexp next-containing
- lim nil
- next-containing nil))
-
- (c-beginning-of-statement-1
- (c-most-enclosing-brace paren-state))
- (setq bufpos (point))))
- )
- bufpos))
- ))
- (defun c-looking-at-special-brace-list (&optional lim)
-
-
-
-
-
-
-
-
-
-
-
- (if c-special-brace-lists
- (condition-case ()
- (save-excursion
- (let ((beg (point))
- inner-beg end type)
- (c-forward-syntactic-ws)
- (if (eq (char-after) ?\()
- (progn
- (forward-char 1)
- (c-forward-syntactic-ws)
- (setq inner-beg (point))
- (setq type (assq (char-after) c-special-brace-lists)))
- (if (setq type (assq (char-after) c-special-brace-lists))
- (progn
- (setq inner-beg (point))
- (c-backward-syntactic-ws)
- (forward-char -1)
- (setq beg (if (eq (char-after) ?\()
- (point)
- nil)))))
- (if (and beg type)
- (if (and (c-safe
- (goto-char beg)
- (c-forward-sexp 1)
- (setq end (point))
- (= (char-before) ?\)))
- (c-safe
- (goto-char inner-beg)
- (if (looking-at "\\s(")
-
-
- (progn
- (c-forward-sexp 1)
- t)
-
-
-
-
- (goto-char end)
- (backward-char)
- (c-backward-syntactic-ws)
- (= (char-before) (cdr type)))))
- (if (or (/= (char-syntax (char-before)) ?\))
- (= (progn
- (c-forward-syntactic-ws)
- (point))
- (1- end)))
- (cons (cons beg end) type))
- (cons (list beg) type)))))
- (error nil))))
- (defun c-looking-at-bos (&optional lim)
-
-
-
-
-
-
-
- (c-at-statement-start-p))
- (make-obsolete 'c-looking-at-bos 'c-at-statement-start-p "22.1")
- (defun c-looking-at-inexpr-block (lim containing-sexp &optional check-at-end)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (save-excursion
- (let ((res 'maybe) passed-paren
- (closest-lim (or containing-sexp lim (point-min)))
-
-
- (block-follows (and (eq (char-after) ?{) (point))))
- (while (and (eq res 'maybe)
- (progn (c-backward-syntactic-ws)
- (> (point) closest-lim))
- (not (bobp))
- (progn (backward-char)
- (looking-at "[\]\).]\\|\\w\\|\\s_"))
- (c-safe (forward-char)
- (goto-char (scan-sexps (point) -1))))
- (setq res
- (if (looking-at c-keywords-regexp)
- (let ((kw-sym (c-keyword-sym (match-string 1))))
- (cond
- ((and block-follows
- (c-keyword-member kw-sym 'c-inexpr-class-kwds))
- (and (not (eq passed-paren ?\[))
- (or (not (looking-at c-class-key))
-
-
-
- (let ((prev (point)))
- (while (and
- (= (c-backward-token-2 1 nil closest-lim) 0)
- (eq (char-syntax (char-after)) ?w))
- (setq prev (point)))
- (goto-char prev)
- (not (c-at-statement-start-p)))
-
-
-
- (save-excursion
- (and check-at-end
- (c-major-mode-is 'pike-mode)
- (progn (goto-char block-follows)
- (zerop (c-forward-token-2 1 t)))
- (eq (char-after) ?\())))
- (cons 'inexpr-class (point))))
- ((c-keyword-member kw-sym 'c-inexpr-block-kwds)
- (when (not passed-paren)
- (cons 'inexpr-statement (point))))
- ((c-keyword-member kw-sym 'c-lambda-kwds)
- (when (or (not passed-paren)
- (eq passed-paren ?\())
- (cons 'inlambda (point))))
- ((c-keyword-member kw-sym 'c-block-stmt-kwds)
- nil)
- (t
- 'maybe)))
- (if (looking-at "\\s(")
- (if passed-paren
- (if (and (eq passed-paren ?\[)
- (eq (char-after) ?\[))
-
-
- 'maybe)
- (setq passed-paren (char-after))
- 'maybe)
- 'maybe))))
- (if (eq res 'maybe)
- (when (and c-recognize-paren-inexpr-blocks
- block-follows
- containing-sexp
- (eq (char-after containing-sexp) ?\())
- (goto-char containing-sexp)
- (if (or (save-excursion
- (c-backward-syntactic-ws lim)
- (and (> (point) (or lim (point-min)))
- (c-on-identifier)))
- (and c-special-brace-lists
- (c-looking-at-special-brace-list)))
- nil
- (cons 'inexpr-statement (point))))
- res))))
- (defun c-looking-at-inexpr-block-backward (paren-state)
-
-
-
-
-
- (save-excursion
-
- (let ((here (point))
- (elem (car-safe paren-state))
- containing-sexp)
- (when (and (consp elem)
- (progn (goto-char (cdr elem))
- (c-forward-syntactic-ws here)
- (= (point) here)))
- (goto-char (car elem))
- (if (setq paren-state (cdr paren-state))
- (setq containing-sexp (car-safe paren-state)))
- (c-looking-at-inexpr-block (c-safe-position containing-sexp
- paren-state)
- containing-sexp)))))
- (defun c-at-macro-vsemi-p (&optional pos)
-
-
-
-
-
-
-
- (save-excursion
- (save-restriction
- (widen)
- (if pos
- (goto-char pos)
- (setq pos (point)))
- (and
- c-macro-with-semi-re
- (eq (skip-chars-backward " \t") 0)
-
-
- (skip-chars-forward " \t")
- (progn
- (while
- (and
- (looking-at "\\(\\\\[\n\r][ \t]*\\)*")
- (goto-char (match-end 0))
- (cond
- ((looking-at c-block-comment-start-regexp)
- (and (forward-comment 1)
- (skip-chars-forward " \t")))
- ((looking-at c-line-comment-start-regexp)
- (end-of-line)
- nil)
- (t nil))))
- (eolp))
- (goto-char pos)
- (progn (c-backward-syntactic-ws)
- (eq (point) pos))
-
- (or (not (eq (char-before) ?\)))
- (when (c-go-list-backward)
- (c-backward-syntactic-ws)
- t))
- (c-simple-skip-symbol-backward)
- (looking-at c-macro-with-semi-re)
- (goto-char pos)
- (not (c-in-literal))))))
- (defun c-macro-vsemi-status-unknown-p () t)
- (defvar c-auto-newline-analysis nil)
- (defun c-brace-anchor-point (bracepos)
-
-
-
-
-
-
-
-
- (save-excursion
- (let ((boi (c-point 'boi bracepos)))
- (goto-char bracepos)
- (while (and (> (point) boi)
- (not (looking-at c-other-decl-block-key)))
- (c-backward-token-2))
- (if (> (point) boi) (point) boi))))
- (defsubst c-add-syntax (symbol &rest args)
-
-
-
-
- (setq c-syntactic-context (cons (cons symbol args)
- c-syntactic-context)))
- (defsubst c-append-syntax (symbol &rest args)
-
-
- (setq c-syntactic-context (nconc c-syntactic-context
- (list (cons symbol args)))))
- (defun c-add-stmt-syntax (syntax-symbol
- syntax-extra-args
- stop-at-boi-only
- containing-sexp
- paren-state)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (if (= (point) (c-point 'boi))
-
-
- (apply 'c-add-syntax syntax-symbol (point) syntax-extra-args)
- (let ((syntax-last c-syntactic-context)
- (boi (c-point 'boi))
-
-
-
- on-label)
-
- (apply 'c-add-syntax syntax-symbol
- (if (rassq syntax-symbol c-other-decl-block-key-in-symbols-alist)
- (point) nil)
- syntax-extra-args)
-
- (while
- (and
- (catch 'back-up-block
-
- (while (or (/= (point) boi)
- on-label
- (looking-at c-comment-start-regexp))
-
-
- (let ((savepos (point)))
- (while (and (/= savepos boi)
- (c-backward-single-comment))
- (setq savepos (point)
- boi (c-point 'boi)))
- (goto-char savepos))
-
-
- (let ((old-pos (point))
- (old-boi boi)
- (step-type (c-beginning-of-statement-1 containing-sexp)))
- (setq boi (c-point 'boi)
- on-label (eq step-type 'label))
- (cond ((= (point) old-pos)
-
-
- (throw 'back-up-block t))
- ((and (eq step-type 'up)
- (>= (point) old-boi)
- (looking-at "else\\>[^_]")
- (save-excursion
- (goto-char old-pos)
- (looking-at "if\\>[^_]")))
-
-
- )
- ((and (not stop-at-boi-only)
- (/= old-pos old-boi)
- (memq step-type '(up previous)))
-
-
-
-
- (goto-char old-pos)
- (throw 'back-up-block nil))
- (t
- (if (and (not stop-at-boi-only)
- (memq step-type '(up previous beginning)))
-
-
-
- (setq stop-at-boi-only t))
-
-
- (when (eq step-type 'up)
- (c-add-syntax 'substatement nil))))
- )))
- containing-sexp)
-
- (goto-char containing-sexp)
-
-
- (when c-special-brace-lists
- (let ((special-list (c-looking-at-special-brace-list)))
- (when (and special-list
- (< (car (car special-list)) (point)))
- (setq containing-sexp (car (car special-list)))
- (goto-char containing-sexp))))
- (setq paren-state (c-whack-state-after containing-sexp paren-state)
- containing-sexp (c-most-enclosing-brace paren-state)
- boi (c-point 'boi))
-
-
- (let ((paren-pos (point))
- (paren-char (char-after))
- step-type)
- (if (eq paren-char ?\()
-
-
- (progn
- (when (/= paren-pos boi)
- (if (and c-recognize-paren-inexpr-blocks
- (progn
- (c-backward-syntactic-ws containing-sexp)
- (or (not (looking-at "\\>"))
- (not (c-on-identifier))))
- (save-excursion
- (goto-char (1+ paren-pos))
- (c-forward-syntactic-ws)
- (eq (char-after) ?{)))
-
-
- (c-add-syntax 'inexpr-statement)
-
- (c-add-syntax 'arglist-cont-nonempty nil paren-pos)))
- (goto-char (max boi
- (if containing-sexp
- (1+ containing-sexp)
- (point-min))))
- (setq step-type 'same
- on-label nil))
-
- (setq step-type (c-beginning-of-statement-1 containing-sexp)
- on-label (eq step-type 'label))
- (if (and (eq step-type 'same)
- (/= paren-pos (point)))
- (let (inexpr)
- (cond
- ((save-excursion
- (goto-char paren-pos)
- (setq inexpr (c-looking-at-inexpr-block
- (c-safe-position containing-sexp paren-state)
- containing-sexp)))
- (c-add-syntax (if (eq (car inexpr) 'inlambda)
- 'defun-block-intro
- 'statement-block-intro)
- nil))
- ((looking-at c-other-decl-block-key)
- (c-add-syntax
- (cdr (assoc (match-string 1)
- c-other-decl-block-key-in-symbols-alist))
- (max (c-point 'boi paren-pos) (point))))
- (t (c-add-syntax 'defun-block-intro nil))))
- (c-add-syntax 'statement-block-intro nil)))
- (if (= paren-pos boi)
-
-
-
- (goto-char paren-pos)
- (setq boi (c-point 'boi)))
- ))
-
-
- (let ((p c-syntactic-context) q)
- (while (not (eq p syntax-last))
- (setq q (cdr (car p)))
- (while q
- (unless (car q)
- (setcar q (point)))
- (setq q (cdr q)))
- (setq p (cdr p))))
- )))
- (defun c-add-class-syntax (symbol
- containing-decl-open
- containing-decl-start
- containing-decl-kwd
- paren-state)
-
-
-
-
-
- (goto-char containing-decl-open)
- (if (and (eq symbol 'inclass) (= (point) (c-point 'boi)))
- (progn
- (c-add-syntax symbol containing-decl-open)
- containing-decl-open)
- (goto-char containing-decl-start)
-
-
- (back-to-indentation)
- (c-add-syntax symbol (point))
- (if (and (c-keyword-member containing-decl-kwd
- 'c-inexpr-class-kwds)
- (/= containing-decl-start (c-point 'boi containing-decl-start)))
- (c-add-syntax 'inexpr-class))
- (point)))
- (defun c-guess-continued-construct (indent-point
- char-after-ip
- beg-of-same-or-containing-stmt
- containing-sexp
- paren-state)
-
-
-
-
-
- (let (special-brace-list placeholder)
- (goto-char indent-point)
- (skip-chars-forward " \t")
- (cond
-
-
- ((setq special-brace-list
- (or (and c-special-brace-lists
- (c-looking-at-special-brace-list))
- (eq char-after-ip ?{)))
- (cond
-
- ((save-excursion
- (and (eq (char-after) ?{)
- (c-looking-at-decl-block containing-sexp t)
- (setq beg-of-same-or-containing-stmt (point))))
- (c-add-syntax 'class-open beg-of-same-or-containing-stmt))
-
- ((or (consp special-brace-list)
- (save-excursion
- (goto-char beg-of-same-or-containing-stmt)
- (c-syntactic-re-search-forward "=\\([^=]\\|$\\)"
- indent-point t t t)))
-
-
-
-
-
-
- (c-beginning-of-statement-1 containing-sexp)
- (c-add-stmt-syntax (if c-auto-newline-analysis
-
-
-
- 'brace-list-open
- 'statement-cont)
- nil nil
- containing-sexp paren-state))
-
-
-
-
- ((and (not (c-at-statement-start-p))
- (eq (c-beginning-of-statement-1 containing-sexp nil nil t)
- 'same)
- (save-excursion
- (let ((c-recognize-typeless-decls nil))
-
-
-
- (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
- (c-add-stmt-syntax 'defun-open nil t
- containing-sexp paren-state))
-
-
-
-
-
-
- (t
- (c-add-stmt-syntax 'substatement-open nil nil
- containing-sexp paren-state))
- ))
-
- ((and (looking-at "\\(<<\\|>>\\)\\([^=]\\|$\\)")
- (save-excursion
- (goto-char beg-of-same-or-containing-stmt)
-
-
- (when (c-syntactic-re-search-forward
- "\\(<<\\|>>\\)\\([^=]\\|$\\)" indent-point 'move t t)
- (c-add-syntax 'stream-op (c-point 'boi))
- t))))
-
-
- ((and (save-excursion
-
-
-
-
-
-
-
-
-
-
- (c-forward-syntactic-ws)
- (eq (char-after) ?{))
- (not (c-at-statement-start-p))
- (eq (c-beginning-of-statement-1 containing-sexp nil nil t)
- 'same)
- (save-excursion
- (let ((c-recognize-typeless-decls nil))
-
-
-
- (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
- (c-add-stmt-syntax 'func-decl-cont nil t
- containing-sexp paren-state))
-
-
- ((and (c-major-mode-is 'java-mode)
- (setq placeholder (point))
- (c-beginning-of-statement-1)
- (progn
- (while (and (c-forward-annotation)
- (< (point) placeholder))
- (c-forward-syntactic-ws))
- t)
- (prog1
- (>= (point) placeholder)
- (goto-char placeholder)))
- (c-beginning-of-statement-1 containing-sexp)
- (c-add-syntax 'annotation-var-cont (point)))
-
-
- ((and (c-major-mode-is 'c++-mode)
- (save-excursion
- (goto-char indent-point)
- (c-with-syntax-table c++-template-syntax-table
- (setq placeholder (c-up-list-backward)))
- (and placeholder
- (eq (char-after placeholder) ?<)
- (/= (char-before placeholder) ?<)
- (progn
- (goto-char (1+ placeholder))
- (not (looking-at c-<-op-cont-regexp))))))
- (c-with-syntax-table c++-template-syntax-table
- (goto-char placeholder)
- (c-beginning-of-statement-1 containing-sexp t)
- (if (save-excursion
- (c-backward-syntactic-ws containing-sexp)
- (eq (char-before) ?<))
-
- (progn
- (goto-char placeholder)
- (c-syntactic-skip-backward "^,;" containing-sexp t)
- (c-forward-syntactic-ws))
- (back-to-indentation)))
-
-
- (c-add-syntax 'template-args-cont (point) placeholder))
-
- (t
- (c-beginning-of-statement-1 containing-sexp)
- (c-add-stmt-syntax 'statement-cont nil nil
- containing-sexp paren-state))
- )))
- (defun c-guess-basic-syntax ()
- "Return the syntactic context of the current line."
- (save-excursion
- (beginning-of-line)
- (c-save-buffer-state
- ((indent-point (point))
- (case-fold-search nil)
-
-
-
-
-
- literal char-before-ip before-ws-ip char-after-ip macro-start
- in-macro-expr c-syntactic-context placeholder c-in-literal-cache
- step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos
- containing-<
-
-
-
-
-
-
-
- containing-decl-open
- containing-decl-start
- containing-decl-kwd
-
-
- containing-sexp
-
-
-
-
- lim
-
-
- (paren-state (c-parse-state))
-
-
- syntactic-relpos
- (c-stmt-delim-chars c-stmt-delim-chars))
-
-
- (when (and (setq containing-sexp
- (c-most-enclosing-brace paren-state))
- (progn
- (goto-char containing-sexp)
- (eq (char-after) ?{))
- (setq placeholder
- (c-looking-at-decl-block
- (c-most-enclosing-brace paren-state
- containing-sexp)
- t)))
- (setq containing-decl-open containing-sexp
- containing-decl-start (point)
- containing-sexp nil)
- (goto-char placeholder)
- (setq containing-decl-kwd (and (looking-at c-keywords-regexp)
- (c-keyword-sym (match-string 1)))))
-
- (if c-state-cache
- (progn
- (setq containing-sexp (car paren-state)
- paren-state (cdr paren-state))
- (if (consp containing-sexp)
- (progn
- (setq lim (cdr containing-sexp))
- (if (cdr c-state-cache)
-
-
- (setq containing-sexp (car (cdr c-state-cache))
- paren-state (cdr paren-state))
-
-
- (setq paren-state (cons containing-sexp paren-state)
- containing-sexp nil)))
- (setq lim (1+ containing-sexp))))
- (setq lim (point-min)))
- (when (c-beginning-of-macro)
- (goto-char indent-point)
- (let ((lim1 (c-determine-limit 2000)))
- (setq lim (max lim lim1))))
-
-
-
-
-
- (when (and containing-sexp
- (eq (char-after containing-sexp) ?\())
- (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma))
-
-
- (goto-char indent-point)
- (c-backward-syntactic-ws lim)
- (setq before-ws-ip (point)
- char-before-ip (char-before))
- (goto-char indent-point)
- (skip-chars-forward " \t")
- (setq char-after-ip (char-after))
-
- (setq literal (c-in-literal lim))
-
- (cond
-
- ((eq literal 'string)
- (c-add-syntax 'string (c-point 'bopl)))
-
- ((and (memq literal '(c c++))
-
-
-
-
-
-
-
-
- (setq placeholder (c-literal-limits lim)))
- (c-add-syntax literal (car placeholder)))
-
- ((and (save-excursion
- (when (c-beginning-of-macro)
- (setq macro-start (point))))
- (/= macro-start (c-point 'boi))
- (progn
- (setq tmpsymbol 'cpp-macro-cont)
- (or (not c-syntactic-indentation-in-macros)
- (save-excursion
- (goto-char macro-start)
-
-
-
-
-
-
- (if (c-forward-to-cpp-define-body)
- (let ((indent-boi (c-point 'boi indent-point)))
- (setq in-macro-expr (> (point) indent-boi)
- tmpsymbol 'cpp-define-intro)
- (= (point) indent-boi))
- (setq in-macro-expr t)
- nil)))))
- (c-add-syntax tmpsymbol macro-start)
- (setq macro-start nil))
-
- ((looking-at "else\\>[^_]")
- (c-beginning-of-statement-1 containing-sexp)
- (c-add-stmt-syntax 'else-clause nil t
- containing-sexp paren-state))
-
- ((and (looking-at "while\\>[^_]")
- (save-excursion
- (prog1 (eq (c-beginning-of-statement-1 containing-sexp)
- 'beginning)
- (setq placeholder (point)))))
- (goto-char placeholder)
- (c-add-stmt-syntax 'do-while-closure nil t
- containing-sexp paren-state))
-
-
-
- ((save-excursion
- (and (cond ((c-major-mode-is 'c++-mode)
- (looking-at "catch\\>[^_]"))
- ((c-major-mode-is 'java-mode)
- (looking-at "\\(catch\\|finally\\)\\>[^_]")))
- (and (c-safe (c-backward-syntactic-ws)
- (c-backward-sexp)
- t)
- (eq (char-after) ?{)
- (c-safe (c-backward-syntactic-ws)
- (c-backward-sexp)
- t)
- (if (eq (char-after) ?\()
- (c-safe (c-backward-sexp) t)
- t))
- (looking-at "\\(try\\|catch\\)\\>[^_]")
- (setq placeholder (point))))
- (goto-char placeholder)
- (c-add-stmt-syntax 'catch-clause nil t
- containing-sexp paren-state))
-
- ((save-excursion
- (and c-opt-block-stmt-key
- (not (eq char-before-ip ?\
- (not (c-at-vsemi-p before-ws-ip))
- (not (memq char-after-ip '(?\) ?\] ?,)))
- (or (not (eq char-before-ip ?}))
- (c-looking-at-inexpr-block-backward c-state-cache))
- (> (point)
- (progn
-
-
- (setq placeholder (point))
- (while (eq (setq step-type
- (c-beginning-of-statement-1 lim))
- 'label))
- (if (eq step-type 'previous)
- (goto-char placeholder)
- (setq placeholder (point))
- (if (and (eq step-type 'same)
- (not (looking-at c-opt-block-stmt-key)))
-
-
- (let (step)
- (while (eq
- (setq step
- (c-beginning-of-statement-1 lim))
- 'label))
- (if (eq step 'up)
- (setq placeholder (point))
-
- (goto-char placeholder)))))
- placeholder))
- (if (looking-at c-block-stmt-2-key)
-
-
-
-
- (and (zerop (c-forward-token-2 1 nil))
- (eq (char-after) ?\())
- (looking-at c-opt-block-stmt-key))))
- (if (eq step-type 'up)
-
- (progn
- (goto-char placeholder)
- (cond
- ((eq char-after-ip ?{)
- (c-add-stmt-syntax 'substatement-open nil nil
- containing-sexp paren-state))
- ((save-excursion
- (goto-char indent-point)
- (back-to-indentation)
- (c-forward-label))
- (c-add-stmt-syntax 'substatement-label nil nil
- containing-sexp paren-state))
- (t
- (c-add-stmt-syntax 'substatement nil nil
- containing-sexp paren-state))))
-
-
- (c-guess-continued-construct indent-point
- char-after-ip
- placeholder
- lim
- paren-state)))
-
- ((looking-at c-label-kwds-regexp)
- (if containing-sexp
- (progn
- (goto-char containing-sexp)
- (setq lim (c-most-enclosing-brace c-state-cache
- containing-sexp))
- (c-backward-to-block-anchor lim)
- (c-add-stmt-syntax 'case-label nil t lim paren-state))
-
-
- (c-add-syntax 'case-label (point-min))))
-
- ((save-excursion
- (back-to-indentation)
- (and (not (looking-at c-syntactic-ws-start))
- (c-forward-label)))
- (cond (containing-decl-open
- (setq placeholder (c-add-class-syntax 'inclass
- containing-decl-open
- containing-decl-start
- containing-decl-kwd
- paren-state))
-
-
- (c-append-syntax 'access-label placeholder))
- (containing-sexp
- (goto-char containing-sexp)
- (setq lim (c-most-enclosing-brace c-state-cache
- containing-sexp))
- (save-excursion
- (setq tmpsymbol
- (if (and (eq (c-beginning-of-statement-1 lim) 'up)
- (looking-at "switch\\>[^_]"))
-
-
-
- 'case-label
- 'label)))
- (c-backward-to-block-anchor lim)
- (c-add-stmt-syntax tmpsymbol nil t lim paren-state))
- (t
-
-
-
- (c-add-syntax 'access-label (point-min)))))
-
-
- ((setq placeholder (c-looking-at-inexpr-block
- (c-safe-position containing-sexp paren-state)
- containing-sexp
-
-
-
- t))
- (setq tmpsymbol (assq (car placeholder)
- '((inexpr-class . class-open)
- (inexpr-statement . block-open))))
- (if tmpsymbol
-
- (setq tmpsymbol (cdr tmpsymbol))
-
-
-
- (setq tmpsymbol (if (eq char-after-ip ?{)
- 'inline-open
- 'lambda-intro-cont)))
- (goto-char (cdr placeholder))
- (back-to-indentation)
- (c-add-stmt-syntax tmpsymbol nil t
- (c-most-enclosing-brace c-state-cache (point))
- paren-state)
- (unless (eq (point) (cdr placeholder))
- (c-add-syntax (car placeholder))))
-
- ((or containing-decl-open (null containing-sexp))
- (cond
-
-
- ((setq special-brace-list
- (or (and c-special-brace-lists
- (c-looking-at-special-brace-list))
- (eq char-after-ip ?{)))
- (cond
-
- ((save-excursion
- (let (tmp)
- (and (eq char-after-ip ?{)
- (setq tmp (c-looking-at-decl-block containing-sexp t))
- (progn
- (setq placeholder (point))
- (goto-char tmp)
- (looking-at c-symbol-key))
- (c-keyword-member
- (c-keyword-sym (setq keyword (match-string 0)))
- 'c-other-block-decl-kwds))))
- (goto-char placeholder)
- (c-add-stmt-syntax
- (if (string-equal keyword "extern")
-
- 'extern-lang-open
- (intern (concat keyword "-open")))
- nil t containing-sexp paren-state))
-
- ((save-excursion
- (goto-char indent-point)
- (skip-chars-forward " \t")
- (and (eq (char-after) ?{)
- (c-looking-at-decl-block containing-sexp t)
- (setq placeholder (point))))
- (c-add-syntax 'class-open placeholder))
-
- ((save-excursion
- (c-beginning-of-decl-1 lim)
- (while (looking-at c-specifier-key)
- (goto-char (match-end 1))
- (c-forward-syntactic-ws indent-point))
- (setq placeholder (c-point 'boi))
- (or (consp special-brace-list)
- (and (or (save-excursion
- (goto-char indent-point)
- (setq tmpsymbol nil)
- (while (and (> (point) placeholder)
- (zerop (c-backward-token-2 1 t))
- (/= (char-after) ?=))
- (and c-opt-inexpr-brace-list-key
- (not tmpsymbol)
- (looking-at c-opt-inexpr-brace-list-key)
- (setq tmpsymbol 'topmost-intro-cont)))
- (eq (char-after) ?=))
- (looking-at c-brace-list-key))
- (save-excursion
- (while (and (< (point) indent-point)
- (zerop (c-forward-token-2 1 t))
- (not (memq (char-after) '(?\
- (not (memq (char-after) '(?\
- ))))
- (if (and (not c-auto-newline-analysis)
- (c-major-mode-is 'java-mode)
- (eq tmpsymbol 'topmost-intro-cont))
-
-
-
-
-
-
-
-
- (progn
- (c-beginning-of-statement-1 lim)
- (c-add-syntax 'topmost-intro-cont (c-point 'boi)))
- (c-add-syntax 'brace-list-open placeholder)))
-
- ((and containing-decl-open
- (not (c-keyword-member containing-decl-kwd
- 'c-other-block-decl-kwds)))
- (c-add-syntax 'inline-open)
- (c-add-class-syntax 'inclass
- containing-decl-open
- containing-decl-start
- containing-decl-kwd
- paren-state))
-
- (t
- (save-excursion
- (c-beginning-of-decl-1 lim)
- (while (looking-at c-specifier-key)
- (goto-char (match-end 1))
- (c-forward-syntactic-ws indent-point))
- (c-add-syntax 'defun-open (c-point 'boi))
-
-
- ))))
-
-
- ((save-excursion
- (when (setq placeholder (c-just-after-func-arglist-p
- (max lim (c-determine-limit 500))))
- (setq tmp-pos (point))))
- (cond
-
- ((eq (char-after tmp-pos) ?:)
- (if (or (>= tmp-pos indent-point)
- (= (c-point 'bosws) (1+ tmp-pos)))
- (progn
-
-
-
-
- (goto-char placeholder)
- (c-add-syntax 'member-init-intro (c-point 'boi)))
-
- (goto-char (1+ tmp-pos))
- (c-forward-syntactic-ws)
- (c-add-syntax 'member-init-cont (point))))
-
- ((and c-recognize-knr-p
- (c-in-knr-argdecl lim))
- (c-beginning-of-statement-1 lim)
- (c-add-syntax 'knr-argdecl-intro (c-point 'boi))
- (if containing-decl-open
- (c-add-class-syntax 'inclass
- containing-decl-open
- containing-decl-start
- containing-decl-kwd
- paren-state)))
-
-
- (t
- (c-beginning-of-statement-1 lim)
- (c-add-syntax 'func-decl-cont (c-point 'boi))
- )))
-
-
- ((or (and (c-major-mode-is 'c++-mode)
- (progn
- (when (eq char-after-ip ?,)
- (skip-chars-forward " \t")
- (forward-char))
- (looking-at c-opt-postfix-decl-spec-key)))
- (and (or (eq char-before-ip ?:)
-
- (save-excursion
- (and (eq char-after-ip ?:)
- (c-safe (forward-char 1) t)
- (not (eq (char-after) ?:))
- )))
- (save-excursion
- (c-backward-syntactic-ws lim)
- (if (eq char-before-ip ?:)
- (progn
- (forward-char -1)
- (c-backward-syntactic-ws lim)))
- (back-to-indentation)
- (looking-at c-class-key)))
-
- (and (c-major-mode-is 'java-mode)
- (let ((fence (save-excursion
- (c-beginning-of-statement-1 lim)
- (point)))
- cont done)
- (save-excursion
- (while (not done)
- (cond ((looking-at c-opt-postfix-decl-spec-key)
- (setq injava-inher (cons cont (point))
- done t))
- ((or (not (c-safe (c-forward-sexp -1) t))
- (<= (point) fence))
- (setq done t))
- )
- (setq cont t)))
- injava-inher)
- (not (c-crosses-statement-barrier-p (cdr injava-inher)
- (point)))
- ))
- (cond
-
- ((eq char-after-ip ?:)
- (c-beginning-of-statement-1 lim)
- (c-add-syntax 'inher-intro (c-point 'boi))
-
-
- )
-
- ((eq char-before-ip ?:)
- (c-beginning-of-statement-1 lim)
- (c-add-syntax 'inher-intro (c-point 'boi))
- (if containing-decl-open
- (c-add-class-syntax 'inclass
- containing-decl-open
- containing-decl-start
- containing-decl-kwd
- paren-state)))
-
- (injava-inher
- (let ((where (cdr injava-inher))
- (cont (car injava-inher)))
- (goto-char where)
- (cond ((looking-at "throws\\>[^_]")
- (c-add-syntax 'func-decl-cont
- (progn (c-beginning-of-statement-1 lim)
- (c-point 'boi))))
- (cont (c-add-syntax 'inher-cont where))
- (t (c-add-syntax 'inher-intro
- (progn (goto-char (cdr injava-inher))
- (c-beginning-of-statement-1 lim)
- (point))))
- )))
-
- (t
- (c-beginning-of-inheritance-list lim)
- (c-add-syntax 'inher-cont (point))
-
-
- )))
-
-
-
- ((save-excursion
-
-
- (if c-recognize-<>-arglists
- (while (and
- (progn
- (c-syntactic-skip-backward "^;,=<>" lim t)
- (> (point) lim))
- (or
- (when c-overloadable-operators-regexp
- (when (setq placeholder (c-after-special-operator-id lim))
- (goto-char placeholder)
- t))
- (cond
- ((eq (char-before) ?>)
- (or (c-backward-<>-arglist nil lim)
- (backward-char))
- t)
- ((eq (char-before) ?<)
- (backward-char)
- (if (save-excursion
- (c-forward-<>-arglist nil))
- (progn (forward-char)
- nil)
- t))
- (t nil)))))
-
-
- (c-syntactic-skip-backward "^;,=" lim t))
- (memq (char-before) '(?, ?= ?<)))
- (cond
-
- ((and (c-major-mode-is 'c++-mode)
- (save-excursion
- (save-restriction
- (c-with-syntax-table c++-template-syntax-table
- (goto-char indent-point)
- (setq placeholder (c-up-list-backward))
- (and placeholder
- (eq (char-after placeholder) ?<))))))
- (c-with-syntax-table c++-template-syntax-table
- (goto-char placeholder)
- (c-beginning-of-statement-1 lim t)
- (if (save-excursion
- (c-backward-syntactic-ws lim)
- (eq (char-before) ?<))
-
- (progn
- (goto-char placeholder)
- (c-syntactic-skip-backward "^,;" lim t)
- (c-forward-syntactic-ws))
- (back-to-indentation)))
-
-
- (c-add-syntax 'template-args-cont (point) placeholder))
-
- ((and (c-major-mode-is 'c++-mode)
- (save-excursion
- (c-beginning-of-statement-1 lim)
- (setq placeholder (point))
- (if (looking-at "static\\>[^_]")
- (c-forward-token-2 1 nil indent-point))
- (and (looking-at c-class-key)
- (zerop (c-forward-token-2 2 nil indent-point))
- (if (eq (char-after) ?<)
- (c-with-syntax-table c++-template-syntax-table
- (zerop (c-forward-token-2 1 t indent-point)))
- t)
- (eq (char-after) ?:))))
- (goto-char placeholder)
- (c-add-syntax 'inher-cont (c-point 'boi)))
-
-
- (t
- (while (and (setq placeholder (point))
- (eq (car (c-beginning-of-decl-1 containing-sexp))
- 'same)
- (save-excursion
- (c-backward-syntactic-ws)
- (eq (char-before) ?}))
- (< (point) placeholder)))
- (c-add-stmt-syntax
- (cond
- ((eq (point) placeholder) 'statement)
-
-
-
-
- ((eq char-before-ip ?,) 'topmost-intro-cont)
- (t 'statement-cont))
- nil nil containing-sexp paren-state))
- ))
-
- ((and (eq char-after-ip ?})
- (c-keyword-member containing-decl-kwd
- 'c-other-block-decl-kwds))
-
-
- (goto-char containing-decl-start)
- (c-add-stmt-syntax
- (if (string-equal (symbol-name containing-decl-kwd) "extern")
-
-
- 'extern-lang-close
- (intern (concat (symbol-name containing-decl-kwd)
- "-close")))
- nil t
- (c-most-enclosing-brace paren-state (point))
- paren-state))
-
-
- ((and containing-sexp
- (eq char-after-ip ?})
- (eq containing-decl-open containing-sexp))
- (c-add-class-syntax 'class-close
- containing-decl-open
- containing-decl-start
- containing-decl-kwd
- paren-state))
-
- ((and c-recognize-knr-p
- (not containing-sexp)
- (not (eq char-before-ip ?}))
- (save-excursion
- (setq placeholder (cdr (c-beginning-of-decl-1 lim)))
- (and placeholder
-
-
-
-
- (not (and c-opt-block-stmt-key
- (looking-at c-opt-block-stmt-key)))))
- (< placeholder indent-point))
- (goto-char placeholder)
- (c-add-syntax 'knr-argdecl (point)))
-
- ((and c-opt-method-key
- (looking-at c-opt-method-key))
- (c-beginning-of-statement-1 nil t)
- (if (= (point) indent-point)
-
-
-
-
-
-
- (goto-char (point-min)))
- (c-add-syntax 'objc-method-intro (c-point 'boi)))
-
-
- ((c-major-mode-is 'awk-mode)
- (setq placeholder (point))
- (c-add-stmt-syntax
- (if (and (eq (c-beginning-of-statement-1) 'same)
- (/= (point) placeholder))
- 'topmost-intro-cont
- 'topmost-intro)
- nil nil
- containing-sexp paren-state))
-
-
-
- ((progn
- (c-backward-syntactic-ws lim)
- (and (eq (char-before) ?})
- (save-excursion
- (let ((start (point)))
- (if (and c-state-cache
- (consp (car c-state-cache))
- (eq (cdar c-state-cache) (point)))
-
- (goto-char (caar c-state-cache)))
- (c-beginning-of-decl-1 containing-sexp)
- (setq placeholder (point))
- (if (= start (point))
-
- nil
- (c-end-of-decl-1)
- (>= (point) indent-point))))))
- (goto-char placeholder)
- (c-add-stmt-syntax 'topmost-intro-cont nil nil
- containing-sexp paren-state))
-
-
-
- ((and
-
- (not (and macro-start
- (> indent-point macro-start)))
- (save-excursion
- (setq placeholder (point))
- (or (memq char-before-ip '(?\
- (c-at-vsemi-p before-ws-ip)
- (when (and (eq char-before-ip ?:)
- (eq (c-beginning-of-statement-1 lim)
- 'label))
- (c-backward-syntactic-ws lim)
- (setq placeholder (point)))
- (and (c-major-mode-is 'objc-mode)
- (catch 'not-in-directive
- (c-beginning-of-statement-1 lim)
- (setq placeholder (point))
- (while (and (c-forward-objc-directive)
- (< (point) indent-point))
- (c-forward-syntactic-ws)
- (if (>= (point) indent-point)
- (throw 'not-in-directive t))
- (setq placeholder (point)))
- nil)))))
-
-
-
-
- (goto-char placeholder)
- (c-add-syntax 'topmost-intro (c-point 'bol))
- (if containing-decl-open
- (if (c-keyword-member containing-decl-kwd
- 'c-other-block-decl-kwds)
- (progn
- (goto-char (c-brace-anchor-point containing-decl-open))
- (c-add-stmt-syntax
- (if (string-equal (symbol-name containing-decl-kwd)
- "extern")
-
-
- 'inextern-lang
- (intern (concat "in"
- (symbol-name containing-decl-kwd))))
- nil t
- (c-most-enclosing-brace paren-state (point))
- paren-state))
- (c-add-class-syntax 'inclass
- containing-decl-open
- containing-decl-start
- containing-decl-kwd
- paren-state)))
- (when (and c-syntactic-indentation-in-macros
- macro-start
- (/= macro-start (c-point 'boi indent-point)))
- (c-add-syntax 'cpp-define-intro)
- (setq macro-start nil)))
-
-
- ((and c-opt-method-key
- (save-excursion
- (c-beginning-of-statement-1 lim)
- (beginning-of-line)
- (when (looking-at c-opt-method-key)
- (setq placeholder (point)))))
- (c-add-syntax 'objc-method-args-cont placeholder))
-
-
- ((and c-recognize-<>-arglists
- (eq (char-before) ?<)
- (not (and c-overloadable-operators-regexp
- (c-after-special-operator-id lim))))
- (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
- (c-add-syntax 'template-args-cont (c-point 'boi)))
-
- (macro-start
- (c-beginning-of-statement-1 containing-sexp)
- (c-add-stmt-syntax 'statement nil t containing-sexp paren-state))
-
-
- ((and (c-major-mode-is 'java-mode)
- (setq placeholder (point))
- (c-beginning-of-statement-1)
- (progn
- (while (and (c-forward-annotation))
- (c-forward-syntactic-ws))
- t)
- (prog1
- (>= (point) placeholder)
- (goto-char placeholder)))
- (c-add-syntax 'annotation-top-cont (c-point 'boi)))
-
- (t
- (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
- (when (c-major-mode-is 'objc-mode)
- (setq placeholder (point))
- (while (and (c-forward-objc-directive)
- (< (point) indent-point))
- (c-forward-syntactic-ws)
- (setq placeholder (point)))
- (goto-char placeholder))
- (c-add-syntax 'topmost-intro-cont (c-point 'boi)))
- ))
-
-
-
-
- ((not (or (and c-special-brace-lists
- (save-excursion
- (goto-char containing-sexp)
- (c-looking-at-special-brace-list)))
- (eq (char-after containing-sexp) ?{)))
- (cond
-
-
- ((memq char-after-ip '(?\) ?\]))
- (goto-char containing-sexp)
- (setq placeholder (c-point 'boi))
- (if (and (c-safe (backward-up-list 1) t)
- (>= (point) placeholder))
- (progn
- (forward-char)
- (skip-chars-forward " \t"))
- (goto-char placeholder))
- (c-add-stmt-syntax 'arglist-close (list containing-sexp) t
- (c-most-enclosing-brace paren-state (point))
- paren-state))
-
-
-
- ((and (eq char-after-ip ?{)
- (progn
- (setq placeholder (c-inside-bracelist-p (point)
- paren-state))
- (if placeholder
- (setq tmpsymbol '(brace-list-open . inexpr-class))
- (setq tmpsymbol '(block-open . inexpr-statement)
- placeholder
- (cdr-safe (c-looking-at-inexpr-block
- (c-safe-position containing-sexp
- paren-state)
- containing-sexp)))
-
-
-
- )))
- (goto-char placeholder)
- (back-to-indentation)
- (c-add-stmt-syntax (car tmpsymbol) nil t
- (c-most-enclosing-brace paren-state (point))
- paren-state)
- (if (/= (point) placeholder)
- (c-add-syntax (cdr tmpsymbol))))
-
-
-
- ((memq char-before-ip '(?\( ?\[))
- (goto-char containing-sexp)
- (setq placeholder (c-point 'boi))
- (if (and (c-safe (backward-up-list 1) t)
- (>= (point) placeholder))
- (progn
- (forward-char)
- (skip-chars-forward " \t"))
- (goto-char placeholder))
- (c-add-stmt-syntax 'arglist-intro (list containing-sexp) t
- (c-most-enclosing-brace paren-state (point))
- paren-state))
-
-
- ((progn
- (goto-char containing-sexp)
- (and (c-safe (c-forward-sexp -1) t)
- (looking-at "\\<for\\>[^_]")))
- (goto-char (1+ containing-sexp))
- (c-forward-syntactic-ws indent-point)
- (if (eq char-before-ip ?\
- (c-add-syntax 'statement (point))
- (c-add-syntax 'statement-cont (point))
- ))
-
-
-
- ((and c-opt-method-key
- (eq (char-after containing-sexp) ?\[)
- (progn
- (goto-char (1- containing-sexp))
- (c-backward-syntactic-ws (c-point 'bod))
- (if (not (looking-at c-symbol-key))
- (c-add-syntax 'objc-method-call-cont containing-sexp))
- )))
-
-
-
-
-
- ((progn
- (goto-char (1+ containing-sexp))
- (< (save-excursion
- (c-forward-syntactic-ws)
- (point))
- (c-point 'bonl)))
- (goto-char containing-sexp)
- (setq placeholder (c-point 'boi))
- (if (and (c-safe (backward-up-list 1) t)
- (>= (point) placeholder))
- (progn
- (forward-char)
- (skip-chars-forward " \t"))
- (goto-char placeholder))
- (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t
- (c-most-enclosing-brace c-state-cache (point))
- paren-state))
-
-
- (t (c-forward-syntactic-ws indent-point)
- (c-add-syntax 'arglist-cont (c-point 'boi)))
- ))
-
- ((and (c-major-mode-is 'c++-mode)
- (save-excursion
- (goto-char indent-point)
- (skip-chars-forward " \t")
- (looking-at c-opt-postfix-decl-spec-key)))
- (goto-char indent-point)
- (skip-chars-forward " \t")
- (cond
-
- ((eq char-after-ip ?:)
- (c-backward-syntactic-ws lim)
- (c-add-syntax 'inher-intro (c-point 'boi)))
-
- ((eq char-before-ip ?:)
- (c-add-syntax 'inher-intro (c-point 'boi)))
-
- (t
- (c-beginning-of-inheritance-list lim)
- (c-add-syntax 'inher-cont (point))
- )))
-
- ((and (not (c-major-mode-is 'awk-mode))
- (setq special-brace-list
- (or (and c-special-brace-lists
- (save-excursion
- (goto-char containing-sexp)
- (c-looking-at-special-brace-list)))
- (c-inside-bracelist-p containing-sexp paren-state))))
- (cond
-
- ((and (consp special-brace-list)
- (save-excursion
- (goto-char containing-sexp)
- (eq (char-after) ?\())
- (eq char-after-ip (car (cdr special-brace-list))))
- (goto-char (car (car special-brace-list)))
- (skip-chars-backward " \t")
- (if (and (bolp)
- (assoc 'statement-cont
- (setq placeholder (c-guess-basic-syntax))))
- (setq c-syntactic-context placeholder)
- (c-beginning-of-statement-1
- (c-safe-position (1- containing-sexp) paren-state))
- (c-forward-token-2 0)
- (while (looking-at c-specifier-key)
- (goto-char (match-end 1))
- (c-forward-syntactic-ws))
- (c-add-syntax 'brace-list-open (c-point 'boi))))
-
- ((if (consp special-brace-list)
-
- (progn
- (goto-char (car (car special-brace-list)))
- (save-excursion
- (goto-char indent-point)
- (back-to-indentation)
- (or
-
- (and (eq (char-after) ?\))
- (eq (1+ (point)) (cdr (car special-brace-list))))
-
- (and (eq (char-after) (cdr (cdr special-brace-list)))
- (zerop (c-forward-token-2))
- (eq (1+ (point)) (cdr (car special-brace-list)))))))
-
- (and (eq char-after-ip ?})
- (c-safe (goto-char (c-up-list-backward (point))) t)
- (= (point) containing-sexp)))
- (if (eq (point) (c-point 'boi))
- (c-add-syntax 'brace-list-close (point))
- (setq lim (c-most-enclosing-brace c-state-cache (point)))
- (c-beginning-of-statement-1 lim)
- (c-add-stmt-syntax 'brace-list-close nil t lim paren-state)))
- (t
-
-
- (if (consp special-brace-list)
- (progn
- (goto-char (car (car special-brace-list)))
- (c-forward-token-2 1 nil indent-point))
- (goto-char containing-sexp))
- (forward-char)
- (let ((start (point)))
- (c-forward-syntactic-ws indent-point)
- (goto-char (max start (c-point 'bol))))
- (c-skip-ws-forward indent-point)
- (cond
-
- ((= (point) indent-point)
- (if (consp special-brace-list)
- (goto-char (car (car special-brace-list)))
- (goto-char containing-sexp))
- (if (eq (point) (c-point 'boi))
- (c-add-syntax 'brace-list-intro (point))
- (setq lim (c-most-enclosing-brace c-state-cache (point)))
- (c-beginning-of-statement-1 lim)
- (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state)))
-
-
- (t (if (or (eq char-after-ip ?{)
- (and c-special-brace-lists
- (save-excursion
- (goto-char indent-point)
- (c-forward-syntactic-ws (c-point 'eol))
- (c-looking-at-special-brace-list (point)))))
- (c-add-syntax 'brace-entry-open (point))
- (c-add-syntax 'brace-list-entry (point))
- ))
- ))))
-
- ((and (not (memq char-before-ip '(?\
- (not (c-at-vsemi-p before-ws-ip))
- (or (not (eq char-before-ip ?}))
- (c-looking-at-inexpr-block-backward c-state-cache))
- (> (point)
- (save-excursion
- (c-beginning-of-statement-1 containing-sexp)
- (setq placeholder (point))))
- (/= placeholder containing-sexp))
-
- (c-guess-continued-construct indent-point
- char-after-ip
- placeholder
- containing-sexp
- paren-state))
-
-
- ((eq char-after-ip ?})
-
- (setq lim (c-most-enclosing-brace paren-state))
- (goto-char containing-sexp)
- (cond
-
-
-
-
- ((c-after-conditional)
- (c-backward-to-block-anchor lim)
- (c-add-stmt-syntax 'block-close nil t lim paren-state))
-
-
- ((setq placeholder (c-looking-at-inexpr-block
- (c-safe-position containing-sexp paren-state)
- nil))
- (setq tmpsymbol (if (eq (car placeholder) 'inlambda)
- 'inline-close
- 'block-close))
- (goto-char containing-sexp)
- (back-to-indentation)
- (if (= containing-sexp (point))
- (c-add-syntax tmpsymbol (point))
- (goto-char (cdr placeholder))
- (back-to-indentation)
- (c-add-stmt-syntax tmpsymbol nil t
- (c-most-enclosing-brace paren-state (point))
- paren-state)
- (if (/= (point) (cdr placeholder))
- (c-add-syntax (car placeholder)))))
-
-
- ((save-excursion
- (and lim
- (progn
- (goto-char lim)
- (c-looking-at-decl-block
- (c-most-enclosing-brace paren-state lim)
- nil))
- (setq placeholder (point))))
- (c-backward-to-decl-anchor lim)
- (back-to-indentation)
- (if (save-excursion
- (goto-char placeholder)
- (looking-at c-other-decl-block-key))
- (c-add-syntax 'defun-close (point))
- (c-add-syntax 'inline-close (point))))
-
-
-
-
-
- ((save-excursion
- (and (not (c-at-statement-start-p))
- (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
- (setq placeholder (point))
- (let ((c-recognize-typeless-decls nil))
-
-
-
- (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
- (back-to-indentation)
- (if (/= (point) containing-sexp)
- (goto-char placeholder))
- (c-add-stmt-syntax 'defun-close nil t lim paren-state))
-
-
-
- (lim
-
-
-
-
-
-
- (while (and (/= (setq placeholder (point)) (c-point 'boi))
- (eq (c-beginning-of-statement-1 lim) 'label)))
- (goto-char placeholder)
- (if (looking-at c-label-kwds-regexp)
- (c-add-syntax 'block-close (point))
- (goto-char containing-sexp)
-
-
- (c-add-stmt-syntax 'block-close nil t lim paren-state)))
-
- (t
- (goto-char containing-sexp)
- (c-backward-to-decl-anchor lim)
- (c-add-stmt-syntax 'defun-close nil nil
- (c-most-enclosing-brace paren-state)
- paren-state))
- ))
-
-
-
-
-
-
-
- ((and c-recognize-<>-arglists
- (setq containing-< (c-up-list-backward indent-point containing-sexp))
- (eq (char-after containing-<) ?\<))
- (setq placeholder (c-point 'boi containing-<))
- (goto-char containing-sexp)
-
- (if (>= (point) placeholder)
- (progn
- (forward-char)
- (skip-chars-forward " \t"))
- (goto-char placeholder))
- (c-add-stmt-syntax 'template-args-cont (list containing-<) t
- (c-most-enclosing-brace c-state-cache (point))
- paren-state))
-
- (t
- (goto-char indent-point)
-
- (while (let* ((prev-point (point))
- (last-step-type (c-beginning-of-statement-1
- containing-sexp)))
- (if (= (point) prev-point)
- (progn
- (setq step-type (or step-type last-step-type))
- nil)
- (setq step-type last-step-type)
- (/= (point) (c-point 'boi)))))
- (cond
-
- ((and (eq step-type 'same)
- (/= (point) indent-point))
- (c-add-stmt-syntax 'statement-cont nil nil
- containing-sexp paren-state))
-
- ((progn
- (while (and (eq step-type 'label)
- (not (looking-at c-label-kwds-regexp)))
- (setq step-type
- (c-beginning-of-statement-1 containing-sexp)))
- (eq step-type 'label))
- (c-add-stmt-syntax (if (eq char-after-ip ?{)
- 'statement-case-open
- 'statement-case-intro)
- nil t containing-sexp paren-state))
-
- ((progn
- (while (eq step-type 'label)
- (setq step-type
- (c-beginning-of-statement-1 containing-sexp)))
- (eq step-type 'previous))
- (c-add-stmt-syntax 'statement nil t
- containing-sexp paren-state)
- (if (eq char-after-ip ?{)
- (c-add-syntax 'block-open)))
-
- ((progn
-
- (goto-char containing-sexp)
-
- (setq lim (c-most-enclosing-brace paren-state containing-sexp))
- (c-after-conditional))
- (c-backward-to-block-anchor lim)
- (c-add-stmt-syntax 'statement-block-intro nil t
- lim paren-state)
- (if (eq char-after-ip ?{)
- (c-add-syntax 'block-open)))
-
-
- ((setq placeholder (c-looking-at-inexpr-block
- (c-safe-position containing-sexp paren-state)
- nil))
- (setq tmpsymbol (if (eq (car placeholder) 'inlambda)
- 'defun-block-intro
- 'statement-block-intro))
- (back-to-indentation)
- (if (= containing-sexp (point))
- (c-add-syntax tmpsymbol (point))
- (goto-char (cdr placeholder))
- (back-to-indentation)
- (c-add-stmt-syntax tmpsymbol nil t
- (c-most-enclosing-brace c-state-cache (point))
- paren-state)
- (if (/= (point) (cdr placeholder))
- (c-add-syntax (car placeholder))))
- (if (eq char-after-ip ?{)
- (c-add-syntax 'block-open)))
-
-
-
-
- ((save-excursion
- (or (not (setq placeholder (c-most-enclosing-brace
- paren-state)))
- (and (progn
- (goto-char placeholder)
- (eq (char-after) ?{))
- (c-looking-at-decl-block (c-most-enclosing-brace
- paren-state (point))
- nil))))
- (c-backward-to-decl-anchor lim)
- (back-to-indentation)
- (c-add-syntax 'defun-block-intro (point)))
-
-
-
-
- ((save-excursion
- (and (not (c-at-statement-start-p))
- (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
- (setq placeholder (point))
- (let ((c-recognize-typeless-decls nil))
-
-
-
- (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
- (back-to-indentation)
- (if (/= (point) containing-sexp)
- (goto-char placeholder))
- (c-add-stmt-syntax 'defun-block-intro nil t
- lim paren-state))
-
- (t
-
-
-
-
-
-
- (while (and (/= (setq placeholder (point)) (c-point 'boi))
- (eq (c-beginning-of-statement-1 lim) 'label)))
- (goto-char placeholder)
- (if (looking-at c-label-kwds-regexp)
- (c-add-syntax 'statement-block-intro (point))
- (goto-char containing-sexp)
-
-
- (c-add-stmt-syntax 'statement-block-intro nil t
- lim paren-state))
- (if (eq char-after-ip ?{)
- (c-add-syntax 'block-open)))
- ))
- )
-
- (goto-char indent-point)
- (skip-chars-forward " \t")
-
- (when (and (looking-at c-comment-start-regexp)
- (/= (c-forward-token-2 0 nil (c-point 'eol)) 0))
- (c-append-syntax 'comment-intro))
-
- (when (and c-opt-friend-key
- (looking-at c-opt-friend-key))
- (c-append-syntax 'friend))
-
- (let ((p c-syntactic-context))
- (while (and p
- (if (integerp (c-langelem-pos (car p)))
- (progn
- (setq syntactic-relpos (c-langelem-pos (car p)))
- nil)
- t))
- (setq p (cdr p))))
-
- (if (and macro-start
- (eq macro-start (c-point 'boi))
- (not (and (c-major-mode-is 'pike-mode)
- (eq (char-after (1+ macro-start)) ?\"))))
- (c-append-syntax 'cpp-macro)
- (when (and c-syntactic-indentation-in-macros macro-start)
- (if in-macro-expr
- (when (or
- (< syntactic-relpos macro-start)
- (not (or
- (assq 'arglist-intro c-syntactic-context)
- (assq 'arglist-cont c-syntactic-context)
- (assq 'arglist-cont-nonempty c-syntactic-context)
- (assq 'arglist-close c-syntactic-context))))
- ;; If inside a cpp expression, i.e. anywhere in a
- ;; cpp directive except a #define body, we only let
- ;; through the syntactic analysis that is internal
- ;; in the expression. That means the arglist
- ;; elements, if they are anchored inside the cpp
- ;; expression.
- (setq c-syntactic-context nil)
- (c-add-syntax 'cpp-macro-cont macro-start))
- (when (and (eq macro-start syntactic-relpos)
- (not (assq 'cpp-define-intro c-syntactic-context))
- (save-excursion
- (goto-char macro-start)
- (or (not (c-forward-to-cpp-define-body))
- (<= (point) (c-point 'boi indent-point)))))
- ;; Inside a #define body and the syntactic analysis is
- ;; anchored on the start of the #define. In this case
- ;; we add cpp-define-intro to get the extra
- ;; indentation of the #define body.
- (c-add-syntax 'cpp-define-intro)))))
- ;; return the syntax
- c-syntactic-context)))
- ;; Indentation calculation.
- (defun c-evaluate-offset (offset langelem symbol)
- ;; offset can be a number, a function, a variable, a list, or one of
- ;; the symbols + or -
- ;;
- ;; This function might do hidden buffer changes.
- (let ((res
- (cond
- ((numberp offset) offset)
- ((vectorp offset) offset)
- ((null offset) nil)
- ((eq offset '+) c-basic-offset)
- ((eq offset '-) (- c-basic-offset))
- ((eq offset '++) (* 2 c-basic-offset))
- ((eq offset '--) (* 2 (- c-basic-offset)))
- ((eq offset '*) (/ c-basic-offset 2))
- ((eq offset '/) (/ (- c-basic-offset) 2))
- ((functionp offset)
- (c-evaluate-offset
- (funcall offset
- (cons (c-langelem-sym langelem)
- (c-langelem-pos langelem)))
- langelem symbol))
- ((listp offset)
- (cond
- ((eq (car offset) 'quote)
- (c-benign-error "The offset %S for %s was mistakenly quoted"
- offset symbol)
- nil)
- ((memq (car offset) '(min max))
- (let (res val (method (car offset)))
- (setq offset (cdr offset))
- (while offset
- (setq val (c-evaluate-offset (car offset) langelem symbol))
- (cond
- ((not val))
- ((not res)
- (setq res val))
- ((integerp val)
- (if (vectorp res)
- (c-benign-error "\
- Error evaluating offset %S for %s: \
- Cannot combine absolute offset %S with relative %S in `%s' method"
- (car offset) symbol res val method)
- (setq res (funcall method res val))))
- (t
- (if (integerp res)
- (c-benign-error "\
- Error evaluating offset %S for %s: \
- Cannot combine relative offset %S with absolute %S in `%s' method"
- (car offset) symbol res val method)
- (setq res (vector (funcall method (aref res 0)
- (aref val 0)))))))
- (setq offset (cdr offset)))
- res))
- ((eq (car offset) 'add)
- (let (res val)
- (setq offset (cdr offset))
- (while offset
- (setq val (c-evaluate-offset (car offset) langelem symbol))
- (cond
- ((not val))
- ((not res)
- (setq res val))
- ((integerp val)
- (if (vectorp res)
- (setq res (vector (+ (aref res 0) val)))
- (setq res (+ res val))))
- (t
- (if (vectorp res)
- (c-benign-error "\
- Error evaluating offset %S for %s: \
- Cannot combine absolute offsets %S and %S in `add' method"
- (car offset) symbol res val)
- (setq res val)))) ; Override.
- (setq offset (cdr offset)))
- res))
- (t
- (let (res)
- (when (eq (car offset) 'first)
- (setq offset (cdr offset)))
- (while (and (not res) offset)
- (setq res (c-evaluate-offset (car offset) langelem symbol)
- offset (cdr offset)))
- res))))
- ((and (symbolp offset) (boundp offset))
- (symbol-value offset))
- (t
- (c-benign-error "Unknown offset format %S for %s" offset symbol)
- nil))))
- (if (or (null res) (integerp res)
- (and (vectorp res) (= (length res) 1) (integerp (aref res 0))))
- res
- (c-benign-error "Error evaluating offset %S for %s: Got invalid value %S"
- offset symbol res)
- nil)))
- (defun c-calc-offset (langelem)
- ;; Get offset from LANGELEM which is a list beginning with the
- ;; syntactic symbol and followed by any analysis data it provides.
- ;; That data may be zero or more elements, but if at least one is
- ;; given then the first is the anchor position (or nil). The symbol
- ;; is matched against `c-offsets-alist' and the offset calculated
- ;; from that is returned.
- ;;
- ;; This function might do hidden buffer changes.
- (let* ((symbol (c-langelem-sym langelem))
- (match (assq symbol c-offsets-alist))
- (offset (cdr-safe match)))
- (if match
- (setq offset (c-evaluate-offset offset langelem symbol))
- (if c-strict-syntax-p
- (c-benign-error "No offset found for syntactic symbol %s" symbol))
- (setq offset 0))
- (if (vectorp offset)
- offset
- (or (and (numberp offset) offset)
- (and (symbolp offset) (symbol-value offset))
- 0))
- ))
- (defun c-get-offset (langelem)
- ;; This is a compatibility wrapper for `c-calc-offset' in case
- ;; someone is calling it directly. It takes an old style syntactic
- ;; element on the form (SYMBOL . ANCHOR-POS) and converts it to the
- ;; new list form.
- ;;
- ;; This function might do hidden buffer changes.
- (if (c-langelem-pos langelem)
- (c-calc-offset (list (c-langelem-sym langelem)
- (c-langelem-pos langelem)))
- (c-calc-offset langelem)))
- (defun c-get-syntactic-indentation (langelems)
- ;; Calculate the syntactic indentation from a syntactic description
- ;; as returned by `c-guess-syntax'.
- ;;
- ;; Note that topmost-intro always has an anchor position at bol, for
- ;; historical reasons. It's often used together with other symbols
- ;; that has more sane positions. Since we always use the first
- ;; found anchor position, we rely on that these other symbols always
- ;; precede topmost-intro in the LANGELEMS list.
- ;;
- ;; This function might do hidden buffer changes.
- (let ((indent 0) anchor)
- (while langelems
- (let* ((c-syntactic-element (car langelems))
- (res (c-calc-offset c-syntactic-element)))
- (if (vectorp res)
- ;; Got an absolute column that overrides any indentation
- ;; we've collected so far, but not the relative
- ;; indentation we might get for the nested structures
- ;; further down the langelems list.
- (setq indent (elt res 0)
- anchor (point-min)) ; A position at column 0.
- ;; Got a relative change of the current calculated
- ;; indentation.
- (setq indent (+ indent res))
- ;; Use the anchor position from the first syntactic
- ;; element with one.
- (unless anchor
- (setq anchor (c-langelem-pos (car langelems)))))
- (setq langelems (cdr langelems))))
- (if anchor
- (+ indent (save-excursion
- (goto-char anchor)
- (current-column)))
- indent)))
- (cc-provide 'cc-engine)
- ;;; cc-engine.el ends here
|