+2009-04-16 Thomas Quinot <quinot@adacore.com>
+
+ * snames.ads-tmpl (Name_Defined): New predefined name for use by the
+ integrated preprocessor.
+
+ * prep.ads, prep.adb (Setup_Hooks): New subprogram.
+ (Initialize): Split into two subprograms, Initialize (to be called
+ prior to compiler command line processing) and Setup_Hooks (to be called
+ later on when the first source file is loaded).
+
+ * gprep.adb: Change call to Prep.Initialize to call to Prep.Setup_Hooks.
+ Add call to Prep.Initialize.
+
+ * sinput-l.adb, prepcomp.adb: Change call to Prep.Initialize to call
+ to Prep.Setup_Hooks.
+
+2009-04-16 Pascal Obry <obry@adacore.com>
+
+ * adaint.h, adaint.c (__gnat_chdir): New routine.
+ Simple wrapper routines used to convert to proper encoding on
+ Windows.
+
+ * s-crtl.ads: Use __gnat_chdir instead of direct call to the C library.
+
+ * a-direct.adb, g-dirope.adb: Use chdir from System.CRTL.
+
2009-04-16 Quentin Ochem <ochem@adacore.com>
* sinput-p.adb (Clear_Source_File_Table): Use Sinput.Initialize instead
procedure Set_Directory (Directory : String) is
C_Dir_Name : constant String := Directory & ASCII.NUL;
-
- function chdir (Dir_Name : String) return Integer;
- pragma Import (C, chdir, "chdir");
-
begin
if not Is_Valid_Path_Name (Directory) then
raise Name_Error with
#endif
}
+/* Changing directory. */
+
+int
+__gnat_chdir (char *path)
+{
+#if defined (__MINGW32__) && ! defined (__vxworks) && ! defined (CROSS_COMPILE)
+ {
+ TCHAR wpath[GNAT_MAX_PATH_LEN];
+
+ S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
+ return _tchdir (wpath);
+ }
+#else
+ return chdir (path);
+#endif
+}
+
FILE *
__gnat_fopen (char *path, char *mode, int encoding ATTRIBUTE_UNUSED)
{
struct stat *);
extern int __gnat_unlink (char *);
extern int __gnat_rename (char *, char *);
+extern int __gnat_chdir (char *);
extern FILE *__gnat_fopen (char *, char *, int);
extern FILE *__gnat_freopen (char *, char *, FILE *,
with Opt; use Opt;
with Osint;
with Par;
+with Prep;
with Prepcomp;
with Restrict; use Restrict;
with Rident; use Rident;
Fname.UF.Initialize;
Checks.Initialize;
Sem_Warn.Initialize;
+ Prep.Initialize;
-- Create package Standard
procedure Change_Dir (Dir_Name : Dir_Name_Str) is
C_Dir_Name : constant String := Dir_Name & ASCII.NUL;
-
- function chdir (Dir_Name : String) return Integer;
- pragma Import (C, chdir, "chdir");
-
begin
if chdir (C_Dir_Name) /= 0 then
raise Directory_Error;
Namet.Initialize;
Snames.Initialize;
Stringt.Initialize;
+ Prep.Initialize;
-- Initialize the preprocessor
- Prep.Initialize
+ Prep.Setup_Hooks
(Error_Msg => Errutil.Error_Msg'Access,
Scan => Scanner.Scan'Access,
Set_Ignore_Errors => Errutil.Set_Ignore_Errors'Access,
String_False : String_Id;
-- "false", as a string_id
- Name_Defined : Name_Id;
- -- defined, as a name_id
-
---------------
-- Behaviour --
---------------
-- Initialize --
----------------
- procedure Initialize
- (Error_Msg : Error_Msg_Proc;
- Scan : Scan_Proc;
- Set_Ignore_Errors : Set_Ignore_Errors_Proc;
- Put_Char : Put_Char_Proc;
- New_EOL : New_EOL_Proc)
- is
+ procedure Initialize is
begin
if not Already_Initialized then
Start_String;
Start_String;
Empty_String := End_String;
- Name_Len := 7;
- Name_Buffer (1 .. Name_Len) := "defined";
- Name_Defined := Name_Find;
-
Start_String;
Store_String_Chars ("False");
String_False := End_String;
Already_Initialized := True;
end if;
-
- Prep.Error_Msg := Error_Msg;
- Prep.Scan := Scan;
- Prep.Set_Ignore_Errors := Set_Ignore_Errors;
- Prep.Put_Char := Put_Char;
- Prep.New_EOL := New_EOL;
end Initialize;
------------------
Source_Modified := No_Error_Found and Modified;
end Preprocess;
+ -----------------
+ -- Setup_Hooks --
+ -----------------
+
+ procedure Setup_Hooks
+ (Error_Msg : Error_Msg_Proc;
+ Scan : Scan_Proc;
+ Set_Ignore_Errors : Set_Ignore_Errors_Proc;
+ Put_Char : Put_Char_Proc;
+ New_EOL : New_EOL_Proc)
+ is
+ begin
+ pragma Assert (Already_Initialized);
+
+ Prep.Error_Msg := Error_Msg;
+ Prep.Scan := Scan;
+ Prep.Set_Ignore_Errors := Set_Ignore_Errors;
+ Prep.Put_Char := Put_Char;
+ Prep.New_EOL := New_EOL;
+ end Setup_Hooks;
+
end Prep;
type New_EOL_Proc is access procedure;
- procedure Initialize
+ procedure Initialize;
+ -- Initialize the preprocessor's global structures
+
+ procedure Setup_Hooks
(Error_Msg : Error_Msg_Proc;
Scan : Scan_Proc;
Set_Ignore_Errors : Set_Ignore_Errors_Proc;
Put_Char : Put_Char_Proc;
New_EOL : New_EOL_Proc);
+ -- Set the i/o hooks used by the preprocessor
procedure Parse_Def_File;
-- Parse the definition file. The definition file must have already been
-- Initialize the preprocessor and set the characteristics of the
-- scanner for a definition file.
- Prep.Initialize
+ Prep.Setup_Hooks
(Error_Msg => Errout.Error_Msg'Access,
Scan => Scn.Scanner.Scan'Access,
Set_Ignore_Errors => Errout.Set_Ignore_Errors'Access,
procedure rmdir (dir_name : String);
pragma Import (C, rmdir, "rmdir");
+ function chdir (dir_name : String) return int;
+ pragma Import (C, chdir, "__gnat_chdir");
+
function setvbuf
(stream : FILEs;
buffer : chars;
Prep_Buffer_Last := 0;
- -- Initialize the preprocessor
+ -- Initialize the preprocessor hooks
- Prep.Initialize
+ Prep.Setup_Hooks
(Error_Msg => Errout.Error_Msg'Access,
Scan => Scn.Scanner.Scan'Access,
Set_Ignore_Errors => Errout.Set_Ignore_Errors'Access,
Name_Put_Line : constant Name_Id := N + $;
Name_To : constant Name_Id := N + $;
+ -- Name used by the integrated preprocessor
+
+ Name_Defined : constant Name_Id := N + $;
+
-- Names for packages that are treated specially by the compiler
Name_Exception_Traces : constant Name_Id := N + $;