Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
a2b22788
Commit
a2b22788
authored
Dec 24, 1991
by
Richard Stallman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
From-SVN: r139
parent
52c00c9c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
286 additions
and
272 deletions
+286
-272
gcc/protoize.c
+286
-272
No files found.
gcc/protoize.c
View file @
a2b22788
...
@@ -28,20 +28,33 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
...
@@ -28,20 +28,33 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define __STDC__ 1
#define __STDC__ 1
#endif
/* defined(__cplusplus) && !defined(__STDC__) */
#endif
/* defined(__cplusplus) && !defined(__STDC__) */
#if defined (__cplusplus)
#if defined(__GNUC__) || defined (__GNUG__)
extern
"C"
{
/* Start of extern "C" section. */
#define VOLATILE volatile
#endif
/* defined(__cplusplus) */
#else
#define VOLATILE
#endif
/* It is incorrect to include config.h here, because this file is being
/* It is incorrect to include config.h here, because this file is being
compiled for the target, and hence definitions concerning only the host
compiled for the target, and hence definitions concerning only the host
do not apply. */
do not apply. Instead we include tconfig.h, which is the xm file
*for the target*, which also includes the tm.h file *for the target*.
This way, we get definitions of POSIX, USG and VMS for the target. */
#include "tm.h"
#include "tconfig.h"
/* The documentation says to use TARGET_POSIX, so check for it as well
as POSIX. */
#if defined(TARGET_POSIX) && !defined(POSIX)
#define POSIX
#endif
/* If the user asked for POSIX via _POSIX_SOURCE, turn on POSIX code. */
#if defined(_POSIX_SOURCE) && !defined(POSIX)
#define POSIX
#endif
/* On a POSIX system, request definition of all the POSIX facilities. */
/* On a POSIX system, request definition of all the POSIX facilities. */
/* We use TARGET_POSIX because protoize is compiled for the target system,
#if defined(POSIX) && !defined(_POSIX_SOURCE)
and TARGET_POSIX is the symbol that describes it in tm.h. */
#ifdef TARGET_POSIX
#define _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#endif
...
@@ -56,7 +69,6 @@ extern "C" { /* Start of extern "C" section. */
...
@@ -56,7 +69,6 @@ extern "C" { /* Start of extern "C" section. */
#include "gvarargs.h"
#include "gvarargs.h"
#include "getopt.h"
#include "getopt.h"
#include <limits.h>
#ifndef PATH_MAX
/* <limits.h> defines this on most POSIX systems. */
#ifndef PATH_MAX
/* <limits.h> defines this on most POSIX systems. */
#include <sys/param.h>
#include <sys/param.h>
#define PATH_MAX MAXPATHLEN
#define PATH_MAX MAXPATHLEN
...
@@ -80,9 +92,10 @@ extern "C" { /* Start of extern "C" section. */
...
@@ -80,9 +92,10 @@ extern "C" { /* Start of extern "C" section. */
#endif
#endif
extern
int
errno
;
extern
int
errno
;
extern
char
*
sys_errlist
[];
extern
char
*
sys_errlist
[];
extern
char
*
version_string
;
#if defined(
TARGET_
POSIX)
#if defined(POSIX)
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <unistd.h>
...
@@ -109,7 +122,7 @@ extern char * sys_errlist[];
...
@@ -109,7 +122,7 @@ extern char * sys_errlist[];
#endif
/* (_POSIX_VERSION < 199009) */
#endif
/* (_POSIX_VERSION < 199009) */
#else
/* !defined(
TARGET_
POSIX) */
#else
/* !defined(POSIX) */
#define R_OK 4
/* Test for Read permission */
#define R_OK 4
/* Test for Read permission */
#define W_OK 2
/* Test for Write permission */
#define W_OK 2
/* Test for Write permission */
...
@@ -130,14 +143,19 @@ extern char *getwd (char *);
...
@@ -130,14 +143,19 @@ extern char *getwd (char *);
extern
char
*
getcwd
(
char
*
,
size_t
);
extern
char
*
getcwd
(
char
*
,
size_t
);
#endif
/* (defined (USG) || defined (VMS)) */
#endif
/* (defined (USG) || defined (VMS)) */
/* Declaring stat, kill or __flsbuf with a prototype
/* Declaring stat or __flsbuf with a prototype
causes conflicts with system headers on some systems.
causes conflicts with system headers on some systems. */
Declaring abort causes trouble if it is a macro. */
#ifndef abort
extern
VOLATILE
void
abort
(
void
);
#endif
extern
int
kill
(
int
,
int
);
extern
int
creat
(
const
char
*
,
int
);
extern
int
creat
(
const
char
*
,
int
);
extern
int
open
(
const
char
*
,
int
,
...);
extern
int
open
(
const
char
*
,
int
,
...);
#if 0 /* These conflict with stdio.h on some systems. */
extern int fprintf (FILE *, const char *, ...);
extern int fprintf (FILE *, const char *, ...);
extern int printf (const char *, ...);
extern int printf (const char *, ...);
#endif /* 0 */
extern
void
exit
(
int
);
extern
void
exit
(
int
);
extern
void
*
malloc
(
size_t
);
extern
void
*
malloc
(
size_t
);
extern
void
*
realloc
(
void
*
,
size_t
);
extern
void
*
realloc
(
void
*
,
size_t
);
...
@@ -160,7 +178,11 @@ extern void longjmp (jmp_buf, int);
...
@@ -160,7 +178,11 @@ extern void longjmp (jmp_buf, int);
extern
char
*
strcat
(
char
*
,
const
char
*
);
extern
char
*
strcat
(
char
*
,
const
char
*
);
extern
int
strcmp
(
const
char
*
,
const
char
*
);
extern
int
strcmp
(
const
char
*
,
const
char
*
);
extern
char
*
strcpy
(
char
*
,
const
char
*
);
extern
char
*
strcpy
(
char
*
,
const
char
*
);
#if 0 /* size_t from sys/types.h may fail to match GCC.
If so, we would get a warning from this.
So do without the prototype. */
extern size_t strlen(const char *);
extern size_t strlen(const char *);
#endif
extern
int
strncmp
(
const
char
*
,
const
char
*
,
size_t
);
extern
int
strncmp
(
const
char
*
,
const
char
*
,
size_t
);
extern
char
*
strncpy
(
char
*
,
const
char
*
,
size_t
);
extern
char
*
strncpy
(
char
*
,
const
char
*
,
size_t
);
extern
char
*
strrchr
(
const
char
*
,
int
);
extern
char
*
strrchr
(
const
char
*
,
int
);
...
@@ -168,13 +190,11 @@ extern char * strrchr(const char *, int);
...
@@ -168,13 +190,11 @@ extern char * strrchr(const char *, int);
#if !(defined (USG) || defined (VMS))
#if !(defined (USG) || defined (VMS))
extern
int
vfork
(
void
);
extern
int
vfork
(
void
);
#define fork vfork
#define fork vfork
#else
extern
int
fork
(
void
);
#endif
/* !(defined (USG) || defined (VMS)) */
#endif
/* !(defined (USG) || defined (VMS)) */
#endif
/* !defined(TARGET_POSIX) */
#endif
/* !defined(POSIX) */
#if defined (__cplusplus)
}
/* End of extern "C" section. */
#endif
/* defined(__cplusplus) */
/* Look for these where the `const' qualifier is intentionally cast aside. */
/* Look for these where the `const' qualifier is intentionally cast aside. */
...
@@ -205,15 +225,11 @@ typedef const void * const_pointer_type;
...
@@ -205,15 +225,11 @@ typedef const void * const_pointer_type;
#define STD_PROTO_DIR "/usr/local/lib"
#define STD_PROTO_DIR "/usr/local/lib"
#endif
/* !defined(STD_PROTO_DIR) */
#endif
/* !defined(STD_PROTO_DIR) */
/* String to identify this version. */
static
const
char
*
const
version_string
=
"Version 1.07"
;
/* Suffix of aux_info files. */
/* Suffix of aux_info files. */
static
const
char
*
const
aux_info_suffix
=
".X"
;
static
const
char
*
const
aux_info_suffix
=
".X"
;
/* String to attach to
path
names for saved versions of original files. */
/* String to attach to
file
names for saved versions of original files. */
static
const
char
*
const
save_suffix
=
".save"
;
static
const
char
*
const
save_suffix
=
".save"
;
...
@@ -229,10 +245,10 @@ static const char * const syscalls_filename = "SYSCALLS.c";
...
@@ -229,10 +245,10 @@ static const char * const syscalls_filename = "SYSCALLS.c";
static
const
char
*
const
default_syscalls_dir
=
STD_PROTO_DIR
;
static
const
char
*
const
default_syscalls_dir
=
STD_PROTO_DIR
;
/* Variable to hold the complete absolutized
path
name of the SYSCALLS.c.X
/* Variable to hold the complete absolutized
file
name of the SYSCALLS.c.X
file. */
file. */
static
char
*
syscalls_
path
name
;
static
char
*
syscalls_
absolute_file
name
;
#endif
/* !defined(UNPROTOIZE) */
#endif
/* !defined(UNPROTOIZE) */
...
@@ -333,13 +349,15 @@ struct string_list *exclude_list;
...
@@ -333,13 +349,15 @@ struct string_list *exclude_list;
static
const
char
*
const
other_var_style
=
"stdarg"
;
static
const
char
*
const
other_var_style
=
"stdarg"
;
#else
/* !defined(UNPROTOIZE) */
#else
/* !defined(UNPROTOIZE) */
static
const
char
*
const
other_var_style
=
"varargs"
;
static
const
char
*
const
other_var_style
=
"varargs"
;
static
const
char
*
const
varargs_style_indicator
=
STRINGIFY
(
va_alist
);
/* Note that this is a string containing the expansion of va_alist.
But in `main' we discard all but the first token. */
static
const
char
*
varargs_style_indicator
=
STRINGIFY
(
va_alist
);
#endif
/* !defined(UNPROTOIZE) */
#endif
/* !defined(UNPROTOIZE) */
/* The following two types are used to create hash tables. In this program,
/* The following two types are used to create hash tables. In this program,
there are two hash tables which are used to store and quickly lookup two
there are two hash tables which are used to store and quickly lookup two
different classes of strings. The first type of strings stored in the
different classes of strings. The first type of strings stored in the
first hash table are absolute
path
names of files which protoize needs to
first hash table are absolute
file
names of files which protoize needs to
know about. The second type of strings (stored in the second hash table)
know about. The second type of strings (stored in the second hash table)
are function names. It is this second class of strings which really
are function names. It is this second class of strings which really
inspired the use of the hash tables, because there may be a lot of them. */
inspired the use of the hash tables, because there may be a lot of them. */
...
@@ -353,10 +371,10 @@ typedef struct file_info_struct file_info;
...
@@ -353,10 +371,10 @@ typedef struct file_info_struct file_info;
typedef
struct
f_list_chain_item_struct
f_list_chain_item
;
typedef
struct
f_list_chain_item_struct
f_list_chain_item
;
/* In the struct below, note that the "_info" field has two different uses
/* In the struct below, note that the "_info" field has two different uses
depending on the type of hash table we are in (i.e. either the
path
names
depending on the type of hash table we are in (i.e. either the
file
names
hash table or the function names hash table). In the
path
names hash table
hash table or the function names hash table). In the
file
names hash table
the info fields of the entries point to the file_info struct which is
the info fields of the entries point to the file_info struct which is
associated with each
pathname (1 per path
name). In the function names
associated with each
filename (1 per file
name). In the function names
hash table, the info field points to the head of a singly linked list of
hash table, the info field points to the head of a singly linked list of
def_dec_info entries which are all defs or decs of the function whose
def_dec_info entries which are all defs or decs of the function whose
name is pointed to by the "symbol" field. Keeping all of the defs/decs
name is pointed to by the "symbol" field. Keeping all of the defs/decs
...
@@ -380,7 +398,7 @@ struct hash_table_entry_struct {
...
@@ -380,7 +398,7 @@ struct hash_table_entry_struct {
typedef
hash_table_entry
hash_table
[
HASH_TABLE_SIZE
];
typedef
hash_table_entry
hash_table
[
HASH_TABLE_SIZE
];
/* The following struct holds all of the important information about any
/* The following struct holds all of the important information about any
single
path
name (e.g. file) which we need to know about. */
single
file
name (e.g. file) which we need to know about. */
struct
file_info_struct
{
struct
file_info_struct
{
const
hash_table_entry
*
hash_entry
;
/* -> to associated hash entry */
const
hash_table_entry
*
hash_entry
;
/* -> to associated hash entry */
...
@@ -439,7 +457,7 @@ struct def_dec_info_struct {
...
@@ -439,7 +457,7 @@ struct def_dec_info_struct {
#endif
/* !defined(UNPROTOIZE) */
#endif
/* !defined(UNPROTOIZE) */
};
};
/* Pointer to the tail component of the
path
name by which this program was
/* Pointer to the tail component of the
file
name by which this program was
invoked. Used everywhere in error and warning messages. */
invoked. Used everywhere in error and warning messages. */
static
const
char
*
pname
;
static
const
char
*
pname
;
...
@@ -479,12 +497,12 @@ static int filename_index = 0;
...
@@ -479,12 +497,12 @@ static int filename_index = 0;
/* Count of command line arguments which were "filename" arguments. */
/* Count of command line arguments which were "filename" arguments. */
static
int
base_source_files
=
0
;
static
int
n_
base_source_files
=
0
;
/* Points to a malloc'ed list of pointers to all of the filenames of base
/* Points to a malloc'ed list of pointers to all of the filenames of base
source files which were specified on the command line. */
source files which were specified on the command line. */
static
const
char
**
base_source_
path
s
;
static
const
char
**
base_source_
filename
s
;
/* Line number of the line within the current aux_info file that we
/* Line number of the line within the current aux_info file that we
are currently processing. Used for error messages in case the prototypes
are currently processing. Used for error messages in case the prototypes
...
@@ -494,13 +512,13 @@ static int current_aux_info_lineno;
...
@@ -494,13 +512,13 @@ static int current_aux_info_lineno;
/* Pointer to the name of the source file currently being converted. */
/* Pointer to the name of the source file currently being converted. */
static
const
char
*
convert_
path
;
static
const
char
*
convert_
filename
;
/* Pointer to relative root string (taken from aux_info file) which indicates
/* Pointer to relative root string (taken from aux_info file) which indicates
where directory the user was in when he did the compilation step that
where directory the user was in when he did the compilation step that
produced the containing aux_info file. */
produced the containing aux_info file. */
static
const
char
*
invocation_
path
;
static
const
char
*
invocation_
filename
;
/* Pointer to the base of the input buffer that holds the original text for the
/* Pointer to the base of the input buffer that holds the original text for the
source file currently being converted. */
source file currently being converted. */
...
@@ -555,9 +573,9 @@ static const char *last_known_line_start;
...
@@ -555,9 +573,9 @@ static const char *last_known_line_start;
static
int
last_known_line_number
;
static
int
last_known_line_number
;
/* The
path
names hash table. */
/* The
file
names hash table. */
static
hash_table
path
name_primary
;
static
hash_table
file
name_primary
;
/* The function names hash table. */
/* The function names hash table. */
...
@@ -568,7 +586,7 @@ static hash_table function_name_primary;
...
@@ -568,7 +586,7 @@ static hash_table function_name_primary;
static
jmp_buf
source_confusion_recovery
;
static
jmp_buf
source_confusion_recovery
;
/* A pointer to the current directory
path
name (used by abspath). */
/* A pointer to the current directory
file
name (used by abspath). */
static
char
*
cwd_buffer
;
static
char
*
cwd_buffer
;
...
@@ -584,7 +602,7 @@ static char * saved_repl_write_ptr;
...
@@ -584,7 +602,7 @@ static char * saved_repl_write_ptr;
/* Forward declaration. */
/* Forward declaration. */
static
const
char
*
shortpath
(
const
char
*
cwd
,
const
char
*
path
name
);
static
const
char
*
shortpath
(
const
char
*
cwd
,
const
char
*
file
name
);
/* Allocate some space, but check that the allocation was successful. */
/* Allocate some space, but check that the allocation was successful. */
...
@@ -596,7 +614,7 @@ xmalloc (size_t byte_count)
...
@@ -596,7 +614,7 @@ xmalloc (size_t byte_count)
if
((
rv
=
malloc
(
byte_count
))
==
NULL
)
if
((
rv
=
malloc
(
byte_count
))
==
NULL
)
{
{
fprintf
(
stderr
,
"
\n
%s: fatal error: can't allocate %u more bytes of memory
\n
"
,
fprintf
(
stderr
,
"
\n
%s: fatal error: can't allocate %u more bytes of memory
\n
"
,
pname
,
byte_count
);
pname
,
byte_count
);
exit
(
1
);
exit
(
1
);
return
0
;
/* avoid warnings */
return
0
;
/* avoid warnings */
}
}
...
@@ -614,7 +632,7 @@ xrealloc (pointer_type old_space, size_t byte_count)
...
@@ -614,7 +632,7 @@ xrealloc (pointer_type old_space, size_t byte_count)
if
((
rv
=
realloc
(
old_space
,
byte_count
))
==
NULL
)
if
((
rv
=
realloc
(
old_space
,
byte_count
))
==
NULL
)
{
{
fprintf
(
stderr
,
"
\n
%s: fatal error: can't allocate %u more bytes of memory
\n
"
,
fprintf
(
stderr
,
"
\n
%s: fatal error: can't allocate %u more bytes of memory
\n
"
,
pname
,
byte_count
);
pname
,
byte_count
);
exit
(
1
);
exit
(
1
);
return
0
;
/* avoid warnings */
return
0
;
/* avoid warnings */
}
}
...
@@ -636,7 +654,7 @@ xfree (const_pointer_type p)
...
@@ -636,7 +654,7 @@ xfree (const_pointer_type p)
/* Make a copy of a string INPUT with size SIZE. */
/* Make a copy of a string INPUT with size SIZE. */
static
char
*
static
char
*
savestring
(
char
*
input
,
int
size
)
savestring
(
c
onst
c
har
*
input
,
int
size
)
{
{
char
*
output
=
(
char
*
)
xmalloc
(
size
+
1
);
char
*
output
=
(
char
*
)
xmalloc
(
size
+
1
);
strcpy
(
output
,
input
);
strcpy
(
output
,
input
);
...
@@ -683,7 +701,7 @@ substr (const char *s1, const char *const s2)
...
@@ -683,7 +701,7 @@ substr (const char *s1, const char *const s2)
{
{
const
char
*
p1
;
const
char
*
p1
;
const
char
*
p2
;
const
char
*
p2
;
char
c
;
int
c
;
for
(
p1
=
s1
,
p2
=
s2
;
c
=
*
p2
;
p1
++
,
p2
++
)
for
(
p1
=
s1
,
p2
=
s2
;
c
=
*
p2
;
p1
++
,
p2
++
)
if
(
*
p1
!=
c
)
if
(
*
p1
!=
c
)
...
@@ -729,15 +747,16 @@ static void
...
@@ -729,15 +747,16 @@ static void
usage
(
void
)
usage
(
void
)
{
{
#ifdef UNPROTOIZE
#ifdef UNPROTOIZE
fprintf
(
stderr
,
"%s: usage '%s [ -VqfnkN ] [ -i <istring> ] [ pathname ... ]'
\n
"
,
fprintf
(
stderr
,
"%s: usage '%s [ -VqfnkN ] [ -i <istring> ] [ filename ... ]'
\n
"
,
pname
,
pname
);
#else
/* !defined(UNPROTOIZE) */
#else
/* !defined(UNPROTOIZE) */
fprintf
(
stderr
,
"%s: usage '%s [ -VqfnkNlgC ] [ -B <diname> ] [ pathname ... ]'
\n
"
,
fprintf
(
stderr
,
"%s: usage '%s [ -VqfnkNlgC ] [ -B <diname> ] [ filename ... ]'
\n
"
,
pname
,
pname
);
#endif
/* !defined(UNPROTOIZE) */
#endif
/* !defined(UNPROTOIZE) */
pname
,
pname
);
exit
(
1
);
exit
(
1
);
}
}
/* Return true if the given
pathname (assumed to be an absolute path
name)
/* Return true if the given
filename (assumed to be an absolute file
name)
designates a file residing anywhere beneath any one of the "system"
designates a file residing anywhere beneath any one of the "system"
include directories. */
include directories. */
...
@@ -747,7 +766,7 @@ in_system_include_dir (const char *path)
...
@@ -747,7 +766,7 @@ in_system_include_dir (const char *path)
struct
default_include
*
p
;
struct
default_include
*
p
;
if
(
path
[
0
]
!=
'/'
)
if
(
path
[
0
]
!=
'/'
)
abort
();
/* Must be an absolutized
path
name. */
abort
();
/* Must be an absolutized
file
name. */
for
(
p
=
include_defaults
;
p
->
fname
;
p
++
)
for
(
p
=
include_defaults
;
p
->
fname
;
p
++
)
if
(
!
strncmp
(
path
,
p
->
fname
,
strlen
(
p
->
fname
))
if
(
!
strncmp
(
path
,
p
->
fname
,
strlen
(
p
->
fname
))
...
@@ -757,7 +776,7 @@ in_system_include_dir (const char *path)
...
@@ -757,7 +776,7 @@ in_system_include_dir (const char *path)
}
}
#if 0
#if 0
/* Return true if the given
path
name designates a file that the user has
/* Return true if the given
file
name designates a file that the user has
read access to and for which the user has write access to the containing
read access to and for which the user has write access to the containing
directory. */
directory. */
...
@@ -777,7 +796,7 @@ file_could_be_converted (const char *path)
...
@@ -777,7 +796,7 @@ file_could_be_converted (const char *path)
if (dir_last_slash)
if (dir_last_slash)
*dir_last_slash = '\0';
*dir_last_slash = '\0';
else
else
abort (); /* Should have been an absolutized
path
name. */
abort (); /* Should have been an absolutized
file
name. */
}
}
if (access (path, W_OK))
if (access (path, W_OK))
...
@@ -786,7 +805,7 @@ file_could_be_converted (const char *path)
...
@@ -786,7 +805,7 @@ file_could_be_converted (const char *path)
return 1;
return 1;
}
}
/* Return true if the given
path
name designates a file that we are allowed
/* Return true if the given
file
name designates a file that we are allowed
to modify. Files which we should not attempt to modify are (a) "system"
to modify. Files which we should not attempt to modify are (a) "system"
include files, and (b) files which the user doesn't have write access to,
include files, and (b) files which the user doesn't have write access to,
and (c) files which reside in directories which the user doesn't have
and (c) files which reside in directories which the user doesn't have
...
@@ -811,14 +830,14 @@ file_normally_convertable (const char *path)
...
@@ -811,14 +830,14 @@ file_normally_convertable (const char *path)
if (dir_last_slash)
if (dir_last_slash)
*dir_last_slash = '\0';
*dir_last_slash = '\0';
else
else
abort (); /* Should have been an absolutized
path
name. */
abort (); /* Should have been an absolutized
file
name. */
}
}
if (access (path, R_OK))
if (access (path, R_OK))
{
{
if (!quiet_flag)
if (!quiet_flag)
fprintf (stderr, "%s: warning: no read access for file `%s'\n",
fprintf (stderr, "%s: warning: no read access for file `%s'\n",
pname, shortpath (NULL, path));
pname, shortpath (NULL, path));
return 0;
return 0;
}
}
...
@@ -826,7 +845,7 @@ file_normally_convertable (const char *path)
...
@@ -826,7 +845,7 @@ file_normally_convertable (const char *path)
{
{
if (!quiet_flag)
if (!quiet_flag)
fprintf (stderr, "%s: warning: no write access for file `%s'\n",
fprintf (stderr, "%s: warning: no write access for file `%s'\n",
pname, shortpath (NULL, path));
pname, shortpath (NULL, path));
return 0;
return 0;
}
}
...
@@ -834,7 +853,7 @@ file_normally_convertable (const char *path)
...
@@ -834,7 +853,7 @@ file_normally_convertable (const char *path)
{
{
if (!quiet_flag)
if (!quiet_flag)
fprintf (stderr, "%s: warning: no write access for dir containing `%s'\n",
fprintf (stderr, "%s: warning: no write access for dir containing `%s'\n",
pname, shortpath (NULL, path));
pname, shortpath (NULL, path));
return 0;
return 0;
}
}
...
@@ -983,7 +1002,7 @@ add_symbol (hash_table_entry *p, const char *s)
...
@@ -983,7 +1002,7 @@ add_symbol (hash_table_entry *p, const char *s)
return
p
;
return
p
;
}
}
/* Look for a particular function name or
path
name in the particular
/* Look for a particular function name or
file
name in the particular
hash table indicated by "hash_tab_p". If the name is not in the
hash table indicated by "hash_tab_p". If the name is not in the
given hash table, add it. Either way, return a pointer to the
given hash table, add it. Either way, return a pointer to the
hash table entry for the given name. */
hash table entry for the given name. */
...
@@ -1117,40 +1136,40 @@ continue_outer: ;
...
@@ -1117,40 +1136,40 @@ continue_outer: ;
return
(
got_unexpanded
?
dupstr
(
line_buf
)
:
0
);
return
(
got_unexpanded
?
dupstr
(
line_buf
)
:
0
);
}
}
/* Return the absolutized
path
name for the given relative
/* Return the absolutized
file
name for the given relative
pathname. Note that if that path
name is already absolute, it may
filename. Note that if that file
name is already absolute, it may
still be returned in a modified form because this routine also
still be returned in a modified form because this routine also
eliminates redundant slashes and single dots and eliminates double
eliminates redundant slashes and single dots and eliminates double
dots to get a shortest possible
path
name from the given input
dots to get a shortest possible
file
name from the given input
pathname. The absolutization of relative path
names is made by
filename. The absolutization of relative file
names is made by
assuming that the given
path
name is to be taken as relative to
assuming that the given
file
name is to be taken as relative to
the first argument (cwd) or to the current directory if cwd is
the first argument (cwd) or to the current directory if cwd is
NULL. */
NULL. */
static
char
*
static
char
*
abspath
(
const
char
*
cwd
,
const
char
*
rel_
path
name
)
abspath
(
const
char
*
cwd
,
const
char
*
rel_
file
name
)
{
{
/* Setup the current working directory as needed. */
/* Setup the current working directory as needed. */
const
char
*
cwd2
=
(
cwd
)
?
cwd
:
cwd_buffer
;
const
char
*
cwd2
=
(
cwd
)
?
cwd
:
cwd_buffer
;
char
*
const
abs_buffer
char
*
const
abs_buffer
=
(
char
*
)
alloca
(
strlen
(
cwd2
)
+
strlen
(
rel_
path
name
)
+
1
);
=
(
char
*
)
alloca
(
strlen
(
cwd2
)
+
strlen
(
rel_
file
name
)
+
1
);
char
*
endp
=
abs_buffer
;
char
*
endp
=
abs_buffer
;
char
*
outp
,
*
inp
;
char
*
outp
,
*
inp
;
/* Copy the
path
name (possibly preceeded by the current working
/* Copy the
file
name (possibly preceeded by the current working
directory name) into the absolutization buffer. */
directory name) into the absolutization buffer. */
{
{
const
char
*
src_p
;
const
char
*
src_p
;
if
(
rel_
path
name
[
0
]
!=
'/'
)
if
(
rel_
file
name
[
0
]
!=
'/'
)
{
{
src_p
=
cwd2
;
src_p
=
cwd2
;
while
(
*
endp
++
=
*
src_p
++
)
while
(
*
endp
++
=
*
src_p
++
)
continue
;
continue
;
*
(
endp
-
1
)
=
'/'
;
/* overwrite null */
*
(
endp
-
1
)
=
'/'
;
/* overwrite null */
}
}
src_p
=
rel_
path
name
;
src_p
=
rel_
file
name
;
while
(
*
endp
++
=
*
src_p
++
)
while
(
*
endp
++
=
*
src_p
++
)
continue
;
continue
;
if
(
endp
[
-
1
]
==
'/'
)
if
(
endp
[
-
1
]
==
'/'
)
...
@@ -1158,7 +1177,7 @@ abspath (const char *cwd, const char *rel_pathname)
...
@@ -1158,7 +1177,7 @@ abspath (const char *cwd, const char *rel_pathname)
}
}
/* Now make a copy of abs_buffer into abs_buffer, shortening the
/* Now make a copy of abs_buffer into abs_buffer, shortening the
path
name (by taking out slashes and dots) as we go. */
file
name (by taking out slashes and dots) as we go. */
outp
=
inp
=
abs_buffer
;
outp
=
inp
=
abs_buffer
;
*
outp
++
=
*
inp
++
;
/* copy first slash */
*
outp
++
=
*
inp
++
;
/* copy first slash */
...
@@ -1192,8 +1211,8 @@ abspath (const char *cwd, const char *rel_pathname)
...
@@ -1192,8 +1211,8 @@ abspath (const char *cwd, const char *rel_pathname)
point above the absolute root of the logical file
point above the absolute root of the logical file
system. */
system. */
fprintf
(
stderr
,
"%s:
fatal error: invalid path
name: %s
\n
"
,
fprintf
(
stderr
,
"%s:
invalid file
name: %s
\n
"
,
pname
,
rel_path
name
);
pname
,
rel_file
name
);
exit
(
1
);
exit
(
1
);
}
}
*++
outp
=
'\0'
;
*++
outp
=
'\0'
;
...
@@ -1216,22 +1235,22 @@ abspath (const char *cwd, const char *rel_pathname)
...
@@ -1216,22 +1235,22 @@ abspath (const char *cwd, const char *rel_pathname)
return
dupstr
(
abs_buffer
);
return
dupstr
(
abs_buffer
);
}
}
/* Given a
pathname (and possibly a directory name from which the path
name
/* Given a
filename (and possibly a directory name from which the file
name
is relative) return a string which is the shortest possible
is relative) return a string which is the shortest possible
equivalent for the corresponding full (absolutized)
path
name. The
equivalent for the corresponding full (absolutized)
file
name. The
shortest possible equivalent may be constructed by converting the
shortest possible equivalent may be constructed by converting the
absolutized
pathname to be a relative path
name (i.e. relative to
absolutized
filename to be a relative file
name (i.e. relative to
the actual current working directory). However if a relative
path
name
the actual current working directory). However if a relative
file
name
is longer, then the full absolute
path
name is returned.
is longer, then the full absolute
file
name is returned.
KNOWN BUG:
KNOWN BUG:
Note that "simple-minded" conversion of any given type of
path
name (either
Note that "simple-minded" conversion of any given type of
file
name (either
relative or absolute) may not result in a valid equivalent
path
name if any
relative or absolute) may not result in a valid equivalent
file
name if any
subpart of the original
path
name is actually a symbolic link. */
subpart of the original
file
name is actually a symbolic link. */
static
const
char
*
static
const
char
*
shortpath
(
const
char
*
cwd
,
const
char
*
path
name
)
shortpath
(
const
char
*
cwd
,
const
char
*
file
name
)
{
{
char
*
rel_buffer
;
char
*
rel_buffer
;
char
*
rel_buf_p
;
char
*
rel_buf_p
;
...
@@ -1239,7 +1258,7 @@ shortpath (const char *cwd, const char *pathname)
...
@@ -1239,7 +1258,7 @@ shortpath (const char *cwd, const char *pathname)
char
*
path_p
;
char
*
path_p
;
int
unmatched_slash_count
=
0
;
int
unmatched_slash_count
=
0
;
path_p
=
abspath
(
cwd
,
path
name
);
path_p
=
abspath
(
cwd
,
file
name
);
rel_buf_p
=
rel_buffer
=
(
char
*
)
xmalloc
(
strlen
(
path_p
)
+
1
);
rel_buf_p
=
rel_buffer
=
(
char
*
)
xmalloc
(
strlen
(
path_p
)
+
1
);
while
(
*
cwd_p
&&
(
*
cwd_p
==
*
path_p
))
while
(
*
cwd_p
&&
(
*
cwd_p
==
*
path_p
))
...
@@ -1283,25 +1302,27 @@ shortpath (const char *cwd, const char *pathname)
...
@@ -1283,25 +1302,27 @@ shortpath (const char *cwd, const char *pathname)
--
rel_buf_p
;
--
rel_buf_p
;
if
(
*
(
rel_buf_p
-
1
)
==
'/'
)
if
(
*
(
rel_buf_p
-
1
)
==
'/'
)
*--
rel_buf_p
=
'\0'
;
*--
rel_buf_p
=
'\0'
;
if
(
strlen
(
rel_buffer
)
>
strlen
(
path
name
))
if
(
strlen
(
rel_buffer
)
>
strlen
(
file
name
))
strcpy
(
rel_buffer
,
path
name
);
strcpy
(
rel_buffer
,
file
name
);
return
rel_buffer
;
return
rel_buffer
;
}
}
/* NOTREACHED */
/* NOTREACHED */
return
0
;
/* Prevent warnings for old versions of GCC. */
return
0
;
/* Prevent warnings for old versions of GCC. */
}
}
/* Lookup the given
pathname in the hash table for path
names. If it is a
/* Lookup the given
filename in the hash table for file
names. If it is a
new one, then the hash table info pointer will be null. In this case,
new one, then the hash table info pointer will be null. In this case,
we create a new file_info record to go with the
path
name, and we initialize
we create a new file_info record to go with the
file
name, and we initialize
that record with some reasonable values. */
that record with some reasonable values. */
static
file_info
*
static
file_info
*
find_file
(
const
char
*
pathname
,
int
do_not_stat
)
find_file
(
char
*
filename
,
int
do_not_stat
)
/* FILENAME was const, but that causes a warning on AIX when calling stat.
That is probably a bug in AIX, but might as well avoid the warning. */
{
{
hash_table_entry
*
hash_entry_p
;
hash_table_entry
*
hash_entry_p
;
hash_entry_p
=
lookup
(
pathname_primary
,
path
name
);
hash_entry_p
=
lookup
(
filename_primary
,
file
name
);
if
(
hash_entry_p
->
fip
)
if
(
hash_entry_p
->
fip
)
return
hash_entry_p
->
fip
;
return
hash_entry_p
->
fip
;
else
else
...
@@ -1316,10 +1337,10 @@ find_file (const char *pathname, int do_not_stat)
...
@@ -1316,10 +1337,10 @@ find_file (const char *pathname, int do_not_stat)
stat_buf
.
st_mtime
=
(
time_t
)
0
;
stat_buf
.
st_mtime
=
(
time_t
)
0
;
else
else
{
{
if
(
stat
(
path
name
,
&
stat_buf
)
==
-
1
)
if
(
stat
(
file
name
,
&
stat_buf
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't get status of `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't get status of `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
path
name
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
file
name
),
sys_errlist
[
errno
]);
stat_buf
.
st_mtime
=
(
time_t
)
-
1
;
stat_buf
.
st_mtime
=
(
time_t
)
-
1
;
}
}
}
}
...
@@ -1339,7 +1360,7 @@ static void
...
@@ -1339,7 +1360,7 @@ static void
aux_info_corrupted
(
void
)
aux_info_corrupted
(
void
)
{
{
fprintf
(
stderr
,
"
\n
%s: fatal error: aux info file corrupted at line %d
\n
"
,
fprintf
(
stderr
,
"
\n
%s: fatal error: aux info file corrupted at line %d
\n
"
,
pname
,
current_aux_info_lineno
);
pname
,
current_aux_info_lineno
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -1409,7 +1430,7 @@ referenced_file_is_newer (const char *l, time_t aux_info_mtime)
...
@@ -1409,7 +1430,7 @@ referenced_file_is_newer (const char *l, time_t aux_info_mtime)
may cause a new file_info record to be created if this is the first time
may cause a new file_info record to be created if this is the first time
that we have ever known about this particular file. */
that we have ever known about this particular file. */
fi_p
=
find_file
(
abspath
(
invocation_
path
,
filename
),
0
);
fi_p
=
find_file
(
abspath
(
invocation_
filename
,
filename
),
0
);
return
(
fi_p
->
mtime
>
aux_info_mtime
);
return
(
fi_p
->
mtime
>
aux_info_mtime
);
}
}
...
@@ -1464,16 +1485,16 @@ save_def_or_dec (const char *l, int is_syscalls)
...
@@ -1464,16 +1485,16 @@ save_def_or_dec (const char *l, int is_syscalls)
may cause a new file_info record to be created if this is the first time
may cause a new file_info record to be created if this is the first time
that we have ever known about this particular file.
that we have ever known about this particular file.
Note that we started out by forcing all of the base source file
path
names
Note that we started out by forcing all of the base source file names
(i.e. the names of the aux_info files with the .X stripped off) into the
(i.e. the names of the aux_info files with the .X stripped off) into the
path
names hash table, and we simultaneously setup file_info records for
file
names hash table, and we simultaneously setup file_info records for
all of these base file
path
names (even if they may be useless later).
all of these base file names (even if they may be useless later).
The file_info records for all of these "base" file
path
names (properly)
The file_info records for all of these "base" file names (properly)
act as file_info records for the "original" (i.e. un-included) files
act as file_info records for the "original" (i.e. un-included) files
which were submitted to gcc for compilation (when the -fgen-aux-info
which were submitted to gcc for compilation (when the -fgen-aux-info
option was used). */
option was used). */
def_dec_p
->
file
=
find_file
(
abspath
(
invocation_
path
,
filename
),
is_syscalls
);
def_dec_p
->
file
=
find_file
(
abspath
(
invocation_
filename
,
filename
),
is_syscalls
);
}
}
{
{
...
@@ -1868,25 +1889,25 @@ munge_compile_params (const char *params_list)
...
@@ -1868,25 +1889,25 @@ munge_compile_params (const char *params_list)
file to go with a specific base source file. */
file to go with a specific base source file. */
static
int
static
int
gen_aux_info_file
(
const
char
*
base_
path
name
)
gen_aux_info_file
(
const
char
*
base_
file
name
)
{
{
int
child_pid
;
int
child_pid
;
if
(
!
filename_index
)
if
(
!
filename_index
)
munge_compile_params
(
""
);
munge_compile_params
(
""
);
compile_params
[
filename_index
]
=
shortpath
(
NULL
,
base_
path
name
);
compile_params
[
filename_index
]
=
shortpath
(
NULL
,
base_
file
name
);
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
fprintf
(
stderr
,
"%s: compiling `%s'
\n
"
,
fprintf
(
stderr
,
"%s: compiling `%s'
\n
"
,
pname
,
compile_params
[
filename_index
]);
pname
,
compile_params
[
filename_index
]);
if
(
child_pid
=
fork
())
if
(
child_pid
=
fork
())
{
{
if
(
child_pid
==
-
1
)
if
(
child_pid
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: could not fork process: %s
\n
"
,
fprintf
(
stderr
,
"%s: error: could not fork process: %s
\n
"
,
pname
,
sys_errlist
[
errno
]);
pname
,
sys_errlist
[
errno
]);
return
0
;
return
0
;
}
}
...
@@ -1914,7 +1935,7 @@ gen_aux_info_file (const char *base_pathname)
...
@@ -1914,7 +1935,7 @@ gen_aux_info_file (const char *base_pathname)
if
(
wait
(
&
wait_status
)
==
-
1
)
if
(
wait
(
&
wait_status
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: wait for process failed: %s
\n
"
,
fprintf
(
stderr
,
"%s: error: wait for process failed: %s
\n
"
,
pname
,
sys_errlist
[
errno
]);
pname
,
sys_errlist
[
errno
]);
return
0
;
return
0
;
}
}
if
(
!
WIFEXITED
(
wait_status
))
if
(
!
WIFEXITED
(
wait_status
))
...
@@ -1930,7 +1951,7 @@ gen_aux_info_file (const char *base_pathname)
...
@@ -1930,7 +1951,7 @@ gen_aux_info_file (const char *base_pathname)
if
(
execvp
(
compile_params
[
0
],
(
char
*
const
*
)
compile_params
))
if
(
execvp
(
compile_params
[
0
],
(
char
*
const
*
)
compile_params
))
{
{
fprintf
(
stderr
,
"%s: error: execvp returned: %s
\n
"
,
fprintf
(
stderr
,
"%s: error: execvp returned: %s
\n
"
,
pname
,
sys_errlist
[
errno
]);
pname
,
sys_errlist
[
errno
]);
exit
(
errno
);
exit
(
errno
);
}
}
return
1
;
/* Never executed. */
return
1
;
/* Never executed. */
...
@@ -1941,10 +1962,10 @@ gen_aux_info_file (const char *base_pathname)
...
@@ -1941,10 +1962,10 @@ gen_aux_info_file (const char *base_pathname)
Save all of the important stuff for later. */
Save all of the important stuff for later. */
static
void
static
void
process_aux_info_file
(
const
char
*
base_source_
path
name
,
int
keep_it
,
int
is_syscalls
)
process_aux_info_file
(
const
char
*
base_source_
file
name
,
int
keep_it
,
int
is_syscalls
)
{
{
char
*
const
aux_info_
path
name
char
*
const
aux_info_
file
name
=
(
char
*
)
alloca
(
strlen
(
base_source_
path
name
)
=
(
char
*
)
alloca
(
strlen
(
base_source_
file
name
)
+
strlen
(
aux_info_suffix
)
+
1
);
+
strlen
(
aux_info_suffix
)
+
1
);
char
*
aux_info_base
;
char
*
aux_info_base
;
char
*
aux_info_limit
;
char
*
aux_info_limit
;
...
@@ -1952,10 +1973,10 @@ process_aux_info_file (const char *base_source_pathname, int keep_it, int is_sys
...
@@ -1952,10 +1973,10 @@ process_aux_info_file (const char *base_source_pathname, int keep_it, int is_sys
time_t
aux_info_mtime
;
time_t
aux_info_mtime
;
size_t
aux_info_size
;
size_t
aux_info_size
;
/* Construct the aux_info
pathname from the base source path
name. */
/* Construct the aux_info
filename from the base source file
name. */
strcpy
(
aux_info_
pathname
,
base_source_path
name
);
strcpy
(
aux_info_
filename
,
base_source_file
name
);
strcat
(
aux_info_
path
name
,
aux_info_suffix
);
strcat
(
aux_info_
file
name
,
aux_info_suffix
);
/* Check that the aux_info file exists and is readable. If it does not
/* Check that the aux_info file exists and is readable. If it does not
exist, try to create it (once only). */
exist, try to create it (once only). */
...
@@ -1966,17 +1987,17 @@ start_over: ;
...
@@ -1966,17 +1987,17 @@ start_over: ;
int
retries
=
0
;
int
retries
=
0
;
retry
:
retry
:
if
(
access
(
aux_info_
path
name
,
R_OK
)
==
-
1
)
if
(
access
(
aux_info_
file
name
,
R_OK
)
==
-
1
)
{
{
if
(
errno
==
ENOENT
&&
retries
==
0
)
if
(
errno
==
ENOENT
&&
retries
==
0
)
{
{
if
(
is_syscalls
)
if
(
is_syscalls
)
{
{
fprintf
(
stderr
,
"%s: warning: missing SYSCALLS file `%s'
\n
"
,
fprintf
(
stderr
,
"%s: warning: missing SYSCALLS file `%s'
\n
"
,
pname
,
aux_info_path
name
);
pname
,
aux_info_file
name
);
return
;
return
;
}
}
if
(
!
gen_aux_info_file
(
base_source_
path
name
))
if
(
!
gen_aux_info_file
(
base_source_
file
name
))
return
;
return
;
retries
++
;
retries
++
;
goto
retry
;
goto
retry
;
...
@@ -1984,7 +2005,8 @@ retry:
...
@@ -1984,7 +2005,8 @@ retry:
else
else
{
{
fprintf
(
stderr
,
"%s: error: can't read aux info file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't read aux info file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_pathname
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
aux_info_filename
),
sys_errlist
[
errno
]);
errors
++
;
errors
++
;
return
;
return
;
}
}
...
@@ -1996,10 +2018,11 @@ retry:
...
@@ -1996,10 +2018,11 @@ retry:
/* Get some status information about this aux_info file. */
/* Get some status information about this aux_info file. */
if
(
stat
(
aux_info_
path
name
,
&
stat_buf
)
==
-
1
)
if
(
stat
(
aux_info_
file
name
,
&
stat_buf
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't get status of aux info file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't get status of aux info file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_pathname
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
aux_info_filename
),
sys_errlist
[
errno
]);
errors
++
;
errors
++
;
return
;
return
;
}
}
...
@@ -2022,10 +2045,11 @@ retry:
...
@@ -2022,10 +2045,11 @@ retry:
/* Open the aux_info file. */
/* Open the aux_info file. */
if
((
aux_info_file
=
open
(
aux_info_
path
name
,
O_RDONLY
,
0444
))
==
-
1
)
if
((
aux_info_file
=
open
(
aux_info_
file
name
,
O_RDONLY
,
0444
))
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't open aux info file `%s' for reading: %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't open aux info file `%s' for reading: %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_pathname
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
aux_info_filename
),
sys_errlist
[
errno
]);
return
;
return
;
}
}
...
@@ -2040,7 +2064,8 @@ retry:
...
@@ -2040,7 +2064,8 @@ retry:
if
(
read
(
aux_info_file
,
aux_info_base
,
aux_info_size
)
!=
aux_info_size
)
if
(
read
(
aux_info_file
,
aux_info_base
,
aux_info_size
)
!=
aux_info_size
)
{
{
fprintf
(
stderr
,
"%s: error: while reading aux info file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: while reading aux info file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_pathname
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
aux_info_filename
),
sys_errlist
[
errno
]);
free
(
aux_info_base
);
free
(
aux_info_base
);
close
(
aux_info_file
);
close
(
aux_info_file
);
return
;
return
;
...
@@ -2051,7 +2076,8 @@ retry:
...
@@ -2051,7 +2076,8 @@ retry:
if
(
close
(
aux_info_file
))
if
(
close
(
aux_info_file
))
{
{
fprintf
(
stderr
,
"%s: error: while closing aux info file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: while closing aux info file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_pathname
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
aux_info_filename
),
sys_errlist
[
errno
]);
free
(
aux_info_base
);
free
(
aux_info_base
);
close
(
aux_info_file
);
close
(
aux_info_file
);
return
;
return
;
...
@@ -2062,15 +2088,16 @@ retry:
...
@@ -2062,15 +2088,16 @@ retry:
fails for some reason, don't even worry about it. */
fails for some reason, don't even worry about it. */
if
(
!
keep_it
)
if
(
!
keep_it
)
if
(
unlink
(
aux_info_
path
name
)
==
-
1
)
if
(
unlink
(
aux_info_
file
name
)
==
-
1
)
fprintf
(
stderr
,
"%s: error: can't delete aux info file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't delete aux info file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_pathname
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
aux_info_filename
),
sys_errlist
[
errno
]);
/* Save a pointer into the first line of the aux_info file which
/* Save a pointer into the first line of the aux_info file which
contains the
path
name of the directory from which the compiler
contains the
file
name of the directory from which the compiler
was invoked when the associated source file was compiled.
was invoked when the associated source file was compiled.
This information is used later to help create complete
This information is used later to help create complete
pathnames out of the (potentially) relative path
names in
filenames out of the (potentially) relative file
names in
the aux_info file. */
the aux_info file. */
{
{
...
@@ -2081,7 +2108,7 @@ retry:
...
@@ -2081,7 +2108,7 @@ retry:
p
++
;
p
++
;
while
(
*
p
==
' '
)
while
(
*
p
==
' '
)
p
++
;
p
++
;
invocation_
path
=
p
;
/* Save a pointer to first byte of path. */
invocation_
filename
=
p
;
/* Save a pointer to first byte of path. */
while
(
*
p
!=
' '
)
while
(
*
p
!=
' '
)
p
++
;
p
++
;
*
p
++
=
'/'
;
*
p
++
=
'/'
;
...
@@ -2109,12 +2136,11 @@ retry:
...
@@ -2109,12 +2136,11 @@ retry:
if
(
referenced_file_is_newer
(
aux_info_p
,
aux_info_mtime
))
if
(
referenced_file_is_newer
(
aux_info_p
,
aux_info_mtime
))
{
{
free
(
aux_info_base
);
free
(
aux_info_base
);
if
(
unlink
(
aux_info_
path
name
)
==
-
1
)
if
(
unlink
(
aux_info_
file
name
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't delete file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't delete file `%s': %s
\n
"
,
pname
,
pname
,
shortpath
(
NULL
,
aux_info_filename
),
shortpath
(
NULL
,
aux_info_pathname
),
sys_errlist
[
errno
]);
sys_errlist
[
errno
]);
return
;
return
;
}
}
goto
start_over
;
goto
start_over
;
...
@@ -2167,9 +2193,9 @@ retry:
...
@@ -2167,9 +2193,9 @@ retry:
static
void
static
void
rename_c_file
(
const
hash_table_entry
*
hp
)
rename_c_file
(
const
hash_table_entry
*
hp
)
{
{
const
char
*
path
name
=
hp
->
symbol
;
const
char
*
file
name
=
hp
->
symbol
;
int
last_char_index
=
strlen
(
path
name
)
-
1
;
int
last_char_index
=
strlen
(
file
name
)
-
1
;
char
*
const
new_
pathname
=
(
char
*
)
alloca
(
strlen
(
path
name
)
+
1
);
char
*
const
new_
filename
=
(
char
*
)
alloca
(
strlen
(
file
name
)
+
1
);
/* Note that we don't care here if the given file was converted or not. It
/* Note that we don't care here if the given file was converted or not. It
is possible that the given file was *not* converted, simply because there
is possible that the given file was *not* converted, simply because there
...
@@ -2177,25 +2203,25 @@ rename_c_file (const hash_table_entry *hp)
...
@@ -2177,25 +2203,25 @@ rename_c_file (const hash_table_entry *hp)
we want to do the renaming. Note that we only rename files with the .c
we want to do the renaming. Note that we only rename files with the .c
suffix. */
suffix. */
if
(
pathname
[
last_char_index
]
!=
'c'
||
path
name
[
last_char_index
-
1
]
!=
'.'
)
if
(
filename
[
last_char_index
]
!=
'c'
||
file
name
[
last_char_index
-
1
]
!=
'.'
)
return
;
return
;
strcpy
(
new_
pathname
,
path
name
);
strcpy
(
new_
filename
,
file
name
);
new_
path
name
[
last_char_index
]
=
'C'
;
new_
file
name
[
last_char_index
]
=
'C'
;
if
(
link
(
pathname
,
new_path
name
)
==
-
1
)
if
(
link
(
filename
,
new_file
name
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: warning: can't link file `%s' to `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: warning: can't link file `%s' to `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
path
name
),
pname
,
shortpath
(
NULL
,
file
name
),
shortpath
(
NULL
,
new_path
name
),
sys_errlist
[
errno
]);
shortpath
(
NULL
,
new_file
name
),
sys_errlist
[
errno
]);
errors
++
;
errors
++
;
return
;
return
;
}
}
if
(
unlink
(
path
name
)
==
-
1
)
if
(
unlink
(
file
name
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: warning: can't delete file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: warning: can't delete file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
path
name
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
file
name
),
sys_errlist
[
errno
]);
errors
++
;
errors
++
;
return
;
return
;
}
}
...
@@ -2316,26 +2342,24 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
...
@@ -2316,26 +2342,24 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
{
{
conflict_noted
=
1
;
conflict_noted
=
1
;
fprintf
(
stderr
,
"%s: error: conflicting extern definitions of '%s'
\n
"
,
fprintf
(
stderr
,
"%s: error: conflicting extern definitions of '%s'
\n
"
,
pname
,
head
->
hash_entry
->
symbol
);
pname
,
head
->
hash_entry
->
symbol
);
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
{
{
fprintf
(
stderr
,
"%s: declarations of '%s' will not be converted
\n
"
,
fprintf
(
stderr
,
"%s: declarations of '%s' will not be converted
\n
"
,
pname
,
head
->
hash_entry
->
symbol
);
pname
,
head
->
hash_entry
->
symbol
);
fprintf
(
stderr
,
"%s: conflict list for '%s' follows:
\n
"
,
fprintf
(
stderr
,
"%s: conflict list for '%s' follows:
\n
"
,
pname
,
head
->
hash_entry
->
symbol
);
pname
,
head
->
hash_entry
->
symbol
);
fprintf
(
stderr
,
"%s: %s(%d): %s
\n
"
,
fprintf
(
stderr
,
"%s: %s(%d): %s
\n
"
,
pname
,
pname
,
shortpath
(
NULL
,
extern_def_p
->
file
->
hash_entry
->
symbol
),
shortpath
(
NULL
,
extern_def_p
->
file
->
hash_entry
->
symbol
),
extern_def_p
->
line
,
extern_def_p
->
line
,
extern_def_p
->
ansi_decl
);
extern_def_p
->
ansi_decl
);
}
}
}
}
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
fprintf
(
stderr
,
"%s: %s(%d): %s
\n
"
,
fprintf
(
stderr
,
"%s: %s(%d): %s
\n
"
,
pname
,
pname
,
shortpath
(
NULL
,
dd_p
->
file
->
hash_entry
->
symbol
),
shortpath
(
NULL
,
dd_p
->
file
->
hash_entry
->
symbol
),
dd_p
->
line
,
dd_p
->
line
,
dd_p
->
ansi_decl
);
dd_p
->
ansi_decl
);
}
}
}
}
...
@@ -2357,9 +2381,9 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
...
@@ -2357,9 +2381,9 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
extern_def_p
=
dd_p
;
/* save a pointer to the definition */
extern_def_p
=
dd_p
;
/* save a pointer to the definition */
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
fprintf
(
stderr
,
"%s: warning: using formals list from %s(%d) for function `%s'
\n
"
,
fprintf
(
stderr
,
"%s: warning: using formals list from %s(%d) for function `%s'
\n
"
,
pname
,
pname
,
shortpath
(
NULL
,
dd_p
->
file
->
hash_entry
->
symbol
),
shortpath
(
NULL
,
dd_p
->
file
->
hash_entry
->
symbol
),
dd_p
->
line
,
dd_p
->
hash_entry
->
symbol
);
dd_p
->
line
,
dd_p
->
hash_entry
->
symbol
);
break
;
break
;
}
}
...
@@ -2392,18 +2416,14 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
...
@@ -2392,18 +2416,14 @@ find_extern_def (const def_dec_info *head, const def_dec_info *user)
+
strlen
(
user
->
hash_entry
->
symbol
)
+
2
;
+
strlen
(
user
->
hash_entry
->
symbol
)
+
2
;
strcpy
(
p
,
"???);"
);
strcpy
(
p
,
"???);"
);
fprintf
(
stderr
,
"%s: please add `%s' to SYSCALLS (see %s(%d))
\n
"
,
fprintf
(
stderr
,
"%s: %d: `%s' used but missing from SYSCALLS
\n
"
,
pname
,
shortpath
(
NULL
,
file
),
user
->
line
,
needed
+
7
,
/* Don't print "extern " */
needed
+
7
);
/* Don't print "extern " */
shortpath
(
NULL
,
file
),
user
->
line
);
}
}
else
else
fprintf
(
stderr
,
"%s: warning: no extern definition for `%s' (see %s(%d))
\n
"
,
fprintf
(
stderr
,
"%s: %d: warning: no extern definition for `%s'
\n
"
,
pname
,
shortpath
(
NULL
,
file
),
user
->
line
,
user
->
hash_entry
->
symbol
,
user
->
hash_entry
->
symbol
);
shortpath
(
NULL
,
file
),
user
->
line
);
}
}
}
}
return
extern_def_p
;
return
extern_def_p
;
...
@@ -2431,16 +2451,14 @@ find_static_definition (const def_dec_info *user)
...
@@ -2431,16 +2451,14 @@ find_static_definition (const def_dec_info *user)
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
fprintf
(
stderr
,
"%s: warning: no static definition for `%s' in file `%s'
\n
"
,
fprintf
(
stderr
,
"%s: warning: no static definition for `%s' in file `%s'
\n
"
,
pname
,
pname
,
head
->
hash_entry
->
symbol
,
head
->
hash_entry
->
symbol
,
shortpath
(
NULL
,
user
->
file
->
hash_entry
->
symbol
));
shortpath
(
NULL
,
user
->
file
->
hash_entry
->
symbol
));
}
}
else
if
(
num_static_defs
>
1
)
else
if
(
num_static_defs
>
1
)
{
{
fprintf
(
stderr
,
"%s: error: multiple static defs of `%s' in file `%s'
\n
"
,
fprintf
(
stderr
,
"%s: error: multiple static defs of `%s' in file `%s'
\n
"
,
pname
,
pname
,
head
->
hash_entry
->
symbol
,
head
->
hash_entry
->
symbol
,
shortpath
(
NULL
,
user
->
file
->
hash_entry
->
symbol
));
shortpath
(
NULL
,
user
->
file
->
hash_entry
->
symbol
));
return
NULL
;
return
NULL
;
}
}
return
static_def_p
;
return
static_def_p
;
...
@@ -2608,11 +2626,12 @@ declare_source_confusing (const char *clean_p)
...
@@ -2608,11 +2626,12 @@ declare_source_confusing (const char *clean_p)
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
{
{
if
(
clean_p
==
0
)
if
(
clean_p
==
0
)
fprintf
(
stderr
,
"%s:
warning: source too confusing near %s(%d)
\n
"
,
fprintf
(
stderr
,
"%s:
%d: warning: source too confusing
\n
"
,
pname
,
shortpath
(
NULL
,
convert_path
),
last_known_line_number
);
shortpath
(
NULL
,
convert_filename
),
last_known_line_number
);
else
else
fprintf
(
stderr
,
"%s: warning: source too confusing at %s(%d)
\n
"
,
fprintf
(
stderr
,
"%s: %d: warning: source too confusing
\n
"
,
pname
,
shortpath
(
NULL
,
convert_path
),
identify_lineno
(
clean_p
));
shortpath
(
NULL
,
convert_filename
),
identify_lineno
(
clean_p
));
}
}
longjmp
(
source_confusion_recovery
,
1
);
longjmp
(
source_confusion_recovery
,
1
);
}
}
...
@@ -2805,10 +2824,9 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
...
@@ -2805,10 +2824,9 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
if
(
other_variable_style_function
(
definition
->
ansi_decl
))
if
(
other_variable_style_function
(
definition
->
ansi_decl
))
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
fprintf
(
stderr
,
"%s: warning: varargs function declaration at %s(%d) not converted
\n
"
,
fprintf
(
stderr
,
"%s: %d: warning: varargs function declaration not converted
\n
"
,
pname
,
shortpath
(
NULL
,
def_dec_p
->
file
->
hash_entry
->
symbol
),
shortpath
(
NULL
,
def_dec_p
->
file
->
hash_entry
->
symbol
),
def_dec_p
->
line
);
def_dec_p
->
line
);
return
;
return
;
}
}
...
@@ -2822,7 +2840,7 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
...
@@ -2822,7 +2840,7 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
{
{
restore_pointers
();
restore_pointers
();
fprintf
(
stderr
,
"%s: declaration of function `%s' not converted
\n
"
,
fprintf
(
stderr
,
"%s: declaration of function `%s' not converted
\n
"
,
pname
,
function_to_edit
);
pname
,
function_to_edit
);
return
;
return
;
}
}
...
@@ -2945,7 +2963,7 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
...
@@ -2945,7 +2963,7 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
fprintf
(
stderr
,
"%s: warning: too many parameter lists in declaration of `%s'
\n
"
,
fprintf
(
stderr
,
"%s: warning: too many parameter lists in declaration of `%s'
\n
"
,
pname
,
def_dec_p
->
hash_entry
->
symbol
);
pname
,
def_dec_p
->
hash_entry
->
symbol
);
check_source
(
0
,
end_formals
);
/* leave the declaration intact */
check_source
(
0
,
end_formals
);
/* leave the declaration intact */
}
}
#endif
/* !defined(UNPROTOIZE) */
#endif
/* !defined(UNPROTOIZE) */
...
@@ -2966,7 +2984,7 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
...
@@ -2966,7 +2984,7 @@ edit_fn_declaration (const def_dec_info *def_dec_p,
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
fprintf
(
stderr
,
"
\n
%s: warning: too few parameter lists in declaration of `%s'
\n
"
,
fprintf
(
stderr
,
"
\n
%s: warning: too few parameter lists in declaration of `%s'
\n
"
,
pname
,
def_dec_p
->
hash_entry
->
symbol
);
pname
,
def_dec_p
->
hash_entry
->
symbol
);
check_source
(
0
,
start_formals
);
/* leave the decl intact */
check_source
(
0
,
start_formals
);
/* leave the decl intact */
}
}
#endif
/* !defined(UNPROTOIZE) */
#endif
/* !defined(UNPROTOIZE) */
...
@@ -3057,14 +3075,13 @@ edit_formals_lists (const char *end_formals, unsigned f_list_count, const def_de
...
@@ -3057,14 +3075,13 @@ edit_formals_lists (const char *end_formals, unsigned f_list_count, const def_de
if
(
func_name_len
==
0
)
if
(
func_name_len
==
0
)
check_source
(
0
,
func_name_start
);
check_source
(
0
,
func_name_start
);
if
(
func_name_len
!=
strlen
(
expected
)
if
(
func_name_len
!=
strlen
(
expected
)
||
strncmp
(
func_name_start
,
expected
,
func_name_len
))
||
strncmp
(
func_name_start
,
expected
,
func_name_len
))
{
{
fprintf
(
stderr
,
"%s: warning: found `%s' at %s(%d) but expected `%s'
\n
"
,
fprintf
(
stderr
,
"%s: %d: warning: found `%s' but expected `%s'
\n
"
,
pname
,
shortpath
(
NULL
,
def_dec_p
->
file
->
hash_entry
->
symbol
),
dupnstr
(
func_name_start
,
func_name_len
),
identify_lineno
(
func_name_start
),
shortpath
(
NULL
,
def_dec_p
->
file
->
hash_entry
->
symbol
),
dupnstr
(
func_name_start
,
func_name_len
),
identify_lineno
(
func_name_start
),
expected
);
expected
);
return
1
;
return
1
;
}
}
}
}
...
@@ -3218,7 +3235,7 @@ add_local_decl (const def_dec_info *def_dec_p, const char *clean_text_p)
...
@@ -3218,7 +3235,7 @@ add_local_decl (const def_dec_info *def_dec_p, const char *clean_text_p)
{
{
restore_pointers
();
restore_pointers
();
fprintf
(
stderr
,
"%s: local declaration for function `%s' not inserted
\n
"
,
fprintf
(
stderr
,
"%s: local declaration for function `%s' not inserted
\n
"
,
pname
,
function_to_edit
);
pname
,
function_to_edit
);
return
;
return
;
}
}
...
@@ -3245,11 +3262,9 @@ add_local_decl (const def_dec_info *def_dec_p, const char *clean_text_p)
...
@@ -3245,11 +3262,9 @@ add_local_decl (const def_dec_info *def_dec_p, const char *clean_text_p)
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
fprintf
(
stderr
,
fprintf
(
stderr
,
"
\n
%s: warning: can't add declaration of `%s' into macro call at %s(%d)
\n
"
,
"
\n
%s: %d: warning: can't add declaration of `%s' into macro call
\n
"
,
pname
,
def_dec_p
->
file
->
hash_entry
->
symbol
,
def_dec_p
->
line
,
def_dec_p
->
hash_entry
->
symbol
,
def_dec_p
->
hash_entry
->
symbol
);
def_dec_p
->
file
->
hash_entry
->
symbol
,
def_dec_p
->
line
);
return
;
return
;
}
}
...
@@ -3320,7 +3335,7 @@ add_global_decls (const file_info *file_p, const char *clean_text_p)
...
@@ -3320,7 +3335,7 @@ add_global_decls (const file_info *file_p, const char *clean_text_p)
{
{
restore_pointers
();
restore_pointers
();
fprintf
(
stderr
,
"%s: global declarations for file `%s' not inserted
\n
"
,
fprintf
(
stderr
,
"%s: global declarations for file `%s' not inserted
\n
"
,
pname
,
shortpath
(
NULL
,
file_p
->
hash_entry
->
symbol
));
pname
,
shortpath
(
NULL
,
file_p
->
hash_entry
->
symbol
));
return
;
return
;
}
}
...
@@ -3409,7 +3424,7 @@ edit_fn_definition (const def_dec_info *def_dec_p, const char *clean_text_p)
...
@@ -3409,7 +3424,7 @@ edit_fn_definition (const def_dec_info *def_dec_p, const char *clean_text_p)
{
{
restore_pointers
();
restore_pointers
();
fprintf
(
stderr
,
"%s: definition of function `%s' not converted
\n
"
,
fprintf
(
stderr
,
"%s: definition of function `%s' not converted
\n
"
,
pname
,
function_to_edit
);
pname
,
function_to_edit
);
return
;
return
;
}
}
...
@@ -3427,11 +3442,10 @@ edit_fn_definition (const def_dec_info *def_dec_p, const char *clean_text_p)
...
@@ -3427,11 +3442,10 @@ edit_fn_definition (const def_dec_info *def_dec_p, const char *clean_text_p)
if
(
other_variable_style_function
(
def_dec_p
->
ansi_decl
))
if
(
other_variable_style_function
(
def_dec_p
->
ansi_decl
))
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
fprintf
(
stderr
,
"%s: warning: %s function definition at %s(%d) not converted
\n
"
,
fprintf
(
stderr
,
"%s: %d: warning: definition of %s not converted
\n
"
,
pname
,
shortpath
(
NULL
,
def_dec_p
->
file
->
hash_entry
->
symbol
),
other_var_style
,
identify_lineno
(
end_formals
),
shortpath
(
NULL
,
def_dec_p
->
file
->
hash_entry
->
symbol
),
other_var_style
);
identify_lineno
(
end_formals
));
output_up_to
(
end_formals
);
output_up_to
(
end_formals
);
return
;
return
;
}
}
...
@@ -3440,7 +3454,7 @@ edit_fn_definition (const def_dec_info *def_dec_p, const char *clean_text_p)
...
@@ -3440,7 +3454,7 @@ edit_fn_definition (const def_dec_info *def_dec_p, const char *clean_text_p)
{
{
restore_pointers
();
restore_pointers
();
fprintf
(
stderr
,
"%s: definition of function `%s' not converted
\n
"
,
fprintf
(
stderr
,
"%s: definition of function `%s' not converted
\n
"
,
pname
,
function_to_edit
);
pname
,
function_to_edit
);
return
;
return
;
}
}
...
@@ -3765,11 +3779,9 @@ scan_for_missed_items (const file_info *file_p)
...
@@ -3765,11 +3779,9 @@ scan_for_missed_items (const file_info *file_p)
/* If we make it here, then we did not know about this
/* If we make it here, then we did not know about this
function definition. */
function definition. */
fprintf
(
stderr
,
"%s: warning: `%s' at %s(%d) was #if 0
\n
"
,
fprintf
(
stderr
,
"%s: %d: warning: `%s' was #if 0
\n
"
,
pname
,
func_name
,
shortpath
(
NULL
,
file_p
->
hash_entry
->
symbol
),
shortpath
(
NULL
,
file_p
->
hash_entry
->
symbol
),
identify_lineno
(
id_start
));
identify_lineno
(
id_start
)
,
func_name
);
fprintf
(
stderr
,
"%s: function definition not converted
\n
"
,
fprintf
(
stderr
,
"%s: function definition not converted
\n
"
,
pname
);
pname
);
}
}
...
@@ -3811,13 +3823,13 @@ edit_file (const hash_table_entry *hp)
...
@@ -3811,13 +3823,13 @@ edit_file (const hash_table_entry *hp)
if
(
!
needs_to_be_converted
(
file_p
))
if
(
!
needs_to_be_converted
(
file_p
))
return
;
return
;
convert_
path
=
file_p
->
hash_entry
->
symbol
;
convert_
filename
=
file_p
->
hash_entry
->
symbol
;
/* Convert a file if it is in a directory where we want conversion
/* Convert a file if it is in a directory where we want conversion
and the file is not excluded. */
and the file is not excluded. */
if
(
!
directory_specified_p
(
convert_
path
)
if
(
!
directory_specified_p
(
convert_
filename
)
||
file_excluded_p
(
convert_
path
))
||
file_excluded_p
(
convert_
filename
))
{
{
if
(
!
quiet_flag
if
(
!
quiet_flag
#ifdef UNPROTOIZE
#ifdef UNPROTOIZE
...
@@ -3825,31 +3837,32 @@ edit_file (const hash_table_entry *hp)
...
@@ -3825,31 +3837,32 @@ edit_file (const hash_table_entry *hp)
protoizing. If we are protoizing, we mention these as a
protoizing. If we are protoizing, we mention these as a
gentile way of prodding the user to convert his "system"
gentile way of prodding the user to convert his "system"
include files to prototype format. */
include files to prototype format. */
&&
!
in_system_include_dir
(
convert_
path
)
&&
!
in_system_include_dir
(
convert_
filename
)
#endif
/* defined(UNPROTOIZE) */
#endif
/* defined(UNPROTOIZE) */
)
)
fprintf
(
stderr
,
"%s: file `%s' not converted
\n
"
,
fprintf
(
stderr
,
"%s: file `%s' not converted
\n
"
,
pname
,
shortpath
(
NULL
,
convert_path
));
pname
,
shortpath
(
NULL
,
convert_filename
));
return
;
return
;
}
}
/* Let the user know what we are up to. */
/* Let the user know what we are up to. */
if
(
nochange_flag
)
if
(
nochange_flag
)
puts
(
shortpath
(
NULL
,
convert_
path
));
puts
(
shortpath
(
NULL
,
convert_
filename
));
else
else
{
{
fprintf
(
stderr
,
"%s: converting file `%s'
\n
"
,
fprintf
(
stderr
,
"%s: converting file `%s'
\n
"
,
pname
,
shortpath
(
NULL
,
convert_path
));
pname
,
shortpath
(
NULL
,
convert_filename
));
fflush
(
stderr
);
fflush
(
stderr
);
}
}
/* Find out the size (in bytes) of the original file. */
/* Find out the size (in bytes) of the original file. */
if
(
stat
(
convert_path
,
&
stat_buf
)
==
-
1
)
/* The cast avoids an erroneous warning on AIX. */
if
(
stat
((
char
*
)
convert_filename
,
&
stat_buf
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't get status for file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't get status for file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_path
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
return
;
return
;
}
}
orig_size
=
stat_buf
.
st_size
;
orig_size
=
stat_buf
.
st_size
;
...
@@ -3880,10 +3893,11 @@ edit_file (const hash_table_entry *hp)
...
@@ -3880,10 +3893,11 @@ edit_file (const hash_table_entry *hp)
/* Open the file to be converted in READ ONLY mode. */
/* Open the file to be converted in READ ONLY mode. */
if
((
input_file
=
open
(
convert_
path
,
O_RDONLY
,
0444
))
==
-
1
)
if
((
input_file
=
open
(
convert_
filename
,
O_RDONLY
,
0444
))
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't open file `%s' for reading: %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't open file `%s' for reading: %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_path
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
return
;
return
;
}
}
...
@@ -3895,7 +3909,8 @@ edit_file (const hash_table_entry *hp)
...
@@ -3895,7 +3909,8 @@ edit_file (const hash_table_entry *hp)
{
{
close
(
input_file
);
close
(
input_file
);
fprintf
(
stderr
,
"
\n
%s: error: while reading input file `%s': %s
\n
"
,
fprintf
(
stderr
,
"
\n
%s: error: while reading input file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_path
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
return
;
return
;
}
}
...
@@ -3918,18 +3933,17 @@ edit_file (const hash_table_entry *hp)
...
@@ -3918,18 +3933,17 @@ edit_file (const hash_table_entry *hp)
{
{
int clean_file;
int clean_file;
size_t clean_size = orig_text_limit - orig_text_base;
size_t clean_size = orig_text_limit - orig_text_base;
char *const clean_
path = (char *) alloca (strlen (convert_path
) + 6 + 1);
char *const clean_
filename = (char *) alloca (strlen (convert_filename
) + 6 + 1);
/* Open (and create) the clean file. */
/* Open (and create) the clean file. */
strcpy (clean_
path, convert_path
);
strcpy (clean_
filename, convert_filename
);
strcat (clean_
path
, ".clean");
strcat (clean_
filename
, ".clean");
if ((clean_file = creat (clean_
path
, 0666)) == -1)
if ((clean_file = creat (clean_
filename
, 0666)) == -1)
{
{
fprintf (stderr, "%s: error: can't create/open clean file `%s': %s\n",
fprintf (stderr, "%s: error: can't create/open clean file `%s': %s\n",
pname,
pname, shortpath (NULL, clean_filename),
shortpath (NULL, clean_path),
sys_errlist[errno]);
sys_errlist[errno]);
return;
return;
}
}
...
@@ -3937,7 +3951,7 @@ edit_file (const hash_table_entry *hp)
...
@@ -3937,7 +3951,7 @@ edit_file (const hash_table_entry *hp)
if (write (clean_file, new_clean_text_base, clean_size) != clean_size)
if (write (clean_file, new_clean_text_base, clean_size) != clean_size)
fprintf (stderr, "%s: error: while writing file `%s': %s\n",
fprintf (stderr, "%s: error: while writing file `%s': %s\n",
pname, shortpath (NULL, clean_path
), sys_errlist[errno]);
pname, shortpath (NULL, clean_filename
), sys_errlist[errno]);
close (clean_file);
close (clean_file);
}
}
...
@@ -4019,39 +4033,37 @@ edit_file (const hash_table_entry *hp)
...
@@ -4019,39 +4033,37 @@ edit_file (const hash_table_entry *hp)
if
(
!
nosave_flag
)
if
(
!
nosave_flag
)
{
{
char
*
new_
path
=
char
*
new_
filename
=
(
char
*
)
xmalloc
(
strlen
(
convert_
path
)
+
strlen
(
save_suffix
)
+
2
);
(
char
*
)
xmalloc
(
strlen
(
convert_
filename
)
+
strlen
(
save_suffix
)
+
2
);
strcpy
(
new_
path
,
convert_path
);
strcpy
(
new_
filename
,
convert_filename
);
strcat
(
new_
path
,
save_suffix
);
strcat
(
new_
filename
,
save_suffix
);
if
(
link
(
convert_
path
,
new_path
)
==
-
1
)
if
(
link
(
convert_
filename
,
new_filename
)
==
-
1
)
{
{
if
(
errno
==
EEXIST
)
if
(
errno
==
EEXIST
)
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
fprintf
(
stderr
,
"%s: warning: file `%s' already saved in `%s'
\n
"
,
fprintf
(
stderr
,
"%s: warning: file `%s' already saved in `%s'
\n
"
,
pname
,
pname
,
shortpath
(
NULL
,
convert_path
),
shortpath
(
NULL
,
convert_filename
),
shortpath
(
NULL
,
new_path
));
shortpath
(
NULL
,
new_filename
));
}
}
else
else
{
{
fprintf
(
stderr
,
"%s: error: can't link file `%s' to `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't link file `%s' to `%s': %s
\n
"
,
pname
,
pname
,
shortpath
(
NULL
,
convert_path
),
shortpath
(
NULL
,
convert_filename
),
shortpath
(
NULL
,
new_path
),
shortpath
(
NULL
,
new_filename
),
sys_errlist
[
errno
]);
sys_errlist
[
errno
]);
return
;
return
;
}
}
}
}
}
}
if
(
unlink
(
convert_
path
)
==
-
1
)
if
(
unlink
(
convert_
filename
)
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't delete file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't delete file `%s': %s
\n
"
,
pname
,
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
shortpath
(
NULL
,
convert_path
),
sys_errlist
[
errno
]);
return
;
return
;
}
}
...
@@ -4060,12 +4072,11 @@ edit_file (const hash_table_entry *hp)
...
@@ -4060,12 +4072,11 @@ edit_file (const hash_table_entry *hp)
/* Open (and create) the output file. */
/* Open (and create) the output file. */
if
((
output_file
=
creat
(
convert_
path
,
0666
))
==
-
1
)
if
((
output_file
=
creat
(
convert_
filename
,
0666
))
==
-
1
)
{
{
fprintf
(
stderr
,
"%s: error: can't create/open output file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't create/open output file `%s': %s
\n
"
,
pname
,
pname
,
shortpath
(
NULL
,
convert_filename
),
shortpath
(
NULL
,
convert_path
),
sys_errlist
[
errno
]);
sys_errlist
[
errno
]);
return
;
return
;
}
}
...
@@ -4076,7 +4087,8 @@ edit_file (const hash_table_entry *hp)
...
@@ -4076,7 +4087,8 @@ edit_file (const hash_table_entry *hp)
if
(
write
(
output_file
,
repl_text_base
,
out_size
)
!=
out_size
)
if
(
write
(
output_file
,
repl_text_base
,
out_size
)
!=
out_size
)
fprintf
(
stderr
,
"%s: error: while writing file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: while writing file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_path
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
}
}
close
(
output_file
);
close
(
output_file
);
...
@@ -4090,9 +4102,10 @@ edit_file (const hash_table_entry *hp)
...
@@ -4090,9 +4102,10 @@ edit_file (const hash_table_entry *hp)
/* Change the mode of the output file to match the original file. */
/* Change the mode of the output file to match the original file. */
if
(
chmod
(
convert_path
,
stat_buf
.
st_mode
)
==
-
1
)
/* The cast avoids an erroneous warning on AIX. */
if
(
chmod
((
char
*
)
convert_filename
,
stat_buf
.
st_mode
)
==
-
1
)
fprintf
(
stderr
,
"%s: error: can't change mode of file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error: can't change mode of file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_path
),
sys_errlist
[
errno
]);
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
/* Note: We would try to change the owner and group of the output file
/* Note: We would try to change the owner and group of the output file
to match those of the input file here, except that may not be a good
to match those of the input file here, except that may not be a good
...
@@ -4108,7 +4121,8 @@ static void
...
@@ -4108,7 +4121,8 @@ static void
do_processing
(
void
)
do_processing
(
void
)
{
{
const
char
*
const
*
base_pp
;
const
char
*
const
*
base_pp
;
const
char
*
const
*
const
end_pps
=
&
base_source_paths
[
base_source_files
];
const
char
*
const
*
const
end_pps
=
&
base_source_filenames
[
n_base_source_files
];
#ifndef UNPROTOIZE
#ifndef UNPROTOIZE
int
syscalls_len
;
int
syscalls_len
;
...
@@ -4119,7 +4133,7 @@ do_processing (void)
...
@@ -4119,7 +4133,7 @@ do_processing (void)
aux_info_file just read will be automatically deleted unless the
aux_info_file just read will be automatically deleted unless the
keep_flag is set. */
keep_flag is set. */
for
(
base_pp
=
base_source_
path
s
;
base_pp
<
end_pps
;
base_pp
++
)
for
(
base_pp
=
base_source_
filename
s
;
base_pp
<
end_pps
;
base_pp
++
)
process_aux_info_file
(
*
base_pp
,
keep_flag
,
0
);
process_aux_info_file
(
*
base_pp
,
keep_flag
,
0
);
#ifndef UNPROTOIZE
#ifndef UNPROTOIZE
...
@@ -4129,31 +4143,31 @@ do_processing (void)
...
@@ -4129,31 +4143,31 @@ do_processing (void)
if
(
nondefault_syscalls_dir
)
if
(
nondefault_syscalls_dir
)
{
{
syscalls_
path
name
syscalls_
absolute_file
name
=
(
char
*
)
xmalloc
(
strlen
(
nondefault_syscalls_dir
)
=
(
char
*
)
xmalloc
(
strlen
(
nondefault_syscalls_dir
)
+
strlen
(
syscalls_filename
)
+
1
);
+
strlen
(
syscalls_filename
)
+
1
);
strcpy
(
syscalls_
path
name
,
nondefault_syscalls_dir
);
strcpy
(
syscalls_
absolute_file
name
,
nondefault_syscalls_dir
);
}
}
else
else
{
{
syscalls_
path
name
syscalls_
absolute_file
name
=
(
char
*
)
xmalloc
(
strlen
(
default_syscalls_dir
)
=
(
char
*
)
xmalloc
(
strlen
(
default_syscalls_dir
)
+
strlen
(
syscalls_filename
)
+
1
);
+
strlen
(
syscalls_filename
)
+
1
);
strcpy
(
syscalls_
path
name
,
default_syscalls_dir
);
strcpy
(
syscalls_
absolute_file
name
,
default_syscalls_dir
);
}
}
syscalls_len
=
strlen
(
syscalls_
path
name
);
syscalls_len
=
strlen
(
syscalls_
file
name
);
if
(
*
(
syscalls_
path
name
+
syscalls_len
-
1
)
!=
'/'
)
if
(
*
(
syscalls_
absolute_file
name
+
syscalls_len
-
1
)
!=
'/'
)
{
{
*
(
syscalls_
path
name
+
syscalls_len
++
)
=
'/'
;
*
(
syscalls_
absolute_file
name
+
syscalls_len
++
)
=
'/'
;
*
(
syscalls_
path
name
+
syscalls_len
)
=
'\0'
;
*
(
syscalls_
absolute_file
name
+
syscalls_len
)
=
'\0'
;
}
}
strcat
(
syscalls_
path
name
,
syscalls_filename
);
strcat
(
syscalls_
absolute_file
name
,
syscalls_filename
);
/* Call process_aux_info_file in such a way that it does not try to
/* Call process_aux_info_file in such a way that it does not try to
delete the SYSCALLS aux_info file. */
delete the SYSCALLS aux_info file. */
process_aux_info_file
(
syscalls_
path
name
,
1
,
1
);
process_aux_info_file
(
syscalls_
absolute_file
name
,
1
,
1
);
#endif
/* !defined(UNPROTOIZE) */
#endif
/* !defined(UNPROTOIZE) */
...
@@ -4164,7 +4178,7 @@ do_processing (void)
...
@@ -4164,7 +4178,7 @@ do_processing (void)
file_info record that they hang from. The following line causes all of
file_info record that they hang from. The following line causes all of
these lists to be rearranged into ascending line number order. */
these lists to be rearranged into ascending line number order. */
visit_each_hash_node
(
path
name_primary
,
reverse_def_dec_list
);
visit_each_hash_node
(
file
name_primary
,
reverse_def_dec_list
);
#ifndef UNPROTOIZE
#ifndef UNPROTOIZE
...
@@ -4181,7 +4195,7 @@ do_processing (void)
...
@@ -4181,7 +4195,7 @@ do_processing (void)
/* Now convert each file that can be converted (and needs to be). */
/* Now convert each file that can be converted (and needs to be). */
visit_each_hash_node
(
path
name_primary
,
edit_file
);
visit_each_hash_node
(
file
name_primary
,
edit_file
);
#ifndef UNPROTOIZE
#ifndef UNPROTOIZE
...
@@ -4189,7 +4203,7 @@ do_processing (void)
...
@@ -4189,7 +4203,7 @@ do_processing (void)
files. Don't panic if some of the renames don't work. */
files. Don't panic if some of the renames don't work. */
if
(
cplusplus_flag
&&
!
nochange_flag
)
if
(
cplusplus_flag
&&
!
nochange_flag
)
visit_each_hash_node
(
path
name_primary
,
rename_c_file
);
visit_each_hash_node
(
file
name_primary
,
rename_c_file
);
#endif
/* !defined(UNPROTOIZE) */
#endif
/* !defined(UNPROTOIZE) */
}
}
...
@@ -4231,11 +4245,11 @@ main (int argc, char **const argv)
...
@@ -4231,11 +4245,11 @@ main (int argc, char **const argv)
size
=
100
;
size
=
100
;
while
(
1
)
while
(
1
)
{
{
int
value
;
char
*
value
;
cwd_buffer
=
(
char
*
)
xmalloc
(
size
);
cwd_buffer
=
(
char
*
)
xmalloc
(
size
);
value
=
getcwd
(
cwd_buffer
,
size
);
value
=
getcwd
(
cwd_buffer
,
size
);
if
(
value
>
0
&&
value
<
size
)
if
(
value
!=
0
||
errno
!=
ERANGE
)
break
;
break
;
free
(
cwd_buffer
);
free
(
cwd_buffer
);
size
*=
2
;
size
*=
2
;
...
@@ -4311,23 +4325,23 @@ main (int argc, char **const argv)
...
@@ -4311,23 +4325,23 @@ main (int argc, char **const argv)
}
}
}
}
base_source_files
=
argc
-
optind
;
n_
base_source_files
=
argc
-
optind
;
/* Now actually make a list of the base source
path
names. */
/* Now actually make a list of the base source
file
names. */
base_source_
path
s
=
base_source_
filename
s
=
(
const
char
**
)
xmalloc
((
base_source_files
+
1
)
*
sizeof
(
char
*
));
(
const
char
**
)
xmalloc
((
n_
base_source_files
+
1
)
*
sizeof
(
char
*
));
base_source_files
=
0
;
n_
base_source_files
=
0
;
for
(;
optind
<
argc
;
optind
++
)
for
(;
optind
<
argc
;
optind
++
)
{
{
const
char
*
path
=
abspath
(
NULL
,
argv
[
optind
]);
const
char
*
path
=
abspath
(
NULL
,
argv
[
optind
]);
int
len
=
strlen
(
path
);
int
len
=
strlen
(
path
);
if
(
path
[
len
-
1
]
==
'c'
&&
path
[
len
-
2
]
==
'.'
)
if
(
path
[
len
-
1
]
==
'c'
&&
path
[
len
-
2
]
==
'.'
)
base_source_
paths
[
base_source_files
++
]
=
path
;
base_source_
filenames
[
n_
base_source_files
++
]
=
path
;
else
else
{
{
fprintf
(
stderr
,
"%s: input
path
names must have .c suffixes: %s
\n
"
,
fprintf
(
stderr
,
"%s: input
file
names must have .c suffixes: %s
\n
"
,
pname
,
shortpath
(
NULL
,
path
));
pname
,
shortpath
(
NULL
,
path
));
errors
++
;
errors
++
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment