Changeset 2182
- Timestamp:
- 06/17/03 12:08:13 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2181 r2182 5 5 * meventdisp/MGEvtDisplay.cc: 6 6 - fixed a bug which caused a endlessloop 7 8 * mmain/MStatusDisplay.cc: 9 - fixed UpdatePSHeader for gcc 3.* and Suse 8.2 7 10 8 11 -
trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc
r2180 r2182 1433 1433 void MStatusDisplay::UpdatePSHeader(const TString &name) const 1434 1434 { 1435 const TString newstr("%%DocumentPaperSizes: a4\n%%Orientation: Landscape"); 1436 1437 /* FIXME: Does gcc 2.95 need this flag, too? |ios::nocreate */ 1435 const TString newstr("%%DocumentPaperSizes: a4\n%%Orientation: Landscape\n"); 1436 const Int_t l = newstr.Length(); 1437 1438 Long_t t[4]; // { id, size, flags, modtime } 1439 gSystem->GetPathInfo(name, t, t+1, t+2, t+3); 1440 1441 char *c[2] = { new char[l], new char[l] }; 1442 1438 1443 fstream f(name, ios::in|ios::out); 1439 1444 1440 1445 TString str; 1441 f >> str; 1442 1443 const streampos p = f.tellg(); 1444 1445 char *c1 = new char[newstr.Length()]; 1446 char *c2 = new char[newstr.Length()]; 1447 1448 f.read(c1, newstr.Length()); 1449 1450 f.seekp(p); 1451 f.seekp(1, ios::cur); 1452 1453 f << newstr; 1454 1446 f >> str >> c[0][0]; // Read "%!PS-Adobe-2.0\n" (Mini Header) 1447 f.read(c[0], l); 1448 f.seekp(-l, ios::cur); 1449 f.write(newstr, l); 1450 1451 int i=0; 1455 1452 while (1) 1456 1453 { 1457 conststreampos p1 = f.tellg();1458 f.read(c 2, newstr.Length());1459 const streampos p2 = f.tellg();1460 f.seekp(p1); 1454 streampos p1 = f.tellg(); 1455 f.read(c[(i+1)%2], l); 1456 f.seekp(-l, ios::cur); 1457 1461 1458 if (f) 1462 1459 { 1463 f.write(c1, newstr.Length()); 1464 memcpy(c1, c2, newstr.Length()); 1460 f.write(c[i%2],l); 1461 i++; 1462 i%=2; 1465 1463 continue; 1466 1464 } 1467 1465 1466 const Int_t ssz = str.Length()+1; // Length of Mini-Header 1467 const Int_t block = t[1]-ssz; // Length of block to be shifted 1468 const Int_t size = block%l; // Reminder 1469 const Int_t pos = (block/l)*l + ssz + 1; // Position to start writing 1470 1468 1471 f.clear(); 1469 f.write(c1, newstr.Length()); 1470 f.write(c2, p2-p1); 1472 f.seekp(pos); 1473 f.write(c[i%2], l); 1474 f.write(c[(i+1)%2], size); 1471 1475 break; 1472 1476 } 1473 1477 1474 delete c 2;1475 delete c 1;1478 delete c[1]; 1479 delete c[0]; 1476 1480 } 1477 1481
Note:
See TracChangeset
for help on using the changeset viewer.