Changeset 18037
- Timestamp:
- 12/15/14 09:36:20 (10 years ago)
- Location:
- branches/MarsResidualTimeSpread
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MarsResidualTimeSpread/mbase/MEnv.cc
r9345 r18037 51 51 #include "MEnv.h" 52 52 53 #include <fstream> 54 #include <exception> 55 53 56 #include <Gtypes.h> 54 57 #include <TObjString.h> … … 97 100 98 101 SetRcName(fname); 102 103 if (!IsTEnvCompliant(name)){ 104 throw "This file can't be correctly parsed by TEnv"; 105 return; 106 } 99 107 100 108 // No file found … … 189 197 190 198 return 0; 199 } 200 201 //--------------------------------------------------------------------------- 202 // 203 // Check if the input file is compatible to the way TEnv parses a resource file. 204 // 205 // Returns true in case everything is file and 206 // false in case there is a problem with the file. 207 // 208 // Background: 209 // This check has been introduced as a workaround for a ROOT feature. 210 // TEnv will not see the last line in a text file, when this last line 211 // does not end with a \n. 212 // 213 // In addition we check for the occurence of \r, since some editors would 214 // place \r instead of \n (unlike windows that uses \n\r), which would 215 // also result in problems. 216 // FIXME: So currently we also complain about "\n\r" and "\r\n" as well as 217 // "\r \t \n" or "\n \t\t\t\r", which would in fact not be a problem at 218 // all. 219 Bool_t MEnv::IsTEnvCompliant(const char *fname) 220 { 221 ifstream ifs(fname); 222 bool printable_char_since_last_lf = false; 223 char c; 224 while (ifs.good()){ 225 ifs.get(c); 226 227 if (c==13){ 228 gLog << err << "Menv::IsTEnvCompliant - file:" << fname 229 << " contains \\r this might lead to parsing errors. " 230 <<"Please exchange \\r by \\n everywhere in that file." 231 << endl; 232 return false; 233 } 234 if (c=='\n'){ 235 printable_char_since_last_lf = false; 236 } 237 if (isgraph(c)){ 238 printable_char_since_last_lf = true; 239 } 240 } 241 if (printable_char_since_last_lf){ 242 gLog << err << "Menv::IsTEnvCompliant - file:" << fname 243 << " must have \\n at the end of the file. " 244 <<"Please make sure this is the case." 245 << endl; 246 return false; 247 } 248 return true; 191 249 } 192 250 -
branches/MarsResidualTimeSpread/mbase/MEnv.h
r9518 r18037 27 27 TString Compile(TString str, const char *post) const; 28 28 Int_t ReadInclude(); 29 Bool_t IsTEnvCompliant(const char *fname); 29 30 30 31 public: -
branches/MarsResidualTimeSpread/mcore/factofits.h
r17304 r18037 224 224 c.SetStr( "RAWSUM", " 0", "Checksum of raw little endian data"); 225 225 c.SetFloat("ZRATIO", 0, "Compression ratio"); 226 226 227 c.SetInt( "ZSHRINK", 1, "Catalog shrink factor"); 227 228 c.End(); … … 280 281 //update relevant keywords 281 282 c.SetFloat("ZRATIO", (float)(1024*1440*2)/(float)(compressed_size)); 282 c.SetInt("PCOUNT", compressed_size + catalog_size); 283 c.SetInt("PCOUNT", compressed_size);// + catalog_size); 284 285 286 //cout << "DEBUG: compressed_size=" << compressed_size << " " << compressed_size%2880 << " " << catalog_size << endl; 287 283 288 284 289 #if GCC_VERSION < 40603 … … 302 307 return good(); 303 308 } 309 304 310 ///Apply the drs offset calibration (overload of super-method) 305 311 virtual void DrsOffsetCalibrate(char* target_location)
Note:
See TracChangeset
for help on using the changeset viewer.