#define EXPAND_ARGV_RATE 128
static void
-append_arg (int *index, LPWSTR value, char ***argv, int *last)
+append_arg (int *index, LPWSTR dir, LPWSTR value,
+ char ***argv, int *last, int quoted)
{
int size;
+ LPWSTR fullvalue;
+ int vallen = _tcslen (value);
+ int dirlen;
+
+ if (dir == NULL)
+ {
+ /* no dir prefix */
+ dirlen = 0;
+ fullvalue = xmalloc ((vallen + 1) * sizeof(TCHAR));
+ }
+ else
+ {
+ /* Add dir first */
+ dirlen = _tcslen (dir);
+
+ fullvalue = xmalloc ((dirlen + vallen + 1) * sizeof(TCHAR));
+ _tcscpy (fullvalue, dir);
+ }
+
+ /* Append value */
+
+ if (quoted)
+ {
+ _tcsncpy (fullvalue + dirlen, value + 1, vallen - 1);
+ fullvalue [dirlen + vallen - sizeof(TCHAR)] = _T('\0');
+ }
+ else
+ _tcscpy (fullvalue + dirlen, value);
if (*last <= *index)
{
*argv = (char **) xrealloc (*argv, (*last) * sizeof (char *));
}
- size = WS2SC (NULL, value, 0);
- (*argv)[*index] = (char *) xmalloc (size + 1);
- WS2SC ((*argv)[*index], value, size);
+ size = WS2SC (NULL, fullvalue, 0);
+ (*argv)[*index] = (char *) xmalloc (size + sizeof(TCHAR));
+ WS2SC ((*argv)[*index], fullvalue, size);
+
+ free (fullvalue);
(*index)++;
}
/* argv[0] is the executable full path-name. */
SearchPath (NULL, wargv[0], _T(".exe"), MAX_PATH, result, NULL);
- append_arg (&argc_expanded, result, &gnat_argv, &last);
+ append_arg (&argc_expanded, NULL, result, &gnat_argv, &last, 0);
for (k=1; k<wargc; k++)
{
/* Wilcards are present, append all corresponding matches. */
WIN32_FIND_DATA FileData;
HANDLE hDir = FindFirstFile (wargv[k], &FileData);
+ LPWSTR dir = NULL;
+ LPWSTR ldir = _tcsrchr (wargv[k], _T('\\'));
+
+ if (ldir == NULL)
+ ldir = _tcsrchr (wargv[k], _T('/'));
if (hDir == INVALID_HANDLE_VALUE)
{
/* No match, append arg as-is. */
- append_arg (&argc_expanded, wargv[k], &gnat_argv, &last);
+ append_arg (&argc_expanded, NULL, wargv[k],
+ &gnat_argv, &last, quoted);
}
else
{
+ if (ldir != NULL)
+ {
+ int n = ldir - wargv[k] + 1;
+ dir = xmalloc ((n + 1) * sizeof (TCHAR));
+ _tcsncpy (dir, wargv[k], n);
+ dir[n] = _T('\0');
+ }
+
/* Append first match and all remaining ones. */
do {
- append_arg (&argc_expanded,
- FileData.cFileName, &gnat_argv, &last);
+ /* Do not add . and .. special entries */
+
+ if (_tcscmp (FileData.cFileName, _T(".")) != 0
+ && _tcscmp (FileData.cFileName, _T("..")) != 0)
+ append_arg (&argc_expanded, dir, FileData.cFileName,
+ &gnat_argv, &last, 0);
} while (FindNextFile (hDir, &FileData));
FindClose (hDir);
+
+ if (dir != NULL)
+ free (dir);
}
}
else
{
/* No wildcard. Store parameter as-is. Remove quote if
needed. */
- if (quoted)
- {
- int len = _tcslen (wargv[k]);
-
- /* Remove ending quote */
- wargv[k][len-1] = _T('\0');
- append_arg
- (&argc_expanded, &wargv[k][1], &gnat_argv, &last);
- }
- else
- append_arg (&argc_expanded, wargv[k], &gnat_argv, &last);
+ append_arg (&argc_expanded, NULL, wargv[k],
+ &gnat_argv, &last, quoted);
}
}
declare
Name : String renames Name_Buffer (1 .. Name_Len);
- Inc : String renames Include_Dir_Default_Prefix.all;
+ Inc : String renames Include_Dir_Default_Prefix.all;
+
begin
if Debug.Debug_Flag_Dot_N then
Write_Line (Name);
and then Inc'Length < Name_Len
and then Name_Buffer (1 .. Inc'Length) = Inc
then
- null; -- Part of runtimes, so ignore it
+ -- Part of runtimes, so ignore it
+
+ null;
else
File_Name_Chars.Append_All (File_Name_Chars.Table_Type (Name));
begin
-- Allocate source buffer, allowing extra character at end for EOF
- -- Some systems (e.g. VMS) have file types that require one
- -- read per line, so read until we get the Len bytes or until
- -- there are no more characters.
+ -- Some systems (e.g. VMS) have file types that require one read per
+ -- line, so read until we get the Len bytes or until there are no
+ -- more characters.
Hi := Lo;
loop
Actual_Ptr (Hi) := EOF;
-- Now we need to work out the proper virtual origin pointer to
- -- return. This is exactly Actual_Ptr (0)'Address, but we have
- -- to be careful to suppress checks to compute this address.
+ -- return. This is exactly Actual_Ptr (0)'Address, but we have to
+ -- be careful to suppress checks to compute this address.
declare
pragma Suppress (All_Checks);
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2009, 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- --
-- Start of processing for Analyze_Attribute_Definition_Clause
begin
+ -- Process Ignore_Rep_Clauses option
+
if Ignore_Rep_Clauses then
case Id is
- -- The following should be ignored
+ -- The following should be ignored. They do not affect legality
+ -- and may be target dependent. The basic idea of -gnatI is to
+ -- ignore any rep clauses that may be target dependent but do not
+ -- affect legality (except possibly to be rejected because they
+ -- are incompatible with the compilation target).
when Attribute_Address |
Attribute_Alignment |
Rewrite (N, Make_Null_Statement (Sloc (N)));
return;
- -- The following should not be ignored
+ -- The following should not be ignored, because in the first place
+ -- they are reasonably portable, and should not cause problems in
+ -- compiling code from another target, and also they do affect
+ -- legality, e.g. failing to provide a stream attribute for a
+ -- type may make a program illegal.
when Attribute_External_Tag |
Attribute_Input |