8sa1-gcc/gcc/ada/a-textio.adb
Geert Bosch bcea76b65d 1aexcept.adb, [...]: Merge header, formatting and other trivial changes from ACT.
* 1aexcept.adb, 1aexcept.ads, 1ic.ads, 1ssecsta.adb,
	1ssecsta.ads, 31soccon.ads, 31soliop.ads, 3asoccon.ads,
	3bsoccon.ads, 3gsoccon.ads, 3hsoccon.ads, 3ssoccon.ads,
	3ssoliop.ads, 3wsoccon.ads, 3wsocthi.adb, 3wsocthi.ads,
	3wsoliop.ads, 41intnam.ads, 42intnam.ads, 4aintnam.ads,
	4cintnam.ads, 4dintnam.ads, 4gintnam.ads, 4hexcpol.adb,
	4hintnam.ads, 4lintnam.ads, 4mintnam.ads, 4nintnam.ads,
	4ointnam.ads, 4onumaux.ads, 4pintnam.ads, 4rintnam.ads,
	4sintnam.ads, 4uintnam.ads, 4vcaldel.adb, 4vcalend.adb,
	4vcalend.ads, 4vintnam.ads, 4wcalend.adb, 4wexcpol.adb,
	4wintnam.ads, 4zintnam.ads, 4znumaux.ads, 4zsytaco.adb,
	4zsytaco.ads, 51osinte.adb, 51osinte.ads, 52osinte.adb,
	52osinte.ads, 52system.ads, 53osinte.ads, 54osinte.ads,
	5amastop.adb, 5aosinte.adb, 5aosinte.ads, 5asystem.ads,
	5ataprop.adb, 5atasinf.ads, 5ataspri.ads, 5atpopsp.adb,
	5avxwork.ads, 5bosinte.adb, 5bosinte.ads, 5bsystem.ads,
	5cosinte.ads, 5dosinte.ads, 5esystem.ads, 5etpopse.adb,
	5fintman.adb, 5fosinte.ads, 5fsystem.ads, 5ftaprop.adb,
	5ftasinf.ads, 5ginterr.adb, 5gintman.adb, 5gmastop.adb,
	5gosinte.ads, 5gproinf.adb, 5gproinf.ads, 5gsystem.ads,
	5gtaprop.adb, 5gtasinf.adb, 5gtasinf.ads, 5gtpgetc.adb,
	5hosinte.adb, 5hosinte.ads, 5hparame.ads, 5hsystem.ads,
	5htaprop.adb, 5htaspri.ads, 5htraceb.adb, 5iosinte.adb,
	5iosinte.ads, 5itaprop.adb, 5itaspri.ads, 5ksystem.ads,
	5kvxwork.ads, 5lintman.adb, 5lml-tgt.adb, 5losinte.ads,
	5lsystem.ads, 5mosinte.ads, 5mvxwork.ads, 5ninmaop.adb,
	5nintman.adb, 5nosinte.ads, 5ntaprop.adb, 5ntaspri.ads,
	5ointerr.adb, 5omastop.adb, 5oosinte.adb, 5oosinte.ads,
	5oosprim.adb, 5oparame.adb, 5osystem.ads, 5otaprop.adb,
	5otaspri.ads, 5posinte.ads, 5posprim.adb, 5pvxwork.ads,
	5qosinte.adb, 5qosinte.ads, 5qstache.adb, 5qtaprop.adb,
	5qtaspri.ads, 5rosinte.adb, 5rosinte.ads, 5rparame.adb,
	5sintman.adb, 5sosinte.adb, 5sosinte.ads, 5sparame.adb,
	5ssystem.ads, 5staprop.adb, 5stasinf.adb, 5stasinf.ads,
	5staspri.ads, 5stpopse.adb, 5svxwork.ads, 5tosinte.ads,
	5uintman.adb, 5uosinte.ads, 5vasthan.adb, 5vinmaop.adb,
	5vinterr.adb, 5vintman.adb, 5vintman.ads, 5vmastop.adb,
	5vosinte.adb, 5vosinte.ads, 5vosprim.adb, 5vosprim.ads,
	5vparame.ads, 5vsystem.ads, 5vtaprop.adb, 5vtaspri.ads,
	5vtpopde.adb, 5vtpopde.ads, 5vvaflop.adb, 5wgloloc.adb,
	5wintman.adb, 5wmemory.adb, 5wosinte.ads, 5wosprim.adb,
	5wsystem.ads, 5wtaprop.adb, 5wtaspri.ads, 5ysystem.ads,
	5zinterr.adb, 5zintman.adb, 5zosinte.adb, 5zosinte.ads,
	5zosprim.adb, 5zsystem.ads, 5ztaprop.adb, 6vcpp.adb,
	6vcstrea.adb, 6vinterf.ads, 7sinmaop.adb, 7sintman.adb,
	7sosinte.adb, 7sosprim.adb, 7staprop.adb, 7staspri.ads,
	7stpopsp.adb, 7straceb.adb, 86numaux.adb, 86numaux.ads,
	9drpc.adb, a-astaco.adb, a-astaco.ads, a-caldel.adb,
	a-caldel.ads, a-calend.adb, a-calend.ads, a-chahan.adb,
	a-chahan.ads, a-charac.ads, a-chlat1.ads, a-chlat9.ads,
	a-colien.adb, a-colien.ads, a-colire.adb, a-colire.ads,
	a-comlin.adb, a-comlin.ads, a-cwila1.ads, a-cwila9.ads,
	a-decima.adb, a-decima.ads, a-diocst.adb, a-diocst.ads,
	a-direio.adb, a-direio.ads, a-dynpri.adb, a-dynpri.ads,
	a-einuoc.adb, a-einuoc.ads, a-except.adb, a-except.ads,
	a-excpol.adb, a-exctra.adb, a-exctra.ads, a-filico.adb,
	a-filico.ads, a-finali.adb, a-finali.ads, a-flteio.ads,
	a-fwteio.ads, a-inteio.ads, a-interr.adb, a-interr.ads,
	a-intnam.ads, a-intsig.adb, a-intsig.ads, a-ioexce.ads,
	a-iwteio.ads, a-lfteio.ads, a-lfwtio.ads, a-liteio.ads,
	a-liwtio.ads, a-llftio.ads, a-llfwti.ads, a-llitio.ads,
	a-lliwti.ads, a-ncelfu.ads, a-ngcefu.adb, a-ngcefu.ads,
	a-ngcoty.adb, a-ngcoty.ads, a-ngelfu.adb, a-ngelfu.ads,
	a-nlcefu.ads, a-nlcoty.ads, a-nlelfu.ads, a-nllcef.ads,
	a-nllcty.ads, a-nllefu.ads, a-nscefu.ads, a-nscoty.ads,
	a-nselfu.ads, a-nucoty.ads, a-nudira.adb, a-nudira.ads,
	a-nuelfu.ads, a-nuflra.adb, a-nuflra.ads, a-numaux.ads,
	a-numeri.ads, a-reatim.adb, a-reatim.ads, a-retide.adb,
	a-retide.ads, a-sequio.adb, a-sequio.ads, a-sfteio.ads,
	a-sfwtio.ads, a-siocst.adb, a-siocst.ads, a-siteio.ads,
	a-siwtio.ads, a-ssicst.adb, a-ssicst.ads, a-ssitio.ads,
	a-ssiwti.ads, a-stmaco.ads, a-storio.adb, a-storio.ads,
	a-strbou.adb, a-strbou.ads, a-stream.ads, a-strfix.adb,
	a-strfix.ads, a-string.ads, a-strmap.adb, a-strmap.ads,
	a-strsea.adb, a-strsea.ads, a-strunb.adb, a-strunb.ads,
	a-ststio.adb, a-ststio.ads, a-stunau.adb, a-stunau.ads,
	a-stwibo.adb, a-stwibo.ads, a-stwifi.adb, a-stwifi.ads,
	a-stwima.adb, a-stwima.ads, a-stwise.adb, a-stwise.ads,
	a-stwiun.adb, a-stwiun.ads, a-suteio.adb, a-suteio.ads,
	a-swmwco.ads, a-swuwti.adb, a-swuwti.ads, a-sytaco.adb,
	a-sytaco.ads, a-tags.adb, a-tags.ads, a-tasatt.adb,
	a-tasatt.ads, a-taside.adb, a-taside.ads, a-teioed.adb,
	a-teioed.ads, a-textio.adb, a-textio.ads, a-ticoau.adb,
	a-ticoau.ads, a-ticoio.adb, a-ticoio.ads, a-tideau.adb,
	a-tideau.ads, a-tideio.adb, a-tideio.ads, a-tienau.adb,
	a-tienau.ads, a-tienio.adb, a-tienio.ads, a-tifiio.adb,
	a-tifiio.ads, a-tiflau.adb, a-tiflau.ads, a-tiflio.adb,
	a-tiflio.ads, a-tigeau.adb, a-tigeau.ads, a-tiinau.adb,
	a-tiinau.ads, a-tiinio.adb, a-tiinio.ads, a-timoau.adb,
	a-timoau.ads, a-timoio.adb, a-timoio.ads, a-tiocst.adb,
	a-tiocst.ads, a-titest.adb, a-titest.ads, a-unccon.ads,
	a-uncdea.ads, a-witeio.adb, a-witeio.ads, a-wtcoau.adb,
	a-wtcoau.ads, a-wtcoio.adb, a-wtcoio.ads, a-wtcstr.adb,
	a-wtcstr.ads, a-wtdeau.adb, a-wtdeau.ads, a-wtdeio.adb,
	a-wtdeio.ads, a-wtedit.adb, a-wtedit.ads, a-wtenau.adb,
	a-wtenau.ads, a-wtenio.adb, a-wtenio.ads, a-wtfiio.adb,
	a-wtfiio.ads, a-wtflau.adb, a-wtflau.ads, a-wtflio.adb,
	a-wtflio.ads, a-wtgeau.adb, a-wtgeau.ads, a-wtinau.adb,
	a-wtinau.ads, a-wtinio.adb, a-wtinio.ads, a-wtmoau.adb,
	a-wtmoau.ads, a-wtmoio.adb, a-wtmoio.ads, a-wttest.adb,
	a-wttest.ads, ada-tree.h, ada.ads, ada.h,
	adadecode.c, adadecode.h, ali-util.adb, ali-util.ads,
	ali.adb, ali.ads, alloc.ads, argv.c,
	atree.adb, atree.ads, atree.h, aux-io.c,
	back_end.adb, back_end.ads, bcheck.adb, bcheck.ads,
	binde.adb, binde.ads, binderr.adb, binderr.ads,
	bindgen.adb, bindgen.ads, bindusg.adb, bindusg.ads,
	butil.adb, butil.ads, cal.c, calendar.ads,
	casing.adb, casing.ads, ceinfo.adb, checks.adb,
	checks.ads, cio.c, comperr.adb, comperr.ads,
	config-lang.in, csets.adb, csets.ads, csinfo.adb,
	cstand.adb, cstand.ads, cuintp.c, debug.adb,
	debug.ads, debug_a.adb, debug_a.ads, dec-io.adb,
	dec-io.ads, dec.ads, deftarg.c, directio.ads,
	einfo.adb, einfo.ads, elists.adb, elists.ads,
	elists.h, errno.c, errout.adb, errout.ads,
	eval_fat.adb, eval_fat.ads, exit.c, exp_aggr.adb,
	exp_aggr.ads, exp_attr.adb, exp_attr.ads, exp_ch10.ads,
	exp_ch11.adb, exp_ch11.ads, exp_ch12.adb, exp_ch12.ads,
	exp_ch13.adb, exp_ch13.ads, exp_ch2.adb, exp_ch2.ads,
	exp_ch3.adb, exp_ch3.ads, exp_ch4.adb, exp_ch4.ads,
	exp_ch5.adb, exp_ch5.ads, exp_ch6.adb, exp_ch6.ads,
	exp_ch7.adb, exp_ch7.ads, exp_ch8.adb, exp_ch8.ads,
	exp_ch9.adb, exp_ch9.ads, exp_code.adb, exp_code.ads,
	exp_dbug.adb, exp_dbug.ads, exp_disp.adb, exp_disp.ads,
	exp_dist.adb, exp_dist.ads, exp_fixd.adb, exp_fixd.ads,
	exp_imgv.adb, exp_imgv.ads, exp_intr.adb, exp_intr.ads,
	exp_pakd.adb, exp_pakd.ads, exp_prag.adb, exp_prag.ads,
	exp_smem.adb, exp_smem.ads, exp_strm.adb, exp_strm.ads,
	exp_tss.adb, exp_tss.ads, exp_util.adb, exp_util.ads,
	exp_vfpt.adb, exp_vfpt.ads, expander.adb, expander.ads,
	fmap.adb, fmap.ads, fname-sf.adb, fname-sf.ads,
	fname-uf.adb, fname-uf.ads, fname.adb, fname.ads,
	freeze.adb, freeze.ads, frontend.adb, frontend.ads,
	g-awk.adb, g-awk.ads, g-busora.adb, g-busora.ads,
	g-busorg.adb, g-busorg.ads, g-calend.adb, g-calend.ads,
	g-casuti.adb, g-casuti.ads, g-catiio.adb, g-catiio.ads,
	g-cgi.adb, g-cgi.ads, g-cgicoo.adb, g-cgicoo.ads,
	g-cgideb.adb, g-cgideb.ads, g-comlin.adb, g-comlin.ads,
	g-crc32.adb, g-crc32.ads, g-curexc.ads, g-debpoo.adb,
	g-debpoo.ads, g-debuti.adb, g-debuti.ads, g-diopit.adb,
	g-diopit.ads, g-dirope.adb, g-dirope.ads, g-dyntab.adb,
	g-dyntab.ads, g-enblsp.adb, g-except.ads, g-exctra.adb,
	g-exctra.ads, g-expect.adb, g-expect.ads, g-flocon.ads,
	g-hesora.adb, g-hesora.ads, g-hesorg.adb, g-hesorg.ads,
	g-htable.adb, g-htable.ads, g-io.adb, g-io.ads,
	g-io_aux.adb, g-io_aux.ads, g-locfil.ads, g-md5.adb,
	g-md5.ads, g-moreex.adb, g-moreex.ads, g-os_lib.adb,
	g-os_lib.ads, g-regexp.adb, g-regexp.ads, g-regist.ads,
	g-regpat.adb, g-regpat.ads, g-soccon.ads, g-socket.adb,
	g-socket.ads, g-socthi.adb, g-socthi.ads, g-soliop.ads,
	g-souinf.ads, g-speche.adb, g-speche.ads, g-spipat.adb,
	g-spipat.ads, g-spitbo.adb, g-spitbo.ads, g-sptabo.ads,
	g-sptain.ads, g-sptavs.ads, g-table.adb, g-table.ads,
	g-tasloc.adb, g-tasloc.ads, g-thread.adb, g-thread.ads,
	g-traceb.adb, g-traceb.ads, g-trasym.adb, g-trasym.ads,
	get_targ.adb, get_targ.ads, gnat-style.texi, gnat.ads,
	gnat1drv.adb, gnat1drv.ads, gnatbind.adb, gnatbind.ads,
	gnatbl.c, gnatchop.adb, gnatcmd.adb, gnatcmd.ads,
	gnatdll.adb, gnatfind.adb, gnatkr.adb, gnatkr.ads,
	gnatlbr.adb, gnatlink.adb, gnatlink.ads, gnatls.adb,
	gnatls.ads, gnatmake.adb, gnatmake.ads, gnatmem.adb,
	gnatname.adb, gnatname.ads, gnatprep.adb, gnatprep.ads,
	gnatpsta.adb, gnatvsn.adb, gnatvsn.ads, gnatxref.adb,
	hlo.adb, hlo.ads, hostparm.ads, i-c.adb,
	i-c.ads, i-cexten.ads, i-cobol.adb, i-cobol.ads,
	i-cpoint.adb, i-cpoint.ads, i-cpp.adb, i-cpp.ads,
	i-cstrea.adb, i-cstrea.ads, i-cstrin.adb, i-cstrin.ads,
	i-fortra.adb, i-fortra.ads, i-os2err.ads, i-os2lib.adb,
	i-os2lib.ads, i-os2syn.ads, i-os2thr.ads, i-pacdec.adb,
	i-pacdec.ads, i-vxwork.ads, impunit.adb, impunit.ads,
	inline.adb, inline.ads, interfac.ads, ioexcept.ads,
	itypes.adb, itypes.ads, krunch.adb, krunch.ads,
	layout.adb, layout.ads, lib-list.adb, lib-load.adb,
	lib-load.ads, lib-sort.adb, lib-util.adb, lib-util.ads,
	lib-writ.adb, lib-writ.ads, lib-xref.adb, lib-xref.ads,
	lib.adb, lib.ads, live.adb, live.ads,
	machcode.ads, make.adb, make.ads, makeusg.adb,
	makeusg.ads, math_lib.adb, mdll-fil.adb, mdll-fil.ads,
	mdll-utl.adb, mdll-utl.ads, mdll.adb, mdll.ads,
	memroot.adb, memroot.ads, memtrack.adb, mlib-fil.adb,
	mlib-fil.ads, mlib-prj.adb, mlib-prj.ads, mlib-tgt.adb,
	mlib-tgt.ads, mlib-utl.adb, mlib-utl.ads, mlib.adb,
	mlib.ads, namet.adb, namet.ads, nlists.adb,
	nlists.ads, opt.adb, opt.ads, osint-b.adb,
	osint-b.ads, osint-c.adb, osint-c.ads, osint-l.adb,
	osint-l.ads, osint-m.adb, osint-m.ads, osint.adb,
	osint.ads, output.adb, output.ads, par-ch10.adb,
	par-ch11.adb, par-ch12.adb, par-ch13.adb, par-ch2.adb,
	par-ch3.adb, par-ch4.adb, par-ch5.adb, par-ch6.adb,
	par-ch7.adb, par-ch8.adb, par-ch9.adb, par-endh.adb,
	par-labl.adb, par-load.adb, par-prag.adb, par-sync.adb,
	par-tchk.adb, par-util.adb, par.adb, par.ads,
	prj-attr.adb, prj-attr.ads, prj-com.adb, prj-com.ads,
	prj-dect.adb, prj-dect.ads, prj-env.adb, prj-env.ads,
	prj-ext.adb, prj-ext.ads, prj-makr.adb, prj-makr.ads,
	prj-nmsc.adb, prj-nmsc.ads, prj-pars.adb, prj-pars.ads,
	prj-part.adb, prj-part.ads, prj-pp.adb, prj-pp.ads,
	prj-proc.adb, prj-proc.ads, prj-strt.adb, prj-strt.ads,
	prj-tree.adb, prj-tree.ads, prj-util.adb, prj-util.ads,
	prj.adb, prj.ads, repinfo.adb, repinfo.ads,
	restrict.adb, restrict.ads, rident.ads, rtsfind.adb,
	rtsfind.ads, s-addima.adb, s-addima.ads, s-arit64.adb,
	s-arit64.ads, s-assert.adb, s-assert.ads, s-asthan.adb,
	s-asthan.ads, s-atacco.adb, s-atacco.ads, s-auxdec.adb,
	s-auxdec.ads, s-bitops.adb, s-bitops.ads, s-chepoo.ads,
	s-crc32.adb, s-crc32.ads, s-direio.adb, s-direio.ads,
	s-errrep.adb, s-errrep.ads, s-except.ads, s-exctab.adb,
	s-exctab.ads, s-exnflt.ads, s-exngen.adb, s-exngen.ads,
	s-exnint.ads, s-exnlfl.ads, s-exnlin.ads, s-exnllf.ads,
	s-exnlli.ads, s-exnsfl.ads, s-exnsin.ads, s-exnssi.ads,
	s-expflt.ads, s-expgen.adb, s-expgen.ads, s-expint.ads,
	s-explfl.ads, s-explin.ads, s-expllf.ads, s-explli.ads,
	s-expllu.adb, s-expllu.ads, s-expmod.adb, s-expmod.ads,
	s-expsfl.ads, s-expsin.ads, s-expssi.ads, s-expuns.adb,
	s-expuns.ads, s-fatflt.ads, s-fatgen.adb, s-fatgen.ads,
	s-fatlfl.ads, s-fatllf.ads, s-fatsfl.ads, s-ficobl.ads,
	s-fileio.adb, s-fileio.ads, s-finimp.adb, s-finimp.ads,
	s-finroo.adb, s-finroo.ads, s-fore.adb, s-fore.ads,
	s-gloloc.adb, s-gloloc.ads, s-imgbiu.adb, s-imgbiu.ads,
	s-imgboo.adb, s-imgboo.ads, s-imgcha.adb, s-imgcha.ads,
	s-imgdec.adb, s-imgdec.ads, s-imgenu.adb, s-imgenu.ads,
	s-imgint.adb, s-imgint.ads, s-imgllb.adb, s-imgllb.ads,
	s-imglld.adb, s-imglld.ads, s-imglli.adb, s-imglli.ads,
	s-imgllu.adb, s-imgllu.ads, s-imgllw.adb, s-imgllw.ads,
	s-imgrea.adb, s-imgrea.ads, s-imguns.adb, s-imguns.ads,
	s-imgwch.adb, s-imgwch.ads, s-imgwiu.adb, s-imgwiu.ads,
	s-inmaop.ads, s-interr.adb, s-interr.ads, s-intman.ads,
	s-io.adb, s-io.ads, s-maccod.ads, s-mantis.adb,
	s-mantis.ads, s-mastop.adb, s-mastop.ads, s-memory.adb,
	s-memory.ads, s-osprim.ads, s-pack03.adb, s-pack03.ads,
	s-pack05.adb, s-pack05.ads, s-pack06.adb, s-pack06.ads,
	s-pack07.adb, s-pack07.ads, s-pack09.adb, s-pack09.ads,
	s-pack10.adb, s-pack10.ads, s-pack11.adb, s-pack11.ads,
	s-pack12.adb, s-pack12.ads, s-pack13.adb, s-pack13.ads,
	s-pack14.adb, s-pack14.ads, s-pack15.adb, s-pack15.ads,
	s-pack17.adb, s-pack17.ads, s-pack18.adb, s-pack18.ads,
	s-pack19.adb, s-pack19.ads, s-pack20.adb, s-pack20.ads,
	s-pack21.adb, s-pack21.ads, s-pack22.adb, s-pack22.ads,
	s-pack23.adb, s-pack23.ads, s-pack24.adb, s-pack24.ads,
	s-pack25.adb, s-pack25.ads, s-pack26.adb, s-pack26.ads,
	s-pack27.adb, s-pack27.ads, s-pack28.adb, s-pack28.ads,
	s-pack29.adb, s-pack29.ads, s-pack30.adb, s-pack30.ads,
	s-pack31.adb, s-pack31.ads, s-pack33.adb, s-pack33.ads,
	s-pack34.adb, s-pack34.ads, s-pack35.adb, s-pack35.ads,
	s-pack36.adb, s-pack36.ads, s-pack37.adb, s-pack37.ads,
	s-pack38.adb, s-pack38.ads, s-pack39.adb, s-pack39.ads,
	s-pack40.adb, s-pack40.ads, s-pack41.adb, s-pack41.ads,
	s-pack42.adb, s-pack42.ads, s-pack43.adb, s-pack43.ads,
	s-pack44.adb, s-pack44.ads, s-pack45.adb, s-pack45.ads,
	s-pack46.adb, s-pack46.ads, s-pack47.adb, s-pack47.ads,
	s-pack48.adb, s-pack48.ads, s-pack49.adb, s-pack49.ads,
	s-pack50.adb, s-pack50.ads, s-pack51.adb, s-pack51.ads,
	s-pack52.adb, s-pack52.ads, s-pack53.adb, s-pack53.ads,
	s-pack54.adb, s-pack54.ads, s-pack55.adb, s-pack55.ads,
	s-pack56.adb, s-pack56.ads, s-pack57.adb, s-pack57.ads,
	s-pack58.adb, s-pack58.ads, s-pack59.adb, s-pack59.ads,
	s-pack60.adb, s-pack60.ads, s-pack61.adb, s-pack61.ads,
	s-pack62.adb, s-pack62.ads, s-pack63.adb, s-pack63.ads,
	s-parame.adb, s-parame.ads, s-parint.adb, s-parint.ads,
	s-pooglo.adb, s-pooglo.ads, s-pooloc.adb, s-pooloc.ads,
	s-poosiz.adb, s-poosiz.ads, s-powtab.ads, s-proinf.adb,
	s-proinf.ads, s-rpc.adb, s-rpc.ads, s-scaval.ads,
	s-secsta.adb, s-secsta.ads, s-sequio.adb, s-sequio.ads,
	s-shasto.adb, s-shasto.ads, s-soflin.adb, s-soflin.ads,
	s-sopco3.adb, s-sopco3.ads, s-sopco4.adb, s-sopco4.ads,
	s-sopco5.adb, s-sopco5.ads, s-stache.adb, s-stache.ads,
	s-stalib.adb, s-stalib.ads, s-stoele.adb, s-stoele.ads,
	s-stopoo.ads, s-stratt.adb, s-stratt.ads, s-strops.adb,
	s-strops.ads, s-taasde.adb, s-taasde.ads, s-tadeca.adb,
	s-tadeca.ads, s-tadert.adb, s-tadert.ads, s-taenca.adb,
	s-taenca.ads, s-taprob.adb, s-taprob.ads, s-taprop.ads,
	s-tarest.adb, s-tarest.ads, s-tasdeb.adb, s-tasdeb.ads,
	s-tasinf.adb, s-tasinf.ads, s-tasini.adb, s-tasini.ads,
	s-taskin.adb, s-taskin.ads, s-tasque.adb, s-tasque.ads,
	s-tasren.adb, s-tasren.ads, s-tasres.ads, s-tassta.adb,
	s-tassta.ads, s-tasuti.adb, s-tasuti.ads, s-tataat.adb,
	s-tataat.ads, s-tpinop.adb, s-tpinop.ads, s-tpoben.adb,
	s-tpoben.ads, s-tpobop.adb, s-tpobop.ads, s-tposen.adb,
	s-tposen.ads, s-traceb.adb, s-traceb.ads, s-traces.adb,
	s-traces.ads, s-tratas.adb, s-tratas.ads, s-unstyp.ads,
	s-vaflop.adb, s-vaflop.ads, s-valboo.adb, s-valboo.ads,
	s-valcha.adb, s-valcha.ads, s-valdec.adb, s-valdec.ads,
	s-valenu.adb, s-valenu.ads, s-valint.adb, s-valint.ads,
	s-vallld.adb, s-vallld.ads, s-vallli.adb, s-vallli.ads,
	s-valllu.adb, s-valllu.ads, s-valrea.adb, s-valrea.ads,
	s-valuns.adb, s-valuns.ads, s-valuti.adb, s-valuti.ads,
	s-valwch.adb, s-valwch.ads, s-vercon.adb, s-vercon.ads,
	s-vmexta.adb, s-vmexta.ads, s-wchcnv.adb, s-wchcnv.ads,
	s-wchcon.ads, s-wchjis.adb, s-wchjis.ads, s-wchstw.adb,
	s-wchstw.ads, s-wchwts.adb, s-wchwts.ads, s-widboo.adb,
	s-widboo.ads, s-widcha.adb, s-widcha.ads, s-widenu.adb,
	s-widenu.ads, s-widlli.adb, s-widlli.ads, s-widllu.adb,
	s-widllu.ads, s-widwch.adb, s-widwch.ads, s-wwdcha.adb,
	s-wwdcha.ads, s-wwdenu.adb, s-wwdenu.ads, s-wwdwch.adb,
	s-wwdwch.ads, scans.adb, scans.ads, scn-nlit.adb,
	scn-slit.adb, scn.adb, scn.ads, sdefault.ads,
	sem.adb, sem.ads, sem_aggr.adb, sem_aggr.ads,
	sem_attr.adb, sem_attr.ads, sem_case.adb, sem_case.ads,
	sem_cat.adb, sem_cat.ads, sem_ch10.adb, sem_ch10.ads,
	sem_ch11.adb, sem_ch11.ads, sem_ch12.adb, sem_ch12.ads,
	sem_ch13.adb, sem_ch13.ads, sem_ch2.adb, sem_ch2.ads,
	sem_ch3.adb, sem_ch3.ads, sem_ch4.adb, sem_ch4.ads,
	sem_ch5.adb, sem_ch5.ads, sem_ch6.adb, sem_ch6.ads,
	sem_ch7.adb, sem_ch7.ads, sem_ch8.adb, sem_ch8.ads,
	sem_ch9.adb, sem_ch9.ads, sem_disp.adb, sem_disp.ads,
	sem_dist.adb, sem_dist.ads, sem_elab.adb, sem_elab.ads,
	sem_elim.adb, sem_elim.ads, sem_eval.adb, sem_eval.ads,
	sem_intr.adb, sem_intr.ads, sem_maps.adb, sem_maps.ads,
	sem_mech.adb, sem_mech.ads, sem_prag.adb, sem_prag.ads,
	sem_res.adb, sem_res.ads, sem_smem.adb, sem_smem.ads,
	sem_type.adb, sem_type.ads, sem_util.adb, sem_util.ads,
	sem_vfpt.adb, sem_vfpt.ads, sem_warn.adb, sem_warn.ads,
	sequenio.ads, sfn_scan.adb, sfn_scan.ads, sinfo-cn.adb,
	sinfo-cn.ads, sinfo.adb, sinfo.ads, sinput-d.adb,
	sinput-d.ads, sinput-l.adb, sinput-l.ads, sinput-p.adb,
	sinput-p.ads, sinput.adb, sinput.ads, snames.adb,
	snames.ads, sprint.adb, sprint.ads, stand.adb,
	stand.ads, stringt.adb, stringt.ads, style.adb,
	style.ads, stylesw.adb, stylesw.ads, switch-b.adb,
	switch-b.ads, switch-c.adb, switch-c.ads, switch-m.adb,
	switch-m.ads, switch.adb, switch.ads, system.ads,
	table.adb, table.ads, targparm.adb, targparm.ads,
	tbuild.adb, tbuild.ads, text_io.ads, trans.c,
	tree_gen.adb, tree_gen.ads, tree_in.adb, tree_in.ads,
	tree_io.adb, tree_io.ads, treepr.adb, treepr.ads,
	ttypef.ads, ttypes.ads, types.adb, types.ads,
	uintp.adb, uintp.ads, uname.adb, uname.ads,
	unchconv.ads, unchdeal.ads, urealp.adb, urealp.ads,
	usage.adb, usage.ads, validsw.adb, validsw.ads,
	widechar.adb, widechar.ads, xeinfo.adb, xnmake.adb,
	xr_tabls.adb, xr_tabls.ads, xref_lib.adb, xref_lib.ads,
	xsinfo.adb, xsnames.adb, xtreeprs.adb : Merge header,
	formatting and other trivial changes from ACT.

From-SVN: r66044
2003-04-24 19:54:20 +02:00

1805 lines
47 KiB
Ada

------------------------------------------------------------------------------
-- --
-- GNAT RUNTIME COMPONENTS --
-- --
-- A D A . T E X T _ I O --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Streams; use Ada.Streams;
with Interfaces.C_Streams; use Interfaces.C_Streams;
with System;
with System.File_IO;
with Unchecked_Conversion;
with Unchecked_Deallocation;
pragma Elaborate_All (System.File_IO);
-- Needed because of calls to Chain_File in package body elaboration
package body Ada.Text_IO is
package FIO renames System.File_IO;
subtype AP is FCB.AFCB_Ptr;
function To_FCB is new Unchecked_Conversion (File_Mode, FCB.File_Mode);
function To_TIO is new Unchecked_Conversion (FCB.File_Mode, File_Mode);
use type FCB.File_Mode;
-------------------
-- AFCB_Allocate --
-------------------
function AFCB_Allocate (Control_Block : Text_AFCB) return FCB.AFCB_Ptr is
pragma Warnings (Off, Control_Block);
begin
return new Text_AFCB;
end AFCB_Allocate;
----------------
-- AFCB_Close --
----------------
procedure AFCB_Close (File : access Text_AFCB) is
begin
-- If the file being closed is one of the current files, then close
-- the corresponding current file. It is not clear that this action
-- is required (RM A.10.3(23)) but it seems reasonable, and besides
-- ACVC test CE3208A expects this behavior.
if File_Type (File) = Current_In then
Current_In := null;
elsif File_Type (File) = Current_Out then
Current_Out := null;
elsif File_Type (File) = Current_Err then
Current_Err := null;
end if;
Terminate_Line (File_Type (File));
end AFCB_Close;
---------------
-- AFCB_Free --
---------------
procedure AFCB_Free (File : access Text_AFCB) is
type FCB_Ptr is access all Text_AFCB;
FT : FCB_Ptr := FCB_Ptr (File);
procedure Free is new Unchecked_Deallocation (Text_AFCB, FCB_Ptr);
begin
Free (FT);
end AFCB_Free;
-----------
-- Close --
-----------
procedure Close (File : in out File_Type) is
begin
FIO.Close (AP (File));
end Close;
---------
-- Col --
---------
-- Note: we assume that it is impossible in practice for the column
-- to exceed the value of Count'Last, i.e. no check is required for
-- overflow raising layout error.
function Col (File : in File_Type) return Positive_Count is
begin
FIO.Check_File_Open (AP (File));
return File.Col;
end Col;
function Col return Positive_Count is
begin
return Col (Current_Out);
end Col;
------------
-- Create --
------------
procedure Create
(File : in out File_Type;
Mode : in File_Mode := Out_File;
Name : in String := "";
Form : in String := "")
is
File_Control_Block : Text_AFCB;
begin
FIO.Open (File_Ptr => AP (File),
Dummy_FCB => File_Control_Block,
Mode => To_FCB (Mode),
Name => Name,
Form => Form,
Amethod => 'T',
Creat => True,
Text => True);
File.Self := File;
end Create;
-------------------
-- Current_Error --
-------------------
function Current_Error return File_Type is
begin
return Current_Err;
end Current_Error;
function Current_Error return File_Access is
begin
return Current_Err.Self'Access;
end Current_Error;
-------------------
-- Current_Input --
-------------------
function Current_Input return File_Type is
begin
return Current_In;
end Current_Input;
function Current_Input return File_Access is
begin
return Current_In.Self'Access;
end Current_Input;
--------------------
-- Current_Output --
--------------------
function Current_Output return File_Type is
begin
return Current_Out;
end Current_Output;
function Current_Output return File_Access is
begin
return Current_Out.Self'Access;
end Current_Output;
------------
-- Delete --
------------
procedure Delete (File : in out File_Type) is
begin
FIO.Delete (AP (File));
end Delete;
-----------------
-- End_Of_File --
-----------------
function End_Of_File (File : in File_Type) return Boolean is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
if File.Before_LM then
if File.Before_LM_PM then
return Nextc (File) = EOF;
end if;
else
ch := Getc (File);
if ch = EOF then
return True;
elsif ch /= LM then
Ungetc (ch, File);
return False;
else -- ch = LM
File.Before_LM := True;
end if;
end if;
-- Here we are just past the line mark with Before_LM set so that we
-- do not have to try to back up past the LM, thus avoiding the need
-- to back up more than one character.
ch := Getc (File);
if ch = EOF then
return True;
elsif ch = PM and then File.Is_Regular_File then
File.Before_LM_PM := True;
return Nextc (File) = EOF;
-- Here if neither EOF nor PM followed end of line
else
Ungetc (ch, File);
return False;
end if;
end End_Of_File;
function End_Of_File return Boolean is
begin
return End_Of_File (Current_In);
end End_Of_File;
-----------------
-- End_Of_Line --
-----------------
function End_Of_Line (File : in File_Type) return Boolean is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
if File.Before_LM then
return True;
else
ch := Getc (File);
if ch = EOF then
return True;
else
Ungetc (ch, File);
return (ch = LM);
end if;
end if;
end End_Of_Line;
function End_Of_Line return Boolean is
begin
return End_Of_Line (Current_In);
end End_Of_Line;
-----------------
-- End_Of_Page --
-----------------
function End_Of_Page (File : in File_Type) return Boolean is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
if not File.Is_Regular_File then
return False;
elsif File.Before_LM then
if File.Before_LM_PM then
return True;
end if;
else
ch := Getc (File);
if ch = EOF then
return True;
elsif ch /= LM then
Ungetc (ch, File);
return False;
else -- ch = LM
File.Before_LM := True;
end if;
end if;
-- Here we are just past the line mark with Before_LM set so that we
-- do not have to try to back up past the LM, thus avoiding the need
-- to back up more than one character.
ch := Nextc (File);
return ch = PM or else ch = EOF;
end End_Of_Page;
function End_Of_Page return Boolean is
begin
return End_Of_Page (Current_In);
end End_Of_Page;
-----------
-- Flush --
-----------
procedure Flush (File : in File_Type) is
begin
FIO.Flush (AP (File));
end Flush;
procedure Flush is
begin
Flush (Current_Out);
end Flush;
----------
-- Form --
----------
function Form (File : in File_Type) return String is
begin
return FIO.Form (AP (File));
end Form;
---------
-- Get --
---------
procedure Get
(File : in File_Type;
Item : out Character)
is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
if File.Before_LM then
File.Before_LM := False;
File.Col := 1;
if File.Before_LM_PM then
File.Line := 1;
File.Page := File.Page + 1;
File.Before_LM_PM := False;
else
File.Line := File.Line + 1;
end if;
end if;
loop
ch := Getc (File);
if ch = EOF then
raise End_Error;
elsif ch = LM then
File.Line := File.Line + 1;
File.Col := 1;
elsif ch = PM and then File.Is_Regular_File then
File.Page := File.Page + 1;
File.Line := 1;
else
Item := Character'Val (ch);
File.Col := File.Col + 1;
return;
end if;
end loop;
end Get;
procedure Get (Item : out Character) is
begin
Get (Current_In, Item);
end Get;
procedure Get
(File : in File_Type;
Item : out String)
is
ch : int;
J : Natural;
begin
FIO.Check_Read_Status (AP (File));
if File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
File.Col := 1;
if File.Before_LM_PM then
File.Line := 1;
File.Page := File.Page + 1;
File.Before_LM_PM := False;
else
File.Line := File.Line + 1;
end if;
end if;
J := Item'First;
while J <= Item'Last loop
ch := Getc (File);
if ch = EOF then
raise End_Error;
elsif ch = LM then
File.Line := File.Line + 1;
File.Col := 1;
elsif ch = PM and then File.Is_Regular_File then
File.Page := File.Page + 1;
File.Line := 1;
else
Item (J) := Character'Val (ch);
J := J + 1;
File.Col := File.Col + 1;
end if;
end loop;
end Get;
procedure Get (Item : out String) is
begin
Get (Current_In, Item);
end Get;
-------------------
-- Get_Immediate --
-------------------
-- More work required here ???
procedure Get_Immediate
(File : in File_Type;
Item : out Character)
is
ch : int;
end_of_file : int;
procedure getc_immediate
(stream : FILEs; ch : out int; end_of_file : out int);
pragma Import (C, getc_immediate, "getc_immediate");
begin
FIO.Check_Read_Status (AP (File));
if File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
ch := LM;
else
getc_immediate (File.Stream, ch, end_of_file);
if ferror (File.Stream) /= 0 then
raise Device_Error;
elsif end_of_file /= 0 then
raise End_Error;
end if;
end if;
Item := Character'Val (ch);
end Get_Immediate;
procedure Get_Immediate
(Item : out Character)
is
begin
Get_Immediate (Current_In, Item);
end Get_Immediate;
procedure Get_Immediate
(File : in File_Type;
Item : out Character;
Available : out Boolean)
is
ch : int;
end_of_file : int;
avail : int;
procedure getc_immediate_nowait
(stream : FILEs;
ch : out int;
end_of_file : out int;
avail : out int);
pragma Import (C, getc_immediate_nowait, "getc_immediate_nowait");
begin
FIO.Check_Read_Status (AP (File));
-- If we are logically before an end of line, but physically after it,
-- then we just return the end of line character, no I/O is necessary.
if File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
Available := True;
Item := Character'Val (LM);
-- Normal case where a read operation is required
else
getc_immediate_nowait (File.Stream, ch, end_of_file, avail);
if ferror (File.Stream) /= 0 then
raise Device_Error;
elsif end_of_file /= 0 then
raise End_Error;
elsif avail = 0 then
Available := False;
Item := ASCII.NUL;
else
Available := True;
Item := Character'Val (ch);
end if;
end if;
end Get_Immediate;
procedure Get_Immediate
(Item : out Character;
Available : out Boolean)
is
begin
Get_Immediate (Current_In, Item, Available);
end Get_Immediate;
--------------
-- Get_Line --
--------------
procedure Get_Line
(File : in File_Type;
Item : out String;
Last : out Natural)
is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
Last := Item'First - 1;
-- Immediate exit for null string, this is a case in which we do not
-- need to test for end of file and we do not skip a line mark under
-- any circumstances.
if Last >= Item'Last then
return;
end if;
-- Here we have at least one character, if we are immediately before
-- a line mark, then we will just skip past it storing no characters.
if File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
-- Otherwise we need to read some characters
else
ch := Getc (File);
-- If we are at the end of file now, it means we are trying to
-- skip a file terminator and we raise End_Error (RM A.10.7(20))
if ch = EOF then
raise End_Error;
end if;
-- Loop through characters. Don't bother if we hit a page mark,
-- since in normal files, page marks can only follow line marks
-- in any case and we only promise to treat the page nonsense
-- correctly in the absense of such rogue page marks.
loop
-- Exit the loop if read is terminated by encountering line mark
exit when ch = LM;
-- Otherwise store the character, note that we know that ch is
-- something other than LM or EOF. It could possibly be a page
-- mark if there is a stray page mark in the middle of a line,
-- but this is not an official page mark in any case, since
-- official page marks can only follow a line mark. The whole
-- page business is pretty much nonsense anyway, so we do not
-- want to waste time trying to make sense out of non-standard
-- page marks in the file! This means that the behavior of
-- Get_Line is different from repeated Get of a character, but
-- that's too bad. We only promise that page numbers etc make
-- sense if the file is formatted in a standard manner.
-- Note: we do not adjust the column number because it is quicker
-- to adjust it once at the end of the operation than incrementing
-- it each time around the loop.
Last := Last + 1;
Item (Last) := Character'Val (ch);
-- All done if the string is full, this is the case in which
-- we do not skip the following line mark. We need to adjust
-- the column number in this case.
if Last = Item'Last then
File.Col := File.Col + Count (Item'Length);
return;
end if;
-- Otherwise read next character. We also exit from the loop if
-- we read an end of file. This is the case where the last line
-- is not terminated with a line mark, and we consider that there
-- is an implied line mark in this case (this is a non-standard
-- file, but it is nice to treat it reasonably).
ch := Getc (File);
exit when ch = EOF;
end loop;
end if;
-- We have skipped past, but not stored, a line mark. Skip following
-- page mark if one follows, but do not do this for a non-regular
-- file (since otherwise we get annoying wait for an extra character)
File.Line := File.Line + 1;
File.Col := 1;
if File.Before_LM_PM then
File.Line := 1;
File.Before_LM_PM := False;
File.Page := File.Page + 1;
elsif File.Is_Regular_File then
ch := Getc (File);
if ch = PM and then File.Is_Regular_File then
File.Line := 1;
File.Page := File.Page + 1;
else
Ungetc (ch, File);
end if;
end if;
end Get_Line;
procedure Get_Line
(Item : out String;
Last : out Natural)
is
begin
Get_Line (Current_In, Item, Last);
end Get_Line;
----------
-- Getc --
----------
function Getc (File : File_Type) return int is
ch : int;
begin
ch := fgetc (File.Stream);
if ch = EOF and then ferror (File.Stream) /= 0 then
raise Device_Error;
else
return ch;
end if;
end Getc;
-------------
-- Is_Open --
-------------
function Is_Open (File : in File_Type) return Boolean is
begin
return FIO.Is_Open (AP (File));
end Is_Open;
----------
-- Line --
----------
-- Note: we assume that it is impossible in practice for the line
-- to exceed the value of Count'Last, i.e. no check is required for
-- overflow raising layout error.
function Line (File : in File_Type) return Positive_Count is
begin
FIO.Check_File_Open (AP (File));
return File.Line;
end Line;
function Line return Positive_Count is
begin
return Line (Current_Out);
end Line;
-----------------
-- Line_Length --
-----------------
function Line_Length (File : in File_Type) return Count is
begin
FIO.Check_Write_Status (AP (File));
return File.Line_Length;
end Line_Length;
function Line_Length return Count is
begin
return Line_Length (Current_Out);
end Line_Length;
----------------
-- Look_Ahead --
----------------
procedure Look_Ahead
(File : in File_Type;
Item : out Character;
End_Of_Line : out Boolean)
is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
if File.Before_LM then
End_Of_Line := True;
Item := ASCII.NUL;
else
ch := Nextc (File);
if ch = LM
or else ch = EOF
or else (ch = PM and then File.Is_Regular_File)
then
End_Of_Line := True;
Item := ASCII.NUL;
else
End_Of_Line := False;
Item := Character'Val (ch);
end if;
end if;
end Look_Ahead;
procedure Look_Ahead
(Item : out Character;
End_Of_Line : out Boolean)
is
begin
Look_Ahead (Current_In, Item, End_Of_Line);
end Look_Ahead;
----------
-- Mode --
----------
function Mode (File : in File_Type) return File_Mode is
begin
return To_TIO (FIO.Mode (AP (File)));
end Mode;
----------
-- Name --
----------
function Name (File : in File_Type) return String is
begin
return FIO.Name (AP (File));
end Name;
--------------
-- New_Line --
--------------
procedure New_Line
(File : in File_Type;
Spacing : in Positive_Count := 1)
is
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if Spacing not in Positive_Count then
raise Constraint_Error;
end if;
FIO.Check_Write_Status (AP (File));
for K in 1 .. Spacing loop
Putc (LM, File);
File.Line := File.Line + 1;
if File.Page_Length /= 0
and then File.Line > File.Page_Length
then
Putc (PM, File);
File.Line := 1;
File.Page := File.Page + 1;
end if;
end loop;
File.Col := 1;
end New_Line;
procedure New_Line (Spacing : in Positive_Count := 1) is
begin
New_Line (Current_Out, Spacing);
end New_Line;
--------------
-- New_Page --
--------------
procedure New_Page (File : in File_Type) is
begin
FIO.Check_Write_Status (AP (File));
if File.Col /= 1 or else File.Line = 1 then
Putc (LM, File);
end if;
Putc (PM, File);
File.Page := File.Page + 1;
File.Line := 1;
File.Col := 1;
end New_Page;
procedure New_Page is
begin
New_Page (Current_Out);
end New_Page;
-----------
-- Nextc --
-----------
function Nextc (File : File_Type) return int is
ch : int;
begin
ch := fgetc (File.Stream);
if ch = EOF then
if ferror (File.Stream) /= 0 then
raise Device_Error;
end if;
else
if ungetc (ch, File.Stream) = EOF then
raise Device_Error;
end if;
end if;
return ch;
end Nextc;
----------
-- Open --
----------
procedure Open
(File : in out File_Type;
Mode : in File_Mode;
Name : in String;
Form : in String := "")
is
File_Control_Block : Text_AFCB;
begin
FIO.Open (File_Ptr => AP (File),
Dummy_FCB => File_Control_Block,
Mode => To_FCB (Mode),
Name => Name,
Form => Form,
Amethod => 'T',
Creat => False,
Text => True);
File.Self := File;
end Open;
----------
-- Page --
----------
-- Note: we assume that it is impossible in practice for the page
-- to exceed the value of Count'Last, i.e. no check is required for
-- overflow raising layout error.
function Page (File : in File_Type) return Positive_Count is
begin
FIO.Check_File_Open (AP (File));
return File.Page;
end Page;
function Page return Positive_Count is
begin
return Page (Current_Out);
end Page;
-----------------
-- Page_Length --
-----------------
function Page_Length (File : in File_Type) return Count is
begin
FIO.Check_Write_Status (AP (File));
return File.Page_Length;
end Page_Length;
function Page_Length return Count is
begin
return Page_Length (Current_Out);
end Page_Length;
---------
-- Put --
---------
procedure Put
(File : in File_Type;
Item : in Character)
is
begin
FIO.Check_Write_Status (AP (File));
if File.Line_Length /= 0 and then File.Col > File.Line_Length then
New_Line (File);
end if;
if fputc (Character'Pos (Item), File.Stream) = EOF then
raise Device_Error;
end if;
File.Col := File.Col + 1;
end Put;
procedure Put (Item : in Character) is
begin
FIO.Check_Write_Status (AP (Current_Out));
if Current_Out.Line_Length /= 0
and then Current_Out.Col > Current_Out.Line_Length
then
New_Line (Current_Out);
end if;
if fputc (Character'Pos (Item), Current_Out.Stream) = EOF then
raise Device_Error;
end if;
Current_Out.Col := Current_Out.Col + 1;
end Put;
---------
-- Put --
---------
procedure Put
(File : in File_Type;
Item : in String)
is
begin
FIO.Check_Write_Status (AP (File));
if Item'Length > 0 then
-- If we have bounded lines, then do things character by
-- character (this seems a rare case anyway!)
if File.Line_Length /= 0 then
for J in Item'Range loop
Put (File, Item (J));
end loop;
-- Otherwise we can output the entire string at once. Note that if
-- there are LF or FF characters in the string, we do not bother to
-- count them as line or page terminators.
else
FIO.Write_Buf (AP (File), Item'Address, Item'Length);
File.Col := File.Col + Item'Length;
end if;
end if;
end Put;
procedure Put (Item : in String) is
begin
Put (Current_Out, Item);
end Put;
--------------
-- Put_Line --
--------------
procedure Put_Line
(File : in File_Type;
Item : in String)
is
begin
FIO.Check_Write_Status (AP (File));
-- If we have bounded lines, then just do a put and a new line. In
-- this case we will end up doing things character by character in
-- any case, and it is a rare situation.
if File.Line_Length /= 0 then
Put (File, Item);
New_Line (File);
return;
end if;
-- We setup a single string that has the necessary terminators and
-- then write it with a single call. The reason for doing this is
-- that it gives better behavior for the use of Put_Line in multi-
-- tasking programs, since often the OS will treat the entire put
-- operation as an atomic operation.
declare
Ilen : constant Natural := Item'Length;
Buffer : String (1 .. Ilen + 2);
Plen : size_t;
begin
Buffer (1 .. Ilen) := Item;
Buffer (Ilen + 1) := Character'Val (LM);
if File.Page_Length /= 0
and then File.Line > File.Page_Length
then
Buffer (Ilen + 2) := Character'Val (PM);
Plen := size_t (Ilen) + 2;
File.Line := 1;
File.Page := File.Page + 1;
else
Plen := size_t (Ilen) + 1;
File.Line := File.Line + 1;
end if;
FIO.Write_Buf (AP (File), Buffer'Address, Plen);
File.Col := 1;
end;
end Put_Line;
procedure Put_Line (Item : in String) is
begin
Put_Line (Current_Out, Item);
end Put_Line;
----------
-- Putc --
----------
procedure Putc (ch : int; File : File_Type) is
begin
if fputc (ch, File.Stream) = EOF then
raise Device_Error;
end if;
end Putc;
----------
-- Read --
----------
-- This is the primitive Stream Read routine, used when a Text_IO file
-- is treated directly as a stream using Text_IO.Streams.Stream.
procedure Read
(File : in out Text_AFCB;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
ch : int;
begin
if File.Mode /= FCB.In_File then
raise Mode_Error;
end if;
-- Deal with case where our logical and physical position do not match
-- because of being after an LM or LM-PM sequence when in fact we are
-- logically positioned before it.
if File.Before_LM then
-- If we are before a PM, then it is possible for a stream read
-- to leave us after the LM and before the PM, which is a bit
-- odd. The easiest way to deal with this is to unget the PM,
-- so we are indeed positioned between the characters. This way
-- further stream read operations will work correctly, and the
-- effect on text processing is a little weird, but what can
-- be expected if stream and text input are mixed this way?
if File.Before_LM_PM then
ch := ungetc (PM, File.Stream);
File.Before_LM_PM := False;
end if;
File.Before_LM := False;
Item (Item'First) := Stream_Element (Character'Pos (ASCII.LF));
if Item'Length = 1 then
Last := Item'Last;
else
Last :=
Item'First +
Stream_Element_Offset
(fread (buffer => Item'Address,
index => size_t (Item'First + 1),
size => 1,
count => Item'Length - 1,
stream => File.Stream));
end if;
return;
end if;
-- Now we do the read. Since this is a text file, it is normally in
-- text mode, but stream data must be read in binary mode, so we
-- temporarily set binary mode for the read, resetting it after.
-- These calls have no effect in a system (like Unix) where there is
-- no distinction between text and binary files.
set_binary_mode (fileno (File.Stream));
Last :=
Item'First +
Stream_Element_Offset
(fread (Item'Address, 1, Item'Length, File.Stream)) - 1;
if Last < Item'Last then
if ferror (File.Stream) /= 0 then
raise Device_Error;
end if;
end if;
set_text_mode (fileno (File.Stream));
end Read;
-----------
-- Reset --
-----------
procedure Reset
(File : in out File_Type;
Mode : in File_Mode)
is
begin
-- Don't allow change of mode for current file (RM A.10.2(5))
if (File = Current_In or else
File = Current_Out or else
File = Current_Error)
and then To_FCB (Mode) /= File.Mode
then
raise Mode_Error;
end if;
Terminate_Line (File);
FIO.Reset (AP (File), To_FCB (Mode));
File.Page := 1;
File.Line := 1;
File.Col := 1;
File.Line_Length := 0;
File.Page_Length := 0;
File.Before_LM := False;
File.Before_LM_PM := False;
end Reset;
procedure Reset (File : in out File_Type) is
begin
Terminate_Line (File);
FIO.Reset (AP (File));
File.Page := 1;
File.Line := 1;
File.Col := 1;
File.Line_Length := 0;
File.Page_Length := 0;
File.Before_LM := False;
File.Before_LM_PM := False;
end Reset;
-------------
-- Set_Col --
-------------
procedure Set_Col
(File : in File_Type;
To : in Positive_Count)
is
ch : int;
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if To not in Positive_Count then
raise Constraint_Error;
end if;
FIO.Check_File_Open (AP (File));
if To = File.Col then
return;
end if;
if Mode (File) >= Out_File then
if File.Line_Length /= 0 and then To > File.Line_Length then
raise Layout_Error;
end if;
if To < File.Col then
New_Line (File);
end if;
while File.Col < To loop
Put (File, ' ');
end loop;
else
loop
ch := Getc (File);
if ch = EOF then
raise End_Error;
elsif ch = LM then
File.Line := File.Line + 1;
File.Col := 1;
elsif ch = PM and then File.Is_Regular_File then
File.Page := File.Page + 1;
File.Line := 1;
File.Col := 1;
elsif To = File.Col then
Ungetc (ch, File);
return;
else
File.Col := File.Col + 1;
end if;
end loop;
end if;
end Set_Col;
procedure Set_Col (To : in Positive_Count) is
begin
Set_Col (Current_Out, To);
end Set_Col;
---------------
-- Set_Error --
---------------
procedure Set_Error (File : in File_Type) is
begin
FIO.Check_Write_Status (AP (File));
Current_Err := File;
end Set_Error;
---------------
-- Set_Input --
---------------
procedure Set_Input (File : in File_Type) is
begin
FIO.Check_Read_Status (AP (File));
Current_In := File;
end Set_Input;
--------------
-- Set_Line --
--------------
procedure Set_Line
(File : in File_Type;
To : in Positive_Count)
is
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if To not in Positive_Count then
raise Constraint_Error;
end if;
FIO.Check_File_Open (AP (File));
if To = File.Line then
return;
end if;
if Mode (File) >= Out_File then
if File.Page_Length /= 0 and then To > File.Page_Length then
raise Layout_Error;
end if;
if To < File.Line then
New_Page (File);
end if;
while File.Line < To loop
New_Line (File);
end loop;
else
while To /= File.Line loop
Skip_Line (File);
end loop;
end if;
end Set_Line;
procedure Set_Line (To : in Positive_Count) is
begin
Set_Line (Current_Out, To);
end Set_Line;
---------------------
-- Set_Line_Length --
---------------------
procedure Set_Line_Length (File : in File_Type; To : in Count) is
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if To not in Count then
raise Constraint_Error;
end if;
FIO.Check_Write_Status (AP (File));
File.Line_Length := To;
end Set_Line_Length;
procedure Set_Line_Length (To : in Count) is
begin
Set_Line_Length (Current_Out, To);
end Set_Line_Length;
----------------
-- Set_Output --
----------------
procedure Set_Output (File : in File_Type) is
begin
FIO.Check_Write_Status (AP (File));
Current_Out := File;
end Set_Output;
---------------------
-- Set_Page_Length --
---------------------
procedure Set_Page_Length (File : in File_Type; To : in Count) is
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if To not in Count then
raise Constraint_Error;
end if;
FIO.Check_Write_Status (AP (File));
File.Page_Length := To;
end Set_Page_Length;
procedure Set_Page_Length (To : in Count) is
begin
Set_Page_Length (Current_Out, To);
end Set_Page_Length;
---------------
-- Skip_Line --
---------------
procedure Skip_Line
(File : in File_Type;
Spacing : in Positive_Count := 1)
is
ch : int;
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if Spacing not in Positive_Count then
raise Constraint_Error;
end if;
FIO.Check_Read_Status (AP (File));
for L in 1 .. Spacing loop
if File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
else
ch := Getc (File);
-- If at end of file now, then immediately raise End_Error. Note
-- that we can never be positioned between a line mark and a page
-- mark, so if we are at the end of file, we cannot logically be
-- before the implicit page mark that is at the end of the file.
-- For the same reason, we do not need an explicit check for a
-- page mark. If there is a FF in the middle of a line, the file
-- is not in canonical format and we do not care about the page
-- numbers for files other than ones in canonical format.
if ch = EOF then
raise End_Error;
end if;
-- If not at end of file, then loop till we get to an LM or EOF.
-- The latter case happens only in non-canonical files where the
-- last line is not terminated by LM, but we don't want to blow
-- up for such files, so we assume an implicit LM in this case.
loop
exit when ch = LM or ch = EOF;
ch := Getc (File);
end loop;
end if;
-- We have got past a line mark, now, for a regular file only,
-- see if a page mark immediately follows this line mark and
-- if so, skip past the page mark as well. We do not do this
-- for non-regular files, since it would cause an undesirable
-- wait for an additional character.
File.Col := 1;
File.Line := File.Line + 1;
if File.Before_LM_PM then
File.Page := File.Page + 1;
File.Line := 1;
File.Before_LM_PM := False;
elsif File.Is_Regular_File then
ch := Getc (File);
-- Page mark can be explicit, or implied at the end of the file
if (ch = PM or else ch = EOF)
and then File.Is_Regular_File
then
File.Page := File.Page + 1;
File.Line := 1;
else
Ungetc (ch, File);
end if;
end if;
end loop;
end Skip_Line;
procedure Skip_Line (Spacing : in Positive_Count := 1) is
begin
Skip_Line (Current_In, Spacing);
end Skip_Line;
---------------
-- Skip_Page --
---------------
procedure Skip_Page (File : in File_Type) is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
-- If at page mark already, just skip it
if File.Before_LM_PM then
File.Before_LM := False;
File.Before_LM_PM := False;
File.Page := File.Page + 1;
File.Line := 1;
File.Col := 1;
return;
end if;
-- This is a bit tricky, if we are logically before an LM then
-- it is not an error if we are at an end of file now, since we
-- are not really at it.
if File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
ch := Getc (File);
-- Otherwise we do raise End_Error if we are at the end of file now
else
ch := Getc (File);
if ch = EOF then
raise End_Error;
end if;
end if;
-- Now we can just rumble along to the next page mark, or to the
-- end of file, if that comes first. The latter case happens when
-- the page mark is implied at the end of file.
loop
exit when ch = EOF
or else (ch = PM and then File.Is_Regular_File);
ch := Getc (File);
end loop;
File.Page := File.Page + 1;
File.Line := 1;
File.Col := 1;
end Skip_Page;
procedure Skip_Page is
begin
Skip_Page (Current_In);
end Skip_Page;
--------------------
-- Standard_Error --
--------------------
function Standard_Error return File_Type is
begin
return Standard_Err;
end Standard_Error;
function Standard_Error return File_Access is
begin
return Standard_Err'Access;
end Standard_Error;
--------------------
-- Standard_Input --
--------------------
function Standard_Input return File_Type is
begin
return Standard_In;
end Standard_Input;
function Standard_Input return File_Access is
begin
return Standard_In'Access;
end Standard_Input;
---------------------
-- Standard_Output --
---------------------
function Standard_Output return File_Type is
begin
return Standard_Out;
end Standard_Output;
function Standard_Output return File_Access is
begin
return Standard_Out'Access;
end Standard_Output;
--------------------
-- Terminate_Line --
--------------------
procedure Terminate_Line (File : File_Type) is
begin
FIO.Check_File_Open (AP (File));
-- For file other than In_File, test for needing to terminate last line
if Mode (File) /= In_File then
-- If not at start of line definition need new line
if File.Col /= 1 then
New_Line (File);
-- For files other than standard error and standard output, we
-- make sure that an empty file has a single line feed, so that
-- it is properly formatted. We avoid this for the standard files
-- because it is too much of a nuisance to have these odd line
-- feeds when nothing has been written to the file.
elsif (File /= Standard_Err and then File /= Standard_Out)
and then (File.Line = 1 and then File.Page = 1)
then
New_Line (File);
end if;
end if;
end Terminate_Line;
------------
-- Ungetc --
------------
procedure Ungetc (ch : int; File : File_Type) is
begin
if ch /= EOF then
if ungetc (ch, File.Stream) = EOF then
raise Device_Error;
end if;
end if;
end Ungetc;
-----------
-- Write --
-----------
-- This is the primitive Stream Write routine, used when a Text_IO file
-- is treated directly as a stream using Text_IO.Streams.Stream.
procedure Write
(File : in out Text_AFCB;
Item : in Stream_Element_Array)
is
function Has_Translated_Characters return Boolean;
-- return True if Item array contains a character which will be
-- translated under the text file mode. There is only one such
-- character under DOS based systems which is character 10.
text_translation_required : Boolean;
pragma Import (C, text_translation_required,
"__gnat_text_translation_required");
Siz : constant size_t := Item'Length;
function Has_Translated_Characters return Boolean is
begin
for K in Item'Range loop
if Item (K) = 10 then
return True;
end if;
end loop;
return False;
end Has_Translated_Characters;
Needs_Binary_Write : constant Boolean :=
text_translation_required and then Has_Translated_Characters;
begin
if File.Mode = FCB.In_File then
raise Mode_Error;
end if;
-- Now we do the write. Since this is a text file, it is normally in
-- text mode, but stream data must be written in binary mode, so we
-- temporarily set binary mode for the write, resetting it after. This
-- is done only if needed (i.e. there is some characters in Item which
-- needs to be written using the binary mode).
-- These calls have no effect in a system (like Unix) where there is
-- no distinction between text and binary files.
-- Since the character translation is done at the time the buffer is
-- written (this is true under Windows) we first flush current buffer
-- with text mode if needed.
if Needs_Binary_Write then
if fflush (File.Stream) = -1 then
raise Device_Error;
end if;
set_binary_mode (fileno (File.Stream));
end if;
if fwrite (Item'Address, 1, Siz, File.Stream) /= Siz then
raise Device_Error;
end if;
-- At this point we need to flush the buffer using the binary mode then
-- we reset to text mode.
if Needs_Binary_Write then
if fflush (File.Stream) = -1 then
raise Device_Error;
end if;
set_text_mode (fileno (File.Stream));
end if;
end Write;
-- Use "preallocated" strings to avoid calling "new" during the
-- elaboration of the run time. This is needed in the tasking case to
-- avoid calling Task_Lock too early. A filename is expected to end with a
-- null character in the runtime, here the null characters are added just
-- to have a correct filename length.
Err_Name : aliased String := "*stderr" & ASCII.Nul;
In_Name : aliased String := "*stdin" & ASCII.Nul;
Out_Name : aliased String := "*stdout" & ASCII.Nul;
begin
-------------------------------
-- Initialize Standard Files --
-------------------------------
-- Note: the names in these files are bogus, and probably it would be
-- better for these files to have no names, but the ACVC test insist!
-- We use names that are bound to fail in open etc.
Standard_Err.Stream := stderr;
Standard_Err.Name := Err_Name'Access;
Standard_Err.Form := Null_Str'Unrestricted_Access;
Standard_Err.Mode := FCB.Out_File;
Standard_Err.Is_Regular_File := is_regular_file (fileno (stderr)) /= 0;
Standard_Err.Is_Temporary_File := False;
Standard_Err.Is_System_File := True;
Standard_Err.Is_Text_File := True;
Standard_Err.Access_Method := 'T';
Standard_Err.Self := Standard_Err;
Standard_In.Stream := stdin;
Standard_In.Name := In_Name'Access;
Standard_In.Form := Null_Str'Unrestricted_Access;
Standard_In.Mode := FCB.In_File;
Standard_In.Is_Regular_File := is_regular_file (fileno (stdin)) /= 0;
Standard_In.Is_Temporary_File := False;
Standard_In.Is_System_File := True;
Standard_In.Is_Text_File := True;
Standard_In.Access_Method := 'T';
Standard_In.Self := Standard_In;
Standard_Out.Stream := stdout;
Standard_Out.Name := Out_Name'Access;
Standard_Out.Form := Null_Str'Unrestricted_Access;
Standard_Out.Mode := FCB.Out_File;
Standard_Out.Is_Regular_File := is_regular_file (fileno (stdout)) /= 0;
Standard_Out.Is_Temporary_File := False;
Standard_Out.Is_System_File := True;
Standard_Out.Is_Text_File := True;
Standard_Out.Access_Method := 'T';
Standard_Out.Self := Standard_Out;
FIO.Chain_File (AP (Standard_In));
FIO.Chain_File (AP (Standard_Out));
FIO.Chain_File (AP (Standard_Err));
FIO.Make_Unbuffered (AP (Standard_Out));
FIO.Make_Unbuffered (AP (Standard_Err));
end Ada.Text_IO;