Merge branch 'master' into pygromacs
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_anadock.cpp
similarity index 95%
rename from src/gromacs/gmxana/gmx_anadock.c
rename to src/gromacs/gmxana/gmx_anadock.cpp
index 73832bb487c0d46972fbb7e80cc595d71d9b3a61..b377b02c1474ec92f8fcaf9d7bf2a13fab214ac8 100644 (file)
  */
 #include "gmxpre.h"
 
-#include <stdlib.h>
-#include <string.h>
+#include <cmath>
+#include <cstdlib>
+#include <cstring>
 
 #include "gromacs/commandline/pargs.h"
 #include "gromacs/fileio/confio.h"
 #include "gromacs/fileio/xvgr.h"
+#include "gromacs/gmxana/gmx_ana.h"
 #include "gromacs/legacyheaders/copyrite.h"
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/typedefs.h"
@@ -82,15 +84,15 @@ static t_pdbfile *read_pdbf(const char *fn)
         ptr = fgets2(buf, 255, fp);
         if (ptr)
         {
-            if (strstr(buf, "Intermolecular") != NULL)
+            if (std::strstr(buf, "Intermolecular") != NULL)
             {
-                ptr = strchr(buf, '=');
+                ptr = std::strchr(buf, '=');
                 sscanf(ptr+1, "%lf", &e);
                 pdbf->edocked = e;
             }
-            else if (strstr(buf, "Estimated Free") != NULL)
+            else if (std::strstr(buf, "Estimated Free") != NULL)
             {
-                ptr = strchr(buf, '=');
+                ptr = std::strchr(buf, '=');
                 sscanf(ptr+1, "%lf", &e);
                 pdbf->efree = e;
             }
@@ -109,9 +111,9 @@ static t_pdbfile **read_em_all(const char *fn, int *npdbf)
     char        buf[256], name[256];
     gmx_bool    bExist;
 
-    strcpy(buf, fn);
-    buf[strlen(buf)-4] = '\0';
-    maxpdbf            = 100;
+    std::strcpy(buf, fn);
+    buf[std::strlen(buf)-4] = '\0';
+    maxpdbf                 = 100;
     snew(pdbf, maxpdbf);
     i = 0;
     do
@@ -226,7 +228,7 @@ static void clust_stat(FILE *fp, int start, int end, t_pdbfile *pdbf[])
 static real rmsd_dist(t_pdbfile *pa, t_pdbfile *pb, gmx_bool bRMSD)
 {
     int  i;
-    real rmsd, dist;
+    real rmsd;
     rvec acm, bcm, dx;
 
     if (bRMSD)
@@ -237,11 +239,10 @@ static real rmsd_dist(t_pdbfile *pa, t_pdbfile *pb, gmx_bool bRMSD)
             rvec_sub(pa->x[i], pb->x[i], dx);
             rmsd += iprod(dx, dx);
         }
-        rmsd = sqrt(rmsd/pa->atoms.nr);
+        rmsd = std::sqrt(rmsd/pa->atoms.nr);
     }
     else
     {
-        dist = 0;
         clear_rvec(acm);
         clear_rvec(bcm);
         for (i = 0; (i < pa->atoms.nr); i++)