Fix lack of error logging in some situations and fix failure to work on windows when swig is a pure Win32 (non-cygwin) compile

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11034 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-01-07 02:26:34 +00:00
commit 7c81201d28
2 changed files with 24 additions and 14 deletions

View file

@ -329,6 +329,9 @@ static void to_cache(ARGS *args)
while (fgets(out_filename, FILENAME_MAX, file)) { while (fgets(out_filename, FILENAME_MAX, file)) {
char *linefeed = strchr(out_filename, '\n'); char *linefeed = strchr(out_filename, '\n');
if (linefeed) { if (linefeed) {
char *potential_cr = linefeed - 1;
if (potential_cr >= out_filename && *potential_cr == '\r')
*potential_cr = 0;
*linefeed = 0; *linefeed = 0;
if (cached_files_count == 0) { if (cached_files_count == 0) {
@ -337,8 +340,7 @@ static void to_cache(ARGS *args)
sprintf(out_filename_cache, "%s.%d", hashname, cached_files_count); sprintf(out_filename_cache, "%s.%d", hashname, cached_files_count);
} }
if (stat(out_filename, &st1) != 0 || if (commit_to_cache(out_filename, out_filename_cache, hardlink) != 0) {
commit_to_cache(out_filename, out_filename_cache, hardlink) != 0) {
fclose(file); fclose(file);
unlink(tmp_outfiles); unlink(tmp_outfiles);
failed(); failed();
@ -374,8 +376,7 @@ static void to_cache(ARGS *args)
failed(); failed();
} }
} else { } else {
if (stat(output_file, &st1) != 0 || if (commit_to_cache(output_file, hashname, hardlink) != 0) {
commit_to_cache(output_file, hashname, hardlink) != 0) {
failed(); failed();
} }
to_cache_stats_helper(&st1, hashname, 0, &files_size, &cached_files_count); to_cache_stats_helper(&st1, hashname, 0, &files_size, &cached_files_count);
@ -670,6 +671,9 @@ static void from_cache(int first)
while (fgets(out_filename, FILENAME_MAX, file)) { while (fgets(out_filename, FILENAME_MAX, file)) {
char *linefeed = strchr(out_filename, '\n'); char *linefeed = strchr(out_filename, '\n');
if (linefeed) { if (linefeed) {
char *potential_cr = linefeed - 1;
if (potential_cr >= out_filename && *potential_cr == '\r')
*potential_cr = 0;
*linefeed = 0; *linefeed = 0;
if (retrieved_files_count == 0) { if (retrieved_files_count == 0) {

View file

@ -349,6 +349,8 @@ int test_if_compressed(const char *filename) {
int commit_to_cache(const char *src, const char *dest, int hardlink) int commit_to_cache(const char *src, const char *dest, int hardlink)
{ {
int ret = -1; int ret = -1;
struct stat st;
if (stat(src, &st) == 0) {
unlink(dest); unlink(dest);
if (hardlink) { if (hardlink) {
#ifdef _WIN32 #ifdef _WIN32
@ -364,6 +366,10 @@ int commit_to_cache(const char *src, const char *dest, int hardlink)
stats_update(STATS_ERROR); stats_update(STATS_ERROR);
} }
} }
} else {
cc_log("failed to put %s in the cache (%s)\n", src, strerror(errno));
stats_update(STATS_ERROR);
}
return ret; return ret;
} }