Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 9194)
+++ trunk/MagicSoft/Mars/Changelog	(revision 9195)
@@ -19,8 +19,50 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2008/12/21 Thomas Bretz
+
+   * Makefile.rules:
+     - removed $(ROOTSYS) from the call to rootcint. It should
+       be in th epath anyway
+
+   * mars-config.cc, mbase/MZlib.cc:
+     - included string.h
+
+   * showlog.cc, manalysis/MGeomApply.cc, mbase/MAGIC.cc, 
+     mbase/MMath.cc, mbase/MProgressBar.cc, mbase/MSearch.cc,
+     mdata/MDataElement.cc, mfileio/MReadScanFile.cc,
+     mhbase/MH3.cc, mjobs/MSequenceSQL.cc,
+     mpointing/MPointingDevCalc.cc, msql/MSQLMagic.cc:
+     - included stdlib.h
+
+   * mastro/MAstro.h, mhbase/MHn.h:
+     - fixed the naming of some veriables in the definition
+
+   * mbase/MGMap.cc, mtools/MagicJam.cc:
+     - inlcude climits
+
+   * mbase/MStatusDisplay.cc:
+     - implemented a workaround against root's buffer overflows
+     - switched of root's own handling by resetting
+       kShowEventStatus
+
+   * mhbase/MH.[h,cc]:
+     - added a workaround for the buffor overflow in 
+       TH1::GetObjectInfo and TProfile::GetObjectInfo
+
+   * mhist/MHCamera.cc:
+     - implemented a workaround for the buffer overflow in root's
+       GetObjectInfo
+
+   * msql/MSQLServer.[h,cc]:
+     - replaced GetPrimaryKey by GetPrimaryKeys
+
+
+
  2008/12/19 Daniel Hoehne-Moench
 
    * datacenter/macros/filldotrun.C:
-     - implemented SuperArehucas version 081204-0 incl. sumtrigger flag
+     - implemented SuperArehucas version 081204-0 incl. sumtrigger 
+       flag
+
    * datacenter/db/magicdefs.php, datacenter/db/menu.php:
      - implemented sumtrigger flag (in runinfo and sequinfo menus)
Index: trunk/MagicSoft/Mars/Makefile.rules
===================================================================
--- trunk/MagicSoft/Mars/Makefile.rules	(revision 9194)
+++ trunk/MagicSoft/Mars/Makefile.rules	(revision 9195)
@@ -34,5 +34,5 @@
 $(CINT)Cint.cc: $(HEADERS) $(CINT)LinkDef.h
 	@echo " - Generating dictionary $(CINT)Cint.cc"
-	$(ROOTSYS)/bin/rootcint -f $(CINT)Cint.cc \
+	rootcint -f $(CINT)Cint.cc \
 	-c $(INCLUDES) $(DEFINES) $(HEADERS) $(CINT)Incl.h $(CINT)LinkDef.h 
 
Index: trunk/MagicSoft/Mars/manalysis/MGeomApply.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MGeomApply.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/manalysis/MGeomApply.cc	(revision 9195)
@@ -64,4 +64,6 @@
 #include "MGeomApply.h"
 
+#include <stdlib.h> // atoi (Ubuntu 8.10)
+
 #include <fstream>
 
Index: trunk/MagicSoft/Mars/mars-config.cc
===================================================================
--- trunk/MagicSoft/Mars/mars-config.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mars-config.cc	(revision 9195)
@@ -1,3 +1,5 @@
 #include <iostream>
+
+#include <string.h> // strcmp (Ubuntu 8.10)
 
 #include <RVersion.h>
Index: trunk/MagicSoft/Mars/mastro/MAstro.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstro.h	(revision 9194)
+++ trunk/MagicSoft/Mars/mastro/MAstro.h	(revision 9195)
@@ -46,19 +46,19 @@
     static Double_t Hms2Hor(Int_t hor, UInt_t min, Double_t sec, Char_t sgn='+');
 
