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
23459e15
Commit
23459e15
authored
May 20, 2002
by
Kazu Hirata
Committed by
Kazu Hirata
May 20, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* protoize.c: Fix formatting.
From-SVN: r53644
parent
174cc7d1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
770 additions
and
766 deletions
+770
-766
gcc/ChangeLog
+4
-0
gcc/protoize.c
+766
-766
No files found.
gcc/ChangeLog
View file @
23459e15
2002-05-19 Kazu Hirata <kazu@cs.umass.edu>
* protoize.c: Fix formatting.
2002-05-19 Richard Henderson <rth@redhat.com>
2002-05-19 Richard Henderson <rth@redhat.com>
* gensupport.c (init_include_reader): Merge into ...
* gensupport.c (init_include_reader): Merge into ...
...
...
gcc/protoize.c
View file @
23459e15
...
@@ -577,8 +577,8 @@ substr (s1, s2)
...
@@ -577,8 +577,8 @@ substr (s1, s2)
int
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
)
goto
outer
;
goto
outer
;
return
s1
;
return
s1
;
outer
:
outer
:
;
;
...
@@ -730,8 +730,8 @@ file_could_be_converted (const char *path)
...
@@ -730,8 +730,8 @@ file_could_be_converted (const char *path)
{
{
char *slash;
char *slash;
slash = strrchr (dir_last_slash ? dir_last_slash : dir_name,
slash = strrchr (dir_last_slash ? dir_last_slash : dir_name,
DIR_SEPARATOR_2);
DIR_SEPARATOR_2);
if (slash)
if (slash)
dir_last_slash = slash;
dir_last_slash = slash;
}
}
...
@@ -774,8 +774,8 @@ file_normally_convertible (const char *path)
...
@@ -774,8 +774,8 @@ file_normally_convertible (const char *path)
{
{
char *slash;
char *slash;
slash = strrchr (dir_last_slash ? dir_last_slash : dir_name,
slash = strrchr (dir_last_slash ? dir_last_slash : dir_name,
DIR_SEPARATOR_2);
DIR_SEPARATOR_2);
if (slash)
if (slash)
dir_last_slash = slash;
dir_last_slash = slash;
}
}
...
@@ -789,7 +789,7 @@ file_normally_convertible (const char *path)
...
@@ -789,7 +789,7 @@ file_normally_convertible (const char *path)
if (access (path, R_OK))
if (access (path, R_OK))
{
{
if (!quiet_flag)
if (!quiet_flag)
notice ("%s: warning: no read access for file `%s'\n",
notice ("%s: warning: no read access for file `%s'\n",
pname, shortpath (NULL, path));
pname, shortpath (NULL, path));
return 0;
return 0;
}
}
...
@@ -797,7 +797,7 @@ file_normally_convertible (const char *path)
...
@@ -797,7 +797,7 @@ file_normally_convertible (const char *path)
if (access (path, W_OK))
if (access (path, W_OK))
{
{
if (!quiet_flag)
if (!quiet_flag)
notice ("%s: warning: no write access for file `%s'\n",
notice ("%s: warning: no write access for file `%s'\n",
pname, shortpath (NULL, path));
pname, shortpath (NULL, path));
return 0;
return 0;
}
}
...
@@ -805,7 +805,7 @@ file_normally_convertible (const char *path)
...
@@ -805,7 +805,7 @@ file_normally_convertible (const char *path)
if (access (dir_name, W_OK))
if (access (dir_name, W_OK))
{
{
if (!quiet_flag)
if (!quiet_flag)
notice ("%s: warning: no write access for dir containing `%s'\n",
notice ("%s: warning: no write access for dir containing `%s'\n",
pname, shortpath (NULL, path));
pname, shortpath (NULL, path));
return 0;
return 0;
}
}
...
@@ -870,8 +870,8 @@ needs_to_be_converted (file_p)
...
@@ -870,8 +870,8 @@ needs_to_be_converted (file_p)
#endif
/* defined (UNPROTOIZE) */
#endif
/* defined (UNPROTOIZE) */
)
)
/* ... then the containing file needs converting. */
/* ... then the containing file needs converting. */
return
-
1
;
return
-
1
;
return
0
;
return
0
;
}
}
...
@@ -955,11 +955,11 @@ visit_each_hash_node (hash_tab_p, func)
...
@@ -955,11 +955,11 @@ visit_each_hash_node (hash_tab_p, func)
for
(
primary
=
hash_tab_p
;
primary
<
&
hash_tab_p
[
HASH_TABLE_SIZE
];
primary
++
)
for
(
primary
=
hash_tab_p
;
primary
<
&
hash_tab_p
[
HASH_TABLE_SIZE
];
primary
++
)
if
(
primary
->
symbol
)
if
(
primary
->
symbol
)
{
{
hash_table_entry
*
second
;
hash_table_entry
*
second
;
(
*
func
)(
primary
);
(
*
func
)(
primary
);
for
(
second
=
primary
->
hash_next
;
second
;
second
=
second
->
hash_next
)
for
(
second
=
primary
->
hash_next
;
second
;
second
=
second
->
hash_next
)
(
*
func
)
(
second
);
(
*
func
)
(
second
);
}
}
}
}
...
@@ -1006,7 +1006,7 @@ lookup (hash_tab_p, search_symbol)
...
@@ -1006,7 +1006,7 @@ lookup (hash_tab_p, search_symbol)
{
{
p
=
p
->
hash_next
;
p
=
p
->
hash_next
;
if
(
!
strcmp
(
p
->
symbol
,
search_symbol
))
if
(
!
strcmp
(
p
->
symbol
,
search_symbol
))
return
p
;
return
p
;
}
}
p
->
hash_next
=
(
hash_table_entry
*
)
xmalloc
(
sizeof
(
hash_table_entry
));
p
->
hash_next
=
(
hash_table_entry
*
)
xmalloc
(
sizeof
(
hash_table_entry
));
p
=
p
->
hash_next
;
p
=
p
->
hash_next
;
...
@@ -1031,8 +1031,8 @@ free_def_dec (p)
...
@@ -1031,8 +1031,8 @@ free_def_dec (p)
for
(
curr
=
p
->
f_list_chain
;
curr
;
curr
=
next
)
for
(
curr
=
p
->
f_list_chain
;
curr
;
curr
=
next
)
{
{
next
=
curr
->
chain_next
;
next
=
curr
->
chain_next
;
free
((
NONCONST
PTR
)
curr
);
free
((
NONCONST
PTR
)
curr
);
}
}
}
}
#endif
/* !defined (UNPROTOIZE) */
#endif
/* !defined (UNPROTOIZE) */
...
@@ -1069,14 +1069,14 @@ unexpand_if_needed (aux_info_line)
...
@@ -1069,14 +1069,14 @@ unexpand_if_needed (aux_info_line)
for
(
s
=
aux_info_line
;
*
s
!=
'\n'
;
)
for
(
s
=
aux_info_line
;
*
s
!=
'\n'
;
)
{
{
for
(
unexp_p
=
unexpansions
;
unexp_p
->
expanded
;
unexp_p
++
)
for
(
unexp_p
=
unexpansions
;
unexp_p
->
expanded
;
unexp_p
++
)
{
{
const
char
*
in_p
=
unexp_p
->
expanded
;
const
char
*
in_p
=
unexp_p
->
expanded
;
size_t
len
=
strlen
(
in_p
);
size_t
len
=
strlen
(
in_p
);
if
(
*
s
==
*
in_p
&&
!
strncmp
(
s
,
in_p
,
len
)
&&
!
is_id_char
(
s
[
len
]))
if
(
*
s
==
*
in_p
&&
!
strncmp
(
s
,
in_p
,
len
)
&&
!
is_id_char
(
s
[
len
]))
{
{
int
size
=
strlen
(
unexp_p
->
contracted
);
int
size
=
strlen
(
unexp_p
->
contracted
);
got_unexpanded
=
1
;
got_unexpanded
=
1
;
if
(
copy_p
+
size
-
line_buf
>=
line_buf_size
)
if
(
copy_p
+
size
-
line_buf
>=
line_buf_size
)
{
{
int
offset
=
copy_p
-
line_buf
;
int
offset
=
copy_p
-
line_buf
;
...
@@ -1085,16 +1085,16 @@ unexpand_if_needed (aux_info_line)
...
@@ -1085,16 +1085,16 @@ unexpand_if_needed (aux_info_line)
line_buf
=
(
char
*
)
xrealloc
(
line_buf
,
line_buf_size
);
line_buf
=
(
char
*
)
xrealloc
(
line_buf
,
line_buf_size
);
copy_p
=
line_buf
+
offset
;
copy_p
=
line_buf
+
offset
;
}
}
strcpy
(
copy_p
,
unexp_p
->
contracted
);
strcpy
(
copy_p
,
unexp_p
->
contracted
);
copy_p
+=
size
;
copy_p
+=
size
;
/* Assume that there will not be another replacement required
/* Assume that there will not be another replacement required
within the text just replaced. */
within the text just replaced. */
s
+=
len
;
s
+=
len
;
goto
continue_outer
;
goto
continue_outer
;
}
}
}
}
if
(
copy_p
-
line_buf
==
line_buf_size
)
if
(
copy_p
-
line_buf
==
line_buf_size
)
{
{
int
offset
=
copy_p
-
line_buf
;
int
offset
=
copy_p
-
line_buf
;
...
@@ -1126,10 +1126,10 @@ is_abspath (path)
...
@@ -1126,10 +1126,10 @@ is_abspath (path)
{
{
return
(
IS_DIR_SEPARATOR
(
path
[
0
])
return
(
IS_DIR_SEPARATOR
(
path
[
0
])
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
/* Check for disk name on MS-DOS-based systems. */
/* Check for disk name on MS-DOS-based systems. */
||
(
path
[
0
]
&&
path
[
1
]
==
':'
&&
IS_DIR_SEPARATOR
(
path
[
2
]))
||
(
path
[
0
]
&&
path
[
1
]
==
':'
&&
IS_DIR_SEPARATOR
(
path
[
2
]))
#endif
#endif
);
);
}
}
/* Return the absolutized filename for the given relative
/* Return the absolutized filename for the given relative
...
@@ -1162,16 +1162,16 @@ abspath (cwd, rel_filename)
...
@@ -1162,16 +1162,16 @@ abspath (cwd, rel_filename)
if
(
!
is_abspath
(
rel_filename
))
if
(
!
is_abspath
(
rel_filename
))
{
{
src_p
=
cwd2
;
src_p
=
cwd2
;
while
((
*
endp
++
=
*
src_p
++
))
while
((
*
endp
++
=
*
src_p
++
))
continue
;
continue
;
*
(
endp
-
1
)
=
DIR_SEPARATOR
;
/* overwrite null */
*
(
endp
-
1
)
=
DIR_SEPARATOR
;
/* overwrite null */
}
}
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
else
if
(
IS_DIR_SEPARATOR
(
rel_filename
[
0
]))
else
if
(
IS_DIR_SEPARATOR
(
rel_filename
[
0
]))
{
{
/* A path starting with a directory separator is considered absolute
/* A path starting with a directory separator is considered absolute
for dos based filesystems, but it's really not -- it's just the
for dos based filesystems, but it's really not -- it's just the
convention used throughout GCC and it works. However, in this
convention used throughout GCC and it works. However, in this
case, we still need to prepend the drive spec from cwd_buffer. */
case, we still need to prepend the drive spec from cwd_buffer. */
*
endp
++
=
cwd2
[
0
];
*
endp
++
=
cwd2
[
0
];
...
@@ -1195,42 +1195,42 @@ abspath (cwd, rel_filename)
...
@@ -1195,42 +1195,42 @@ abspath (cwd, rel_filename)
for
(;;)
for
(;;)
{
{
if
(
!
inp
[
0
])
if
(
!
inp
[
0
])
break
;
break
;
else
if
(
IS_DIR_SEPARATOR
(
inp
[
0
])
&&
IS_DIR_SEPARATOR
(
outp
[
-
1
]))
else
if
(
IS_DIR_SEPARATOR
(
inp
[
0
])
&&
IS_DIR_SEPARATOR
(
outp
[
-
1
]))
{
{
inp
++
;
inp
++
;
continue
;
continue
;
}
}
else
if
(
inp
[
0
]
==
'.'
&&
IS_DIR_SEPARATOR
(
outp
[
-
1
]))
else
if
(
inp
[
0
]
==
'.'
&&
IS_DIR_SEPARATOR
(
outp
[
-
1
]))
{
{
if
(
!
inp
[
1
])
if
(
!
inp
[
1
])
break
;
break
;
else
if
(
IS_DIR_SEPARATOR
(
inp
[
1
]))
else
if
(
IS_DIR_SEPARATOR
(
inp
[
1
]))
{
{
inp
+=
2
;
inp
+=
2
;
continue
;
continue
;
}
}
else
if
((
inp
[
1
]
==
'.'
)
&&
(
inp
[
2
]
==
0
else
if
((
inp
[
1
]
==
'.'
)
&&
(
inp
[
2
]
==
0
||
IS_DIR_SEPARATOR
(
inp
[
2
])))
||
IS_DIR_SEPARATOR
(
inp
[
2
])))
{
{
inp
+=
(
IS_DIR_SEPARATOR
(
inp
[
2
]))
?
3
:
2
;
inp
+=
(
IS_DIR_SEPARATOR
(
inp
[
2
]))
?
3
:
2
;
outp
-=
2
;
outp
-=
2
;
while
(
outp
>=
abs_buffer
&&
!
IS_DIR_SEPARATOR
(
*
outp
))
while
(
outp
>=
abs_buffer
&&
!
IS_DIR_SEPARATOR
(
*
outp
))
outp
--
;
outp
--
;
if
(
outp
<
abs_buffer
)
if
(
outp
<
abs_buffer
)
{
{
/* Catch cases like /.. where we try to backup to a
/* Catch cases like /.. where we try to backup to a
point above the absolute root of the logical file
point above the absolute root of the logical file
system. */
system. */
notice
(
"%s: invalid file name: %s
\n
"
,
notice
(
"%s: invalid file name: %s
\n
"
,
pname
,
rel_filename
);
pname
,
rel_filename
);
exit
(
FATAL_EXIT_CODE
);
exit
(
FATAL_EXIT_CODE
);
}
}
*++
outp
=
'\0'
;
*++
outp
=
'\0'
;
continue
;
continue
;
}
}
}
}
*
outp
++
=
*
inp
++
;
*
outp
++
=
*
inp
++
;
}
}
...
@@ -1285,29 +1285,29 @@ shortpath (cwd, filename)
...
@@ -1285,29 +1285,29 @@ shortpath (cwd, filename)
{
{
/* whole pwd matched */
/* whole pwd matched */
if
(
!*
path_p
)
/* input *is* the current path! */
if
(
!*
path_p
)
/* input *is* the current path! */
return
"."
;
return
"."
;
else
else
return
++
path_p
;
return
++
path_p
;
}
}
else
else
{
{
if
(
*
path_p
)
if
(
*
path_p
)
{
{
--
cwd_p
;
--
cwd_p
;
--
path_p
;
--
path_p
;
while
(
!
IS_DIR_SEPARATOR
(
*
cwd_p
))
/* backup to last slash */
while
(
!
IS_DIR_SEPARATOR
(
*
cwd_p
))
/* backup to last slash */
{
{
--
cwd_p
;
--
cwd_p
;
--
path_p
;
--
path_p
;
}
}
cwd_p
++
;
cwd_p
++
;
path_p
++
;
path_p
++
;
unmatched_slash_count
++
;
unmatched_slash_count
++
;
}
}
/* Find out how many directory levels in cwd were *not* matched. */
/* Find out how many directory levels in cwd were *not* matched. */
while
(
*
cwd_p
++
)
while
(
*
cwd_p
++
)
if
(
IS_DIR_SEPARATOR
(
*
(
cwd_p
-
1
)))
if
(
IS_DIR_SEPARATOR
(
*
(
cwd_p
-
1
)))
unmatched_slash_count
++
;
unmatched_slash_count
++
;
/* Now we know how long the "short name" will be.
/* Now we know how long the "short name" will be.
...
@@ -1317,15 +1317,15 @@ shortpath (cwd, filename)
...
@@ -1317,15 +1317,15 @@ shortpath (cwd, filename)
/* For each of them, put a `../' at the beginning of the short name. */
/* For each of them, put a `../' at the beginning of the short name. */
while
(
unmatched_slash_count
--
)
while
(
unmatched_slash_count
--
)
{
{
/* Give up if the result gets to be longer
/* Give up if the result gets to be longer
than the absolute path name. */
than the absolute path name. */
if
(
rel_buffer
+
filename_len
<=
rel_buf_p
+
3
)
if
(
rel_buffer
+
filename_len
<=
rel_buf_p
+
3
)
return
filename
;
return
filename
;
*
rel_buf_p
++
=
'.'
;
*
rel_buf_p
++
=
'.'
;
*
rel_buf_p
++
=
'.'
;
*
rel_buf_p
++
=
'.'
;
*
rel_buf_p
++
=
DIR_SEPARATOR
;
*
rel_buf_p
++
=
DIR_SEPARATOR
;
}
}
/* Then tack on the unmatched part of the desired file's name. */
/* Then tack on the unmatched part of the desired file's name. */
do
do
...
@@ -1337,7 +1337,7 @@ shortpath (cwd, filename)
...
@@ -1337,7 +1337,7 @@ shortpath (cwd, filename)
--
rel_buf_p
;
--
rel_buf_p
;
if
(
IS_DIR_SEPARATOR
(
*
(
rel_buf_p
-
1
)))
if
(
IS_DIR_SEPARATOR
(
*
(
rel_buf_p
-
1
)))
*--
rel_buf_p
=
'\0'
;
*--
rel_buf_p
=
'\0'
;
return
rel_buffer
;
return
rel_buffer
;
}
}
}
}
...
@@ -1366,21 +1366,21 @@ find_file (filename, do_not_stat)
...
@@ -1366,21 +1366,21 @@ find_file (filename, do_not_stat)
file_info
*
file_p
=
(
file_info
*
)
xmalloc
(
sizeof
(
file_info
));
file_info
*
file_p
=
(
file_info
*
)
xmalloc
(
sizeof
(
file_info
));
/* If we cannot get status on any given source file, give a warning
/* If we cannot get status on any given source file, give a warning
and then just set its time of last modification to infinity. */
and then just set its time of last modification to infinity. */
if
(
do_not_stat
)
if
(
do_not_stat
)
stat_buf
.
st_mtime
=
(
time_t
)
0
;
stat_buf
.
st_mtime
=
(
time_t
)
0
;
else
else
{
{
if
(
stat
(
filename
,
&
stat_buf
)
==
-
1
)
if
(
stat
(
filename
,
&
stat_buf
)
==
-
1
)
{
{
int
errno_val
=
errno
;
int
errno_val
=
errno
;
notice
(
"%s: %s: can't get status: %s
\n
"
,
notice
(
"%s: %s: can't get status: %s
\n
"
,
pname
,
shortpath
(
NULL
,
filename
),
pname
,
shortpath
(
NULL
,
filename
),
xstrerror
(
errno_val
));
xstrerror
(
errno_val
));
stat_buf
.
st_mtime
=
(
time_t
)
-
1
;
stat_buf
.
st_mtime
=
(
time_t
)
-
1
;
}
}
}
}
hash_entry_p
->
fip
=
file_p
;
hash_entry_p
->
fip
=
file_p
;
file_p
->
hash_entry
=
hash_entry_p
;
file_p
->
hash_entry
=
hash_entry_p
;
...
@@ -1426,14 +1426,14 @@ find_corresponding_lparen (p)
...
@@ -1426,14 +1426,14 @@ find_corresponding_lparen (p)
for
(
paren_depth
=
1
,
q
=
p
-
1
;
paren_depth
;
q
--
)
for
(
paren_depth
=
1
,
q
=
p
-
1
;
paren_depth
;
q
--
)
{
{
switch
(
*
q
)
switch
(
*
q
)
{
{
case
')'
:
case
')'
:
paren_depth
++
;
paren_depth
++
;
break
;
break
;
case
'('
:
case
'('
:
paren_depth
--
;
paren_depth
--
;
break
;
break
;
}
}
}
}
return
++
q
;
return
++
q
;
}
}
...
@@ -1461,9 +1461,9 @@ referenced_file_is_newer (l, aux_info_mtime)
...
@@ -1461,9 +1461,9 @@ referenced_file_is_newer (l, aux_info_mtime)
while
(
*
p
!=
':'
while
(
*
p
!=
':'
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
||
(
*
p
==
':'
&&
*
p
&&
*
(
p
+
1
)
&&
IS_DIR_SEPARATOR
(
*
(
p
+
1
)))
||
(
*
p
==
':'
&&
*
p
&&
*
(
p
+
1
)
&&
IS_DIR_SEPARATOR
(
*
(
p
+
1
)))
#endif
#endif
)
)
p
++
;
p
++
;
filename
=
(
char
*
)
alloca
((
size_t
)
(
p
-
filename_start
)
+
1
);
filename
=
(
char
*
)
alloca
((
size_t
)
(
p
-
filename_start
)
+
1
);
strncpy
(
filename
,
filename_start
,
(
size_t
)
(
p
-
filename_start
));
strncpy
(
filename
,
filename_start
,
(
size_t
)
(
p
-
filename_start
));
...
@@ -1523,9 +1523,9 @@ save_def_or_dec (l, is_syscalls)
...
@@ -1523,9 +1523,9 @@ save_def_or_dec (l, is_syscalls)
while
(
*
p
!=
':'
while
(
*
p
!=
':'
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
||
(
*
p
==
':'
&&
*
p
&&
*
(
p
+
1
)
&&
IS_DIR_SEPARATOR
(
*
(
p
+
1
)))
||
(
*
p
==
':'
&&
*
p
&&
*
(
p
+
1
)
&&
IS_DIR_SEPARATOR
(
*
(
p
+
1
)))
#endif
#endif
)
)
p
++
;
p
++
;
filename
=
(
char
*
)
alloca
((
size_t
)
(
p
-
filename_start
)
+
1
);
filename
=
(
char
*
)
alloca
((
size_t
)
(
p
-
filename_start
)
+
1
);
strncpy
(
filename
,
filename_start
,
(
size_t
)
(
p
-
filename_start
));
strncpy
(
filename
,
filename_start
,
(
size_t
)
(
p
-
filename_start
));
...
@@ -1535,7 +1535,7 @@ save_def_or_dec (l, is_syscalls)
...
@@ -1535,7 +1535,7 @@ save_def_or_dec (l, is_syscalls)
which contained this particular def or dec item. Note that this call
which contained this particular def or dec item. Note that this call
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 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
filenames hash table, and we simultaneously setup file_info records for
filenames hash table, and we simultaneously setup file_info records for
...
@@ -1544,7 +1544,7 @@ save_def_or_dec (l, is_syscalls)
...
@@ -1544,7 +1544,7 @@ save_def_or_dec (l, is_syscalls)
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 -aux-info
which were submitted to gcc for compilation (when the -aux-info
option was used). */
option was used). */
def_dec_p
->
file
=
find_file
(
abspath
(
invocation_filename
,
filename
),
is_syscalls
);
def_dec_p
->
file
=
find_file
(
abspath
(
invocation_filename
,
filename
),
is_syscalls
);
}
}
...
@@ -1554,9 +1554,9 @@ save_def_or_dec (l, is_syscalls)
...
@@ -1554,9 +1554,9 @@ save_def_or_dec (l, is_syscalls)
while
(
*
p
!=
':'
while
(
*
p
!=
':'
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
||
(
*
p
==
':'
&&
*
p
&&
*
(
p
+
1
)
&&
IS_DIR_SEPARATOR
(
*
(
p
+
1
)))
||
(
*
p
==
':'
&&
*
p
&&
*
(
p
+
1
)
&&
IS_DIR_SEPARATOR
(
*
(
p
+
1
)))
#endif
#endif
)
)
p
++
;
p
++
;
strncpy
(
line_number
,
line_number_start
,
(
size_t
)
(
p
-
line_number_start
));
strncpy
(
line_number
,
line_number_start
,
(
size_t
)
(
p
-
line_number_start
));
line_number
[
p
-
line_number_start
]
=
'\0'
;
line_number
[
p
-
line_number_start
]
=
'\0'
;
...
@@ -1657,16 +1657,16 @@ save_def_or_dec (l, is_syscalls)
...
@@ -1657,16 +1657,16 @@ save_def_or_dec (l, is_syscalls)
const
char
*
left_paren_p
=
find_corresponding_lparen
(
p
);
const
char
*
left_paren_p
=
find_corresponding_lparen
(
p
);
#ifndef UNPROTOIZE
#ifndef UNPROTOIZE
{
{
f_list_chain_item
*
cip
f_list_chain_item
*
cip
=
(
f_list_chain_item
*
)
xmalloc
(
sizeof
(
f_list_chain_item
));
=
(
f_list_chain_item
*
)
xmalloc
(
sizeof
(
f_list_chain_item
));
cip
->
formals_list
cip
->
formals_list
=
dupnstr
(
left_paren_p
+
1
,
(
size_t
)
(
p
-
(
left_paren_p
+
1
)));
=
dupnstr
(
left_paren_p
+
1
,
(
size_t
)
(
p
-
(
left_paren_p
+
1
)));
/* Add the new chain item at the head of the current list. */
cip
->
chain_next
=
def_dec_p
->
f_list_chain
;
/* Add the new chain item at the head of the current list. */
def_dec_p
->
f_list_chain
=
cip
;
cip
->
chain_next
=
def_dec_p
->
f_list_chain
;
def_dec_p
->
f_list_chain
=
cip
;
}
}
#endif
/* !defined (UNPROTOIZE) */
#endif
/* !defined (UNPROTOIZE) */
def_dec_p
->
f_list_count
++
;
def_dec_p
->
f_list_count
++
;
...
@@ -1674,15 +1674,15 @@ save_def_or_dec (l, is_syscalls)
...
@@ -1674,15 +1674,15 @@ save_def_or_dec (l, is_syscalls)
p
=
left_paren_p
-
2
;
p
=
left_paren_p
-
2
;
/* p must now point either to another right paren, or to the last
/* p must now point either to another right paren, or to the last
character of the name of the function that was declared/defined.
character of the name of the function that was declared/defined.
If p points to another right paren, then this indicates that we
If p points to another right paren, then this indicates that we
are dealing with multiple formals lists. In that case, there
are dealing with multiple formals lists. In that case, there
really should be another right paren preceding this right paren. */
really should be another right paren preceding this right paren. */
if
(
*
p
!=
')'
)
if
(
*
p
!=
')'
)
break
;
break
;
else
else
check_aux_info
(
*--
p
==
')'
);
check_aux_info
(
*--
p
==
')'
);
}
}
...
@@ -1728,19 +1728,19 @@ save_def_or_dec (l, is_syscalls)
...
@@ -1728,19 +1728,19 @@ save_def_or_dec (l, is_syscalls)
for
(
other
=
def_dec_p
->
hash_entry
->
ddip
;
other
;
other
=
other
->
next_for_func
)
for
(
other
=
def_dec_p
->
hash_entry
->
ddip
;
other
;
other
=
other
->
next_for_func
)
{
{
if
(
def_dec_p
->
line
==
other
->
line
&&
def_dec_p
->
file
==
other
->
file
)
if
(
def_dec_p
->
line
==
other
->
line
&&
def_dec_p
->
file
==
other
->
file
)
{
{
if
(
strcmp
(
def_dec_p
->
ansi_decl
,
other
->
ansi_decl
))
if
(
strcmp
(
def_dec_p
->
ansi_decl
,
other
->
ansi_decl
))
{
{
notice
(
"%s:%d: declaration of function `%s' takes different forms
\n
"
,
notice
(
"%s:%d: declaration of function `%s' takes different forms
\n
"
,
def_dec_p
->
file
->
hash_entry
->
symbol
,
def_dec_p
->
file
->
hash_entry
->
symbol
,
def_dec_p
->
line
,
def_dec_p
->
line
,
def_dec_p
->
hash_entry
->
symbol
);
def_dec_p
->
hash_entry
->
symbol
);
exit
(
FATAL_EXIT_CODE
);
exit
(
FATAL_EXIT_CODE
);
}
}
free_def_dec
(
def_dec_p
);
free_def_dec
(
def_dec_p
);
return
;
return
;
}
}
}
}
}
}
...
@@ -1772,15 +1772,15 @@ save_def_or_dec (l, is_syscalls)
...
@@ -1772,15 +1772,15 @@ save_def_or_dec (l, is_syscalls)
check_aux_info
(
*++
p
==
'('
);
check_aux_info
(
*++
p
==
'('
);
{
{
const
char
*
kr_names_start
=
++
p
;
/* Point just inside '('. */
const
char
*
kr_names_start
=
++
p
;
/* Point just inside '('. */
while
(
*
p
++
!=
')'
)
while
(
*
p
++
!=
')'
)
continue
;
continue
;
p
--
;
/* point to closing right paren */
p
--
;
/* point to closing right paren */
/* Make a copy of the K&R parameter names list. */
/* Make a copy of the K&R parameter names list. */
def_dec_p
->
formal_names
def_dec_p
->
formal_names
=
dupnstr
(
kr_names_start
,
(
size_t
)
(
p
-
kr_names_start
));
=
dupnstr
(
kr_names_start
,
(
size_t
)
(
p
-
kr_names_start
));
}
}
...
@@ -1788,42 +1788,42 @@ save_def_or_dec (l, is_syscalls)
...
@@ -1788,42 +1788,42 @@ save_def_or_dec (l, is_syscalls)
p
++
;
p
++
;
/* p now points to the first character of the K&R style declarations
/* p now points to the first character of the K&R style declarations
list (if there is one) or to the star-slash combination that ends
list (if there is one) or to the star-slash combination that ends
the comment in which such lists get embedded. */
the comment in which such lists get embedded. */
/* Make a copy of the K&R formal decls list and set the def_dec record
/* Make a copy of the K&R formal decls list and set the def_dec record
to point to it. */
to point to it. */
if
(
*
p
==
'*'
)
/* Are there no K&R declarations? */
if
(
*
p
==
'*'
)
/* Are there no K&R declarations? */
{
{
check_aux_info
(
*++
p
==
'/'
);
check_aux_info
(
*++
p
==
'/'
);
def_dec_p
->
formal_decls
=
""
;
def_dec_p
->
formal_decls
=
""
;
}
}
else
else
{
{
const
char
*
kr_decls_start
=
p
;
const
char
*
kr_decls_start
=
p
;
while
(
p
[
0
]
!=
'*'
||
p
[
1
]
!=
'/'
)
while
(
p
[
0
]
!=
'*'
||
p
[
1
]
!=
'/'
)
p
++
;
p
++
;
p
--
;
p
--
;
check_aux_info
(
*
p
==
' '
);
check_aux_info
(
*
p
==
' '
);
def_dec_p
->
formal_decls
def_dec_p
->
formal_decls
=
dupnstr
(
kr_decls_start
,
(
size_t
)
(
p
-
kr_decls_start
));
=
dupnstr
(
kr_decls_start
,
(
size_t
)
(
p
-
kr_decls_start
));
}
}
/* Handle a special case. If we have a function definition marked as
/* Handle a special case. If we have a function definition marked as
being in "old" style, and if its formal names list is empty, then
being in "old" style, and if its formal names list is empty, then
it may actually have the string "void" in its real formals list
it may actually have the string "void" in its real formals list
in the original source code. Just to make sure, we will get setup
in the original source code. Just to make sure, we will get setup
to convert such things anyway.
to convert such things anyway.
This kludge only needs to be here because of an insurmountable
This kludge only needs to be here because of an insurmountable
problem with generating .X files. */
problem with generating .X files. */
if
(
!
def_dec_p
->
prototyped
&&
!*
def_dec_p
->
formal_names
)
if
(
!
def_dec_p
->
prototyped
&&
!*
def_dec_p
->
formal_names
)
def_dec_p
->
prototyped
=
1
;
def_dec_p
->
prototyped
=
1
;
}
}
/* Since we are unprotoizing, if this item is already in old (K&R) style,
/* Since we are unprotoizing, if this item is already in old (K&R) style,
...
@@ -1861,25 +1861,25 @@ save_def_or_dec (l, is_syscalls)
...
@@ -1861,25 +1861,25 @@ save_def_or_dec (l, is_syscalls)
const
def_dec_info
*
next
=
curr
->
next_in_file
;
const
def_dec_info
*
next
=
curr
->
next_in_file
;
while
(
next
&&
(
line
<
curr
->
line
))
while
(
next
&&
(
line
<
curr
->
line
))
{
{
prev
=
curr
;
prev
=
curr
;
curr
=
next
;
curr
=
next
;
next
=
next
->
next_in_file
;
next
=
next
->
next_in_file
;
}
}
if
(
line
>=
curr
->
line
)
if
(
line
>=
curr
->
line
)
{
{
def_dec_p
->
next_in_file
=
curr
;
def_dec_p
->
next_in_file
=
curr
;
if
(
prev
)
if
(
prev
)
((
NONCONST
def_dec_info
*
)
prev
)
->
next_in_file
=
def_dec_p
;
((
NONCONST
def_dec_info
*
)
prev
)
->
next_in_file
=
def_dec_p
;
else
else
def_dec_p
->
file
->
defs_decs
=
def_dec_p
;
def_dec_p
->
file
->
defs_decs
=
def_dec_p
;
}
}
else
/* assert (next == NULL); */
else
/* assert (next == NULL); */
{
{
((
NONCONST
def_dec_info
*
)
curr
)
->
next_in_file
=
def_dec_p
;
((
NONCONST
def_dec_info
*
)
curr
)
->
next_in_file
=
def_dec_p
;
/* assert (next == NULL); */
/* assert (next == NULL); */
def_dec_p
->
next_in_file
=
next
;
def_dec_p
->
next_in_file
=
next
;
}
}
}
}
}
}
...
@@ -1906,38 +1906,38 @@ munge_compile_params (params_list)
...
@@ -1906,38 +1906,38 @@ munge_compile_params (params_list)
for
(;;)
for
(;;)
{
{
while
(
ISSPACE
((
const
unsigned
char
)
*
params_list
))
while
(
ISSPACE
((
const
unsigned
char
)
*
params_list
))
params_list
++
;
params_list
++
;
if
(
!*
params_list
)
if
(
!*
params_list
)
break
;
break
;
param
=
params_list
;
param
=
params_list
;
while
(
*
params_list
&&
!
ISSPACE
((
const
unsigned
char
)
*
params_list
))
while
(
*
params_list
&&
!
ISSPACE
((
const
unsigned
char
)
*
params_list
))
params_list
++
;
params_list
++
;
if
(
param
[
0
]
!=
'-'
)
if
(
param
[
0
]
!=
'-'
)
temp_params
[
param_count
++
]
temp_params
[
param_count
++
]
=
dupnstr
(
param
,
(
size_t
)
(
params_list
-
param
));
=
dupnstr
(
param
,
(
size_t
)
(
params_list
-
param
));
else
else
{
{
switch
(
param
[
1
])
switch
(
param
[
1
])
{
{
case
'g'
:
case
'g'
:
case
'O'
:
case
'O'
:
case
'S'
:
case
'S'
:
case
'c'
:
case
'c'
:
break
;
/* Don't copy these. */
break
;
/* Don't copy these. */
case
'o'
:
case
'o'
:
while
(
ISSPACE
((
const
unsigned
char
)
*
params_list
))
while
(
ISSPACE
((
const
unsigned
char
)
*
params_list
))
params_list
++
;
params_list
++
;
while
(
*
params_list
while
(
*
params_list
&&
!
ISSPACE
((
const
unsigned
char
)
*
params_list
))
&&
!
ISSPACE
((
const
unsigned
char
)
*
params_list
))
params_list
++
;
params_list
++
;
break
;
break
;
default
:
default
:
temp_params
[
param_count
++
]
temp_params
[
param_count
++
]
=
dupnstr
(
param
,
(
size_t
)
(
params_list
-
param
));
=
dupnstr
(
param
,
(
size_t
)
(
params_list
-
param
));
}
}
}
}
if
(
!*
params_list
)
if
(
!*
params_list
)
break
;
break
;
}
}
temp_params
[
param_count
++
]
=
"-aux-info"
;
temp_params
[
param_count
++
]
=
"-aux-info"
;
...
@@ -1947,7 +1947,7 @@ munge_compile_params (params_list)
...
@@ -1947,7 +1947,7 @@ munge_compile_params (params_list)
temp_params
[
param_count
++
]
=
"-S"
;
temp_params
[
param_count
++
]
=
"-S"
;
temp_params
[
param_count
++
]
=
"-o"
;
temp_params
[
param_count
++
]
=
"-o"
;
if
((
stat
(
HOST_BIT_BUCKET
,
&
st
)
==
0
)
if
((
stat
(
HOST_BIT_BUCKET
,
&
st
)
==
0
)
&&
(
!
S_ISDIR
(
st
.
st_mode
))
&&
(
!
S_ISDIR
(
st
.
st_mode
))
&&
(
access
(
HOST_BIT_BUCKET
,
W_OK
)
==
0
))
&&
(
access
(
HOST_BIT_BUCKET
,
W_OK
)
==
0
))
...
@@ -1988,7 +1988,7 @@ gen_aux_info_file (base_filename)
...
@@ -1988,7 +1988,7 @@ gen_aux_info_file (base_filename)
/* Add .X to source file name to get aux-info file name. */
/* Add .X to source file name to get aux-info file name. */
compile_params
[
aux_info_file_name_index
]
=
compile_params
[
aux_info_file_name_index
]
=
concat
(
compile_params
[
input_file_name_index
],
aux_info_suffix
,
NULL
);
concat
(
compile_params
[
input_file_name_index
],
aux_info_suffix
,
NULL
);
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
notice
(
"%s: compiling `%s'
\n
"
,
notice
(
"%s: compiling `%s'
\n
"
,
pname
,
compile_params
[
input_file_name_index
]);
pname
,
compile_params
[
input_file_name_index
]);
...
@@ -2128,27 +2128,27 @@ start_over: ;
...
@@ -2128,27 +2128,27 @@ start_over: ;
struct
stat
stat_buf
;
struct
stat
stat_buf
;
/* Get some status information about this aux_info file. */
/* Get some status information about this aux_info file. */
if
(
stat
(
aux_info_filename
,
&
stat_buf
)
==
-
1
)
if
(
stat
(
aux_info_filename
,
&
stat_buf
)
==
-
1
)
{
{
int
errno_val
=
errno
;
int
errno_val
=
errno
;
notice
(
"%s: can't get status of aux info file `%s': %s
\n
"
,
notice
(
"%s: can't get status of aux info file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_filename
),
pname
,
shortpath
(
NULL
,
aux_info_filename
),
xstrerror
(
errno_val
));
xstrerror
(
errno_val
));
errors
++
;
errors
++
;
return
;
return
;
}
}
/* Check on whether or not this aux_info file is zero length. If it is,
/* Check on whether or not this aux_info file is zero length. If it is,
then just ignore it and return. */
then just ignore it and return. */
if
((
aux_info_size
=
stat_buf
.
st_size
)
==
0
)
if
((
aux_info_size
=
stat_buf
.
st_size
)
==
0
)
return
;
return
;
/* Get the date/time of last modification for this aux_info file and
/* Get the date/time of last modification for this aux_info file and
remember it. We will have to check that any source files that it
remember it. We will have to check that any source files that it
contains information about are at least this old or older. */
contains information about are at least this old or older. */
aux_info_mtime
=
stat_buf
.
st_mtime
;
aux_info_mtime
=
stat_buf
.
st_mtime
;
if
(
!
is_syscalls
)
if
(
!
is_syscalls
)
...
@@ -2179,7 +2179,7 @@ start_over: ;
...
@@ -2179,7 +2179,7 @@ start_over: ;
int
fd_flags
;
int
fd_flags
;
/* Open the aux_info file. */
/* Open the aux_info file. */
fd_flags
=
O_RDONLY
;
fd_flags
=
O_RDONLY
;
#ifdef O_BINARY
#ifdef O_BINARY
/* Use binary mode to avoid having to deal with different EOL characters. */
/* Use binary mode to avoid having to deal with different EOL characters. */
...
@@ -2188,43 +2188,43 @@ start_over: ;
...
@@ -2188,43 +2188,43 @@ start_over: ;
if
((
aux_info_file
=
open
(
aux_info_filename
,
fd_flags
,
0444
))
==
-
1
)
if
((
aux_info_file
=
open
(
aux_info_filename
,
fd_flags
,
0444
))
==
-
1
)
{
{
int
errno_val
=
errno
;
int
errno_val
=
errno
;
notice
(
"%s: can't open aux info file `%s' for reading: %s
\n
"
,
notice
(
"%s: can't open aux info file `%s' for reading: %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_filename
),
pname
,
shortpath
(
NULL
,
aux_info_filename
),
xstrerror
(
errno_val
));
xstrerror
(
errno_val
));
return
;
return
;
}
}
/* Allocate space to hold the aux_info file in memory. */
/* Allocate space to hold the aux_info file in memory. */
aux_info_base
=
xmalloc
(
aux_info_size
+
1
);
aux_info_base
=
xmalloc
(
aux_info_size
+
1
);
aux_info_limit
=
aux_info_base
+
aux_info_size
;
aux_info_limit
=
aux_info_base
+
aux_info_size
;
*
aux_info_limit
=
'\0'
;
*
aux_info_limit
=
'\0'
;
/* Read the aux_info file into memory. */
/* Read the aux_info file into memory. */
if
(
safe_read
(
aux_info_file
,
aux_info_base
,
aux_info_size
)
!=
if
(
safe_read
(
aux_info_file
,
aux_info_base
,
aux_info_size
)
!=
(
int
)
aux_info_size
)
(
int
)
aux_info_size
)
{
{
int
errno_val
=
errno
;
int
errno_val
=
errno
;
notice
(
"%s: error reading aux info file `%s': %s
\n
"
,
notice
(
"%s: error reading aux info file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_filename
),
pname
,
shortpath
(
NULL
,
aux_info_filename
),
xstrerror
(
errno_val
));
xstrerror
(
errno_val
));
free
(
aux_info_base
);
free
(
aux_info_base
);
close
(
aux_info_file
);
close
(
aux_info_file
);
return
;
return
;
}
}
/* Close the aux info file. */
/* Close the aux info file. */
if
(
close
(
aux_info_file
))
if
(
close
(
aux_info_file
))
{
{
int
errno_val
=
errno
;
int
errno_val
=
errno
;
notice
(
"%s: error closing aux info file `%s': %s
\n
"
,
notice
(
"%s: error closing aux info file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_filename
),
pname
,
shortpath
(
NULL
,
aux_info_filename
),
xstrerror
(
errno_val
));
xstrerror
(
errno_val
));
free
(
aux_info_base
);
free
(
aux_info_base
);
close
(
aux_info_file
);
close
(
aux_info_file
);
return
;
return
;
}
}
}
}
...
@@ -2252,9 +2252,9 @@ start_over: ;
...
@@ -2252,9 +2252,9 @@ start_over: ;
while
(
*
p
!=
':'
while
(
*
p
!=
':'
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
||
(
*
p
==
':'
&&
*
p
&&
*
(
p
+
1
)
&&
IS_DIR_SEPARATOR
(
*
(
p
+
1
)))
||
(
*
p
==
':'
&&
*
p
&&
*
(
p
+
1
)
&&
IS_DIR_SEPARATOR
(
*
(
p
+
1
)))
#endif
#endif
)
)
p
++
;
p
++
;
p
++
;
p
++
;
while
(
*
p
==
' '
)
while
(
*
p
==
' '
)
...
@@ -2280,8 +2280,8 @@ start_over: ;
...
@@ -2280,8 +2280,8 @@ start_over: ;
{
{
char
*
slash
;
char
*
slash
;
slash
=
strrchr
(
dir_end
?
dir_end
:
aux_info_relocated_name
,
slash
=
strrchr
(
dir_end
?
dir_end
:
aux_info_relocated_name
,
DIR_SEPARATOR_2
);
DIR_SEPARATOR_2
);
if
(
slash
)
if
(
slash
)
dir_end
=
slash
;
dir_end
=
slash
;
}
}
...
@@ -2306,58 +2306,58 @@ start_over: ;
...
@@ -2306,58 +2306,58 @@ start_over: ;
if
(
!
is_syscalls
)
if
(
!
is_syscalls
)
{
{
current_aux_info_lineno
=
2
;
current_aux_info_lineno
=
2
;
for
(
aux_info_p
=
aux_info_second_line
;
*
aux_info_p
;
)
for
(
aux_info_p
=
aux_info_second_line
;
*
aux_info_p
;
)
{
{
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
);
free
(
aux_info_relocated_name
);
free
(
aux_info_relocated_name
);
if
(
keep_it
&&
unlink
(
aux_info_filename
)
==
-
1
)
if
(
keep_it
&&
unlink
(
aux_info_filename
)
==
-
1
)
{
{
int
errno_val
=
errno
;
int
errno_val
=
errno
;
notice
(
"%s: can't delete file `%s': %s
\n
"
,
notice
(
"%s: can't delete file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_filename
),
pname
,
shortpath
(
NULL
,
aux_info_filename
),
xstrerror
(
errno_val
));
xstrerror
(
errno_val
));
return
;
return
;
}
}
must_create
=
1
;
must_create
=
1
;
goto
start_over
;
goto
start_over
;
}
}
/* Skip over the rest of this line to start of next line. */
/* Skip over the rest of this line to start of next line. */
while
(
*
aux_info_p
!=
'\n'
)
while
(
*
aux_info_p
!=
'\n'
)
aux_info_p
++
;
aux_info_p
++
;
aux_info_p
++
;
aux_info_p
++
;
current_aux_info_lineno
++
;
current_aux_info_lineno
++
;
}
}
}
}
/* Now do the real pass on the aux_info lines. Save their information in
/* Now do the real pass on the aux_info lines. Save their information in
the in-core data base. */
the in-core data base. */
current_aux_info_lineno
=
2
;
current_aux_info_lineno
=
2
;
for
(
aux_info_p
=
aux_info_second_line
;
*
aux_info_p
;)
for
(
aux_info_p
=
aux_info_second_line
;
*
aux_info_p
;)
{
{
char
*
unexpanded_line
=
unexpand_if_needed
(
aux_info_p
);
char
*
unexpanded_line
=
unexpand_if_needed
(
aux_info_p
);
if
(
unexpanded_line
)
if
(
unexpanded_line
)
{
{
save_def_or_dec
(
unexpanded_line
,
is_syscalls
);
save_def_or_dec
(
unexpanded_line
,
is_syscalls
);
free
(
unexpanded_line
);
free
(
unexpanded_line
);
}
}
else
else
save_def_or_dec
(
aux_info_p
,
is_syscalls
);
save_def_or_dec
(
aux_info_p
,
is_syscalls
);
/* Skip over the rest of this line and get to start of next line. */
/* Skip over the rest of this line and get to start of next line. */
while
(
*
aux_info_p
!=
'\n'
)
while
(
*
aux_info_p
!=
'\n'
)
aux_info_p
++
;
aux_info_p
++
;
aux_info_p
++
;
aux_info_p
++
;
current_aux_info_lineno
++
;
current_aux_info_lineno
++
;
}
}
}
}
...
@@ -2377,8 +2377,8 @@ rename_c_file (hp)
...
@@ -2377,8 +2377,8 @@ rename_c_file (hp)
{
{
const
char
*
filename
=
hp
->
symbol
;
const
char
*
filename
=
hp
->
symbol
;
int
last_char_index
=
strlen
(
filename
)
-
1
;
int
last_char_index
=
strlen
(
filename
)
-
1
;
char
*
const
new_filename
=
(
char
*
)
alloca
(
strlen
(
filename
)
char
*
const
new_filename
=
(
char
*
)
alloca
(
strlen
(
filename
)
+
strlen
(
cplus_suffix
)
+
1
);
+
strlen
(
cplus_suffix
)
+
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
...
@@ -2496,51 +2496,51 @@ find_extern_def (head, user)
...
@@ -2496,51 +2496,51 @@ find_extern_def (head, user)
for
(
dd_p
=
head
;
dd_p
;
dd_p
=
dd_p
->
next_for_func
)
for
(
dd_p
=
head
;
dd_p
;
dd_p
=
dd_p
->
next_for_func
)
if
(
dd_p
->
is_func_def
&&
!
dd_p
->
is_static
)
if
(
dd_p
->
is_func_def
&&
!
dd_p
->
is_static
)
{
{
if
(
!
extern_def_p
)
/* Previous definition? */
if
(
!
extern_def_p
)
/* Previous definition? */
extern_def_p
=
dd_p
;
/* Remember the first definition found. */
extern_def_p
=
dd_p
;
/* Remember the first definition found. */
else
else
{
{
/* Ignore definition just found if it came from SYSCALLS.c.X. */
/* Ignore definition just found if it came from SYSCALLS.c.X. */
if
(
is_syscalls_file
(
dd_p
->
file
))
if
(
is_syscalls_file
(
dd_p
->
file
))
continue
;
continue
;
/* Quietly replace the definition previously found with the one
/* Quietly replace the definition previously found with the one
just found if the previous one was from SYSCALLS.c.X. */
just found if the previous one was from SYSCALLS.c.X. */
if
(
is_syscalls_file
(
extern_def_p
->
file
))
if
(
is_syscalls_file
(
extern_def_p
->
file
))
{
{
extern_def_p
=
dd_p
;
extern_def_p
=
dd_p
;
continue
;
continue
;
}
}
/* If we get here, then there is a conflict between two function
/* If we get here, then there is a conflict between two function
declarations for the same function, both of which came from the
declarations for the same function, both of which came from the
user's own code. */
user's own code. */
if
(
!
conflict_noted
)
/* first time we noticed? */
if
(
!
conflict_noted
)
/* first time we noticed? */
{
{
conflict_noted
=
1
;
conflict_noted
=
1
;
notice
(
"%s: conflicting extern definitions of '%s'
\n
"
,
notice
(
"%s: conflicting extern definitions of '%s'
\n
"
,
pname
,
head
->
hash_entry
->
symbol
);
pname
,
head
->
hash_entry
->
symbol
);
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
{
{
notice
(
"%s: declarations of '%s' will not be converted
\n
"
,
notice
(
"%s: declarations of '%s' will not be converted
\n
"
,
pname
,
head
->
hash_entry
->
symbol
);
pname
,
head
->
hash_entry
->
symbol
);
notice
(
"%s: conflict list for '%s' follows:
\n
"
,
notice
(
"%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
->
ansi_decl
);
extern_def_p
->
line
,
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
->
ansi_decl
);
dd_p
->
line
,
dd_p
->
ansi_decl
);
}
}
}
}
/* We want to err on the side of caution, so if we found multiple conflicting
/* We want to err on the side of caution, so if we found multiple conflicting
...
@@ -2553,64 +2553,64 @@ find_extern_def (head, user)
...
@@ -2553,64 +2553,64 @@ find_extern_def (head, user)
if
(
!
extern_def_p
)
if
(
!
extern_def_p
)
{
{
/* We have no definitions for this function so do the next best thing.
/* We have no definitions for this function so do the next best thing.
Search for an extern declaration already in prototype form. */
Search for an extern declaration already in prototype form. */
for
(
dd_p
=
head
;
dd_p
;
dd_p
=
dd_p
->
next_for_func
)
for
(
dd_p
=
head
;
dd_p
;
dd_p
=
dd_p
->
next_for_func
)
if
(
!
dd_p
->
is_func_def
&&
!
dd_p
->
is_static
&&
dd_p
->
prototyped
)
if
(
!
dd_p
->
is_func_def
&&
!
dd_p
->
is_static
&&
dd_p
->
prototyped
)
{
{
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
)
notice
(
"%s: warning: using formals list from %s(%d) for function `%s'
\n
"
,
notice
(
"%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
;
}
}
/* Gripe about unprototyped function declarations that we found no
/* Gripe about unprototyped function declarations that we found no
corresponding definition (or other source of prototype information)
corresponding definition (or other source of prototype information)
for.
for.
Gripe even if the unprototyped declaration we are worried about
Gripe even if the unprototyped declaration we are worried about
exists in a file in one of the "system" include directories. We
exists in a file in one of the "system" include directories. We
can gripe about these because we should have at least found a
can gripe about these because we should have at least found a
corresponding (pseudo) definition in the SYSCALLS.c.X file. If we
corresponding (pseudo) definition in the SYSCALLS.c.X file. If we
didn't, then that means that the SYSCALLS.c.X file is missing some
didn't, then that means that the SYSCALLS.c.X file is missing some
needed prototypes for this particular system. That is worth telling
needed prototypes for this particular system. That is worth telling
the user about! */
the user about! */
if
(
!
extern_def_p
)
if
(
!
extern_def_p
)
{
{
const
char
*
file
=
user
->
file
->
hash_entry
->
symbol
;
const
char
*
file
=
user
->
file
->
hash_entry
->
symbol
;
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
if
(
in_system_include_dir
(
file
))
if
(
in_system_include_dir
(
file
))
{
{
/* Why copy this string into `needed' at all?
/* Why copy this string into `needed' at all?
Why not just use user->ansi_decl without copying? */
Why not just use user->ansi_decl without copying? */
char
*
needed
=
(
char
*
)
alloca
(
strlen
(
user
->
ansi_decl
)
+
1
);
char
*
needed
=
(
char
*
)
alloca
(
strlen
(
user
->
ansi_decl
)
+
1
);
char
*
p
;
char
*
p
;
strcpy
(
needed
,
user
->
ansi_decl
);
strcpy
(
needed
,
user
->
ansi_decl
);
p
=
(
NONCONST
char
*
)
substr
(
needed
,
user
->
hash_entry
->
symbol
)
p
=
(
NONCONST
char
*
)
substr
(
needed
,
user
->
hash_entry
->
symbol
)
+
strlen
(
user
->
hash_entry
->
symbol
)
+
2
;
+
strlen
(
user
->
hash_entry
->
symbol
)
+
2
;
/* Avoid having ??? in the string. */
/* Avoid having ??? in the string. */
*
p
++
=
'?'
;
*
p
++
=
'?'
;
*
p
++
=
'?'
;
*
p
++
=
'?'
;
*
p
++
=
'?'
;
*
p
++
=
'?'
;
strcpy
(
p
,
");"
);
strcpy
(
p
,
");"
);
notice
(
"%s: %d: `%s' used but missing from SYSCALLS
\n
"
,
notice
(
"%s: %d: `%s' used but missing from SYSCALLS
\n
"
,
shortpath
(
NULL
,
file
),
user
->
line
,
shortpath
(
NULL
,
file
),
user
->
line
,
needed
+
7
);
/* Don't print "extern " */
needed
+
7
);
/* Don't print "extern " */
}
}
#if 0
#if 0
else
else
notice ("%s: %d: warning: no extern definition for `%s'\n",
notice ("%s: %d: warning: no extern definition for `%s'\n",
shortpath (NULL, file), user->line,
shortpath (NULL, file), user->line,
user->hash_entry->symbol);
user->hash_entry->symbol);
#endif
#endif
}
}
}
}
return
extern_def_p
;
return
extern_def_p
;
}
}
...
@@ -2631,13 +2631,13 @@ find_static_definition (user)
...
@@ -2631,13 +2631,13 @@ find_static_definition (user)
for
(
dd_p
=
head
;
dd_p
;
dd_p
=
dd_p
->
next_for_func
)
for
(
dd_p
=
head
;
dd_p
;
dd_p
=
dd_p
->
next_for_func
)
if
(
dd_p
->
is_func_def
&&
dd_p
->
is_static
&&
(
dd_p
->
file
==
user
->
file
))
if
(
dd_p
->
is_func_def
&&
dd_p
->
is_static
&&
(
dd_p
->
file
==
user
->
file
))
{
{
static_def_p
=
dd_p
;
/* save a pointer to the definition */
static_def_p
=
dd_p
;
/* save a pointer to the definition */
num_static_defs
++
;
num_static_defs
++
;
}
}
if
(
num_static_defs
==
0
)
if
(
num_static_defs
==
0
)
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
notice
(
"%s: warning: no static definition for `%s' in file `%s'
\n
"
,
notice
(
"%s: warning: no static definition for `%s' in file `%s'
\n
"
,
pname
,
head
->
hash_entry
->
symbol
,
pname
,
head
->
hash_entry
->
symbol
,
shortpath
(
NULL
,
user
->
file
->
hash_entry
->
symbol
));
shortpath
(
NULL
,
user
->
file
->
hash_entry
->
symbol
));
}
}
...
@@ -2717,12 +2717,12 @@ connect_defs_and_decs (hp)
...
@@ -2717,12 +2717,12 @@ connect_defs_and_decs (hp)
for
(
dd_p
=
hp
->
ddip
;
dd_p
;
dd_p
=
dd_p
->
next_for_func
)
for
(
dd_p
=
hp
->
ddip
;
dd_p
;
dd_p
=
dd_p
->
next_for_func
)
if
(
!
dd_p
->
is_func_def
&&
!
dd_p
->
is_static
&&
!
dd_p
->
definition
)
if
(
!
dd_p
->
is_func_def
&&
!
dd_p
->
is_static
&&
!
dd_p
->
definition
)
{
{
if
(
first_extern_reference
)
if
(
first_extern_reference
)
{
{
extern_def_p
=
find_extern_def
(
hp
->
ddip
,
dd_p
);
extern_def_p
=
find_extern_def
(
hp
->
ddip
,
dd_p
);
first_extern_reference
=
0
;
first_extern_reference
=
0
;
}
}
((
NONCONST
def_dec_info
*
)
dd_p
)
->
definition
=
extern_def_p
;
((
NONCONST
def_dec_info
*
)
dd_p
)
->
definition
=
extern_def_p
;
}
}
/* Traverse the list of definitions and declarations for this particular
/* Traverse the list of definitions and declarations for this particular
...
@@ -2748,37 +2748,37 @@ connect_defs_and_decs (hp)
...
@@ -2748,37 +2748,37 @@ connect_defs_and_decs (hp)
for
(
dd_p
=
hp
->
ddip
;
dd_p
;
dd_p
=
dd_p
->
next_for_func
)
for
(
dd_p
=
hp
->
ddip
;
dd_p
;
dd_p
=
dd_p
->
next_for_func
)
if
(
!
dd_p
->
is_func_def
&&
dd_p
->
is_static
&&
!
dd_p
->
definition
)
if
(
!
dd_p
->
is_func_def
&&
dd_p
->
is_static
&&
!
dd_p
->
definition
)
{
{
const
def_dec_info
*
dd_p2
;
const
def_dec_info
*
dd_p2
;
const
def_dec_info
*
static_def
;
const
def_dec_info
*
static_def
;
/* We have now found a single static declaration for which we need to
/* We have now found a single static declaration for which we need to
find a matching definition. We want to minimize the work (and the
find a matching definition. We want to minimize the work (and the
number of warnings), so we will find an appropriate (matching)
number of warnings), so we will find an appropriate (matching)
static definition for this declaration, and then distribute it
static definition for this declaration, and then distribute it
(as the definition for) any and all other static declarations
(as the definition for) any and all other static declarations
for this function name which occur within the same file, and which
for this function name which occur within the same file, and which
do not already have definitions.
do not already have definitions.
Note that a trick is used here to prevent subsequent attempts to
Note that a trick is used here to prevent subsequent attempts to
call find_static_definition for a given function-name & file
call find_static_definition for a given function-name & file
if the first such call returns NULL. Essentially, we convert
if the first such call returns NULL. Essentially, we convert
these NULL return values to -1, and put the -1 into the definition
these NULL return values to -1, and put the -1 into the definition
field for each other static declaration from the same file which
field for each other static declaration from the same file which
does not already have an associated definition.
does not already have an associated definition.
This makes these other static declarations look like they are
This makes these other static declarations look like they are
actually defined already when the outer loop here revisits them
actually defined already when the outer loop here revisits them
later on. Thus, the outer loop will skip over them. Later, we
later on. Thus, the outer loop will skip over them. Later, we
turn the -1's back to NULL's. */
turn the -1's back to NULL's. */
((
NONCONST
def_dec_info
*
)
dd_p
)
->
definition
=
((
NONCONST
def_dec_info
*
)
dd_p
)
->
definition
=
(
static_def
=
find_static_definition
(
dd_p
))
(
static_def
=
find_static_definition
(
dd_p
))
?
static_def
?
static_def
:
(
const
def_dec_info
*
)
-
1
;
:
(
const
def_dec_info
*
)
-
1
;
for
(
dd_p2
=
dd_p
->
next_for_func
;
dd_p2
;
dd_p2
=
dd_p2
->
next_for_func
)
for
(
dd_p2
=
dd_p
->
next_for_func
;
dd_p2
;
dd_p2
=
dd_p2
->
next_for_func
)
if
(
!
dd_p2
->
is_func_def
&&
dd_p2
->
is_static
if
(
!
dd_p2
->
is_func_def
&&
dd_p2
->
is_static
&&
!
dd_p2
->
definition
&&
(
dd_p2
->
file
==
dd_p
->
file
))
&&
!
dd_p2
->
definition
&&
(
dd_p2
->
file
==
dd_p
->
file
))
((
NONCONST
def_dec_info
*
)
dd_p2
)
->
definition
=
dd_p
->
definition
;
((
NONCONST
def_dec_info
*
)
dd_p2
)
->
definition
=
dd_p
->
definition
;
}
}
/* Convert any dummy (-1) definitions we created in the step above back to
/* Convert any dummy (-1) definitions we created in the step above back to
...
@@ -2816,10 +2816,10 @@ declare_source_confusing (clean_p)
...
@@ -2816,10 +2816,10 @@ declare_source_confusing (clean_p)
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
{
{
if
(
clean_p
==
0
)
if
(
clean_p
==
0
)
notice
(
"%s: %d: warning: source too confusing
\n
"
,
notice
(
"%s: %d: warning: source too confusing
\n
"
,
shortpath
(
NULL
,
convert_filename
),
last_known_line_number
);
shortpath
(
NULL
,
convert_filename
),
last_known_line_number
);
else
else
notice
(
"%s: %d: warning: source too confusing
\n
"
,
notice
(
"%s: %d: warning: source too confusing
\n
"
,
shortpath
(
NULL
,
convert_filename
),
shortpath
(
NULL
,
convert_filename
),
identify_lineno
(
clean_p
));
identify_lineno
(
clean_p
));
}
}
...
@@ -2864,7 +2864,7 @@ seek_to_line (n)
...
@@ -2864,7 +2864,7 @@ seek_to_line (n)
while
(
n
>
last_known_line_number
)
while
(
n
>
last_known_line_number
)
{
{
while
(
*
last_known_line_start
!=
'\n'
)
while
(
*
last_known_line_start
!=
'\n'
)
check_source
(
++
last_known_line_start
<
clean_text_limit
,
0
);
check_source
(
++
last_known_line_start
<
clean_text_limit
,
0
);
last_known_line_start
++
;
last_known_line_start
++
;
last_known_line_number
++
;
last_known_line_number
++
;
}
}
...
@@ -2979,12 +2979,12 @@ other_variable_style_function (ansi_header)
...
@@ -2979,12 +2979,12 @@ other_variable_style_function (ansi_header)
const
char
*
candidate
;
const
char
*
candidate
;
if
((
candidate
=
substr
(
p
,
varargs_style_indicator
))
==
0
)
if
((
candidate
=
substr
(
p
,
varargs_style_indicator
))
==
0
)
return
0
;
return
0
;
else
else
if
(
!
is_id_char
(
candidate
[
-
1
])
&&
!
is_id_char
(
candidate
[
len
]))
if
(
!
is_id_char
(
candidate
[
-
1
])
&&
!
is_id_char
(
candidate
[
len
]))
return
1
;
return
1
;
else
else
p
=
candidate
+
1
;
p
=
candidate
+
1
;
}
}
return
0
;
return
0
;
#endif
/* !defined (UNPROTOIZE) */
#endif
/* !defined (UNPROTOIZE) */
...
@@ -3025,7 +3025,7 @@ edit_fn_declaration (def_dec_p, clean_text_p)
...
@@ -3025,7 +3025,7 @@ edit_fn_declaration (def_dec_p, clean_text_p)
if
(
other_variable_style_function
(
definition
->
ansi_decl
))
if
(
other_variable_style_function
(
definition
->
ansi_decl
))
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
notice
(
"%s: %d: warning: varargs function declaration not converted
\n
"
,
notice
(
"%s: %d: warning: varargs function declaration not converted
\n
"
,
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
;
...
@@ -3065,47 +3065,47 @@ edit_fn_declaration (def_dec_p, clean_text_p)
...
@@ -3065,47 +3065,47 @@ edit_fn_declaration (def_dec_p, clean_text_p)
do
do
{
{
for
(;;)
for
(;;)
{
{
/* Scan leftwards until we find some character which can be
/* Scan leftwards until we find some character which can be
part of an identifier. */
part of an identifier. */
while
(
!
is_id_char
(
*
clean_text_p
))
check_source
(
--
clean_text_p
>
clean_read_ptr
,
0
);
while
(
!
is_id_char
(
*
clean_text_p
))
/* Scan backwards until we find a char that cannot be part of an
check_source
(
--
clean_text_p
>
clean_read_ptr
,
0
);
identifier. */
/* Scan backwards until we find a char that cannot be part of an
while
(
is_id_char
(
*
clean_text_p
))
identifier. */
check_source
(
--
clean_text_p
>
clean_read_ptr
,
0
);
while
(
is_id_char
(
*
clean_text_p
))
/* Having found an "id break", see if the following id is the one
check_source
(
--
clean_text_p
>
clean_read_ptr
,
0
);
that we are looking for. If so, then exit from this loop. */
/* Having found an "id break", see if the following id is the one
if
(
!
strncmp
(
clean_text_p
+
1
,
function_to_edit
,
func_name_len
))
that we are looking for. If so, then exit from this loop. */
{
char
ch
=
*
(
clean_text_p
+
1
+
func_name_len
);
if
(
!
strncmp
(
clean_text_p
+
1
,
function_to_edit
,
func_name_len
))
/* Must also check to see that the name in the source text
{
ends where it should (in order to prevent bogus matches
char
ch
=
*
(
clean_text_p
+
1
+
func_name_len
);
on similar but longer identifiers. */
/* Must also check to see that the name in the source text
if
(
!
is_id_char
(
ch
))
ends where it should (in order to prevent bogus matches
break
;
/* exit from loop */
on similar but longer identifiers. */
}
}
if
(
!
is_id_char
(
ch
))
break
;
/* exit from loop */
}
}
/* We have now found the first perfect match for the function name in
/* We have now found the first perfect match for the function name in
our backward search. This may or may not be the actual function
our backward search. This may or may not be the actual function
name at the start of the actual function declaration (i.e. we could
name at the start of the actual function declaration (i.e. we could
have easily been mislead). We will try to avoid getting fooled too
have easily been mislead). We will try to avoid getting fooled too
often by looking forward for the open paren which should follow the
often by looking forward for the open paren which should follow the
identifier we just found. We ignore whitespace while hunting. If
identifier we just found. We ignore whitespace while hunting. If
the next non-whitespace byte we see is *not* an open left paren,
the next non-whitespace byte we see is *not* an open left paren,
then we must assume that we have been fooled and we start over
then we must assume that we have been fooled and we start over
again accordingly. Note that there is no guarantee, that even if
again accordingly. Note that there is no guarantee, that even if
we do see the open paren, that we are in the right place.
we do see the open paren, that we are in the right place.
Programmers do the strangest things sometimes! */
Programmers do the strangest things sometimes! */
end_of_fn_name
=
clean_text_p
+
strlen
(
def_dec_p
->
hash_entry
->
symbol
);
end_of_fn_name
=
clean_text_p
+
strlen
(
def_dec_p
->
hash_entry
->
symbol
);
start_formals
=
forward_to_next_token_char
(
end_of_fn_name
);
start_formals
=
forward_to_next_token_char
(
end_of_fn_name
);
}
}
...
@@ -3126,76 +3126,76 @@ edit_fn_declaration (def_dec_p, clean_text_p)
...
@@ -3126,76 +3126,76 @@ edit_fn_declaration (def_dec_p, clean_text_p)
for
(;;)
for
(;;)
{
{
{
{
int
depth
;
int
depth
;
end_formals
=
start_formals
+
1
;
end_formals
=
start_formals
+
1
;
depth
=
1
;
depth
=
1
;
for
(;
depth
;
check_source
(
++
end_formals
<
clean_text_limit
,
0
))
for
(;
depth
;
check_source
(
++
end_formals
<
clean_text_limit
,
0
))
{
{
switch
(
*
end_formals
)
switch
(
*
end_formals
)
{
{
case
'('
:
case
'('
:
depth
++
;
depth
++
;
break
;
break
;
case
')'
:
case
')'
:
depth
--
;
depth
--
;
break
;
break
;
}
}
}
}
end_formals
--
;
end_formals
--
;
}
}
/* end_formals now points to the closing right paren of the formals
/* end_formals now points to the closing right paren of the formals
list whose left paren is pointed to by start_formals. */
list whose left paren is pointed to by start_formals. */
/* Now, if we are protoizing, we insert the new ANSI-style formals list
/* Now, if we are protoizing, we insert the new ANSI-style formals list
attached to the associated definition of this function. If however
attached to the associated definition of this function. If however
we are unprotoizing, then we simply delete any formals list which
we are unprotoizing, then we simply delete any formals list which
may be present. */
may be present. */
output_up_to
(
start_formals
);
output_up_to
(
start_formals
);
#ifndef UNPROTOIZE
#ifndef UNPROTOIZE
if
(
this_f_list_chain_item
)
if
(
this_f_list_chain_item
)
{
{
output_string
(
this_f_list_chain_item
->
formals_list
);
output_string
(
this_f_list_chain_item
->
formals_list
);
this_f_list_chain_item
=
this_f_list_chain_item
->
chain_next
;
this_f_list_chain_item
=
this_f_list_chain_item
->
chain_next
;
}
}
else
else
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
notice
(
"%s: warning: too many parameter lists in declaration of `%s'
\n
"
,
notice
(
"%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) */
clean_read_ptr
=
end_formals
-
1
;
clean_read_ptr
=
end_formals
-
1
;
/* Now see if it looks like there may be another formals list associated
/* Now see if it looks like there may be another formals list associated
with the function declaration that we are converting (following the
with the function declaration that we are converting (following the
formals list that we just converted. */
formals list that we just converted. */
{
{
const
char
*
another_r_paren
=
forward_to_next_token_char
(
end_formals
);
const
char
*
another_r_paren
=
forward_to_next_token_char
(
end_formals
);
if
((
*
another_r_paren
!=
')'
)
if
((
*
another_r_paren
!=
')'
)
||
(
*
(
start_formals
=
forward_to_next_token_char
(
another_r_paren
))
!=
'('
))
||
(
*
(
start_formals
=
forward_to_next_token_char
(
another_r_paren
))
!=
'('
))
{
{
#ifndef UNPROTOIZE
#ifndef UNPROTOIZE
if
(
this_f_list_chain_item
)
if
(
this_f_list_chain_item
)
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
notice
(
"
\n
%s: warning: too few parameter lists in declaration of `%s'
\n
"
,
notice
(
"
\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) */
break
;
break
;
}
}
}
}
/* There does appear to be yet another formals list, so loop around
/* There does appear to be yet another formals list, so loop around
again, and convert it also. */
again, and convert it also. */
}
}
}
}
...
@@ -3224,14 +3224,14 @@ edit_formals_lists (end_formals, f_list_count, def_dec_p)
...
@@ -3224,14 +3224,14 @@ edit_formals_lists (end_formals, f_list_count, def_dec_p)
for
(;
depth
;
check_source
(
--
start_formals
>
clean_read_ptr
,
0
))
for
(;
depth
;
check_source
(
--
start_formals
>
clean_read_ptr
,
0
))
{
{
switch
(
*
start_formals
)
switch
(
*
start_formals
)
{
{
case
'('
:
case
'('
:
depth
--
;
depth
--
;
break
;
break
;
case
')'
:
case
')'
:
depth
++
;
depth
++
;
break
;
break
;
}
}
}
}
start_formals
++
;
start_formals
++
;
...
@@ -3248,12 +3248,12 @@ edit_formals_lists (end_formals, f_list_count, def_dec_p)
...
@@ -3248,12 +3248,12 @@ edit_formals_lists (end_formals, f_list_count, def_dec_p)
next_end
=
start_formals
-
1
;
next_end
=
start_formals
-
1
;
check_source
(
next_end
>
clean_read_ptr
,
0
);
check_source
(
next_end
>
clean_read_ptr
,
0
);
while
(
ISSPACE
((
const
unsigned
char
)
*
next_end
))
while
(
ISSPACE
((
const
unsigned
char
)
*
next_end
))
check_source
(
--
next_end
>
clean_read_ptr
,
0
);
check_source
(
--
next_end
>
clean_read_ptr
,
0
);
check_source
(
*
next_end
==
')'
,
next_end
);
check_source
(
*
next_end
==
')'
,
next_end
);
check_source
(
--
next_end
>
clean_read_ptr
,
0
);
check_source
(
--
next_end
>
clean_read_ptr
,
0
);
check_source
(
*
next_end
==
')'
,
next_end
);
check_source
(
*
next_end
==
')'
,
next_end
);
if
(
edit_formals_lists
(
next_end
,
f_list_count
,
def_dec_p
))
if
(
edit_formals_lists
(
next_end
,
f_list_count
,
def_dec_p
))
return
1
;
return
1
;
}
}
/* Check that the function name in the header we are working on is the same
/* Check that the function name in the header we are working on is the same
...
@@ -3269,26 +3269,26 @@ edit_formals_lists (end_formals, f_list_count, def_dec_p)
...
@@ -3269,26 +3269,26 @@ edit_formals_lists (end_formals, f_list_count, def_dec_p)
for
(
func_name_limit
=
start_formals
-
1
;
for
(
func_name_limit
=
start_formals
-
1
;
ISSPACE
((
const
unsigned
char
)
*
func_name_limit
);
)
ISSPACE
((
const
unsigned
char
)
*
func_name_limit
);
)
check_source
(
--
func_name_limit
>
clean_read_ptr
,
0
);
check_source
(
--
func_name_limit
>
clean_read_ptr
,
0
);
for
(
func_name_start
=
func_name_limit
++
;
for
(
func_name_start
=
func_name_limit
++
;
is_id_char
(
*
func_name_start
);
is_id_char
(
*
func_name_start
);
func_name_start
--
)
func_name_start
--
)
check_source
(
func_name_start
>
clean_read_ptr
,
0
);
check_source
(
func_name_start
>
clean_read_ptr
,
0
);
func_name_start
++
;
func_name_start
++
;
func_name_len
=
func_name_limit
-
func_name_start
;
func_name_len
=
func_name_limit
-
func_name_start
;
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
))
{
{
notice
(
"%s: %d: warning: found `%s' but expected `%s'
\n
"
,
notice
(
"%s: %d: warning: found `%s' but expected `%s'
\n
"
,
shortpath
(
NULL
,
def_dec_p
->
file
->
hash_entry
->
symbol
),
shortpath
(
NULL
,
def_dec_p
->
file
->
hash_entry
->
symbol
),
identify_lineno
(
func_name_start
),
identify_lineno
(
func_name_start
),
dupnstr
(
func_name_start
,
func_name_len
),
dupnstr
(
func_name_start
,
func_name_len
),
expected
);
expected
);
return
1
;
return
1
;
}
}
}
}
output_up_to
(
start_formals
);
output_up_to
(
start_formals
);
...
@@ -3393,32 +3393,32 @@ find_rightmost_formals_list (clean_text_p)
...
@@ -3393,32 +3393,32 @@ find_rightmost_formals_list (clean_text_p)
/* Look leftward and try to find a right-paren. */
/* Look leftward and try to find a right-paren. */
while
(
*
end_formals
!=
')'
)
while
(
*
end_formals
!=
')'
)
{
{
if
(
ISSPACE
((
const
unsigned
char
)
*
end_formals
))
if
(
ISSPACE
((
const
unsigned
char
)
*
end_formals
))
while
(
ISSPACE
((
const
unsigned
char
)
*
end_formals
))
while
(
ISSPACE
((
const
unsigned
char
)
*
end_formals
))
check_source
(
--
end_formals
>
clean_read_ptr
,
0
);
check_source
(
--
end_formals
>
clean_read_ptr
,
0
);
else
else
check_source
(
--
end_formals
>
clean_read_ptr
,
0
);
check_source
(
--
end_formals
>
clean_read_ptr
,
0
);
}
}
ch
=
*
(
l_brace_p
=
forward_to_next_token_char
(
end_formals
));
ch
=
*
(
l_brace_p
=
forward_to_next_token_char
(
end_formals
));
/* Since it is possible that we found a right paren before the starting
/* Since it is possible that we found a right paren before the starting
'{' of the body which IS NOT the one at the end of the real K&R
'{' of the body which IS NOT the one at the end of the real K&R
formals list (say for instance, we found one embedded inside one of
formals list (say for instance, we found one embedded inside one of
the old K&R formal parameter declarations) we have to check to be
the old K&R formal parameter declarations) we have to check to be
sure that this is in fact the right paren that we were looking for.
sure that this is in fact the right paren that we were looking for.
The one we were looking for *must* be followed by either a '{' or
The one we were looking for *must* be followed by either a '{' or
by an alphabetic character, while others *cannot* validly be followed
by an alphabetic character, while others *cannot* validly be followed
by such characters. */
by such characters. */
if
((
ch
==
'{'
)
||
ISALPHA
((
unsigned
char
)
ch
))
if
((
ch
==
'{'
)
||
ISALPHA
((
unsigned
char
)
ch
))
break
;
break
;
/* At this point, we have found a right paren, but we know that it is
/* At this point, we have found a right paren, but we know that it is
not the one we were looking for, so backup one character and keep
not the one we were looking for, so backup one character and keep
looking. */
looking. */
check_source
(
--
end_formals
>
clean_read_ptr
,
0
);
check_source
(
--
end_formals
>
clean_read_ptr
,
0
);
}
}
...
@@ -3487,9 +3487,9 @@ add_local_decl (def_dec_p, clean_text_p)
...
@@ -3487,9 +3487,9 @@ add_local_decl (def_dec_p, clean_text_p)
if
(
*
start_of_block
!=
'{'
)
if
(
*
start_of_block
!=
'{'
)
{
{
if
(
!
quiet_flag
)
if
(
!
quiet_flag
)
notice
(
"
\n
%s: %d: warning: can't add declaration of `%s' into macro call
\n
"
,
notice
(
"
\n
%s: %d: warning: can't add declaration of `%s' into macro call
\n
"
,
def_dec_p
->
file
->
hash_entry
->
symbol
,
def_dec_p
->
line
,
def_dec_p
->
file
->
hash_entry
->
symbol
,
def_dec_p
->
line
,
def_dec_p
->
hash_entry
->
symbol
);
def_dec_p
->
hash_entry
->
symbol
);
return
;
return
;
}
}
...
@@ -3516,18 +3516,18 @@ add_local_decl (def_dec_p, clean_text_p)
...
@@ -3516,18 +3516,18 @@ add_local_decl (def_dec_p, clean_text_p)
we just found. */
we just found. */
output_up_to
(
ep
);
output_up_to
(
ep
);
/* Now we go ahead and insert the new declaration at this point.
/* Now we go ahead and insert the new declaration at this point.
If the definition of the given function is in the same file that we
If the definition of the given function is in the same file that we
are currently editing, and if its full ANSI declaration normally
are currently editing, and if its full ANSI declaration normally
would start with the keyword `extern', suppress the `extern'. */
would start with the keyword `extern', suppress the `extern'. */
{
{
const
char
*
decl
=
def_dec_p
->
definition
->
ansi_decl
;
const
char
*
decl
=
def_dec_p
->
definition
->
ansi_decl
;
if
((
*
decl
==
'e'
)
&&
(
def_dec_p
->
file
==
def_dec_p
->
definition
->
file
))
if
((
*
decl
==
'e'
)
&&
(
def_dec_p
->
file
==
def_dec_p
->
definition
->
file
))
decl
+=
7
;
decl
+=
7
;
output_string
(
decl
);
output_string
(
decl
);
}
}
...
@@ -3575,10 +3575,10 @@ add_global_decls (file_p, clean_text_p)
...
@@ -3575,10 +3575,10 @@ add_global_decls (file_p, clean_text_p)
for
(;;
--
scan_p
)
for
(;;
--
scan_p
)
{
{
if
(
scan_p
<
clean_text_base
)
if
(
scan_p
<
clean_text_base
)
break
;
break
;
check_source
(
scan_p
>
clean_read_ptr
,
0
);
check_source
(
scan_p
>
clean_read_ptr
,
0
);
if
(
*
scan_p
==
';'
)
if
(
*
scan_p
==
';'
)
break
;
break
;
}
}
/* scan_p now points either to a semicolon, or to just before the start
/* scan_p now points either to a semicolon, or to just before the start
...
@@ -3602,24 +3602,24 @@ add_global_decls (file_p, clean_text_p)
...
@@ -3602,24 +3602,24 @@ add_global_decls (file_p, clean_text_p)
{
{
int
some_decls_added
=
0
;
int
some_decls_added
=
0
;
for
(
dd_p
=
file_p
->
defs_decs
;
dd_p
;
dd_p
=
dd_p
->
next_in_file
)
for
(
dd_p
=
file_p
->
defs_decs
;
dd_p
;
dd_p
=
dd_p
->
next_in_file
)
if
(
dd_p
->
is_implicit
&&
dd_p
->
definition
&&
!
dd_p
->
definition
->
written
)
if
(
dd_p
->
is_implicit
&&
dd_p
->
definition
&&
!
dd_p
->
definition
->
written
)
{
{
const
char
*
decl
=
dd_p
->
definition
->
ansi_decl
;
const
char
*
decl
=
dd_p
->
definition
->
ansi_decl
;
/* If the function for which we are inserting a declaration is
/* If the function for which we are inserting a declaration is
actually defined later in the same file, then suppress the
actually defined later in the same file, then suppress the
leading `extern' keyword (if there is one). */
leading `extern' keyword (if there is one). */
if
(
*
decl
==
'e'
&&
(
dd_p
->
file
==
dd_p
->
definition
->
file
))
if
(
*
decl
==
'e'
&&
(
dd_p
->
file
==
dd_p
->
definition
->
file
))
decl
+=
7
;
decl
+=
7
;
output_string
(
"
\n
"
);
output_string
(
"
\n
"
);
output_string
(
decl
);
output_string
(
decl
);
some_decls_added
=
1
;
some_decls_added
=
1
;
((
NONCONST
def_dec_info
*
)
dd_p
->
definition
)
->
written
=
1
;
((
NONCONST
def_dec_info
*
)
dd_p
->
definition
)
->
written
=
1
;
}
}
if
(
some_decls_added
)
if
(
some_decls_added
)
output_string
(
"
\n\n
"
);
output_string
(
"
\n\n
"
);
}
}
...
@@ -3667,13 +3667,13 @@ edit_fn_definition (def_dec_p, clean_text_p)
...
@@ -3667,13 +3667,13 @@ edit_fn_definition (def_dec_p, clean_text_p)
function with a variable number of arguments, and if the way it does
function with a variable number of arguments, and if the way it does
that is different from that way we would like it (i.e. varargs vs.
that is different from that way we would like it (i.e. varargs vs.
stdarg) then issue a warning and leave the header unconverted. */
stdarg) then issue a warning and leave the header unconverted. */
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
)
notice
(
"%s: %d: warning: definition of %s not converted
\n
"
,
notice
(
"%s: %d: warning: definition of %s not converted
\n
"
,
shortpath
(
NULL
,
def_dec_p
->
file
->
hash_entry
->
symbol
),
shortpath
(
NULL
,
def_dec_p
->
file
->
hash_entry
->
symbol
),
identify_lineno
(
end_formals
),
identify_lineno
(
end_formals
),
other_var_style
);
other_var_style
);
output_up_to
(
end_formals
);
output_up_to
(
end_formals
);
return
;
return
;
...
@@ -3706,11 +3706,11 @@ edit_fn_definition (def_dec_p, clean_text_p)
...
@@ -3706,11 +3706,11 @@ edit_fn_definition (def_dec_p, clean_text_p)
limit_p
=
decl_p
+
strlen
(
decl_p
);
limit_p
=
decl_p
+
strlen
(
decl_p
);
for
(;
decl_p
<
limit_p
;
decl_p
=
semicolon_p
+
2
)
for
(;
decl_p
<
limit_p
;
decl_p
=
semicolon_p
+
2
)
{
{
for
(
semicolon_p
=
decl_p
;
*
semicolon_p
!=
';'
;
semicolon_p
++
)
for
(
semicolon_p
=
decl_p
;
*
semicolon_p
!=
';'
;
semicolon_p
++
)
continue
;
continue
;
output_string
(
"
\n
"
);
output_string
(
"
\n
"
);
output_string
(
indent_string
);
output_string
(
indent_string
);
output_bytes
(
decl_p
,
(
size_t
)
((
semicolon_p
+
1
)
-
decl_p
));
output_bytes
(
decl_p
,
(
size_t
)
((
semicolon_p
+
1
)
-
decl_p
));
}
}
/* If there are no newlines between the end of the formals list and the
/* If there are no newlines between the end of the formals list and the
...
@@ -3718,12 +3718,12 @@ edit_fn_definition (def_dec_p, clean_text_p)
...
@@ -3718,12 +3718,12 @@ edit_fn_definition (def_dec_p, clean_text_p)
for
(
scan_p
=
end_formals
+
1
;
*
scan_p
!=
'{'
;
)
for
(
scan_p
=
end_formals
+
1
;
*
scan_p
!=
'{'
;
)
{
{
if
(
*
scan_p
==
'\n'
)
if
(
*
scan_p
==
'\n'
)
{
{
had_newlines
=
1
;
had_newlines
=
1
;
break
;
break
;
}
}
check_source
(
++
scan_p
<
clean_text_limit
,
0
);
check_source
(
++
scan_p
<
clean_text_limit
,
0
);
}
}
if
(
!
had_newlines
)
if
(
!
had_newlines
)
output_string
(
"
\n
"
);
output_string
(
"
\n
"
);
...
@@ -3754,24 +3754,24 @@ edit_fn_definition (def_dec_p, clean_text_p)
...
@@ -3754,24 +3754,24 @@ edit_fn_definition (def_dec_p, clean_text_p)
scan_orig
=
end_formals_orig
+
1
;
scan_orig
=
end_formals_orig
+
1
;
for
(;
scan
<
start_body
;
scan
++
,
scan_orig
++
)
for
(;
scan
<
start_body
;
scan
++
,
scan_orig
++
)
{
{
if
(
*
scan
==
*
scan_orig
)
if
(
*
scan
==
*
scan_orig
)
{
{
have_newlines
|=
(
*
scan_orig
==
'\n'
);
have_newlines
|=
(
*
scan_orig
==
'\n'
);
/* Leave identical whitespace alone. */
/* Leave identical whitespace alone. */
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_orig
))
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_orig
))
*
((
NONCONST
char
*
)
scan_orig
)
=
' '
;
/* identical - so whiteout */
*
((
NONCONST
char
*
)
scan_orig
)
=
' '
;
/* identical - so whiteout */
}
}
else
else
have_flotsam
=
1
;
have_flotsam
=
1
;
}
}
if
(
have_flotsam
)
if
(
have_flotsam
)
output_bytes
(
end_formals_orig
+
1
,
output_bytes
(
end_formals_orig
+
1
,
(
size_t
)
(
start_body_orig
-
end_formals_orig
)
-
1
);
(
size_t
)
(
start_body_orig
-
end_formals_orig
)
-
1
);
else
else
if
(
have_newlines
)
if
(
have_newlines
)
output_string
(
"
\n
"
);
output_string
(
"
\n
"
);
else
else
output_string
(
" "
);
output_string
(
" "
);
clean_read_ptr
=
start_body
-
1
;
clean_read_ptr
=
start_body
-
1
;
}
}
#endif
/* !defined (UNPROTOIZE) */
#endif
/* !defined (UNPROTOIZE) */
...
@@ -3792,94 +3792,94 @@ do_cleaning (new_clean_text_base, new_clean_text_limit)
...
@@ -3792,94 +3792,94 @@ do_cleaning (new_clean_text_base, new_clean_text_limit)
for
(
scan_p
=
new_clean_text_base
;
scan_p
<
new_clean_text_limit
;
scan_p
++
)
for
(
scan_p
=
new_clean_text_base
;
scan_p
<
new_clean_text_limit
;
scan_p
++
)
{
{
switch
(
*
scan_p
)
switch
(
*
scan_p
)
{
{
case
'/'
:
/* Handle comments. */
case
'/'
:
/* Handle comments. */
if
(
scan_p
[
1
]
!=
'*'
)
if
(
scan_p
[
1
]
!=
'*'
)
goto
regular
;
goto
regular
;
non_whitespace_since_newline
=
1
;
non_whitespace_since_newline
=
1
;
scan_p
[
0
]
=
' '
;
scan_p
[
0
]
=
' '
;
scan_p
[
1
]
=
' '
;
scan_p
[
1
]
=
' '
;
scan_p
+=
2
;
scan_p
+=
2
;
while
(
scan_p
[
1
]
!=
'/'
||
scan_p
[
0
]
!=
'*'
)
while
(
scan_p
[
1
]
!=
'/'
||
scan_p
[
0
]
!=
'*'
)
{
{
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_p
))
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_p
))
*
scan_p
=
' '
;
*
scan_p
=
' '
;
if
(
++
scan_p
>=
new_clean_text_limit
)
if
(
++
scan_p
>=
new_clean_text_limit
)
abort
();
abort
();
}
}
*
scan_p
++
=
' '
;
*
scan_p
++
=
' '
;
*
scan_p
=
' '
;
*
scan_p
=
' '
;
break
;
break
;
case
'#'
:
/* Handle pp directives. */
case
'#'
:
/* Handle pp directives. */
if
(
non_whitespace_since_newline
)
if
(
non_whitespace_since_newline
)
goto
regular
;
goto
regular
;
*
scan_p
=
' '
;
*
scan_p
=
' '
;
while
(
scan_p
[
1
]
!=
'\n'
||
scan_p
[
0
]
==
'\\'
)
while
(
scan_p
[
1
]
!=
'\n'
||
scan_p
[
0
]
==
'\\'
)
{
{
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_p
))
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_p
))
*
scan_p
=
' '
;
*
scan_p
=
' '
;
if
(
++
scan_p
>=
new_clean_text_limit
)
if
(
++
scan_p
>=
new_clean_text_limit
)
abort
();
abort
();
}
}
*
scan_p
++
=
' '
;
*
scan_p
++
=
' '
;
break
;
break
;
case
'\''
:
/* Handle character literals. */
case
'\''
:
/* Handle character literals. */
non_whitespace_since_newline
=
1
;
non_whitespace_since_newline
=
1
;
while
(
scan_p
[
1
]
!=
'\''
||
scan_p
[
0
]
==
'\\'
)
while
(
scan_p
[
1
]
!=
'\''
||
scan_p
[
0
]
==
'\\'
)
{
{
if
(
scan_p
[
0
]
==
'\\'
if
(
scan_p
[
0
]
==
'\\'
&&
!
ISSPACE
((
const
unsigned
char
)
scan_p
[
1
]))
&&
!
ISSPACE
((
const
unsigned
char
)
scan_p
[
1
]))
scan_p
[
1
]
=
' '
;
scan_p
[
1
]
=
' '
;
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_p
))
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_p
))
*
scan_p
=
' '
;
*
scan_p
=
' '
;
if
(
++
scan_p
>=
new_clean_text_limit
)
if
(
++
scan_p
>=
new_clean_text_limit
)
abort
();
abort
();
}
}
*
scan_p
++
=
' '
;
*
scan_p
++
=
' '
;
break
;
break
;
case
'"'
:
/* Handle string literals. */
case
'"'
:
/* Handle string literals. */
non_whitespace_since_newline
=
1
;
non_whitespace_since_newline
=
1
;
while
(
scan_p
[
1
]
!=
'"'
||
scan_p
[
0
]
==
'\\'
)
while
(
scan_p
[
1
]
!=
'"'
||
scan_p
[
0
]
==
'\\'
)
{
{
if
(
scan_p
[
0
]
==
'\\'
if
(
scan_p
[
0
]
==
'\\'
&&
!
ISSPACE
((
const
unsigned
char
)
scan_p
[
1
]))
&&
!
ISSPACE
((
const
unsigned
char
)
scan_p
[
1
]))
scan_p
[
1
]
=
' '
;
scan_p
[
1
]
=
' '
;
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_p
))
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_p
))
*
scan_p
=
' '
;
*
scan_p
=
' '
;
if
(
++
scan_p
>=
new_clean_text_limit
)
if
(
++
scan_p
>=
new_clean_text_limit
)
abort
();
abort
();
}
}
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_p
))
if
(
!
ISSPACE
((
const
unsigned
char
)
*
scan_p
))
*
scan_p
=
' '
;
*
scan_p
=
' '
;
scan_p
++
;
scan_p
++
;
break
;
break
;
case
'\\'
:
/* Handle line continuations. */
case
'\\'
:
/* Handle line continuations. */
if
(
scan_p
[
1
]
!=
'\n'
)
if
(
scan_p
[
1
]
!=
'\n'
)
goto
regular
;
goto
regular
;
*
scan_p
=
' '
;
*
scan_p
=
' '
;
break
;
break
;
case
'\n'
:
case
'\n'
:
non_whitespace_since_newline
=
0
;
/* Reset. */
non_whitespace_since_newline
=
0
;
/* Reset. */
break
;
break
;
case
' '
:
case
' '
:
case
'\v'
:
case
'\v'
:
case
'\t'
:
case
'\t'
:
case
'\r'
:
case
'\r'
:
case
'\f'
:
case
'\f'
:
case
'\b'
:
case
'\b'
:
break
;
/* Whitespace characters. */
break
;
/* Whitespace characters. */
default
:
default
:
regular
:
regular
:
non_whitespace_since_newline
=
1
;
non_whitespace_since_newline
=
1
;
break
;
break
;
}
}
}
}
}
}
...
@@ -3897,14 +3897,14 @@ careful_find_l_paren (p)
...
@@ -3897,14 +3897,14 @@ careful_find_l_paren (p)
for
(
paren_depth
=
1
,
q
=
p
-
1
;
paren_depth
;
check_source
(
--
q
>=
clean_text_base
,
0
))
for
(
paren_depth
=
1
,
q
=
p
-
1
;
paren_depth
;
check_source
(
--
q
>=
clean_text_base
,
0
))
{
{
switch
(
*
q
)
switch
(
*
q
)
{
{
case
')'
:
case
')'
:
paren_depth
++
;
paren_depth
++
;
break
;
break
;
case
'('
:
case
'('
:
paren_depth
--
;
paren_depth
--
;
break
;
break
;
}
}
}
}
return
++
q
;
return
++
q
;
}
}
...
@@ -3939,50 +3939,50 @@ scan_for_missed_items (file_p)
...
@@ -3939,50 +3939,50 @@ scan_for_missed_items (file_p)
for
(
scan_p
=
clean_text_base
;
scan_p
<
limit
;
scan_p
++
)
for
(
scan_p
=
clean_text_base
;
scan_p
<
limit
;
scan_p
++
)
{
{
if
(
*
scan_p
==
')'
)
if
(
*
scan_p
==
')'
)
{
{
static
const
char
*
last_r_paren
;
static
const
char
*
last_r_paren
;
const
char
*
ahead_p
;
const
char
*
ahead_p
;
last_r_paren
=
scan_p
;
last_r_paren
=
scan_p
;
for
(
ahead_p
=
scan_p
+
1
;
ISSPACE
((
const
unsigned
char
)
*
ahead_p
);
)
for
(
ahead_p
=
scan_p
+
1
;
ISSPACE
((
const
unsigned
char
)
*
ahead_p
);
)
check_source
(
++
ahead_p
<
limit
,
limit
);
check_source
(
++
ahead_p
<
limit
,
limit
);
scan_p
=
ahead_p
-
1
;
scan_p
=
ahead_p
-
1
;
if
(
ISALPHA
((
const
unsigned
char
)
*
ahead_p
)
||
*
ahead_p
==
'{'
)
if
(
ISALPHA
((
const
unsigned
char
)
*
ahead_p
)
||
*
ahead_p
==
'{'
)
{
{
const
char
*
last_l_paren
;
const
char
*
last_l_paren
;
const
int
lineno
=
identify_lineno
(
ahead_p
);
const
int
lineno
=
identify_lineno
(
ahead_p
);
if
(
setjmp
(
source_confusion_recovery
))
if
(
setjmp
(
source_confusion_recovery
))
continue
;
continue
;
/* We know we have a function definition header. Now skip
/* We know we have a function definition header. Now skip
leftwards over all of its associated formals lists. */
leftwards over all of its associated formals lists. */
do
do
{
{
last_l_paren
=
careful_find_l_paren
(
last_r_paren
);
last_l_paren
=
careful_find_l_paren
(
last_r_paren
);
for
(
last_r_paren
=
last_l_paren
-
1
;
for
(
last_r_paren
=
last_l_paren
-
1
;
ISSPACE
((
const
unsigned
char
)
*
last_r_paren
);
)
ISSPACE
((
const
unsigned
char
)
*
last_r_paren
);
)
check_source
(
--
last_r_paren
>=
backup_limit
,
backup_limit
);
check_source
(
--
last_r_paren
>=
backup_limit
,
backup_limit
);
}
}
while
(
*
last_r_paren
==
')'
);
while
(
*
last_r_paren
==
')'
);
if
(
is_id_char
(
*
last_r_paren
))
if
(
is_id_char
(
*
last_r_paren
))
{
{
const
char
*
id_limit
=
last_r_paren
+
1
;
const
char
*
id_limit
=
last_r_paren
+
1
;
const
char
*
id_start
;
const
char
*
id_start
;
size_t
id_length
;
size_t
id_length
;
const
def_dec_info
*
dd_p
;
const
def_dec_info
*
dd_p
;
for
(
id_start
=
id_limit
-
1
;
is_id_char
(
*
id_start
);
)
for
(
id_start
=
id_limit
-
1
;
is_id_char
(
*
id_start
);
)
check_source
(
--
id_start
>=
backup_limit
,
backup_limit
);
check_source
(
--
id_start
>=
backup_limit
,
backup_limit
);
id_start
++
;
id_start
++
;
backup_limit
=
id_start
;
backup_limit
=
id_start
;
if
((
id_length
=
(
size_t
)
(
id_limit
-
id_start
))
==
0
)
if
((
id_length
=
(
size_t
)
(
id_limit
-
id_start
))
==
0
)
goto
not_missed
;
goto
not_missed
;
{
{
char
*
func_name
=
(
char
*
)
alloca
(
id_length
+
1
);
char
*
func_name
=
(
char
*
)
alloca
(
id_length
+
1
);
...
@@ -4024,9 +4024,9 @@ scan_for_missed_items (file_p)
...
@@ -4024,9 +4024,9 @@ scan_for_missed_items (file_p)
pname
);
pname
);
}
}
not_missed
:
;
not_missed
:
;
}
}
}
}
}
}
}
}
}
}
...
@@ -4041,7 +4041,7 @@ scan_for_missed_items (file_p)
...
@@ -4041,7 +4041,7 @@ scan_for_missed_items (file_p)
Note that the trick of making a copy of the original sans comments &
Note that the trick of making a copy of the original sans comments &
preprocessing directives make the editing a whole lot easier. */
preprocessing directives make the editing a whole lot easier. */
static
void
static
void
edit_file
(
hp
)
edit_file
(
hp
)
const
hash_table_entry
*
hp
;
const
hash_table_entry
*
hp
;
...
@@ -4072,14 +4072,14 @@ edit_file (hp)
...
@@ -4072,14 +4072,14 @@ edit_file (hp)
{
{
if
(
!
quiet_flag
if
(
!
quiet_flag
#ifdef UNPROTOIZE
#ifdef UNPROTOIZE
/* Don't even mention "system" include files unless we are
/* Don't even mention "system" include files unless we are
protoizing. If we are protoizing, we mention these as a
protoizing. If we are protoizing, we mention these as a
gentle way of prodding the user to convert his "system"
gentle way of prodding the user to convert his "system"
include files to prototype format. */
include files to prototype format. */
&&
!
in_system_include_dir
(
convert_filename
)
&&
!
in_system_include_dir
(
convert_filename
)
#endif
/* defined (UNPROTOIZE) */
#endif
/* defined (UNPROTOIZE) */
)
)
notice
(
"%s: `%s' not converted
\n
"
,
notice
(
"%s: `%s' not converted
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
));
pname
,
shortpath
(
NULL
,
convert_filename
));
return
;
return
;
}
}
...
@@ -4142,10 +4142,10 @@ edit_file (hp)
...
@@ -4142,10 +4142,10 @@ edit_file (hp)
if
((
input_file
=
open
(
convert_filename
,
fd_flags
,
0444
))
==
-
1
)
if
((
input_file
=
open
(
convert_filename
,
fd_flags
,
0444
))
==
-
1
)
{
{
int
errno_val
=
errno
;
int
errno_val
=
errno
;
notice
(
"%s: can't open file `%s' for reading: %s
\n
"
,
notice
(
"%s: can't open file `%s' for reading: %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
),
pname
,
shortpath
(
NULL
,
convert_filename
),
xstrerror
(
errno_val
));
xstrerror
(
errno_val
));
return
;
return
;
}
}
/* Read the entire original source text file into the original text buffer
/* Read the entire original source text file into the original text buffer
...
@@ -4156,11 +4156,11 @@ edit_file (hp)
...
@@ -4156,11 +4156,11 @@ edit_file (hp)
(
int
)
orig_size
)
(
int
)
orig_size
)
{
{
int
errno_val
=
errno
;
int
errno_val
=
errno
;
close
(
input_file
);
close
(
input_file
);
notice
(
"
\n
%s: error reading input file `%s': %s
\n
"
,
notice
(
"
\n
%s: error reading input file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
),
pname
,
shortpath
(
NULL
,
convert_filename
),
xstrerror
(
errno_val
));
xstrerror
(
errno_val
));
return
;
return
;
}
}
close
(
input_file
);
close
(
input_file
);
...
@@ -4185,22 +4185,22 @@ edit_file (hp)
...
@@ -4185,22 +4185,22 @@ edit_file (hp)
char *const clean_filename = (char *) alloca (strlen (convert_filename) + 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_filename, convert_filename);
strcpy (clean_filename, convert_filename);
strcat (clean_filename, ".clean");
strcat (clean_filename, ".clean");
if ((clean_file = creat (clean_filename, 0666)) == -1)
if ((clean_file = creat (clean_filename, 0666)) == -1)
{
{
int errno_val = errno;
int errno_val = errno;
notice ("%s: can't create/open clean file `%s': %s\n",
notice ("%s: can't create/open clean file `%s': %s\n",
pname, shortpath (NULL, clean_filename),
pname, shortpath (NULL, clean_filename),
xstrerror (errno_val));
xstrerror (errno_val));
return;
return;
}
}
/* Write the clean file. */
/* Write the clean file. */
safe_write (clean_file, new_clean_text_base, clean_size, clean_filename);
safe_write (clean_file, new_clean_text_base, clean_size, clean_filename);
close (clean_file);
close (clean_file);
}
}
#endif /* 0 */
#endif /* 0 */
...
@@ -4226,39 +4226,39 @@ edit_file (hp)
...
@@ -4226,39 +4226,39 @@ edit_file (hp)
def_dec_p
=
file_p
->
defs_decs
;
def_dec_p
=
file_p
->
defs_decs
;
for
(;
def_dec_p
;
def_dec_p
=
def_dec_p
->
next_in_file
)
for
(;
def_dec_p
;
def_dec_p
=
def_dec_p
->
next_in_file
)
{
{
const
char
*
clean_text_p
=
seek_to_line
(
def_dec_p
->
line
);
const
char
*
clean_text_p
=
seek_to_line
(
def_dec_p
->
line
);
/* clean_text_p now points to the first character of the line which
/* clean_text_p now points to the first character of the line which
contains the `terminator' for the declaration or definition that
contains the `terminator' for the declaration or definition that
we are about to process. */
we are about to process. */
#ifndef UNPROTOIZE
#ifndef UNPROTOIZE
if
(
global_flag
&&
def_dec_p
->
is_func_def
&&
first_definition_in_file
)
{
add_global_decls
(
def_dec_p
->
file
,
clean_text_p
);
first_definition_in_file
=
0
;
}
/* Don't edit this item if it is already in prototype format or if it
if
(
global_flag
&&
def_dec_p
->
is_func_def
&&
first_definition_in_file
)
is a function declaration and we have found no corresponding
{
definition. */
add_global_decls
(
def_dec_p
->
file
,
clean_text_p
);
first_definition_in_file
=
0
;
}
if
(
def_dec_p
->
prototyped
/* Don't edit this item if it is already in prototype format or if it
||
(
!
def_dec_p
->
is_func_def
&&
!
def_dec_p
->
definition
))
is a function declaration and we have found no corresponding
continue
;
definition. */
if
(
def_dec_p
->
prototyped
||
(
!
def_dec_p
->
is_func_def
&&
!
def_dec_p
->
definition
))
continue
;
#endif
/* !defined (UNPROTOIZE) */
#endif
/* !defined (UNPROTOIZE) */
if
(
def_dec_p
->
is_func_def
)
if
(
def_dec_p
->
is_func_def
)
edit_fn_definition
(
def_dec_p
,
clean_text_p
);
edit_fn_definition
(
def_dec_p
,
clean_text_p
);
else
else
#ifndef UNPROTOIZE
#ifndef UNPROTOIZE
if
(
def_dec_p
->
is_implicit
)
if
(
def_dec_p
->
is_implicit
)
add_local_decl
(
def_dec_p
,
clean_text_p
);
add_local_decl
(
def_dec_p
,
clean_text_p
);
else
else
#endif
/* !defined (UNPROTOIZE) */
#endif
/* !defined (UNPROTOIZE) */
edit_fn_declaration
(
def_dec_p
,
clean_text_p
);
edit_fn_declaration
(
def_dec_p
,
clean_text_p
);
}
}
}
}
...
@@ -4283,11 +4283,11 @@ edit_file (hp)
...
@@ -4283,11 +4283,11 @@ edit_file (hp)
{
{
char
*
new_filename
char
*
new_filename
=
(
char
*
)
xmalloc
(
strlen
(
convert_filename
)
+
strlen
(
save_suffix
)
+
2
);
=
(
char
*
)
xmalloc
(
strlen
(
convert_filename
)
+
strlen
(
save_suffix
)
+
2
);
strcpy
(
new_filename
,
convert_filename
);
strcpy
(
new_filename
,
convert_filename
);
#ifdef __MSDOS__
#ifdef __MSDOS__
/* MSDOS filenames are restricted to 8.3 format, so we save `foo.c'
/* MSDOS filenames are restricted to 8.3 format, so we save `foo.c'
as `foo.<save_suffix>'. */
as `foo.<save_suffix>'. */
new_filename
[(
strlen
(
convert_filename
)
-
1
]
=
'\0'
;
new_filename
[(
strlen
(
convert_filename
)
-
1
]
=
'\0'
;
#endif
#endif
strcat
(
new_filename
,
save_suffix
);
strcat
(
new_filename
,
save_suffix
);
...
@@ -4302,7 +4302,7 @@ edit_file (hp)
...
@@ -4302,7 +4302,7 @@ edit_file (hp)
shortpath
(
NULL
,
new_filename
));
shortpath
(
NULL
,
new_filename
));
}
}
else
if
(
rename
(
convert_filename
,
new_filename
)
==
-
1
)
else
if
(
rename
(
convert_filename
,
new_filename
)
==
-
1
)
{
{
int
errno_val
=
errno
;
int
errno_val
=
errno
;
notice
(
"%s: can't link file `%s' to `%s': %s
\n
"
,
notice
(
"%s: can't link file `%s' to `%s': %s
\n
"
,
pname
,
pname
,
...
@@ -4310,7 +4310,7 @@ edit_file (hp)
...
@@ -4310,7 +4310,7 @@ edit_file (hp)
shortpath
(
NULL
,
new_filename
),
shortpath
(
NULL
,
new_filename
),
xstrerror
(
errno_val
));
xstrerror
(
errno_val
));
return
;
return
;
}
}
}
}
if
(
unlink
(
convert_filename
)
==
-
1
)
if
(
unlink
(
convert_filename
)
==
-
1
)
...
@@ -4318,7 +4318,7 @@ edit_file (hp)
...
@@ -4318,7 +4318,7 @@ edit_file (hp)
int
errno_val
=
errno
;
int
errno_val
=
errno
;
/* The file may have already been renamed. */
/* The file may have already been renamed. */
if
(
errno_val
!=
ENOENT
)
if
(
errno_val
!=
ENOENT
)
{
{
notice
(
"%s: can't delete file `%s': %s
\n
"
,
notice
(
"%s: can't delete file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
),
pname
,
shortpath
(
NULL
,
convert_filename
),
xstrerror
(
errno_val
));
xstrerror
(
errno_val
));
...
@@ -4330,28 +4330,28 @@ edit_file (hp)
...
@@ -4330,28 +4330,28 @@ edit_file (hp)
int
output_file
;
int
output_file
;
/* Open (and create) the output file. */
/* Open (and create) the output file. */
if
((
output_file
=
creat
(
convert_filename
,
0666
))
==
-
1
)
if
((
output_file
=
creat
(
convert_filename
,
0666
))
==
-
1
)
{
{
int
errno_val
=
errno
;
int
errno_val
=
errno
;
notice
(
"%s: can't create/open output file `%s': %s
\n
"
,
notice
(
"%s: can't create/open output file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
),
pname
,
shortpath
(
NULL
,
convert_filename
),
xstrerror
(
errno_val
));
xstrerror
(
errno_val
));
return
;
return
;
}
}
#ifdef O_BINARY
#ifdef O_BINARY
/* Use binary mode to avoid changing the existing EOL character. */
/* Use binary mode to avoid changing the existing EOL character. */
setmode
(
output_file
,
O_BINARY
);
setmode
(
output_file
,
O_BINARY
);
#endif
#endif
/* Write the output file. */
/* Write the output file. */
{
{
unsigned
int
out_size
=
(
repl_write_ptr
+
1
)
-
repl_text_base
;
unsigned
int
out_size
=
(
repl_write_ptr
+
1
)
-
repl_text_base
;
safe_write
(
output_file
,
repl_text_base
,
out_size
,
convert_filename
);
safe_write
(
output_file
,
repl_text_base
,
out_size
,
convert_filename
);
}
}
close
(
output_file
);
close
(
output_file
);
}
}
...
@@ -4409,8 +4409,8 @@ do_processing ()
...
@@ -4409,8 +4409,8 @@ do_processing ()
if
(
nondefault_syscalls_dir
)
if
(
nondefault_syscalls_dir
)
{
{
syscalls_absolute_filename
syscalls_absolute_filename
=
(
char
*
)
xmalloc
(
strlen
(
nondefault_syscalls_dir
)
+
1
=
(
char
*
)
xmalloc
(
strlen
(
nondefault_syscalls_dir
)
+
1
+
sizeof
(
syscalls_filename
));
+
sizeof
(
syscalls_filename
));
strcpy
(
syscalls_absolute_filename
,
nondefault_syscalls_dir
);
strcpy
(
syscalls_absolute_filename
,
nondefault_syscalls_dir
);
}
}
else
else
...
@@ -4421,10 +4421,10 @@ do_processing ()
...
@@ -4421,10 +4421,10 @@ do_processing ()
default_syscalls_dir
=
standard_exec_prefix
;
default_syscalls_dir
=
standard_exec_prefix
;
}
}
syscalls_absolute_filename
syscalls_absolute_filename
=
(
char
*
)
xmalloc
(
strlen
(
default_syscalls_dir
)
+
0
=
(
char
*
)
xmalloc
(
strlen
(
default_syscalls_dir
)
+
0
+
strlen
(
target_machine
)
+
1
+
strlen
(
target_machine
)
+
1
+
strlen
(
target_version
)
+
1
+
strlen
(
target_version
)
+
1
+
sizeof
(
syscalls_filename
));
+
sizeof
(
syscalls_filename
));
strcpy
(
syscalls_absolute_filename
,
default_syscalls_dir
);
strcpy
(
syscalls_absolute_filename
,
default_syscalls_dir
);
strcat
(
syscalls_absolute_filename
,
target_machine
);
strcat
(
syscalls_absolute_filename
,
target_machine
);
strcat
(
syscalls_absolute_filename
,
"/"
);
strcat
(
syscalls_absolute_filename
,
"/"
);
...
@@ -4439,7 +4439,7 @@ do_processing ()
...
@@ -4439,7 +4439,7 @@ do_processing ()
*
(
syscalls_absolute_filename
+
syscalls_len
)
=
'\0'
;
*
(
syscalls_absolute_filename
+
syscalls_len
)
=
'\0'
;
}
}
strcat
(
syscalls_absolute_filename
,
syscalls_filename
);
strcat
(
syscalls_absolute_filename
,
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. */
...
@@ -4572,7 +4572,7 @@ main (argc, argv)
...
@@ -4572,7 +4572,7 @@ main (argc, argv)
case
'x'
:
case
'x'
:
exclude_list
=
string_list_cons
(
optarg
,
exclude_list
);
exclude_list
=
string_list_cons
(
optarg
,
exclude_list
);
break
;
break
;
case
'v'
:
case
'v'
:
case
'V'
:
case
'V'
:
version_flag
=
1
;
version_flag
=
1
;
...
@@ -4620,7 +4620,7 @@ main (argc, argv)
...
@@ -4620,7 +4620,7 @@ main (argc, argv)
usage
();
usage
();
}
}
}
}
/* Set up compile_params based on -p and -c options. */
/* Set up compile_params based on -p and -c options. */
munge_compile_params
(
params
);
munge_compile_params
(
params
);
...
@@ -4666,7 +4666,7 @@ main (argc, argv)
...
@@ -4666,7 +4666,7 @@ main (argc, argv)
else
else
{
{
if
(
version_flag
)
if
(
version_flag
)
fprintf
(
stderr
,
"%s: %s
\n
"
,
pname
,
version_string
);
fprintf
(
stderr
,
"%s: %s
\n
"
,
pname
,
version_string
);
do_processing
();
do_processing
();
}
}
...
...
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