diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-10-21 13:42:24 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-10-21 13:42:24 +0000 |
commit | 9dfe12ae5b94d03c997ea2903022a5d2d5c5f266 (patch) | |
tree | bdfc70477b60f1220cb05dd233a4570dd9c6bb5c /gcc/ada/g-regpat.adb | |
parent | 1c662558a1113238a624245a45382d3df90ccf13 (diff) | |
download | gcc-9dfe12ae5b94d03c997ea2903022a5d2d5c5f266.tar.gz |
2003-10-21 Arnaud Charlet <charlet@act-europe.fr>
* 3psoccon.ads, 3veacodu.adb, 3vexpect.adb, 3vsoccon.ads,
3vsocthi.adb, 3vsocthi.ads, 3vtrasym.adb, 3zsoccon.ads,
3zsocthi.adb, 3zsocthi.ads, 50system.ads, 51system.ads,
55system.ads, 56osinte.adb, 56osinte.ads, 56taprop.adb,
56taspri.ads, 56tpopsp.adb, 57system.ads, 58system.ads,
59system.ads, 5aml-tgt.adb, 5bml-tgt.adb, 5csystem.ads,
5dsystem.ads, 5fosinte.adb, 5gml-tgt.adb, 5hml-tgt.adb,
5isystem.ads, 5lparame.adb, 5msystem.ads, 5psystem.ads,
5sml-tgt.adb, 5sosprim.adb, 5stpopsp.adb, 5tsystem.ads,
5usystem.ads, 5vml-tgt.adb, 5vsymbol.adb, 5vtraent.adb,
5vtraent.ads, 5wml-tgt.adb, 5xparame.ads, 5xsystem.ads,
5xvxwork.ads, 5yparame.ads, 5ytiitho.adb, 5zinit.adb,
5zml-tgt.adb, 5zparame.ads, 5ztaspri.ads, 5ztfsetr.adb,
5zthrini.adb, 5ztiitho.adb, 5ztpopsp.adb, 7stfsetr.adb,
7straces.adb, 7strafor.adb, 7strafor.ads, 7stratas.adb,
a-excach.adb, a-exexda.adb, a-exexpr.adb, a-exextr.adb,
a-exstat.adb, a-strsup.adb, a-strsup.ads, a-stwisu.adb,
a-stwisu.ads, bld.adb, bld.ads, bld-io.adb,
bld-io.ads, clean.adb, clean.ads, ctrl_c.c,
erroutc.adb, erroutc.ads, errutil.adb, errutil.ads,
err_vars.ads, final.c, g-arrspl.adb, g-arrspl.ads,
g-boubuf.adb, g-boubuf.ads, g-boumai.ads, g-bubsor.adb,
g-bubsor.ads, g-comver.adb, g-comver.ads, g-ctrl_c.ads,
g-dynhta.adb, g-dynhta.ads, g-eacodu.adb, g-excact.adb,
g-excact.ads, g-heasor.adb, g-heasor.ads, g-memdum.adb,
g-memdum.ads, gnatclean.adb, gnatsym.adb, g-pehage.adb,
g-pehage.ads, g-perhas.ads, gpr2make.adb, gpr2make.ads,
gprcmd.adb, gprep.adb, gprep.ads, g-semaph.adb,
g-semaph.ads, g-string.adb, g-string.ads, g-strspl.ads,
g-wistsp.ads, i-vthrea.adb, i-vthrea.ads, i-vxwoio.adb,
i-vxwoio.ads, Makefile.generic, Makefile.prolog, Makefile.rtl,
prep.adb, prep.ads, prepcomp.adb, prepcomp.ads,
prj-err.adb, prj-err.ads, s-boarop.ads, s-carsi8.adb,
s-carsi8.ads, s-carun8.adb, s-carun8.ads, s-casi16.adb,
s-casi16.ads, s-casi32.adb, s-casi32.ads, s-casi64.adb,
s-casi64.ads, s-casuti.adb, s-casuti.ads, s-caun16.adb,
s-caun16.ads, s-caun32.adb, s-caun32.ads, s-caun64.adb,
s-caun64.ads, scng.adb, scng.ads, s-exnint.adb,
s-exnllf.adb, s-exnlli.adb, s-expint.adb, s-explli.adb,
s-geveop.adb, s-geveop.ads, s-hibaen.ads, s-htable.adb,
s-htable.ads, sinput-c.adb, sinput-c.ads, s-memcop.ads,
socket.c, s-purexc.ads, s-scaval.adb, s-stopoo.adb,
s-strcom.adb, s-strcom.ads, s-strxdr.adb, s-rident.ads,
s-thread.adb, s-thread.ads, s-tpae65.adb, s-tpae65.ads,
s-tporft.adb, s-traent.adb, s-traent.ads, styleg.adb,
styleg.ads, styleg-c.adb, styleg-c.ads, s-veboop.adb,
s-veboop.ads, s-vector.ads, symbols.adb, symbols.ads,
tb-alvms.c, tb-alvxw.c, tempdir.adb, tempdir.ads,
vms_conv.ads, vms_conv.adb, vms_data.ads,
vxaddr2line.adb: Files added. Merge with ACT tree.
* 4dintnam.ads, 4mintnam.ads, 4uintnam.ads, 52system.ads,
5dosinte.ads, 5etpopse.adb, 5mosinte.ads, 5qosinte.adb,
5qosinte.ads, 5qstache.adb, 5qtaprop.adb, 5qtaspri.ads,
5stpopse.adb, 5uintman.adb, 5uosinte.ads, adafinal.c,
g-enblsp.adb, io-aux.c, scn-nlit.adb, scn-slit.adb,
s-exnflt.ads, s-exngen.adb, s-exngen.ads, s-exnlfl.ads,
s-exnlin.ads, s-exnsfl.ads, s-exnsin.ads, s-exnssi.ads,
s-expflt.ads, s-expgen.adb, s-expgen.ads, s-explfl.ads,
s-explin.ads, s-expllf.ads, s-expsfl.ads, s-expsin.ads,
s-expssi.ads, style.adb: Files removed. Merge with ACT tree.
* 1ic.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, 4gintnam.ads, 4hexcpol.adb, 4hintnam.ads,
4lintnam.ads, 4nintnam.ads, 4ointnam.ads, 4onumaux.ads,
4pintnam.ads, 4sintnam.ads, 4vcaldel.adb, 4vcalend.adb,
4vintnam.ads, 4wexcpol.adb, 4wintnam.ads, 4zintnam.ads,
51osinte.adb, 51osinte.ads, 52osinte.adb, 52osinte.ads,
53osinte.ads, 54osinte.ads, 5aosinte.adb, 5aosinte.ads,
5asystem.ads, 5ataprop.adb, 5atasinf.ads, 5ataspri.ads,
5atpopsp.adb, 5avxwork.ads, 5bosinte.adb, 5bosinte.ads,
5bsystem.ads, 5cosinte.ads, 5esystem.ads, 5fintman.adb,
5fosinte.ads, 5fsystem.ads, 5ftaprop.adb, 5ftasinf.ads,
5ginterr.adb, 5gintman.adb, 5gmastop.adb, 5gosinte.ads,
5gproinf.ads, 5gsystem.ads, 5gtaprop.adb, 5gtasinf.ads,
5gtpgetc.adb, 5hosinte.adb, 5hosinte.ads, 5hsystem.ads,
5htaprop.adb, 5htaspri.ads, 5htraceb.adb, 5iosinte.adb,
5itaprop.adb, 5itaspri.ads, 5ksystem.ads, 5kvxwork.ads,
5lintman.adb, 5lml-tgt.adb, 5losinte.ads, 5lsystem.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, 5sintman.adb, 5sosinte.adb,
5sosinte.ads, 5ssystem.ads, 5staprop.adb, 5stasinf.ads,
5staspri.ads, 5svxwork.ads, 5tosinte.ads, 5vasthan.adb,
5vinmaop.adb, 5vinterr.adb, 5vintman.adb, 5vintman.ads,
5vmastop.adb, 5vosinte.adb, 5vosinte.ads, 5vosprim.adb,
5vsystem.ads, 5vtaprop.adb, 5vtaspri.ads, 5vtpopde.adb,
5vtpopde.ads, 5wgloloc.adb, 5wintman.adb, 5wmemory.adb,
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, 9drpc.adb,
a-caldel.adb, a-caldel.ads, a-charac.ads, a-colien.ads,
a-comlin.adb, adaint.c, adaint.h, ada-tree.def,
a-diocst.adb, a-diocst.ads, a-direio.adb, a-except.adb,
a-except.ads, a-excpol.adb, a-exctra.adb, a-exctra.ads,
a-filico.adb, a-interr.adb, a-intsig.adb, a-intsig.ads,
ali.adb, ali.ads, ali-util.adb, ali-util.ads,
a-ngcefu.adb, a-ngcoty.adb, a-ngelfu.adb, a-nudira.adb,
a-nudira.ads, a-nuflra.adb, a-nuflra.ads, a-reatim.adb,
a-reatim.ads, a-retide.ads, a-sequio.adb, a-siocst.adb,
a-siocst.ads, a-ssicst.adb, a-ssicst.ads, a-strbou.adb,
a-strbou.ads, a-strfix.adb, a-strmap.adb, a-strsea.ads,
a-strunb.adb, a-strunb.ads, a-ststio.adb, a-stunau.adb,
a-stunau.ads, a-stwibo.adb, a-stwibo.ads, a-stwifi.adb,
a-stwima.adb, a-stwiun.adb, a-stwiun.ads, a-tags.adb,
a-tags.ads, a-tasatt.adb, a-taside.adb, a-teioed.adb,
a-textio.adb, a-textio.ads, a-tienau.adb, a-tifiio.adb,
a-tiflau.adb, a-tiflio.adb, a-tigeau.adb, a-tigeau.ads,
a-tiinau.adb, a-timoau.adb, a-tiocst.adb, a-tiocst.ads,
atree.adb, atree.ads, a-witeio.adb, a-witeio.ads,
a-wtcstr.adb, a-wtcstr.ads, a-wtdeio.adb, a-wtedit.adb,
a-wtenau.adb, a-wtflau.adb, a-wtinau.adb, a-wtmoau.adb,
bcheck.adb, binde.adb, bindgen.adb, bindusg.adb,
checks.adb, checks.ads, cio.c, comperr.adb,
comperr.ads, csets.adb, cstand.adb, cstreams.c,
debug_a.adb, debug_a.ads, debug.adb, decl.c,
einfo.adb, einfo.ads, errout.adb, errout.ads,
eval_fat.adb, eval_fat.ads, exp_aggr.adb, expander.adb,
expander.ads, exp_attr.adb, exp_ch11.adb, exp_ch13.adb,
exp_ch2.adb, exp_ch3.adb, exp_ch3.ads, exp_ch4.adb,
exp_ch5.adb, exp_ch6.adb, exp_ch7.adb, exp_ch7.ads,
exp_ch8.adb, exp_ch9.adb, exp_code.adb, exp_dbug.adb,
exp_dbug.ads, exp_disp.adb, exp_dist.adb, expect.c,
exp_fixd.adb, exp_imgv.adb, exp_intr.adb, exp_pakd.adb,
exp_prag.adb, exp_strm.adb, exp_strm.ads, exp_tss.adb,
exp_tss.ads, exp_util.adb, exp_util.ads, exp_vfpt.adb,
fe.h, fmap.adb, fmap.ads, fname.adb,
fname.ads, fname-uf.adb, fname-uf.ads, freeze.adb,
freeze.ads, frontend.adb, g-awk.adb, g-awk.ads,
g-busora.adb, g-busora.ads, g-busorg.adb, g-busorg.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-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-except.ads, g-exctra.adb, g-exctra.ads, g-expect.adb,
g-expect.ads, g-hesora.adb, g-hesora.ads, g-hesorg.adb,
g-hesorg.ads, g-htable.adb, g-htable.ads, gigi.h,
g-io.adb, g-io.ads, g-io_aux.adb, g-io_aux.ads,
g-locfil.adb, g-locfil.ads, g-md5.adb, g-md5.ads,
gmem.c, gnat1drv.adb, gnatbind.adb, gnatchop.adb,
gnatcmd.adb, gnatfind.adb, gnatkr.adb, gnatlbr.adb,
gnatlink.adb, gnatls.adb, gnatmake.adb, gnatmem.adb,
gnatname.adb, gnatprep.adb, gnatprep.ads, gnatpsta.adb,
gnatxref.adb, g-os_lib.adb, g-os_lib.ads, g-regexp.adb,
g-regexp.ads, g-regist.adb, 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, hostparm.ads,
i-c.ads, i-cobol.adb, i-cpp.adb, i-cstrea.ads,
i-cstrin.adb, i-cstrin.ads, impunit.adb, init.c,
inline.adb, interfac.ads, i-pacdec.ads, itypes.adb,
itypes.ads, i-vxwork.ads, lang.opt, lang-specs.h,
layout.adb, lib.adb, lib.ads, lib-list.adb,
lib-load.adb, lib-load.ads, lib-sort.adb, lib-util.adb,
lib-writ.adb, lib-writ.ads, lib-xref.adb, lib-xref.ads,
link.c, live.adb, make.adb, make.ads,
Makefile.adalib, Makefile.in, Make-lang.in, makeusg.adb,
mdll.adb, mdll-fil.adb, mdll-fil.ads, mdll-utl.adb,
mdll-utl.ads, memroot.adb, memroot.ads, memtrack.adb,
misc.c, mkdir.c, mlib.adb, mlib.ads,
mlib-fil.adb, mlib-fil.ads, mlib-prj.adb, mlib-prj.ads,
mlib-tgt.adb, mlib-tgt.ads, mlib-utl.adb, mlib-utl.ads,
namet.adb, namet.ads, namet.h, nlists.ads,
nlists.h, nmake.adt, opt.adb, opt.ads,
osint.adb, osint.ads, osint-b.adb, osint-c.adb,
par.adb, par-ch10.adb, par-ch11.adb, par-ch2.adb,
par-ch3.adb, par-ch4.adb, par-ch5.adb, par-ch6.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,
prj.adb, prj.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, raise.c, raise.h,
repinfo.adb, repinfo.h, restrict.adb, restrict.ads,
rident.ads, rtsfind.adb, rtsfind.ads, s-addima.ads,
s-arit64.adb, s-assert.adb, s-assert.ads, s-atacco.adb,
s-atacco.ads, s-auxdec.adb, s-auxdec.ads, s-bitops.adb,
scans.ads, scn.adb, scn.ads, s-crc32.adb,
s-crc32.ads, s-direio.adb, sem.adb, sem.ads,
sem_aggr.adb, sem_attr.adb, sem_attr.ads, sem_case.adb,
sem_case.ads, sem_cat.adb, sem_cat.ads, sem_ch10.adb,
sem_ch11.adb, sem_ch12.adb, sem_ch12.ads, sem_ch13.adb,
sem_ch13.ads, sem_ch3.adb, sem_ch3.ads, sem_ch4.adb,
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_disp.adb, sem_disp.ads, sem_dist.adb,
sem_elab.adb, sem_eval.adb, sem_eval.ads, sem_intr.adb,
sem_maps.adb, sem_mech.adb, sem_prag.adb, sem_prag.ads,
sem_res.adb, sem_res.ads, sem_type.adb, sem_type.ads,
sem_util.adb, sem_util.ads, sem_warn.adb, s-errrep.adb,
s-errrep.ads, s-exctab.adb, s-exctab.ads, s-exnint.ads,
s-exnllf.ads, s-exnlli.ads, s-expint.ads, s-explli.ads,
s-expuns.ads, s-fatflt.ads, s-fatgen.adb, s-fatgen.ads,
s-fatlfl.ads, s-fatllf.ads, s-fatsfl.ads, s-fileio.adb,
s-fileio.ads, s-finimp.adb, s-finimp.ads, s-finroo.adb,
s-finroo.ads, sfn_scan.adb, s-gloloc.adb, s-gloloc.ads,
s-imgdec.adb, s-imgenu.adb, s-imgrea.adb, s-imgwch.adb,
sinfo.adb, sinfo.ads, s-inmaop.ads, sinput.adb,
sinput.ads, sinput-d.adb, sinput-l.adb, sinput-l.ads,
sinput-p.adb, sinput-p.ads, s-interr.adb, s-interr.ads,
s-intman.ads, s-maccod.ads, s-mastop.adb, s-mastop.ads,
s-memory.adb, s-memory.ads, snames.adb, snames.ads,
snames.h, s-osprim.ads, s-parame.ads, s-parint.ads,
s-pooloc.adb, s-pooloc.ads, s-poosiz.adb, sprint.adb,
s-proinf.ads, s-scaval.ads, s-secsta.adb, s-secsta.ads,
s-sequio.adb, s-shasto.adb, s-shasto.ads, s-soflin.ads,
s-stache.adb, s-stache.ads, s-stalib.adb, s-stalib.ads,
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,
stringt.adb, stringt.ads, stringt.h, style.ads,
stylesw.adb, stylesw.ads, s-unstyp.ads, s-vaflop.ads,
s-valrea.adb, s-valuti.adb, s-vercon.adb, s-vmexta.adb,
s-wchcnv.ads, s-wchcon.ads, s-widcha.adb, switch.adb,
switch.ads, switch-b.adb, switch-c.adb, switch-m.adb,
s-wwdcha.adb, s-wwdwch.adb, sysdep.c, system.ads,
table.adb, table.ads, targparm.adb, targparm.ads,
targtyps.c, tbuild.adb, tbuild.ads, tracebak.c,
trans.c, tree_io.adb, treepr.adb, treeprs.adt,
ttypes.ads, types.ads, types.h, uintp.adb,
uintp.ads, uintp.h, uname.adb, urealp.adb,
urealp.ads, urealp.h, usage.adb, utils2.c,
utils.c, validsw.adb, validsw.ads, widechar.adb,
xeinfo.adb, xnmake.adb, xref_lib.adb, xref_lib.ads,
xr_tabls.adb, xr_tabls.ads, xtreeprs.adb, xsnames.adb,
einfo.h, sinfo.h, treeprs.ads, nmake.ads, nmake.adb,
gnatvsn.ads: Merge with ACT tree.
* gnatvsn.adb: Rewritten in a simpler and more efficient way.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72751 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-regpat.adb')
-rw-r--r-- | gcc/ada/g-regpat.adb | 563 |
1 files changed, 331 insertions, 232 deletions
diff --git a/gcc/ada/g-regpat.adb b/gcc/ada/g-regpat.adb index 1949a8a5540..4ad6efbf944 100644 --- a/gcc/ada/g-regpat.adb +++ b/gcc/ada/g-regpat.adb @@ -7,7 +7,7 @@ -- B o d y -- -- -- -- Copyright (C) 1986 by University of Toronto. -- --- Copyright (C) 1996-2002 Ada Core Technologies, Inc. -- +-- Copyright (C) 1996-2003 Ada Core Technologies, 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- -- @@ -27,7 +27,8 @@ -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- --- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ @@ -240,7 +241,7 @@ package body GNAT.Regpat is return Boolean; -- Return True if the entry is set for C in the class Bitmap. - procedure Reset_Class (Bitmap : in out Character_Class); + procedure Reset_Class (Bitmap : out Character_Class); -- Clear all the entries in the class Bitmap. pragma Inline (Set_In_Class); @@ -256,7 +257,7 @@ package body GNAT.Regpat is function Is_Alnum (C : Character) return Boolean; -- Return True if C is an alphanum character or an underscore ('_') - function Is_Space (C : Character) return Boolean; + function Is_White_Space (C : Character) return Boolean; -- Return True if C is a whitespace character function Is_Printable (C : Character) return Boolean; @@ -305,7 +306,7 @@ package body GNAT.Regpat is pragma Inline ("="); pragma Inline (Is_Alnum); - pragma Inline (Is_Space); + pragma Inline (Is_White_Space); pragma Inline (Get_Next); pragma Inline (Get_Next_Offset); pragma Inline (Operand); @@ -377,20 +378,19 @@ package body GNAT.Regpat is Emit_Ptr : Pointer := Program_First; Parse_Pos : Natural := Expression'First; -- Input-scan pointer - Parse_End : Natural := Expression'Last; + Parse_End : constant Natural := Expression'Last; ---------------------------- -- Subprograms for Create -- ---------------------------- procedure Emit (B : Character); - -- Output the Character to the Program. - -- If code-generation is disables, simply increments the program - -- counter. + -- Output the Character B to the Program. If code-generation is + -- disabled, simply increments the program counter. function Emit_Node (Op : Opcode) return Pointer; -- If code-generation is enabled, Emit_Node outputs the - -- opcode and reserves space for a pointer to the next node. + -- opcode Op and reserves space for a pointer to the next node. -- Return value is the location of new opcode, ie old Emit_Ptr. procedure Emit_Natural (IP : Pointer; N : Natural); @@ -405,24 +405,26 @@ package body GNAT.Regpat is procedure Parse (Parenthesized : Boolean; - Flags : in out Expression_Flags; + Flags : out Expression_Flags; IP : out Pointer); -- Parse regular expression, i.e. main body or parenthesized thing -- Caller must absorb opening parenthesis. procedure Parse_Branch - (Flags : in out Expression_Flags; + (Flags : out Expression_Flags; First : Boolean; IP : out Pointer); -- Implements the concatenation operator and handles '|' -- First should be true if this is the first item of the alternative. procedure Parse_Piece - (Expr_Flags : in out Expression_Flags; IP : out Pointer); + (Expr_Flags : out Expression_Flags; + IP : out Pointer); -- Parse something followed by possible [*+?] procedure Parse_Atom - (Expr_Flags : in out Expression_Flags; IP : out Pointer); + (Expr_Flags : out Expression_Flags; + IP : out Pointer); -- Parse_Atom is the lowest level parse procedure. -- Optimization: gobbles an entire sequence of ordinary characters -- so that it can turn them into a single node, which is smaller to @@ -475,15 +477,16 @@ package body GNAT.Regpat is Greedy : out Boolean); -- Parse the argument list for a curly operator. -- It is assumed that IP is indeed pointing at a valid operator. + -- So what is IP and how come IP is not referenced in the body ??? procedure Parse_Character_Class (IP : out Pointer); -- Parse a character class. -- The calling subprogram should consume the opening '[' before. - procedure Parse_Literal (Expr_Flags : in out Expression_Flags; - IP : out Pointer); - -- Parse_Literal encodes a string of characters - -- to be matched exactly. + procedure Parse_Literal + (Expr_Flags : out Expression_Flags; + IP : out Pointer); + -- Parse_Literal encodes a string of characters to be matched exactly function Parse_Posix_Character_Class return Std_Class; -- Parse a posic character class, like [:alpha:] or [:^alpha:]. @@ -589,7 +592,7 @@ package body GNAT.Regpat is Max : out Natural; Greedy : out Boolean) is - pragma Warnings (Off, IP); + pragma Unreferenced (IP); Save_Pos : Natural := Parse_Pos + 1; @@ -701,8 +704,8 @@ package body GNAT.Regpat is -- the operator before it. if Emit_Code then - Program (Operand + Size .. Emit_Ptr + Size) - := Program (Operand .. Emit_Ptr); + Program (Operand + Size .. Emit_Ptr + Size) := + Program (Operand .. Emit_Ptr); end if; -- Insert the operator at the position previously occupied by the @@ -848,7 +851,7 @@ package body GNAT.Regpat is procedure Parse (Parenthesized : in Boolean; - Flags : in out Expression_Flags; + Flags : out Expression_Flags; IP : out Pointer) is E : String renames Expression; @@ -972,7 +975,7 @@ package body GNAT.Regpat is ---------------- procedure Parse_Atom - (Expr_Flags : in out Expression_Flags; + (Expr_Flags : out Expression_Flags; IP : out Pointer) is C : Character; @@ -1039,8 +1042,15 @@ package body GNAT.Regpat is when '|' | ASCII.LF | ')' => Fail ("internal urp"); -- Supposed to be caught earlier - when '?' | '+' | '*' | '{' => - Fail ("?+*{ follows nothing"); + when '?' | '+' | '*' => + Fail (C & " follows nothing"); + + when '{' => + if Is_Curly_Operator (Parse_Pos - 1) then + Fail (C & " follows nothing"); + else + Parse_Literal (Expr_Flags, IP); + end if; when '\' => if Parse_Pos > Parse_End then @@ -1096,7 +1106,7 @@ package body GNAT.Regpat is IP := Emit_Node (REFF); declare - Save : Natural := Parse_Pos - 1; + Save : constant Natural := Parse_Pos - 1; begin while Parse_Pos <= Expression'Last @@ -1124,7 +1134,7 @@ package body GNAT.Regpat is ------------------ procedure Parse_Branch - (Flags : in out Expression_Flags; + (Flags : out Expression_Flags; First : Boolean; IP : out Pointer) is @@ -1132,7 +1142,9 @@ package body GNAT.Regpat is Chain : Pointer; Last : Pointer; New_Flags : Expression_Flags; - Dummy : Pointer; + + Discard : Pointer; + pragma Warnings (Off, Discard); begin Flags := Worst_Expression; -- Tentatively @@ -1168,10 +1180,11 @@ package body GNAT.Regpat is Chain := Last; end loop; - if Chain = 0 then -- Loop ran zero CURLY - Dummy := Emit_Node (NOTHING); - end if; + -- Case where loop ran zero CURLY + if Chain = 0 then + Discard := Emit_Node (NOTHING); + end if; end Parse_Branch; --------------------------- @@ -1283,14 +1296,14 @@ package body GNAT.Regpat is when ANYOF_SPACE => for Value in Class_Byte'Range loop - if Is_Space (Character'Val (Value)) then + if Is_White_Space (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NSPACE => for Value in Class_Byte'Range loop - if not Is_Space (Character'Val (Value)) then + if not Is_White_Space (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; @@ -1392,7 +1405,7 @@ package body GNAT.Regpat is when ANYOF_PUNCT => for Value in Class_Byte'Range loop if Is_Printable (Character'Val (Value)) - and then not Is_Space (Character'Val (Value)) + and then not Is_White_Space (Character'Val (Value)) and then not Is_Alnum (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); @@ -1402,7 +1415,7 @@ package body GNAT.Regpat is when ANYOF_NPUNCT => for Value in Class_Byte'Range loop if not Is_Printable (Character'Val (Value)) - or else Is_Space (Character'Val (Value)) + or else Is_White_Space (Character'Val (Value)) or else Is_Alnum (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); @@ -1520,17 +1533,17 @@ package body GNAT.Regpat is -- This is a bit tricky due to quoted chars and due to -- the multiplier characters '*', '+', and '?' that -- take the SINGLE char previous as their operand. - -- + -- On entry, the character at Parse_Pos - 1 is going to go -- into the string, no matter what it is. It could be -- following a \ if Parse_Atom was entered from the '\' case. - -- + -- Basic idea is to pick up a good char in C and examine -- the next char. If Is_Mult (C) then twiddle, if it's a \ -- then frozzle and if it's another magic char then push C and -- terminate the string. If none of the above, push C on the -- string and go around again. - -- + -- Start_Pos is used to remember where "the current character" -- starts in the string, if due to an Is_Mult we need to back -- up and put the current char in a separate 1-character string. @@ -1539,12 +1552,13 @@ package body GNAT.Regpat is -- flag at the end. procedure Parse_Literal - (Expr_Flags : in out Expression_Flags; + (Expr_Flags : out Expression_Flags; IP : out Pointer) is Start_Pos : Natural := 0; C : Character; Length_Ptr : Pointer; + Has_Special_Operator : Boolean := False; begin @@ -1561,7 +1575,6 @@ package body GNAT.Regpat is Parse_Loop : loop - C := Expression (Parse_Pos); -- Get current character case C is @@ -1582,9 +1595,11 @@ package body GNAT.Regpat is -- Are we looking at an operator, or is this -- simply a normal character ? + elsif not Is_Mult (Parse_Pos) then Start_Pos := Parse_Pos; Case_Emit (C); + else -- We've got something like "abc?d". Mark this as a -- special case. What we want to emit is a first @@ -1592,14 +1607,17 @@ package body GNAT.Regpat is -- ultimately be transformed with a CURLY operator, A -- special case has to be handled for "a?", since there -- is no initial string to emit. + Has_Special_Operator := True; exit Parse_Loop; end if; when '\' => Start_Pos := Parse_Pos; + if Parse_Pos = Parse_End then Fail ("Trailing \"); + else case Expression (Parse_Pos + 1) is when 'b' | 'B' | 's' | 'S' | 'd' | 'D' @@ -1613,6 +1631,7 @@ package body GNAT.Regpat is when 'a' => Emit (ASCII.BEL); when others => Emit (Expression (Parse_Pos + 1)); end case; + Parse_Pos := Parse_Pos + 1; end if; @@ -1663,8 +1682,8 @@ package body GNAT.Regpat is -- role is not redundant. procedure Parse_Piece - (Expr_Flags : in out Expression_Flags; - IP : out Pointer) + (Expr_Flags : out Expression_Flags; + IP : out Pointer) is Op : Character; New_Flags : Expression_Flags; @@ -1774,7 +1793,26 @@ package body GNAT.Regpat is Class : Std_Class := ANYOF_NONE; E : String renames Expression; + -- Class names. Note that code assumes that the length of all + -- classes starting with the same letter have the same length. + + Alnum : constant String := "alnum:]"; + Alpha : constant String := "alpha:]"; + Ascii_C : constant String := "ascii:]"; + Cntrl : constant String := "cntrl:]"; + Digit : constant String := "digit:]"; + Graph : constant String := "graph:]"; + Lower : constant String := "lower:]"; + Print : constant String := "print:]"; + Punct : constant String := "punct:]"; + Space : constant String := "space:]"; + Upper : constant String := "upper:]"; + Word : constant String := "word:]"; + Xdigit : constant String := "xdigit:]"; + begin + -- Case of character class specified + if Parse_Pos <= Parse_End and then Expression (Parse_Pos) = ':' then @@ -1789,150 +1827,196 @@ package body GNAT.Regpat is Parse_Pos := Parse_Pos + 1; end if; - -- All classes have 6 characters at least - -- ??? magid constant 6 should have a name! + -- Check for class names based on first letter - if Parse_Pos + 6 <= Parse_End then + case Expression (Parse_Pos) is - case Expression (Parse_Pos) is - when 'a' => - if E (Parse_Pos .. Parse_Pos + 4) = "alnum:]" then + when 'a' => + + -- All 'a' classes have the same length (Alnum'Length) + + if Parse_Pos + Alnum'Length - 1 <= Parse_End then + + if E (Parse_Pos .. Parse_Pos + Alnum'Length - 1) = + Alnum + then if Invert then Class := ANYOF_NALNUMC; else Class := ANYOF_ALNUMC; end if; - elsif E (Parse_Pos .. Parse_Pos + 6) = "alpha:]" then + Parse_Pos := Parse_Pos + Alnum'Length; + + elsif E (Parse_Pos .. Parse_Pos + Alpha'Length - 1) = + Alpha + then if Invert then Class := ANYOF_NALPHA; else Class := ANYOF_ALPHA; end if; - elsif E (Parse_Pos .. Parse_Pos + 6) = "ascii:]" then + Parse_Pos := Parse_Pos + Alpha'Length; + + elsif E (Parse_Pos .. Parse_Pos + Ascii_C'Length - 1) = + Ascii_C + then if Invert then Class := ANYOF_NASCII; else Class := ANYOF_ASCII; end if; + Parse_Pos := Parse_Pos + Ascii_C'Length; end if; + end if; - when 'c' => - if E (Parse_Pos .. Parse_Pos + 6) = "cntrl:]" then - if Invert then - Class := ANYOF_NCNTRL; - else - Class := ANYOF_CNTRL; - end if; + when 'c' => + if Parse_Pos + Cntrl'Length - 1 <= Parse_End + and then E (Parse_Pos .. Parse_Pos + Cntrl'Length - 1) = + Cntrl + then + if Invert then + Class := ANYOF_NCNTRL; + else + Class := ANYOF_CNTRL; end if; - when 'd' => + Parse_Pos := Parse_Pos + Cntrl'Length; + end if; - if E (Parse_Pos .. Parse_Pos + 6) = "digit:]" then - if Invert then - Class := ANYOF_NDIGIT; - else - Class := ANYOF_DIGIT; - end if; + when 'd' => + if Parse_Pos + Digit'Length - 1 <= Parse_End + and then E (Parse_Pos .. Parse_Pos + Digit'Length - 1) = + Digit + then + if Invert then + Class := ANYOF_NDIGIT; + else + Class := ANYOF_DIGIT; end if; - when 'g' => + Parse_Pos := Parse_Pos + Digit'Length; + end if; - if E (Parse_Pos .. Parse_Pos + 6) = "graph:]" then - if Invert then - Class := ANYOF_NGRAPH; - else - Class := ANYOF_GRAPH; - end if; + when 'g' => + if Parse_Pos + Graph'Length - 1 <= Parse_End + and then E (Parse_Pos .. Parse_Pos + Graph'Length - 1) = + Graph + then + if Invert then + Class := ANYOF_NGRAPH; + else + Class := ANYOF_GRAPH; end if; + Parse_Pos := Parse_Pos + Graph'Length; + end if; - when 'l' => - - if E (Parse_Pos .. Parse_Pos + 6) = "lower:]" then - if Invert then - Class := ANYOF_NLOWER; - else - Class := ANYOF_LOWER; - end if; + when 'l' => + if Parse_Pos + Lower'Length - 1 <= Parse_End + and then E (Parse_Pos .. Parse_Pos + Lower'Length - 1) = + Lower + then + if Invert then + Class := ANYOF_NLOWER; + else + Class := ANYOF_LOWER; end if; + Parse_Pos := Parse_Pos + Lower'Length; + end if; - when 'p' => + when 'p' => - if E (Parse_Pos .. Parse_Pos + 6) = "print:]" then + -- All 'p' classes have the same length + + if Parse_Pos + Print'Length - 1 <= Parse_End then + if E (Parse_Pos .. Parse_Pos + Print'Length - 1) = + Print + then if Invert then Class := ANYOF_NPRINT; else Class := ANYOF_PRINT; end if; - elsif E (Parse_Pos .. Parse_Pos + 6) = "punct:]" then + Parse_Pos := Parse_Pos + Print'Length; + + elsif E (Parse_Pos .. Parse_Pos + Punct'Length - 1) = + Punct + then if Invert then Class := ANYOF_NPUNCT; else Class := ANYOF_PUNCT; end if; - end if; - when 's' => - - if E (Parse_Pos .. Parse_Pos + 6) = "space:]" then - if Invert then - Class := ANYOF_NSPACE; - else - Class := ANYOF_SPACE; - end if; + Parse_Pos := Parse_Pos + Punct'Length; end if; + end if; - when 'u' => - - if E (Parse_Pos .. Parse_Pos + 6) = "upper:]" then - if Invert then - Class := ANYOF_NUPPER; - else - Class := ANYOF_UPPER; - end if; + when 's' => + if Parse_Pos + Space'Length - 1 <= Parse_End + and then E (Parse_Pos .. Parse_Pos + Space'Length - 1) = + Space + then + if Invert then + Class := ANYOF_NSPACE; + else + Class := ANYOF_SPACE; end if; - when 'w' => + Parse_Pos := Parse_Pos + Space'Length; + end if; - if E (Parse_Pos .. Parse_Pos + 5) = "word:]" then - if Invert then - Class := ANYOF_NALNUM; - else - Class := ANYOF_ALNUM; - end if; + when 'u' => - Parse_Pos := Parse_Pos - 1; + if Parse_Pos + Upper'Length - 1 <= Parse_End + and then E (Parse_Pos .. Parse_Pos + Upper'Length - 1) = + Upper + then + if Invert then + Class := ANYOF_NUPPER; + else + Class := ANYOF_UPPER; end if; + Parse_Pos := Parse_Pos + Upper'Length; + end if; - when 'x' => - - if Parse_Pos + 7 <= Parse_End - and then E (Parse_Pos .. Parse_Pos + 7) = "xdigit:]" - then - if Invert then - Class := ANYOF_NXDIGIT; - else - Class := ANYOF_XDIGIT; - end if; + when 'w' => - Parse_Pos := Parse_Pos + 1; + if Parse_Pos + Word'Length - 1 <= Parse_End + and then E (Parse_Pos .. Parse_Pos + Word'Length - 1) = + Word + then + if Invert then + Class := ANYOF_NALNUM; + else + Class := ANYOF_ALNUM; end if; + Parse_Pos := Parse_Pos + Word'Length; + end if; - when others => - Class := ANYOF_NONE; + when 'x' => - end case; + if Parse_Pos + Xdigit'Length - 1 <= Parse_End + and then E (Parse_Pos .. Parse_Pos + Xdigit'Length - 1) + = Digit + then + if Invert then + Class := ANYOF_NXDIGIT; + else + Class := ANYOF_XDIGIT; + end if; - if Class /= ANYOF_NONE then - Parse_Pos := Parse_Pos + 7; - end if; + Parse_Pos := Parse_Pos + Xdigit'Length; + end if; - else - Fail ("Invalid character class"); - end if; + when others => + Fail ("Invalid character class"); + end case; + + -- Character class not specified else return ANYOF_NONE; @@ -2040,7 +2124,7 @@ package body GNAT.Regpat is end if; declare - Point : String := Pointer'Image (Index); + Point : constant String := Pointer'Image (Index); begin for J in 1 .. 6 - Point'Length loop @@ -2218,8 +2302,8 @@ package body GNAT.Regpat is Value : constant Class_Byte := Character'Pos (C); begin - return (Bitmap (Value / 8) - and Bit_Conversion (Value mod 8)) /= 0; + return + (Bitmap (Value / 8) and Bit_Conversion (Value mod 8)) /= 0; end Get_From_Class; -------------- @@ -2264,26 +2348,24 @@ package body GNAT.Regpat is ------------------ function Is_Printable (C : Character) return Boolean is - Value : constant Natural := Character'Pos (C); - begin - return (Value > 32 and then Value < 127) - or else Is_Space (C); + -- Printable if space or graphic character or other whitespace + -- Other white space includes (HT/LF/VT/FF/CR = codes 9-13) + + return C in Character'Val (32) .. Character'Val (126) + or else C in ASCII.HT .. ASCII.CR; end Is_Printable; - -------------- - -- Is_Space -- - -------------- + -------------------- + -- Is_White_Space -- + -------------------- - function Is_Space (C : Character) return Boolean is + function Is_White_Space (C : Character) return Boolean is begin - return C = ' ' - or else C = ASCII.HT - or else C = ASCII.CR - or else C = ASCII.LF - or else C = ASCII.VT - or else C = ASCII.FF; - end Is_Space; + -- Note: HT = 9, LF = 10, VT = 11, FF = 12, CR = 13 + + return C = ' ' or else C in ASCII.HT .. ASCII.CR; + end Is_White_Space; ----------- -- Match -- @@ -2292,10 +2374,15 @@ package body GNAT.Regpat is procedure Match (Self : Pattern_Matcher; Data : String; - Matches : out Match_Array) + Matches : out Match_Array; + Data_First : Integer := -1; + Data_Last : Positive := Positive'Last) is Program : Program_Data renames Self.Program; -- Shorter notation + First_In_Data : constant Integer := Integer'Max (Data_First, Data'First); + Last_In_Data : constant Integer := Integer'Min (Data_Last, Data'Last); + -- Global work variables Input_Pos : Natural; -- String-input pointer @@ -2365,9 +2452,11 @@ package body GNAT.Regpat is -- particular by going through "ordinary" nodes (that don't -- need to know whether the rest of the match failed) by -- using a loop instead of recursion. + -- Why is the above comment part of the spec rather than body ??? - function Match_Whilem (IP : Pointer) return Boolean; + function Match_Whilem (IP : Pointer) return Boolean; -- Return True if a WHILEM matches + -- How come IP is unreferenced in the body ??? function Recurse_Match (IP : Pointer; From : Natural) return Boolean; pragma Inline (Recurse_Match); @@ -2401,7 +2490,7 @@ package body GNAT.Regpat is return Natural is begin - for J in Start .. Data'Last loop + for J in Start .. Last_In_Data loop if Data (J) = C then return J; end if; @@ -2416,15 +2505,19 @@ package body GNAT.Regpat is function Recurse_Match (IP : Pointer; From : Natural) return Boolean is L : constant Natural := Last_Paren; + Tmp_F : constant Match_Array := - Matches_Full (From + 1 .. Matches_Full'Last); + Matches_Full (From + 1 .. Matches_Full'Last); + Start : constant Natural_Array := - Matches_Tmp (From + 1 .. Matches_Tmp'Last); + Matches_Tmp (From + 1 .. Matches_Tmp'Last); Input : constant Natural := Input_Pos; + begin if Match (IP) then return True; end if; + Last_Paren := L; Matches_Full (Tmp_F'Range) := Tmp_F; Matches_Tmp (Start'Range) := Start; @@ -2480,28 +2573,24 @@ package body GNAT.Regpat is null; when BOL => - exit State_Machine when - Input_Pos /= BOL_Pos + exit State_Machine when Input_Pos /= BOL_Pos and then ((Self.Flags and Multiple_Lines) = 0 or else Data (Input_Pos - 1) /= ASCII.LF); when MBOL => - exit State_Machine when - Input_Pos /= BOL_Pos + exit State_Machine when Input_Pos /= BOL_Pos and then Data (Input_Pos - 1) /= ASCII.LF; when SBOL => exit State_Machine when Input_Pos /= BOL_Pos; when EOL => - exit State_Machine when - Input_Pos <= Data'Last + exit State_Machine when Input_Pos <= Data'Last and then ((Self.Flags and Multiple_Lines) = 0 or else Data (Input_Pos) /= ASCII.LF); when MEOL => - exit State_Machine when - Input_Pos <= Data'Last + exit State_Machine when Input_Pos <= Data'Last and then Data (Input_Pos) /= ASCII.LF; when SEOL => @@ -2516,11 +2605,11 @@ package body GNAT.Regpat is Ln : Boolean := False; begin - if Input_Pos /= Data'First then + if Input_Pos /= First_In_Data then N := Is_Alnum (Data (Input_Pos - 1)); end if; - if Input_Pos > Data'Last then + if Input_Pos > Last_In_Data then Ln := False; else Ln := Is_Alnum (Data (Input_Pos)); @@ -2538,60 +2627,55 @@ package body GNAT.Regpat is end; when SPACE => - exit State_Machine when - Input_Pos > Data'Last - or else not Is_Space (Data (Input_Pos)); + exit State_Machine when Input_Pos > Last_In_Data + or else not Is_White_Space (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when NSPACE => - exit State_Machine when - Input_Pos > Data'Last - or else Is_Space (Data (Input_Pos)); + exit State_Machine when Input_Pos > Last_In_Data + or else Is_White_Space (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when DIGIT => - exit State_Machine when - Input_Pos > Data'Last + exit State_Machine when Input_Pos > Last_In_Data or else not Is_Digit (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when NDIGIT => - exit State_Machine when - Input_Pos > Data'Last + exit State_Machine when Input_Pos > Last_In_Data or else Is_Digit (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when ALNUM => - exit State_Machine when - Input_Pos > Data'Last + exit State_Machine when Input_Pos > Last_In_Data or else not Is_Alnum (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when NALNUM => - exit State_Machine when - Input_Pos > Data'Last + exit State_Machine when Input_Pos > Last_In_Data or else Is_Alnum (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when ANY => - exit State_Machine when Input_Pos > Data'Last + exit State_Machine when Input_Pos > Last_In_Data or else Data (Input_Pos) = ASCII.LF; Input_Pos := Input_Pos + 1; when SANY => - exit State_Machine when Input_Pos > Data'Last; + exit State_Machine when Input_Pos > Last_In_Data; Input_Pos := Input_Pos + 1; when EXACT => declare - Opnd : Pointer := String_Operand (Scan); - Current : Positive := Input_Pos; + Opnd : Pointer := String_Operand (Scan); + Current : Positive := Input_Pos; + Last : constant Pointer := Opnd + String_Length (Program, Scan); begin while Opnd <= Last loop - exit State_Machine when Current > Data'Last + exit State_Machine when Current > Last_In_Data or else Program (Opnd) /= Data (Current); Current := Current + 1; Opnd := Opnd + 1; @@ -2602,14 +2686,15 @@ package body GNAT.Regpat is when EXACTF => declare - Opnd : Pointer := String_Operand (Scan); - Current : Positive := Input_Pos; + Opnd : Pointer := String_Operand (Scan); + Current : Positive := Input_Pos; + Last : constant Pointer := Opnd + String_Length (Program, Scan); begin while Opnd <= Last loop - exit State_Machine when Current > Data'Last + exit State_Machine when Current > Last_In_Data or else Program (Opnd) /= To_Lower (Data (Current)); Current := Current + 1; Opnd := Opnd + 1; @@ -2624,8 +2709,7 @@ package body GNAT.Regpat is begin Bitmap_Operand (Program, Scan, Bitmap); - exit State_Machine when - Input_Pos > Data'Last + exit State_Machine when Input_Pos > Last_In_Data or else not Get_From_Class (Bitmap, Data (Input_Pos)); Input_Pos := Input_Pos + 1; end; @@ -2633,7 +2717,8 @@ package body GNAT.Regpat is when OPEN => declare No : constant Natural := - Character'Pos (Program (Operand (Scan))); + Character'Pos (Program (Operand (Scan))); + begin Matches_Tmp (No) := Input_Pos; end; @@ -2641,9 +2726,11 @@ package body GNAT.Regpat is when CLOSE => declare No : constant Natural := - Character'Pos (Program (Operand (Scan))); + Character'Pos (Program (Operand (Scan))); + begin Matches_Full (No) := (Matches_Tmp (No), Input_Pos - 1); + if Last_Paren < No then Last_Paren := No; end if; @@ -2653,6 +2740,7 @@ package body GNAT.Regpat is declare No : constant Natural := Character'Pos (Program (Operand (Scan))); + Data_Pos : Natural; begin @@ -2663,8 +2751,9 @@ package body GNAT.Regpat is end if; Data_Pos := Matches_Full (No).First; + while Data_Pos <= Matches_Full (No).Last loop - if Input_Pos > Data'Last + if Input_Pos > Last_In_Data or else Data (Input_Pos) /= Data (Data_Pos) then return False; @@ -2681,6 +2770,7 @@ package body GNAT.Regpat is when STAR | PLUS | CURLY => declare Greed : constant Boolean := Greedy; + begin Greedy := True; return Match_Simple_Operator (Op, Scan, Next, Greed); @@ -2689,15 +2779,18 @@ package body GNAT.Regpat is when CURLYX => -- Looking at something like: + -- 1: CURLYX {n,m} (->4) -- 2: code for complex thing (->3) -- 3: WHILEM (->0) -- 4: NOTHING declare + Min : constant Natural := + Read_Natural (Program, Scan + 3); + Max : constant Natural := + Read_Natural (Program, Scan + 5); Cc : aliased Current_Curly_Record; - Min : Natural := Read_Natural (Program, Scan + 3); - Max : Natural := Read_Natural (Program, Scan + 5); Has_Match : Boolean; @@ -2723,9 +2816,6 @@ package body GNAT.Regpat is when WHILEM => return Match_Whilem (IP); - - when others => - raise Expression_Error; -- Invalid instruction end case; Scan := Next; @@ -2756,7 +2846,7 @@ package body GNAT.Regpat is Operand_Code : Pointer; Old : Natural; Last_Pos : Natural; - Save : Natural := Input_Pos; + Save : constant Natural := Input_Pos; begin -- Lookahead to avoid useless match attempts @@ -2787,6 +2877,7 @@ package body GNAT.Regpat is -- Non greedy operators if not Greedy then + -- Test the minimal repetitions if Min /= 0 @@ -2804,10 +2895,10 @@ package body GNAT.Regpat is Last_Pos := Input_Pos + Max; - if Last_Pos > Data'Last + if Last_Pos > Last_In_Data or else Max = Natural'Last then - Last_Pos := Data'Last; + Last_Pos := Last_In_Data; end if; -- Look for the first possible opportunity @@ -2890,7 +2981,7 @@ package body GNAT.Regpat is while No >= Min loop if not Next_Char_Known - or else (Input_Pos <= Data'Last + or else (Input_Pos <= Last_In_Data and then Data (Input_Pos) = Next_Char) then if Match (Next) then @@ -2903,6 +2994,7 @@ package body GNAT.Regpat is No := No - 1; Input_Pos := Save + No; end loop; + return False; end if; end Match_Simple_Operator; @@ -2911,20 +3003,20 @@ package body GNAT.Regpat is -- Match_Whilem -- ------------------ - -- This is really hard to understand, because after we match what we're - -- trying to match, we must make sure the rest of the REx is going to - -- match for sure, and to do that we have to go back UP the parse tree - -- by recursing ever deeper. And if it fails, we have to reset our - -- parent's current state that we can try again after backing off. + -- This is really hard to understand, because after we match what we + -- are trying to match, we must make sure the rest of the REx is going + -- to match for sure, and to do that we have to go back UP the parse + -- tree by recursing ever deeper. And if it fails, we have to reset + -- our parent's current state that we can try again after backing off. function Match_Whilem (IP : Pointer) return Boolean is - pragma Warnings (Off, IP); + pragma Unreferenced (IP); Cc : Current_Curly_Access := Current_Curly; - N : Natural := Cc.Cur + 1; + N : constant Natural := Cc.Cur + 1; Ln : Natural := 0; - Lastloc : Natural := Cc.Lastloc; + Lastloc : constant Natural := Cc.Lastloc; -- Detection of 0-len. begin @@ -3058,8 +3150,8 @@ package body GNAT.Regpat is Bitmap : Character_Class; begin - if Max = Natural'Last or else Scan + Max - 1 > Data'Last then - Last := Data'Last; + if Max = Natural'Last or else Scan + Max - 1 > Last_In_Data then + Last := Last_In_Data; else Last := Scan + Max - 1; end if; @@ -3125,14 +3217,14 @@ package body GNAT.Regpat is when SPACE => while Scan <= Last - and then Is_Space (Data (Scan)) + and then Is_White_Space (Data (Scan)) loop Scan := Scan + 1; end loop; when NSPACE => while Scan <= Last - and then not Is_Space (Data (Scan)) + and then not Is_White_Space (Data (Scan)) loop Scan := Scan + 1; end loop; @@ -3202,7 +3294,7 @@ package body GNAT.Regpat is Must_First : constant Pointer := Self.Must_Have; Must_Last : constant Pointer := Must_First + Pointer (Self.Must_Have_Length - 1); - Next_Try : Natural := Index (Data'First, First); + Next_Try : Natural := Index (First_In_Data, First); begin while Next_Try /= 0 @@ -3226,11 +3318,11 @@ package body GNAT.Regpat is -- Simplest case first: an anchored match need be tried only once if Self.Anchored and then (Self.Flags and Multiple_Lines) = 0 then - Matched := Try (Data'First); + Matched := Try (First_In_Data); elsif Self.Anchored then declare - Next_Try : Natural := Data'First; + Next_Try : Natural := First_In_Data; begin -- Test the first position in the buffer Matched := Try (Next_Try); @@ -3238,8 +3330,8 @@ package body GNAT.Regpat is -- Else only test after newlines if not Matched then - while Next_Try <= Data'Last loop - while Next_Try <= Data'Last + while Next_Try <= Last_In_Data loop + while Next_Try <= Last_In_Data and then Data (Next_Try) /= ASCII.LF loop Next_Try := Next_Try + 1; @@ -3247,7 +3339,7 @@ package body GNAT.Regpat is Next_Try := Next_Try + 1; - if Next_Try <= Data'Last then + if Next_Try <= Last_In_Data then Matched := Try (Next_Try); exit when Matched; end if; @@ -3256,11 +3348,10 @@ package body GNAT.Regpat is end; elsif Self.First /= ASCII.NUL then - -- We know what char it must start with declare - Next_Try : Natural := Index (Data'First, Self.First); + Next_Try : Natural := Index (First_In_Data, Self.First); begin while Next_Try /= 0 loop @@ -3273,10 +3364,10 @@ package body GNAT.Regpat is else -- Messy cases: try all locations (including for the empty string) - Matched := Try (Data'First); + Matched := Try (First_In_Data); if not Matched then - for S in Data'First + 1 .. Data'Last loop + for S in First_In_Data + 1 .. Last_In_Data loop Matched := Try (S); exit when Matched; end loop; @@ -3295,13 +3386,15 @@ package body GNAT.Regpat is function Match (Self : Pattern_Matcher; - Data : String) + Data : String; + Data_First : Integer := -1; + Data_Last : Positive := Positive'Last) return Natural is Matches : Match_Array (0 .. 0); begin - Match (Self, Data, Matches); + Match (Self, Data, Matches, Data_First, Data_Last); if Matches (0) = No_Match then return Data'First - 1; else @@ -3313,24 +3406,28 @@ package body GNAT.Regpat is (Expression : String; Data : String; Matches : out Match_Array; - Size : Program_Size := 0) + Size : Program_Size := 0; + Data_First : Integer := -1; + Data_Last : Positive := Positive'Last) is PM : Pattern_Matcher (Size); Finalize_Size : Program_Size; begin if Size = 0 then - Match (Compile (Expression), Data, Matches); + Match (Compile (Expression), Data, Matches, Data_First, Data_Last); else Compile (PM, Expression, Finalize_Size); - Match (PM, Data, Matches); + Match (PM, Data, Matches, Data_First, Data_Last); end if; end Match; function Match (Expression : String; Data : String; - Size : Program_Size := 0) + Size : Program_Size := 0; + Data_First : Integer := -1; + Data_Last : Positive := Positive'Last) return Natural is PM : Pattern_Matcher (Size); @@ -3338,17 +3435,19 @@ package body GNAT.Regpat is begin if Size = 0 then - return Match (Compile (Expression), Data); + return Match (Compile (Expression), Data, Data_First, Data_Last); else Compile (PM, Expression, Final_Size); - return Match (PM, Data); + return Match (PM, Data, Data_First, Data_Last); end if; end Match; function Match (Expression : String; Data : String; - Size : Program_Size := 0) + Size : Program_Size := 0; + Data_First : Integer := -1; + Data_Last : Positive := Positive'Last) return Boolean is Matches : Match_Array (0 .. 0); @@ -3357,10 +3456,10 @@ package body GNAT.Regpat is begin if Size = 0 then - Match (Compile (Expression), Data, Matches); + Match (Compile (Expression), Data, Matches, Data_First, Data_Last); else Compile (PM, Expression, Final_Size); - Match (PM, Data, Matches); + Match (PM, Data, Matches, Data_First, Data_Last); end if; return Matches (0).First >= Data'First; @@ -3457,8 +3556,8 @@ package body GNAT.Regpat is begin for J in Str'Range loop case Str (J) is - when '^' | '$' | '|' | '*' | '+' | '?' | '{' - | '}' | '[' | ']' | '(' | ')' | '\' => + when '^' | '$' | '|' | '*' | '+' | '?' | '{' | + '}' | '[' | ']' | '(' | ')' | '\' => S (Last + 1) := '\'; S (Last + 2) := Str (J); @@ -3491,7 +3590,7 @@ package body GNAT.Regpat is -- Reset_Class -- ----------------- - procedure Reset_Class (Bitmap : in out Character_Class) is + procedure Reset_Class (Bitmap : out Character_Class) is begin Bitmap := (others => 0); end Reset_Class; |