-    static void Day2Hms(Double_t day, Char_t &sgn, UShort_t &hor, UShort_t &min, UShort_t &sec);
-    static void Rad2Dms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
-    static void Rad2Hms(Double_t rad, Char_t &sgn, UShort_t &hor, UShort_t &min, UShort_t &sec);
-    static void Deg2Dms(Double_t deg, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
-    static void Deg2Hms(Double_t deg, Char_t &sgn, UShort_t &hor, UShort_t &min, UShort_t &sec);
-    static void Hor2Dms(Double_t hor, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
-    static void Hor2Hms(Double_t hor, Char_t &sgn, UShort_t &hor, UShort_t &min, UShort_t &sec);
+    static void Day2Hms(Double_t day, Char_t &sgn, UShort_t &h, UShort_t &m, UShort_t &s);
+    static void Rad2Dms(Double_t rad, Char_t &sgn, UShort_t &d, UShort_t &m, UShort_t &s);
+    static void Rad2Hms(Double_t rad, Char_t &sgn, UShort_t &h, UShort_t &m, UShort_t &s);
+    static void Deg2Dms(Double_t deg, Char_t &sgn, UShort_t &d, UShort_t &m, UShort_t &s);
+    static void Deg2Hms(Double_t deg, Char_t &sgn, UShort_t &h, UShort_t &m, UShort_t &s);
+    static void Hor2Dms(Double_t hor, Char_t &sgn, UShort_t &d, UShort_t &m, UShort_t &s);
+    static void Hor2Hms(Double_t hor, Char_t &sgn, UShort_t &h, UShort_t &m, UShort_t &s);
 
-    static void Day2Hm(Double_t day, Char_t &sgn, UShort_t &hor, Double_t &min);
-    static void Rad2Dm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
-    static void Rad2Hm(Double_t rad, Char_t &sgn, UShort_t &hor, Double_t &min);
-    static void Deg2Dm(Double_t deg, Char_t &sgn, UShort_t &deg, Double_t &min);
-    static void Deg2Hm(Double_t deg, Char_t &sgn, UShort_t &hor, Double_t &min);
-    static void Hor2Dm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
-    static void Hor2Hm(Double_t rad, Char_t &sgn, UShort_t &hor, Double_t &min);
+    static void Day2Hm(Double_t day, Char_t &sgn, UShort_t &h, Double_t &m);
+    static void Rad2Dm(Double_t rad, Char_t &sgn, UShort_t &d, Double_t &m);
+    static void Rad2Hm(Double_t rad, Char_t &sgn, UShort_t &h, Double_t &m);
+    static void Deg2Dm(Double_t deg, Char_t &sgn, UShort_t &d, Double_t &m);
+    static void Deg2Hm(Double_t deg, Char_t &sgn, UShort_t &h, Double_t &m);
+    static void Hor2Dm(Double_t rad, Char_t &sgn, UShort_t &d, Double_t &m);
+    static void Hor2Hm(Double_t rad, Char_t &sgn, UShort_t &h, Double_t &m);
 
     // Print funtions
Index: trunk/MagicSoft/Mars/mbase/MAGIC.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MAGIC.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mbase/MAGIC.cc	(revision 9195)
@@ -30,4 +30,6 @@
 #include "MAGIC.h"
 
+#include <stdlib.h> // getenv (Ubuntu 8.10)
+
 #include <iostream>
 
Index: trunk/MagicSoft/Mars/mbase/MGMap.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MGMap.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mbase/MGMap.cc	(revision 9195)
@@ -39,5 +39,5 @@
 #include "MGMap.h"
 
-//#include <limits.h>  // INT_MAX
+#include <climits>  // INT_MAX (Ubuntu 8.10)
 
 #include <TMath.h>
Index: trunk/MagicSoft/Mars/mbase/MMath.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 9195)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.41 2008-07-01 14:03:58 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.42 2008-12-21 18:09:49 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -34,4 +34,6 @@
 #include "MMath.h"
 
+#include <stdlib.h> // atof (Ubuntu 8.10)
+
 #ifndef ROOT_TVector2
 #include <TVector2.h>
Index: trunk/MagicSoft/Mars/mbase/MProgressBar.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MProgressBar.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mbase/MProgressBar.cc	(revision 9195)
@@ -30,6 +30,7 @@
 //
 /////////////////////////////////////////////////////////////////////////////
+#include "MProgressBar.h"
 
-#include "MProgressBar.h"
+#include <stdlib.h>         // rand (Ubuntu 8.10)
 
 #include <TSystem.h>        // gSystem
Index: trunk/MagicSoft/Mars/mbase/MSearch.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MSearch.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mbase/MSearch.cc	(revision 9195)
@@ -40,4 +40,6 @@
 /////////////////////////////////////////////////////////////////////////////
 #include "MSearch.h"
+
+#include <stdlib.h>         // rand (Ubuntu 8.10)
 
 #include <TSystem.h>      // gSystem
Index: trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 9195)
@@ -62,4 +62,5 @@
 
 #include <errno.h>
