Changeset 2182 for trunk


Ignore:
Timestamp:
06/17/03 12:08:13 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2181 r2182  
    55   * meventdisp/MGEvtDisplay.cc:
    66     - fixed a bug which caused a endlessloop
     7
     8   * mmain/MStatusDisplay.cc:
     9     - fixed UpdatePSHeader for gcc 3.* and Suse 8.2
    710
    811
  • trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc

    r2180 r2182  
    14331433void MStatusDisplay::UpdatePSHeader(const TString &name) const
    14341434{
    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
    14381443    fstream f(name, ios::in|ios::out);
    14391444
    14401445    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;
    14551452    while (1)
    14561453    {
    1457         const streampos p1 = f.tellg();
    1458         f.read(c2, 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
    14611458        if (f)
    14621459        {
    1463             f.write(c1, newstr.Length());
    1464             memcpy(c1, c2, newstr.Length());
     1460            f.write(c[i%2],l);
     1461            i++;
     1462            i%=2;
    14651463            continue;
    14661464        }
    14671465
     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
    14681471        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);
    14711475        break;
    14721476    }
    14731477
    1474     delete c2;
    1475     delete c1;
     1478    delete c[1];
     1479    delete c[0];
    14761480}
    14771481
Note: See TracChangeset for help on using the changeset viewer.