summaryrefslogtreecommitdiff
path: root/gcc/protoize.c
diff options
context:
space:
mode:
authorJeff Law <law@gcc.gnu.org>1998-04-04 06:32:39 -0700
committerJeff Law <law@gcc.gnu.org>1998-04-04 06:32:39 -0700
commite5e809f4194e578b5fbd48fc5a1df2377f28d197 (patch)
tree6743f11e58bd7a933b08900d973d89026cd11c43 /gcc/protoize.c
parent31031eddacda46a500b2390f52cd4474bcaf84ca (diff)
downloadgcc-e5e809f4194e578b5fbd48fc5a1df2377f28d197.tar.gz
* Check in merge from gcc2. See ChangeLog.11 and ChangeLog.12
for details. * haifa-sched.c: Mirror recent changes from gcc2. From-SVN: r18984
Diffstat (limited to 'gcc/protoize.c')
-rw-r--r--gcc/protoize.c88
1 files changed, 59 insertions, 29 deletions
diff --git a/gcc/protoize.c b/gcc/protoize.c
index 98f3e33d0d2..8efad717662 100644
--- a/gcc/protoize.c
+++ b/gcc/protoize.c
@@ -128,7 +128,11 @@ extern char *version_string;
#define my_access(file,flag) access((char *)file, flag)
#define my_stat(file,pkt) stat((char *)file, pkt)
+#ifdef __MINGW32__
+#define my_link(file1, file2) -1
+#else
#define my_link(file1, file2) link((char *)file1, (char *)file2)
+#endif
#define my_unlink(file) unlink((char *)file)
#define my_open(file, mode, flag) open((char *)file, mode, flag)
#define my_chmod(file, mode) chmod((char *)file, mode)
@@ -212,9 +216,6 @@ extern int atoi ();
extern int puts ();
extern int fputs ();
extern int fputc ();
-#if !defined(_WIN32)
-extern int link ();
-#endif
extern int unlink ();
extern int access ();
@@ -844,12 +845,13 @@ safe_write (desc, ptr, len, out_fname)
int written = write (desc, ptr, len);
if (written < 0)
{
+ int errno_val = errno;
#ifdef EINTR
- if (errno == EINTR)
+ if (errno_val == EINTR)
continue;
#endif
fprintf (stderr, "%s: error writing file `%s': %s\n",
- pname, shortpath (NULL, out_fname), my_strerror(errno));
+ pname, shortpath (NULL, out_fname), my_strerror (errno_val));
return;
}
ptr += written;
@@ -1540,8 +1542,10 @@ find_file (filename, do_not_stat)
{
if (my_stat (filename, &stat_buf) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: %s: can't get status: %s\n",
- pname, shortpath (NULL, filename), my_strerror(errno));
+ pname, shortpath (NULL, filename),
+ my_strerror (errno_val));
stat_buf.st_mtime = (time_t) -1;
}
}
@@ -2231,9 +2235,10 @@ start_over: ;
}
else
{
+ int errno_val = errno;
fprintf (stderr, "%s: can't read aux info file `%s': %s\n",
pname, shortpath (NULL, aux_info_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
errors++;
return;
}
@@ -2259,9 +2264,10 @@ start_over: ;
}
if (my_access (aux_info_filename, R_OK) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: can't read aux info file `%s': %s\n",
pname, shortpath (NULL, aux_info_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
errors++;
return;
}
@@ -2274,9 +2280,10 @@ start_over: ;
if (my_stat (aux_info_filename, &stat_buf) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: can't get status of aux info file `%s': %s\n",
pname, shortpath (NULL, aux_info_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
errors++;
return;
}
@@ -2301,9 +2308,10 @@ start_over: ;
if (my_stat (base_source_filename, &stat_buf) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: can't get status of aux info file `%s': %s\n",
pname, shortpath (NULL, base_source_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
errors++;
return;
}
@@ -2322,9 +2330,10 @@ start_over: ;
if ((aux_info_file = my_open (aux_info_filename, O_RDONLY, 0444 )) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: can't open aux info file `%s' for reading: %s\n",
pname, shortpath (NULL, aux_info_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
return;
}
@@ -2338,9 +2347,10 @@ start_over: ;
if (safe_read (aux_info_file, aux_info_base, aux_info_size) != aux_info_size)
{
+ int errno_val = errno;
fprintf (stderr, "%s: error reading aux info file `%s': %s\n",
pname, shortpath (NULL, aux_info_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
free (aux_info_base);
close (aux_info_file);
return;
@@ -2350,9 +2360,10 @@ start_over: ;
if (close (aux_info_file))
{
+ int errno_val = errno;
fprintf (stderr, "%s: error closing aux info file `%s': %s\n",
pname, shortpath (NULL, aux_info_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
free (aux_info_base);
close (aux_info_file);
return;
@@ -2364,9 +2375,12 @@ start_over: ;
if (must_create && !keep_it)
if (my_unlink (aux_info_filename) == -1)
- fprintf (stderr, "%s: can't delete aux info file `%s': %s\n",
- pname, shortpath (NULL, aux_info_filename),
- my_strerror(errno));
+ {
+ int errno_val = errno;
+ fprintf (stderr, "%s: can't delete aux info file `%s': %s\n",
+ pname, shortpath (NULL, aux_info_filename),
+ my_strerror (errno_val));
+ }
/* Save a pointer into the first line of the aux_info file which
contains the filename of the directory from which the compiler
@@ -2430,9 +2444,10 @@ start_over: ;
xfree (aux_info_relocated_name);
if (keep_it && my_unlink (aux_info_filename) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: can't delete file `%s': %s\n",
pname, shortpath (NULL, aux_info_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
return;
}
must_create = 1;
@@ -2506,17 +2521,19 @@ rename_c_file (hp)
if (my_link (filename, new_filename) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: warning: can't link file `%s' to `%s': %s\n",
pname, shortpath (NULL, filename),
- shortpath (NULL, new_filename), my_strerror(errno));
+ shortpath (NULL, new_filename), my_strerror (errno_val));
errors++;
return;
}
if (my_unlink (filename) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: warning: can't delete file `%s': %s\n",
- pname, shortpath (NULL, filename), my_strerror(errno));
+ pname, shortpath (NULL, filename), my_strerror (errno_val));
errors++;
return;
}
@@ -4213,8 +4230,10 @@ edit_file (hp)
/* The cast avoids an erroneous warning on AIX. */
if (my_stat ((char *)convert_filename, &stat_buf) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: can't get status for file `%s': %s\n",
- pname, shortpath (NULL, convert_filename), my_strerror(errno));
+ pname, shortpath (NULL, convert_filename),
+ my_strerror (errno_val));
return;
}
orig_size = stat_buf.st_size;
@@ -4247,9 +4266,10 @@ edit_file (hp)
if ((input_file = my_open (convert_filename, O_RDONLY, 0444)) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: can't open file `%s' for reading: %s\n",
pname, shortpath (NULL, convert_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
return;
}
@@ -4259,10 +4279,11 @@ edit_file (hp)
if (safe_read (input_file, new_orig_text_base, orig_size) != orig_size)
{
+ int errno_val = errno;
close (input_file);
fprintf (stderr, "\n%s: error reading input file `%s': %s\n",
pname, shortpath (NULL, convert_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
return;
}
@@ -4293,9 +4314,10 @@ edit_file (hp)
strcat (clean_filename, ".clean");
if ((clean_file = creat (clean_filename, 0666)) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: can't create/open clean file `%s': %s\n",
pname, shortpath (NULL, clean_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
return;
}
@@ -4390,7 +4412,8 @@ edit_file (hp)
strcat (new_filename, save_suffix);
if (my_link (convert_filename, new_filename) == -1)
{
- if (errno == EEXIST)
+ int errno_val = errno;
+ if (errno_val == EEXIST)
{
if (!quiet_flag)
fprintf (stderr, "%s: warning: file `%s' already saved in `%s'\n",
@@ -4404,7 +4427,7 @@ edit_file (hp)
pname,
shortpath (NULL, convert_filename),
shortpath (NULL, new_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
return;
}
}
@@ -4412,8 +4435,10 @@ edit_file (hp)
if (my_unlink (convert_filename) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: can't delete file `%s': %s\n",
- pname, shortpath (NULL, convert_filename), my_strerror(errno));
+ pname, shortpath (NULL, convert_filename),
+ my_strerror (errno_val));
return;
}
@@ -4424,9 +4449,10 @@ edit_file (hp)
if ((output_file = creat (convert_filename, 0666)) == -1)
{
+ int errno_val = errno;
fprintf (stderr, "%s: can't create/open output file `%s': %s\n",
pname, shortpath (NULL, convert_filename),
- my_strerror(errno));
+ my_strerror (errno_val));
return;
}
@@ -4451,8 +4477,12 @@ edit_file (hp)
/* The cast avoids an erroneous warning on AIX. */
if (my_chmod ((char *)convert_filename, stat_buf.st_mode) == -1)
- fprintf (stderr, "%s: can't change mode of file `%s': %s\n",
- pname, shortpath (NULL, convert_filename), my_strerror(errno));
+ {
+ int errno_val = errno;
+ fprintf (stderr, "%s: can't change mode of file `%s': %s\n",
+ pname, shortpath (NULL, convert_filename),
+ my_strerror (errno_val));
+ }
/* Note: We would try to change the owner and group of the output file
to match those of the input file here, except that may not be a good