summaryrefslogtreecommitdiffabout
path: root/lib/sitecing_enflesher.ll
Side-by-side diff
Diffstat (limited to 'lib/sitecing_enflesher.ll') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/sitecing_enflesher.ll1
1 files changed, 0 insertions, 1 deletions
diff --git a/lib/sitecing_enflesher.ll b/lib/sitecing_enflesher.ll
index bb667be..f833af2 100644
--- a/lib/sitecing_enflesher.ll
+++ b/lib/sitecing_enflesher.ll
@@ -211,50 +211,49 @@ void sitecing_enflesher::outs_close() {
}else{
if(stat(fn_s.c_str(),&st_s))
throw preprocessor_error(CODEPOINT,"failed to stat() supposedly created file");
if(st_s.st_size!=st_d.st_size) {
overwrite = true;
}else{
ifstream i_s(fn_s.c_str(),ios::in);
if(!i_s)
throw preprocessor_error(CODEPOINT,"failed to open supposedly created file");
ifstream i_d(fn_d.c_str(),ios::in);
if(!i_d)
throw preprocessor_error(CODEPOINT,"failed to open the old preprocessed source");
off_t remaining = st_s.st_size;
char t1[2048];
char t2[sizeof(t1)];
while(remaining) {
int rb = remaining;
if(rb>sizeof(t1))
rb = sizeof(t1);
if(i_s.read(t1,rb).gcount()!=rb)
throw preprocessor_error(CODEPOINT,"error reading just created file");
if(i_d.read(t2,rb).gcount()!=rb)
throw preprocessor_error(CODEPOINT,"error reading the old preprocessed source");
if(memcmp(t1,t2,rb)) {
overwrite = true;
break;
}
remaining -= rb;
}
}
}
if(overwrite) {
- cerr << "renaming '" << fn_s << "'" << endl;
if(rename(fn_s.c_str(),fn_d.c_str()))
throw preprocessor_error(CODEPOINT,"failed to rename() generated output");
}
}
outs_filename.erase();
}
void sitecing_enflesher::outs_open(const string& nfile) {
outs_close();
outs_filename = nfile;
outs.open((nfile+".new").c_str(),ios::trunc);
if(!outs.good())
throw preprocessor_error(CODEPOINT,"failed to write preprocessor output");
}
/*
* vim:set ft=lex:
*/