Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2181)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2182)
@@ -5,4 +5,7 @@
    * meventdisp/MGEvtDisplay.cc:
      - fixed a bug which caused a endlessloop
+
+   * mmain/MStatusDisplay.cc:
+     - fixed UpdatePSHeader for gcc 3.* and Suse 8.2
 
 
Index: /trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc	(revision 2181)
+++ /trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc	(revision 2182)
@@ -1433,45 +1433,49 @@
 void MStatusDisplay::UpdatePSHeader(const TString &name) const
 {
-    const TString newstr("%%DocumentPaperSizes: a4\n%%Orientation: Landscape");
-
-    /* FIXME: Does gcc 2.95 need this flag, too? |ios::nocreate */
+    const TString newstr("%%DocumentPaperSizes: a4\n%%Orientation: Landscape\n");
+    const Int_t   l = newstr.Length();
+
+    Long_t t[4]; // { id, size, flags, modtime }
+    gSystem->GetPathInfo(name, t, t+1, t+2, t+3);
+
+    char *c[2] = { new char[l], new char[l] };
+
     fstream f(name, ios::in|ios::out);
 
     TString str;
-    f >> str;
-
-    const streampos p = f.tellg();
-
-    char *c1 = new char[newstr.Length()];
-    char *c2 = new char[newstr.Length()];
-
-    f.read(c1, newstr.Length());
-
-    f.seekp(p);
-    f.seekp(1, ios::cur);
-
-    f << newstr;
-
+    f >> str >> c[0][0];     // Read "%!PS-Adobe-2.0\n" (Mini Header)
+    f.read(c[0], l);
+    f.seekp(-l, ios::cur);
+    f.write(newstr, l);
+
+    int i=0;
     while (1)
     {
-        const streampos p1 = f.tellg();
-        f.read(c2, newstr.Length());
-        const streampos p2 = f.tellg();
-        f.seekp(p1);
+        streampos p1 = f.tellg();
+        f.read(c[(i+1)%2], l);
+        f.seekp(-l, ios::cur);
+
         if (f)
         {
-            f.write(c1, newstr.Length());
-            memcpy(c1, c2, newstr.Length());
+            f.write(c[i%2],l);
+            i++;
+            i%=2;
             continue;
         }
 
+        const Int_t ssz   = str.Length()+1;        // Length of Mini-Header
+        const Int_t block = t[1]-ssz;              // Length of block to be shifted
+        const Int_t size  = block%l;               // Reminder
+        const Int_t pos   = (block/l)*l + ssz + 1; // Position to start writing
+
         f.clear();
-        f.write(c1, newstr.Length());
-        f.write(c2, p2-p1);
+        f.seekp(pos);
+        f.write(c[i%2], l);
+        f.write(c[(i+1)%2], size);
         break;
     }
 
-    delete c2;
-    delete c1;
+    delete c[1];
+    delete c[0];
 }
 