+#include <stdlib.h>               // mktemp (Ubunto 8.10)
 
 #include <fstream>                // fstream
@@ -110,4 +111,8 @@
 #include "MParContainer.h"        // MParContainer::GetDescriptor
 #include "MStatusArray.h"         // MStatusArray
+
+#if ROOT_VERSION_CODE <= ROOT_VERSION(5,22,00)
+#include "../mhbase/MH.h"
+#endif
 
 #undef DEBUG
@@ -1040,5 +1045,21 @@
 
     if (gPad)
+    {
+        // Find the object which will get picked by the GetObjectInfo
+        // due to buffer overflows in many root-versions
+        // in TH1 and TProfile we have to work around and implement
+        // our own GetObjectInfo which make everything a bit more
+        // complicated.
+#if ROOT_VERSION_CODE > ROOT_VERSION(5,22,00)
         SetStatusLine2(selected->GetObjectInfo(px,py));
+#else
+        TObjLink *link=0;
+        static_cast<TPad*>(gPad)->Pick(px, py, link);
+
+        const TObject *o = link ? link->GetObject() : 0;
+        if (o)
+            SetStatusLine2(MH::GetObjectInfo(px, py, *o));
+#endif
+    }
 
     gPad=save;
@@ -1119,4 +1140,10 @@
     c.Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
               "MStatusDisplay", this, "EventInfo(Int_t,Int_t,Int_t,TObject*)");
+
+    // Make sure that root itself doesn't try to call GetObjectInfo
+    // This is now handled from EventsInfo. This is necessary
+    // due to the buffer overflow bug in GetObjectInfo of
+    // TProfile and TH1
+    c.ResetBit(TCanvas::kShowEventStatus);
 
     // Remove the canvas from the global list to make sure it is
Index: trunk/MagicSoft/Mars/mbase/MZlib.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MZlib.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mbase/MZlib.cc	(revision 9195)
@@ -35,4 +35,6 @@
 //////////////////////////////////////////////////////////////////////////////
 #include "MZlib.h"
+
+#include <string.h> // memcpy (UBuntu 8.10)
 
 ClassImp(MZlib);
Index: trunk/MagicSoft/Mars/mdata/MDataElement.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataElement.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mdata/MDataElement.cc	(revision 9195)
@@ -37,4 +37,6 @@
 /////////////////////////////////////////////////////////////////////////////
 #include "MDataElement.h"
+
+#include <stdlib.h>   // atoi (Ubuntu 8.10)
 
 #include <fstream>
Index: trunk/MagicSoft/Mars/mfileio/MReadScanFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadScanFile.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mfileio/MReadScanFile.cc	(revision 9195)
@@ -30,4 +30,6 @@
 #include "MReadScanFile.h"
 
+#include <stdlib.h> // atoi (Ubuntu 8.10)
+
 #include "MLog.h"
 #include "MLogManip.h"
Index: trunk/MagicSoft/Mars/mhbase/MH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mhbase/MH.cc	(revision 9195)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.41 2008-12-02 11:22:15 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.42 2008-12-21 18:09:49 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -1616,5 +1616,14 @@
         CreateGradientColorTable(8, s, r, g, b, ncol);
         found=kTRUE;
-    }
+    }/*
+    if (paletteName.Contains("glows2"))
+    {
+        double s[10] = {0.00, 0.17, 0.35, 0.50, 0.65, 0.73, 0.77, 0.85, 0.92, 1.00};
+        double r[10] = {0.09, 0.18, 0.09, 0.00, 0.00, 0.20, 0.55, 0.85, 1.00, 1.00};
+        double g[10] = {0.81, 0.51, 0.27, 0.00, 0.00, 0.05, 0.10, 0.20, 0.73, 1.00};
+        double b[10] = {0.70, 0.40, 0.02, 0.00, 0.27, 0.40, 0.35, 0.16, 0.03, 1.00};
+        gStyle->CreateGradientColorTable(10, s, r, g, b, ncol);
+        found=kTRUE;
+    }*/
 
     if (paletteName.Contains("redish"))
