diff options
author | bosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-08 20:11:04 +0000 |
---|---|---|
committer | bosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-08 20:11:04 +0000 |
commit | f15731c43ae5e8cea424ea40f905c19afa1bd2e4 (patch) | |
tree | b584a79288c93215b05fb451943291ccd039388b /gcc/ada/fmap.adb | |
parent | 1d347c236ad815c77bd345611ed221b0bd6091de (diff) | |
download | gcc-f15731c43ae5e8cea424ea40f905c19afa1bd2e4.tar.gz |
* 41intnam.ads, 42intnam.ads, 4aintnam.ads, 4cintnam.ads,
4dintnam.ads, 4gintnam.ads, 4hintnam.ads, 4lintnam.ads,
4mintnam.ads, 4pintnam.ads, 4rintnam.ads, 4sintnam.ads,
4uintnam.ads, 4vcalend.adb, 4zintnam.ads, 52system.ads,
5amastop.adb, 5asystem.ads, 5ataprop.adb, 5atpopsp.adb,
5avxwork.ads, 5bosinte.adb, 5bsystem.ads, 5esystem.ads,
5fsystem.ads, 5ftaprop.adb, 5ginterr.adb, 5gmastop.adb,
5gsystem.ads, 5gtaprop.adb, 5gtasinf.adb, 5gtasinf.ads,
5hparame.ads, 5hsystem.ads, 5htaprop.adb, 5htraceb.adb,
5itaprop.adb, 5ksystem.ads, 5kvxwork.ads, 5lintman.adb,
5lsystem.ads, 5mvxwork.ads, 5ninmaop.adb, 5nosinte.ads,
5ntaprop.adb, 5ointerr.adb, 5omastop.adb, 5oosinte.adb,
5osystem.ads, 5otaprop.adb, 5otaspri.ads, 5pvxwork.ads,
5qtaprop.adb, 5sintman.adb, 5ssystem.ads, 5staprop.adb,
5stpopse.adb, 5svxwork.ads, 5tosinte.ads, 5uintman.adb,
5vasthan.adb, 5vinmaop.adb, 5vinterr.adb, 5vintman.adb,
5vmastop.adb, 5vparame.ads, 5vsystem.ads, 5vtaprop.adb,
5vtpopde.adb, 5wmemory.adb, 5wsystem.ads, 5wtaprop.adb,
5ysystem.ads, 5zinterr.adb, 5zintman.adb, 5zosinte.adb,
5zosinte.ads, 5zsystem.ads, 5ztaprop.adb, 6vcpp.adb, 6vcstrea.adb,
7sintman.adb, 7staprop.adb, 7stpopsp.adb, 9drpc.adb,
Make-lang.in, Makefile.in, a-caldel.adb, a-comlin.ads,
a-dynpri.adb, a-except.adb, a-except.ads, a-finali.adb,
a-ncelfu.ads, a-reatim.adb, a-retide.adb, a-stream.ads,
a-ststio.adb, a-ststio.ads, a-stwifi.adb, a-tags.adb, a-tasatt.adb,
a-textio.adb, a-tideau.adb, a-tiflau.adb, a-tigeau.adb,
a-tigeau.ads, a-tiinau.adb, a-timoau.adb, a-witeio.adb,
a-wtdeau.adb, a-wtenau.adb, a-wtflau.adb, a-wtgeau.adb,
a-wtgeau.ads, a-wtinau.adb, a-wtmoau.adb, ada-tree.def, ada-tree.h,
adaint.c, adaint.h, ali-util.adb, ali.adb, ali.ads, atree.adb,
atree.ads, atree.h, back_end.adb, bcheck.adb, bindgen.adb,
bindusg.adb, checks.adb, comperr.adb, config-lang.in, csets.adb,
csets.ads, cstand.adb, cstreams.c, debug.adb, debug.ads, decl.c,
einfo.adb, einfo.ads, einfo.h, elists.h, errout.adb, errout.ads,
eval_fat.adb, exp_aggr.adb, exp_attr.adb, exp_ch11.adb,
exp_ch12.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_ch9.adb, exp_ch9.ads, exp_dbug.adb, exp_dbug.ads, exp_disp.ads,
exp_dist.adb, exp_fixd.adb, exp_intr.adb, exp_pakd.adb,
exp_prag.adb, exp_strm.adb, exp_util.adb, exp_util.ads,
expander.adb, expect.c, fe.h, fmap.adb, fmap.ads, fname-uf.adb,
freeze.adb, frontend.adb, g-awk.adb, g-cgideb.adb, g-comlin.adb,
g-comlin.ads, g-debpoo.adb, g-dirope.adb, g-dirope.ads,
g-dyntab.adb, g-expect.adb, g-expect.ads, g-io.ads, g-io_aux.adb,
g-io_aux.ads, g-locfil.adb, g-locfil.ads, g-os_lib.adb,
g-os_lib.ads, g-regexp.adb, g-regpat.adb, g-socket.adb,
g-socket.ads, g-spipat.adb, g-table.adb, g-trasym.adb,
g-trasym.ads, gigi.h, gmem.c, gnat1drv.adb, gnatbind.adb, gnatbl.c,
gnatchop.adb, gnatcmd.adb, gnatdll.adb, gnatfind.adb, gnatlbr.adb,
gnatlink.adb, gnatls.adb, gnatmem.adb, gnatprep.adb, gnatvsn.ads,
gnatxref.adb, hlo.adb, hostparm.ads, i-cobol.adb, i-cpp.adb,
i-cstrea.ads, i-cstrin.adb, i-pacdec.adb, i-vxwork.ads,
impunit.adb, init.c, inline.adb, io-aux.c, layout.adb, lib-load.adb,
lib-util.adb, lib-writ.adb, lib-writ.ads, lib-xref.adb,
lib-xref.ads, lib.adb, lib.ads, make.adb, makeusg.adb, mdll.adb,
memroot.adb, misc.c, mlib-tgt.adb, mlib-utl.adb, mlib-utl.ads,
mlib.adb, namet.adb, namet.ads, namet.h, nlists.h, nmake.adb,
nmake.ads, nmake.adt, opt.adb, opt.ads, osint.adb, osint.ads,
output.adb, output.ads, par-ch2.adb, par-ch3.adb, par-ch5.adb,
par-prag.adb, par-tchk.adb, par-util.adb, par.adb, prj-attr.adb,
prj-dect.adb, prj-env.adb, prj-env.ads, prj-nmsc.adb, prj-part.adb,
prj-proc.adb, prj-strt.adb, prj-tree.adb, prj-tree.ads, prj.adb,
prj.ads, raise.c, raise.h, repinfo.adb, restrict.adb, restrict.ads,
rident.ads, rtsfind.adb, rtsfind.ads, s-arit64.adb, s-asthan.adb,
s-atacco.adb, s-atacco.ads, s-auxdec.adb, s-crc32.adb, s-crc32.ads,
s-direio.adb, s-fatgen.adb, s-fileio.adb, s-finimp.adb,
s-gloloc.adb, s-gloloc.ads, s-interr.adb, s-mastop.adb,
s-mastop.ads, s-memory.adb, s-parame.ads, s-parint.adb,
s-pooglo.adb, s-pooloc.adb, s-rpc.adb, s-secsta.adb, s-sequio.adb,
s-shasto.adb, s-soflin.adb, s-soflin.ads, s-stache.adb,
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-taprop.ads, s-tarest.adb, s-tasdeb.adb,
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-tassta.adb, s-tasuti.adb, s-tasuti.ads, s-tataat.adb,
s-tataat.ads, s-tpoben.adb, s-tpoben.ads, s-tpobop.adb,
s-tposen.adb, s-tposen.ads, s-traceb.adb, s-traceb.ads,
s-unstyp.ads, s-widenu.adb, scn-nlit.adb, scn.adb, sem.adb,
sem_aggr.adb, sem_attr.adb, sem_attr.ads, sem_case.adb,
sem_ch10.adb, sem_ch11.adb, sem_ch11.ads, sem_ch12.adb,
sem_ch13.adb, sem_ch13.ads, sem_ch2.adb, sem_ch3.adb, sem_ch3.ads,
sem_ch4.adb, sem_ch5.adb, sem_ch6.adb, sem_ch6.ads, sem_ch7.adb,
sem_ch8.adb, sem_ch8.ads, sem_ch9.adb, sem_disp.adb, sem_dist.adb,
sem_elab.adb, sem_elim.adb, sem_elim.ads, sem_eval.adb,
sem_intr.adb, sem_mech.adb, sem_prag.adb, sem_res.adb,
sem_type.adb, sem_util.adb, sem_util.ads, sem_vfpt.adb,
sem_warn.adb, sinfo.adb, sinfo.ads, sinfo.h, sinput-l.adb,
sinput-l.ads, sinput.adb, sinput.ads, snames.adb, snames.ads,
snames.h, sprint.adb, sprint.ads, stringt.adb, stringt.ads,
stringt.h, style.adb, switch.adb, switch.ads, sysdep.c, system.ads,
table.adb, targparm.adb, targparm.ads, targtyps.c, tbuild.adb,
tbuild.ads, tracebak.c, trans.c, tree_gen.adb, tree_io.adb,
treepr.adb, treepr.ads, treeprs.ads, treeprs.adt, ttypes.ads,
types.adb, types.ads, types.h, uintp.ads, urealp.ads, usage.adb,
utils.c, utils2.c, validsw.adb, xnmake.adb, xr_tabls.adb,
xr_tabls.ads, xref_lib.adb, xref_lib.ads : Merge in ACT changes.
* 1ssecsta.adb, 1ssecsta.ads, a-chlat9.ads, a-cwila9.ads,
g-enblsp.adb, g-md5.adb, g-md5.ads, gnatname.adb, gnatname.ads,
mkdir.c, osint-b.adb, osint-b.ads, osint-c.adb, osint-c.ads,
osint-l.adb, osint-l.ads, osint-m.adb, osint-m.ads : New files
* 3lsoccon.ads, 5qparame.ads, 5qvxwork.ads, 5smastop.adb,
5zparame.ads, gnatmain.adb, gnatmain.ads, gnatpsys.adb : Removed
* mdllfile.adb, mdllfile.ads, mdlltool.adb, mdlltool.ads : Renamed
to mdll-fil.ad[bs] and mdll-util.ad[bs]
* mdll-fil.adb, mdll-fil.ads, mdll-utl.adb, mdll-utl.ads : Renamed
from mdllfile.ad[bs] and mdlltool.ad[bs]
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50451 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/fmap.adb')
-rw-r--r-- | gcc/ada/fmap.adb | 221 |
1 files changed, 167 insertions, 54 deletions
diff --git a/gcc/ada/fmap.adb b/gcc/ada/fmap.adb index 54409cd9e35..9c1ffea5191 100644 --- a/gcc/ada/fmap.adb +++ b/gcc/ada/fmap.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- $Revision: 1.1 $ +-- $Revision$ -- -- -- Copyright (C) 2001, Free Software Foundation, Inc. -- -- -- @@ -26,9 +26,11 @@ -- -- ------------------------------------------------------------------------------ -with Namet; use Namet; -with Osint; use Osint; -with Output; use Output; +with GNAT.OS_Lib; use GNAT.OS_Lib; +with Namet; use Namet; +with Opt; use Opt; +with Osint; use Osint; +with Output; use Output; with Table; with Unchecked_Conversion; @@ -43,8 +45,13 @@ package body Fmap is function To_Big_String_Ptr is new Unchecked_Conversion (Source_Buffer_Ptr, Big_String_Ptr); + type Mapping is record + Uname : Unit_Name_Type; + Fname : File_Name_Type; + end record; + package File_Mapping is new Table.Table ( - Table_Component_Type => File_Name_Type, + Table_Component_Type => Mapping, Table_Index_Type => Int, Table_Low_Bound => 0, Table_Initial => 1_000, @@ -53,7 +60,7 @@ package body Fmap is -- Mapping table to map unit names to file names. package Path_Mapping is new Table.Table ( - Table_Component_Type => File_Name_Type, + Table_Component_Type => Mapping, Table_Index_Type => Int, Table_Low_Bound => 0, Table_Initial => 1_000, @@ -89,6 +96,8 @@ package body Fmap is -- Hash table to map file names to path names. Used in conjunction with -- table Path_Mapping above. + Last_In_Table : Int := 0; + --------------------- -- Add_To_File_Map -- --------------------- @@ -101,10 +110,12 @@ package body Fmap is begin File_Mapping.Increment_Last; Unit_Hash_Table.Set (Unit_Name, File_Mapping.Last); - File_Mapping.Table (File_Mapping.Last) := File_Name; + File_Mapping.Table (File_Mapping.Last) := + (Uname => Unit_Name, Fname => File_Name); Path_Mapping.Increment_Last; File_Hash_Table.Set (File_Name, Path_Mapping.Last); - Path_Mapping.Table (Path_Mapping.Last) := Path_Name; + Path_Mapping.Table (Path_Mapping.Last) := + (Uname => Unit_Name, Fname => Path_Name); end Add_To_File_Map; ---------- @@ -126,13 +137,15 @@ package body Fmap is BS : Big_String_Ptr; SP : String_Ptr; - Deb : Positive := 1; - Fin : Natural := 0; + First : Positive := 1; + Last : Natural := 0; Uname : Unit_Name_Type; Fname : Name_Id; Pname : Name_Id; + The_Mapping : Mapping; + procedure Empty_Tables; -- Remove all entries in case of incorrect mapping file @@ -153,6 +166,7 @@ package body Fmap is File_Hash_Table.Reset; Path_Mapping.Set_Last (0); File_Mapping.Set_Last (0); + Last_In_Table := 0; end Empty_Tables; -------------- @@ -163,29 +177,29 @@ package body Fmap is use ASCII; begin - Deb := Fin + 1; + First := Last + 1; -- If not at the end of file, skip the end of line - while Deb < SP'Last - and then (SP (Deb) = CR - or else SP (Deb) = LF - or else SP (Deb) = EOF) + while First < SP'Last + and then (SP (First) = CR + or else SP (First) = LF + or else SP (First) = EOF) loop - Deb := Deb + 1; + First := First + 1; end loop; - -- If not at the end of line, find the end of this new line + -- If not at the end of file, find the end of this new line - if Deb < SP'Last and then SP (Deb) /= EOF then - Fin := Deb; + if First < SP'Last and then SP (First) /= EOF then + Last := First; - while Fin < SP'Last - and then SP (Fin + 1) /= CR - and then SP (Fin + 1) /= LF - and then SP (Fin + 1) /= EOF + while Last < SP'Last + and then SP (Last + 1) /= CR + and then SP (Last + 1) /= LF + and then SP (Last + 1) /= EOF loop - Fin := Fin + 1; + Last := Last + 1; end loop; end if; @@ -197,22 +211,27 @@ package body Fmap is procedure Report_Truncated is begin - Write_Str ("warning: mapping file """); - Write_Str (File_Name); - Write_Line (""" is truncated"); + if not Quiet_Output then + Write_Str ("warning: mapping file """); + Write_Str (File_Name); + Write_Line (""" is truncated"); + end if; end Report_Truncated; -- Start of procedure Initialize begin + Empty_Tables; Name_Len := File_Name'Length; Name_Buffer (1 .. Name_Len) := File_Name; Read_Source_File (Name_Enter, 0, Hi, Src, Config); if Src = null then - Write_Str ("warning: could not read mapping file """); - Write_Str (File_Name); - Write_Line (""""); + if not Quiet_Output then + Write_Str ("warning: could not read mapping file """); + Write_Str (File_Name); + Write_Line (""""); + end if; else BS := To_Big_String_Ptr (Src); @@ -225,14 +244,14 @@ package body Fmap is -- Exit if end of file has been reached - exit when Deb > Fin; + exit when First > Last; - pragma Assert (Fin >= Deb + 2); - pragma Assert (SP (Fin - 1) = '%'); - pragma Assert (SP (Fin) = 's' or else SP (Fin) = 'b'); + pragma Assert (Last >= First + 2); + pragma Assert (SP (Last - 1) = '%'); + pragma Assert (SP (Last) = 's' or else SP (Last) = 'b'); - Name_Len := Fin - Deb + 1; - Name_Buffer (1 .. Name_Len) := SP (Deb .. Fin); + Name_Len := Last - First + 1; + Name_Buffer (1 .. Name_Len) := SP (First .. Last); Uname := Name_Find; -- Get the file name @@ -241,14 +260,14 @@ package body Fmap is -- If end of line has been reached, file is truncated - if Deb > Fin then + if First > Last then Report_Truncated; Empty_Tables; return; end if; - Name_Len := Fin - Deb + 1; - Name_Buffer (1 .. Name_Len) := SP (Deb .. Fin); + Name_Len := Last - First + 1; + Name_Buffer (1 .. Name_Len) := SP (First .. Last); Fname := Name_Find; -- Get the path name @@ -257,34 +276,48 @@ package body Fmap is -- If end of line has been reached, file is truncated - if Deb > Fin then + if First > Last then Report_Truncated; Empty_Tables; return; end if; - Name_Len := Fin - Deb + 1; - Name_Buffer (1 .. Name_Len) := SP (Deb .. Fin); + Name_Len := Last - First + 1; + Name_Buffer (1 .. Name_Len) := SP (First .. Last); Pname := Name_Find; -- Check for duplicate entries if Unit_Hash_Table.Get (Uname) /= No_Entry then - Write_Str ("warning: duplicate entry """); - Write_Str (Get_Name_String (Uname)); - Write_Str (""" in mapping file """); - Write_Str (File_Name); - Write_Line (""""); + if not Quiet_Output then + Write_Str ("warning: duplicate entry """); + Write_Str (Get_Name_String (Uname)); + Write_Str (""" in mapping file """); + Write_Str (File_Name); + Write_Line (""""); + The_Mapping := + File_Mapping.Table (Unit_Hash_Table.Get (Uname)); + Write_Line (Get_Name_String (The_Mapping.Uname)); + Write_Line (Get_Name_String (The_Mapping.Fname)); + end if; + Empty_Tables; return; end if; if File_Hash_Table.Get (Fname) /= No_Entry then - Write_Str ("warning: duplicate entry """); - Write_Str (Get_Name_String (Fname)); - Write_Str (""" in mapping file """); - Write_Str (File_Name); - Write_Line (""""); + if not Quiet_Output then + Write_Str ("warning: duplicate entry """); + Write_Str (Get_Name_String (Fname)); + Write_Str (""" in mapping file """); + Write_Str (File_Name); + Write_Line (""""); + The_Mapping := + Path_Mapping.Table (File_Hash_Table.Get (Fname)); + Write_Line (Get_Name_String (The_Mapping.Uname)); + Write_Line (Get_Name_String (The_Mapping.Fname)); + end if; + Empty_Tables; return; end if; @@ -294,6 +327,11 @@ package body Fmap is Add_To_File_Map (Uname, Fname, Pname); end loop; end if; + + -- Record the length of the two mapping tables + + Last_In_Table := File_Mapping.Last; + end Initialize; ---------------------- @@ -307,7 +345,7 @@ package body Fmap is if The_Index = No_Entry then return No_File; else - return File_Mapping.Table (The_Index); + return File_Mapping.Table (The_Index).Fname; end if; end Mapped_File_Name; @@ -324,8 +362,83 @@ package body Fmap is if Index = No_Entry then return No_File; else - return Path_Mapping.Table (Index); + return Path_Mapping.Table (Index).Fname; end if; end Mapped_Path_Name; + ------------------------- + -- Update_Mapping_File -- + ------------------------- + + procedure Update_Mapping_File (File_Name : String) is + File : File_Descriptor; + + procedure Put_Line (Name : Name_Id); + -- Put Name as a line in the Mapping File + + -------------- + -- Put_Line -- + -------------- + + procedure Put_Line (Name : Name_Id) is + N_Bytes : Integer; + begin + Get_Name_String (Name); + Name_Len := Name_Len + 1; + Name_Buffer (Name_Len) := ASCII.LF; + N_Bytes := Write (File, Name_Buffer (1)'Address, Name_Len); + + if N_Bytes < Name_Len then + Fail ("disk full"); + end if; + + end Put_Line; + + -- Start of Update_Mapping_File + + begin + + -- Only Update if there are new entries in the mappings + + if Last_In_Table < File_Mapping.Last then + + -- If the tables have been emptied, recreate the file. + -- Otherwise, append to it. + + if Last_In_Table = 0 then + declare + Discard : Boolean; + + begin + Delete_File (File_Name, Discard); + end; + + File := Create_File (File_Name, Binary); + + else + File := Open_Read_Write (Name => File_Name, Fmode => Binary); + end if; + + if File /= Invalid_FD then + if Last_In_Table > 0 then + Lseek (File, 0, Seek_End); + end if; + + for Unit in Last_In_Table + 1 .. File_Mapping.Last loop + Put_Line (File_Mapping.Table (Unit).Uname); + Put_Line (File_Mapping.Table (Unit).Fname); + Put_Line (Path_Mapping.Table (Unit).Fname); + end loop; + + Close (File); + + elsif not Quiet_Output then + Write_Str ("warning: could not open mapping file """); + Write_Str (File_Name); + Write_Line (""" for update"); + end if; + + end if; + end Update_Mapping_File; + end Fmap; |