@@ -1668,2 +1677,136 @@
         gLog << warn << "MH::SetPalette: Palette " << paletteName << " unknown... ignored." << endl;
 }
+
+// --------------------------------------------------------------------------
+//
+// Unfortunately in TH1::GetObjectInfo the buffer is just 64 characters
+// which is sometimes to small. This is just a copy of the code but the
+// buffer has been increased to 128 which should fairly be enough.
+//
+//  Necessary for root <= 5.22/00
+//
+char *MH::GetObjectInfoH(Int_t px, Int_t py, const TH1 &h)
+{
+   const TH1 *fH = &h;
+   const TAxis *fXaxis = h.GetXaxis();
+   const TAxis *fYaxis = h.GetYaxis();
+
+   //   Redefines TObject::GetObjectInfo.
+   //   Displays the histogram info (bin number, contents, integral up to bin
+   //   corresponding to cursor position px,py
+
+   if (!gPad) return (char*)"";
+
+   static char info[128];
+   Double_t x  = gPad->PadtoX(gPad->AbsPixeltoX(px));
+   Double_t y  = gPad->PadtoY(gPad->AbsPixeltoY(py));
+   Double_t x1 = gPad->PadtoX(gPad->AbsPixeltoX(px+1));
+   const char *drawOption = fH->GetDrawOption();
+   Double_t xmin, xmax, uxmin,uxmax;
+   Double_t ymin, ymax, uymin,uymax;
+   if (fH->GetDimension() == 2) {
+      if (gPad->GetView() || strncmp(drawOption,"cont",4) == 0
+                          || strncmp(drawOption,"CONT",4) == 0) {
+         uxmin=gPad->GetUxmin();
+         uxmax=gPad->GetUxmax();
+         xmin = fXaxis->GetBinLowEdge(fXaxis->GetFirst());
+         xmax = fXaxis->GetBinUpEdge(fXaxis->GetLast());
+         x = xmin +(xmax-xmin)*(x-uxmin)/(uxmax-uxmin);
+         uymin=gPad->GetUymin();
+         uymax=gPad->GetUymax();
+         ymin = fYaxis->GetBinLowEdge(fYaxis->GetFirst());
+         ymax = fYaxis->GetBinUpEdge(fYaxis->GetLast());
+         y = ymin +(ymax-ymin)*(y-uymin)/(uymax-uymin);
+      }
+   }
+   Int_t binx,biny,binmin,binx1;
+   if (gPad->IsVertical()) {
+      binx   = fXaxis->FindFixBin(x);
+      binmin = fXaxis->GetFirst();
+      binx1  = fXaxis->FindFixBin(x1);
+      // special case if more than 1 bin in x per pixel
+      if (binx1-binx>1 && fH->GetDimension() == 1) {
+         Double_t binval=fH->GetBinContent(binx);
+         Int_t binnear=binx;
+         for (Int_t ibin=binx+1; ibin<binx1; ibin++) {
+            Double_t binvaltmp = fH->GetBinContent(ibin);
+            if (TMath::Abs(y-binvaltmp) < TMath::Abs(y-binval)) {
+               binval=binvaltmp;
+               binnear=ibin;
+            }
+         }
+         binx = binnear;
+      }
+   } else {
+      x1 = gPad->PadtoY(gPad->AbsPixeltoY(py+1));
+      binx   = fXaxis->FindFixBin(y);
+      binmin = fXaxis->GetFirst();
+      binx1  = fXaxis->FindFixBin(x1);
+      // special case if more than 1 bin in x per pixel
+      if (binx1-binx>1 && fH->GetDimension() == 1) {
+         Double_t binval=fH->GetBinContent(binx);
+         Int_t binnear=binx;
+         for (Int_t ibin=binx+1; ibin<binx1; ibin++) {
+            Double_t binvaltmp = fH->GetBinContent(ibin);
+            if (TMath::Abs(x-binvaltmp) < TMath::Abs(x-binval)) {
+               binval=binvaltmp;
+               binnear=ibin;
+            }
+         }
+         binx = binnear;
+      }
+   }
+   if (fH->GetDimension() == 1) {
+      Double_t integ = 0;
+      for (Int_t bin=binmin;bin<=binx;bin++) {integ += fH->GetBinContent(bin);}
+      sprintf(info,"(x=%g, y=%g, binx=%d, binc=%g, Sum=%g)",x,y,binx,fH->GetBinContent(binx),integ);
+   } else {
+      biny = fYaxis->FindFixBin(y);
+      sprintf(info,"(x=%g, y=%g, binx=%d, biny=%d, binc=%g)",x,y,binx,biny,fH->GetCellContent(binx,biny));
+   }
+   return info;
+}
+
+// --------------------------------------------------------------------------
+//
+// Unfortunately in TProfile::GetObjectInfo the buffer is just 64 characters
+// which is sometimes to small. This is just a copy of the code but the
+// buffer has been increased to 128 which should fairly be enough.
+//
+//  Necessary for root <= 5.22/00
+//
+char *MH::GetObjectInfoP(Int_t px, Int_t py, const TProfile &p)
+{
+    if (!gPad) return (char*)"";
+    static char info[128];
+    Double_t x  = gPad->PadtoX(gPad->AbsPixeltoX(px));
+    Double_t y  = gPad->PadtoY(gPad->AbsPixeltoY(py));
+    Int_t binx   = p.GetXaxis()->FindFixBin(x);
+    sprintf(info,"(x=%g, y=%g, binx=%d, binc=%g, bine=%g, binn=%d)", x, y, binx, p.GetBinContent(binx), p.GetBinError(binx), (Int_t)p.GetBinEntries(binx));
+    return info;
+}
+
+// --------------------------------------------------------------------------
+//
+// Unfortunately TH1::GetObjectInfo and TProfile::GetObjectInfo can
+// result in buffer ovwerflows therefor we have to re-implement these
+// function by our own.
+//
+//  Necessary for root <= 5.22/00
+//
+char *MH::GetObjectInfo(Int_t px, Int_t py, const TObject &o)
+{
+    if (!o.InheritsFrom(TH1::Class()))
+        return o.GetObjectInfo(px, py);
+
+    if (o.InheritsFrom(TProfile::Class()))
+        return GetObjectInfoP(px, py, static_cast<const TProfile&>(o));
+
+    if (o.InheritsFrom("MHCamera"))
+        return o.GetObjectInfo(px, py);
+
+    if (o.InheritsFrom(TH1::Class()))
+        return GetObjectInfoH(px, py, static_cast<const TH1&>(o));
+
+    return "MH::GetObjectInfo: unknown class.";
+}
Index: trunk/MagicSoft/Mars/mhbase/MH3.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 9195)
@@ -146,5 +146,6 @@
 #include "MH3.h"
 
-#include <ctype.h>   // tolower
+#include <ctype.h>    // tolower
+#include <stdlib.h>   // atoi (Ubuntu 8.10)
 #include <fstream>
 
Index: trunk/MagicSoft/Mars/mhbase/MHn.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MHn.h	(revision 9194)
+++ trunk/MagicSoft/Mars/mhbase/MHn.h	(revision 9195)
@@ -21,6 +21,6 @@
     void InitHist();
 
-    Bool_t InitName(Int_t n,  const char *n);
-    Bool_t InitTitle(Int_t n, const char *t);
+    Bool_t InitName(Int_t n,  const char *name);
+    Bool_t InitTitle(Int_t n, const char *title);
     Bool_t SetDrawOption(Int_t n, const char *opt);
 
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 9195)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.110 2008-12-02 11:22:19 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.111 2008-12-21 18:09:49 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -2006,5 +2006,9 @@
 {
     if (TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
+#if ROOT_VERSION_CODE > ROOT_VERSION(5,22,00)
+        return MH::GetObjectInfoH(px, py, *this);
+#else
         return TH1D::GetObjectInfo(px, py);
+#endif
 
     static char info[128];
Index: trunk/MagicSoft/Mars/mjobs/MSequenceSQL.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequenceSQL.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mjobs/MSequenceSQL.cc	(revision 9195)
@@ -67,4 +67,6 @@
 #include "MSequenceSQL.h"
 
+#include <stdlib.h> // atof (Ubuntu 8.10)
+
 #include <TSQLRow.h>
 #include <TSQLResult.h>
Index: trunk/MagicSoft/Mars/mpointing/MPointingDevCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mpointing/MPointingDevCalc.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mpointing/MPointingDevCalc.cc	(revision 9195)
@@ -256,4 +256,6 @@
 #include "MPointingDevCalc.h"
 
+#include <stdlib.h> // atoi (Ubuntu 8.10)
+
 #include "MLog.h"
 #include "MLogManip.h"
Index: trunk/MagicSoft/Mars/msql/MSQLMagic.cc
===================================================================
--- trunk/MagicSoft/Mars/msql/MSQLMagic.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/msql/MSQLMagic.cc	(revision 9195)
@@ -33,4 +33,6 @@
 #include "MSQLMagic.h"
 
+#include <stdlib.h> // atoi (Ubuntu 8.10)
+
 #include <iostream>
 
Index: trunk/MagicSoft/Mars/msql/MSQLServer.cc
===================================================================
--- trunk/MagicSoft/Mars/msql/MSQLServer.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/msql/MSQLServer.cc	(revision 9195)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MSQLServer.cc,v 1.16 2008-07-05 18:57:35 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MSQLServer.cc,v 1.17 2008-12-21 18:09:49 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -58,4 +58,7 @@
 #include <TBrowser.h>
 
+#include <TObjString.h>
+#include <TObjArray.h>
+
 ClassImp(MSQLServer);
 
@@ -781,5 +784,5 @@
 // Return the name of the (first) column with a primary key
 //
-TString MSQLServer::GetPrimaryKey(const char *table)
+TString MSQLServer::GetPrimaryKeys(const char *table)
 {
     TSQLResult *res = GetColumns(table);
@@ -787,5 +790,6 @@
         return "";
 
-    TString rc;
+    TObjArray arr;
+    arr.SetOwner();
 
     TSQLRow *row = 0;
@@ -794,13 +798,18 @@
         const TString key = (*row)[3];
         if (key=="PRI")
-        {
-            if (!rc.IsNull())
-                rc += ", ";
-            rc += (*row)[0];
-        }
+            arr.Add(new TObjString((*row)[0]));
         delete row;
     }
-
     delete res;
+
+    arr.Sort();
+
+    TString rc;
+    for (int i=0; i<arr.GetEntries(); i++)
+    {
+        if (i>0)
+            rc += ", ";
+        rc += arr[i]->GetName();
+    }
     return rc;
 }
@@ -849,5 +858,5 @@
 
         // Now get the primary key of the table to be joined
-        const TString prim = GetPrimaryKey(tab);
+        const TString prim = GetPrimaryKeys(tab);
         if (prim.IsNull())
             continue;
Index: trunk/MagicSoft/Mars/msql/MSQLServer.h
===================================================================
--- trunk/MagicSoft/Mars/msql/MSQLServer.h	(revision 9194)
+++ trunk/MagicSoft/Mars/msql/MSQLServer.h	(revision 9195)
@@ -123,5 +123,5 @@
 
     TString     GetEntry(const char *where, const char *col=0, const char *table=0) const;
-    TString     GetPrimaryKey(const char *table);
+    TString     GetPrimaryKeys(const char *table);
     TString     GetJoins(const char *table, const TString text);
 
Index: trunk/MagicSoft/Mars/mtools/MagicJam.cc
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicJam.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/mtools/MagicJam.cc	(revision 9195)
@@ -53,4 +53,6 @@
 #include "MagicJam.h"
 
+#include <climits> // INT_MAX (Ubuntu 8.10)
+
 #include <iostream>
 #include <fstream>
Index: trunk/MagicSoft/Mars/showlog.cc
===================================================================
--- trunk/MagicSoft/Mars/showlog.cc	(revision 9194)
+++ trunk/MagicSoft/Mars/showlog.cc	(revision 9195)
@@ -1,3 +1,5 @@
 #include <errno.h>
+#include <stdlib.h> // strtol (Ubuntu 8.10)
+
 #include <fstream>
 
