programs/view: move from C to C++ headers
authorAlexey Shvetsov <alexxy@omrb.pnpi.spb.ru>
Fri, 17 Jul 2015 18:23:42 +0000 (21:23 +0300)
committerAlexey Shvetsov <alexxy@omrb.pnpi.spb.ru>
Tue, 15 Sep 2015 11:51:04 +0000 (14:51 +0300)
All functions from headers sdtlib stdio ctypes string
were replaced to std:: ones

Change-Id: If8a8a7bfd539f339e3fb0bce6e45a9a7c1c42c70
Signed-off-by: Alexey Shvetsov <alexxy@omrb.pnpi.spb.ru>
19 files changed:
src/programs/view/3dview.cpp
src/programs/view/buttons.cpp
src/programs/view/dialogs.cpp
src/programs/view/fgrid.cpp
src/programs/view/filter.cpp
src/programs/view/logo.cpp
src/programs/view/manager.cpp
src/programs/view/molps.cpp
src/programs/view/nleg.cpp
src/programs/view/nmol.cpp
src/programs/view/popup.cpp
src/programs/view/pulldown.cpp
src/programs/view/view.cpp
src/programs/view/x11.cpp
src/programs/view/xdlg.cpp
src/programs/view/xdlghi.cpp
src/programs/view/xdlgitem.cpp
src/programs/view/xmb.cpp
src/programs/view/xutil.cpp

index 01cc064241b80c1f97345a4ffa8cf4cafc940b70..af36b05cad1bbb7f9d02278e42536b595055f80c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,7 +38,8 @@
 
 #include "3dview.h"
 
-#include <math.h>
+#include <cmath>
+#include <cstdio>
 
 #include <algorithm>
 
@@ -65,11 +66,11 @@ static void calculate_view(t_3dview *view)
     dx = view->eye[XX];
     dy = view->eye[YY];
     dz = view->eye[ZZ];
-    l  = sqrt(dx*dx+dy*dy+dz*dz);
-    r  = sqrt(dx*dx+dy*dy);
+    l  = std::sqrt(dx*dx+dy*dy+dz*dz);
+    r  = std::sqrt(dx*dx+dy*dy);
 #ifdef DEBUG
     gmx_vec4_print(debug, "eye", view->eye);
-    printf("del: %10.5f%10.5f%10.5f l: %10.5f, r: %10.5f\n", dx, dy, dz, l, r);
+    std::printf("del: %10.5f%10.5f%10.5f l: %10.5f, r: %10.5f\n", dx, dy, dz, l, r);
 #endif
     if (l < SMALL)
     {
@@ -129,7 +130,7 @@ gmx_bool zoom_3d(t_3dview *view, real fac)
         dr   = view->eye[i];
         dr2 += dr*dr;
     }
-    dr1 = sqrt(dr2);
+    dr1 = std::sqrt(dr2);
     if (fac < 1)
     {
         bm = std::max(norm(view->box[XX]), std::max(norm(view->box[YY]), norm(view->box[ZZ])));
@@ -184,7 +185,7 @@ void rotate_3d(t_3dview *view, int axis, gmx_bool bPositive)
 void translate_view(t_3dview *view, int axis, gmx_bool bPositive)
 {
 #ifdef DEBUG
-    printf("Translate called\n");
+    std::printf("Translate called\n");
 #endif
     if (bPositive)
     {
@@ -200,7 +201,7 @@ void translate_view(t_3dview *view, int axis, gmx_bool bPositive)
 void reset_view(t_3dview *view)
 {
 #ifdef DEBUG
-    printf("Reset view called\n");
+    std::printf("Reset view called\n");
 #endif
     set_scale(view, 4.0, 4.0);
     clear_rvec(view->eye);
index e5157ffe424cfefdeb159617893821b62654af7e..73eca20d445506ebfd347acbeff6b616bd777a94 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,8 +38,8 @@
 
 #include "buttons.h"
 
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
 
 #include <algorithm>
 
@@ -213,7 +213,7 @@ t_butbox *init_vbox(t_x11 *x11, Window Parent, Window SendTo, unsigned long fg,
                 break;
             default:
                 fprintf(stderr, "Invalid bitmap in init_vbox %d\n", ID);
-                exit(1);
+                std::exit(1);
         }
         /* Rely on the fact that all bitmaps are equal size */
         pm = XCreatePixmapFromBitmapData(x11->disp, x11->root,
index 4f69d7a4a81b6cd0438b339d60813c7e8367de37..6adf4aa1f557b808fc00b3d5a3596979505250ff 100644 (file)
  */
 #include "gmxpre.h"
 
+#include "dialogs.h"
+
 #include "config.h"
 
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
 #ifdef HAVE_UNISTD_H
 #include <unistd.h> // for fork()
 #endif
 
-#include "dialogs.h"
-
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/names.h"
 #include "gromacs/utility/cstringutil.h"
@@ -81,33 +84,33 @@ static void shell_comm(const char *title, const char *script, int nsleep)
     char  command[STRLEN];
     char  tmp[32];
 
-    strcpy(tmp, "dialogXXXXXX");
+    std::strcpy(tmp, "dialogXXXXXX");
     gmx_tmpnam(tmp);
 
-    if ((tfil = fopen(tmp, "w")) == NULL)
+    if ((tfil = std::fopen(tmp, "w")) == NULL)
     {
-        sprintf(tmp, "%ctmp%cdialogXXXXXX", DIR_SEPARATOR, DIR_SEPARATOR);
+        std::sprintf(tmp, "%ctmp%cdialogXXXXXX", DIR_SEPARATOR, DIR_SEPARATOR);
         gmx_tmpnam(tmp);
     }
     else
     {
-        fclose(tfil);
+        std::fclose(tfil);
     }
-    if ((tfil = fopen(tmp, "w")) == NULL)
+    if ((tfil = std::fopen(tmp, "w")) == NULL)
     {
         gmx_fatal(FARGS, "Can not open tmp file %s", tmp);
     }
 
-    fprintf(tfil, "%s\n", script);
-    fprintf(tfil, "sleep %d\n", nsleep);
-    fclose(tfil);
+    std::fprintf(tfil, "%s\n", script);
+    std::fprintf(tfil, "sleep %d\n", nsleep);
+    std::fclose(tfil);
 
-    sprintf(command, "xterm -title %s -e sh %s", title, tmp);
+    std::sprintf(command, "xterm -title %s -e sh %s", title, tmp);
 #ifdef DEBUG
-    fprintf(stderr, "command: %s\n", command);
+    std::fprintf(stderr, "command: %s\n", command);
 #endif
 
-    if (0 != system(command))
+    if (0 != std::system(command))
     {
         gmx_fatal(FARGS, "Failed to execute command: %s", command);
     }
@@ -243,13 +246,13 @@ static void ExportCB(t_x11 *x11, int dlg_mess, int item_id,
                     break;
             }
 #ifdef DEBUG
-            fprintf(stderr, "exportcb: item_id=%d\n", item_id);
+            std::fprintf(stderr, "exportcb: item_id=%d\n", item_id);
 #endif
             break;
         case DLG_EXIT:
             if ((bOk = gmx_strcasecmp("ok", set)) == 0)
             {
-                strcpy(gmx->confout, EditText(dlg, eExConf));
+                std::strcpy(gmx->confout, EditText(dlg, eExConf));
             }
             HideDlg(dlg);
             if (bOk)
@@ -271,7 +274,7 @@ static void Extract(t_dlg *dlg, int ID, char *buf)
     et = EditText(dlg, ID);
     if (et)
     {
-        strcpy(buf, et);
+        std::strcpy(buf, et);
     }
 }
 
@@ -321,8 +324,8 @@ static void BondsCB(t_x11 *x11, int dlg_mess, int item_id,
                     case ebDPlus:
                         DO_NOT(gmx->man->bPlus);
 #ifdef DEBUG
-                        fprintf(stderr, "gmx->man->bPlus=%s\n",
-                                gmx->man->bPlus ? "true" : "false");
+                        std::fprintf(stderr, "gmx->man->bPlus=%s\n",
+                                     gmx->man->bPlus ? "true" : "false");
 #endif
                         break;
                     case ebRMPBC:
@@ -331,16 +334,16 @@ static void BondsCB(t_x11 *x11, int dlg_mess, int item_id,
                     case ebCue:
                         DO_NOT(gmx->man->bSort);
 #ifdef DEBUG
-                        fprintf(stderr, "gmx->man->bSort=%s\n",
-                                gmx->man->bSort ? "true" : "false");
+                        std::fprintf(stderr, "gmx->man->bSort=%s\n",
+                                     gmx->man->bSort ? "true" : "false");
 #endif
                         break;
                     case ebSkip:
-                        nskip = strtol(set, &endptr, 10);
+                        nskip = std::strtol(set, &endptr, 10);
                         if (endptr != set)
                         {
 #ifdef DEBUG
-                            fprintf(stderr, "nskip: %d frames\n", nskip);
+                            std::fprintf(stderr, "nskip: %d frames\n", nskip);
 #endif
                             if (nskip >= 0)
                             {
@@ -349,11 +352,11 @@ static void BondsCB(t_x11 *x11, int dlg_mess, int item_id,
                         }
                         break;
                     case ebWait:
-                        nwait = strtol(set, &endptr, 10);
+                        nwait = std::strtol(set, &endptr, 10);
                         if (endptr != set)
                         {
 #ifdef DEBUG
-                            fprintf(stderr, "wait: %d ms\n", nwait);
+                            std::fprintf(stderr, "wait: %d ms\n", nwait);
 #endif
                             if (nwait >= 0)
                             {
@@ -362,7 +365,7 @@ static void BondsCB(t_x11 *x11, int dlg_mess, int item_id,
                         }
                     default:
 #ifdef DEBUG
-                        fprintf(stderr, "item_id: %d, set: %s\n", item_id, set);
+                        std::fprintf(stderr, "item_id: %d, set: %s\n", item_id, set);
 #endif
                         break;
                 }
@@ -491,8 +494,8 @@ void edit_file(const char *fn)
     {
         char script[256];
 
-        sprintf(script, "vi  %s", fn);
+        std::sprintf(script, "vi  %s", fn);
         shell_comm(fn, script, 0);
-        exit(0);
+        std::exit(0);
     }
 }
index 12491724250834930f6b8b0031d8f26f91165d85..08dc54edfc14fcd58f64890fc18cecde0d878894 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 
 #include "fgrid.h"
 
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 
 #include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/futil.h"
@@ -55,46 +55,46 @@ static const char *type[] = {
 void ReadDlgError(const char *infile, eDLGERR err, const char *s,
                   const char *file, int line)
 {
-    fprintf(stderr, "Error: ");
+    std::fprintf(stderr, "Error: ");
     switch (err)
     {
         case eNOVALS:
-            fprintf(stderr, "Not enough values for %s", s);
+            std::fprintf(stderr, "Not enough values for %s", s);
             break;
         case eGRIDEXP:
-            fprintf(stderr, "'grid' expected instead of %s", s);
+            std::fprintf(stderr, "'grid' expected instead of %s", s);
             break;
         case eACCOEXP:
-            fprintf(stderr, "'{' expected instead of %s", s);
+            std::fprintf(stderr, "'{' expected instead of %s", s);
             break;
         case eACCCEXP:
-            fprintf(stderr, "'}' expected instead of %s", s);
+            std::fprintf(stderr, "'}' expected instead of %s", s);
             break;
         case eGRPEXP:
-            fprintf(stderr, "'group' expected instead of %s", s);
+            std::fprintf(stderr, "'group' expected instead of %s", s);
             break;
         case eITEMEXP:
-            fprintf(stderr, "item expected instead of %s", s);
+            std::fprintf(stderr, "item expected instead of %s", s);
             break;
         case eSAMEPOINT:
-            fprintf(stderr, "grid point for %s already in use", s);
+            std::fprintf(stderr, "grid point for %s already in use", s);
             break;
         case eTOOWIDE:
-            fprintf(stderr, "grid too wide for %s", s);
+            std::fprintf(stderr, "grid too wide for %s", s);
             break;
         case eTOOHIGH:
-            fprintf(stderr, "grid too high for %s", s);
+            std::fprintf(stderr, "grid too high for %s", s);
             break;
         case eQUOTE:
-            fprintf(stderr, "quote expected instead of %s", s);
+            std::fprintf(stderr, "quote expected instead of %s", s);
             break;
         default:
-            fprintf(stderr, "????");
+            std::fprintf(stderr, "????");
             break;
     }
-    fprintf(stderr, " in file %s\n", infile);
-    fprintf(stderr, "source file: %s, line: %d\n", file, line);
-    exit(1);
+    std::fprintf(stderr, " in file %s\n", infile);
+    std::fprintf(stderr, "source file: %s, line: %d\n", file, line);
+    std::exit(1);
 }
 
 #define ReadDlgErr(in, er, es) ReadDlgError(in, er, es, __FILE__, __LINE__)
@@ -104,8 +104,8 @@ static void ReadAccOpen(const char *infile, FILE *in)
     char buf[STRLEN];
     int  result;
 
-    result = fscanf(in, "%4s", buf);
-    if ((1 != result) || strcmp(buf, "{") != 0)
+    result = std::fscanf(in, "%4s", buf);
+    if ((1 != result) || std::strcmp(buf, "{") != 0)
     {
         ReadDlgErr(infile, eACCOEXP, buf);
     }
@@ -116,8 +116,8 @@ static void ReadAccClose(const char *infile, FILE *in)
     char buf[STRLEN];
     int  result;
 
-    result = fscanf(in, "%4s", buf);
-    if ((1 != result) || strcmp(buf, "}") != 0)
+    result = std::fscanf(in, "%4s", buf);
+    if ((1 != result) || std::strcmp(buf, "}") != 0)
     {
         ReadDlgErr(infile, eACCCEXP, buf);
     }
@@ -129,16 +129,16 @@ void ReadQuoteString(const char *infile, FILE *in, char *buf)
     int  i = 0;
 
     /* Read until first quote */
-    while ((c[0] = fgetc(in)) != '"')
+    while ((c[0] = std::fgetc(in)) != '"')
     {
-        if (!isspace(c[0]))
+        if (!std::isspace(c[0]))
         {
             c[1] = '\0';
             ReadDlgErr(infile, eQUOTE, c);
         }
     }
     /* Read until second quote */
-    while ((c[0] = fgetc(in)) != '"')
+    while ((c[0] = std::fgetc(in)) != '"')
     {
         buf[i++] = c[0];
     }
@@ -153,7 +153,7 @@ static void ReadQuoteStringOrAccClose(FILE *in, char *buf)
     /* Read until first quote */
     do
     {
-        c = fgetc(in);
+        c = std::fgetc(in);
         if (c == '}')
         {
             buf[0] = c;
@@ -164,7 +164,7 @@ static void ReadQuoteStringOrAccClose(FILE *in, char *buf)
     while (c != '"');
 
     /* Read until second quote */
-    while ((c = fgetc(in)) != '"')
+    while ((c = std::fgetc(in)) != '"')
     {
         buf[i++] = c;
     }
@@ -173,7 +173,7 @@ static void ReadQuoteStringOrAccClose(FILE *in, char *buf)
 
 static bool bNotAccClose(const char *buf)
 {
-    return (strcmp(buf, "}") != 0);
+    return (std::strcmp(buf, "}") != 0);
 }
 
 static t_fitem *NewFItem(void)
@@ -312,7 +312,7 @@ static t_fitem *ScanFItem(const char *infile, FILE *in, char *buf)
 
     for (edlg = 0; (edlg < edlgNR+1); edlg++)
     {
-        if (strcmp(buf, type[edlg]) == 0)
+        if (std::strcmp(buf, type[edlg]) == 0)
         {
             break;
         }
@@ -378,8 +378,8 @@ t_fgrid *FGridFromFile(const char *infile)
     int        gridx, gridy;
 
     in     = libopen(infile);
-    result = fscanf(in, "%6s", buf);
-    if ((1 != result) || strcmp(buf, "grid") != 0)
+    result = std::fscanf(in, "%6s", buf);
+    if ((1 != result) || std::strcmp(buf, "grid") != 0)
     {
         ReadDlgErr(infile, eGRIDEXP, buf);
     }
@@ -391,7 +391,7 @@ t_fgrid *FGridFromFile(const char *infile)
     fgrid->w = gridx;
     fgrid->h = gridy;
     ReadAccOpen(infile, in);
-    result = fscanf(in, "%15s", buf);
+    result = std::fscanf(in, "%15s", buf);
     while ((1 == result) && bNotAccClose(buf))
     {
         if (strcmp(buf, "group") == 0)
@@ -412,11 +412,11 @@ t_fgrid *FGridFromFile(const char *infile)
                 ReadDlgErr(infile, eTOOHIGH, buf);
             }
             ReadAccOpen(infile, in);
-            result = fscanf(in, "%15s", buf);
+            result = std::fscanf(in, "%15s", buf);
             while ((1 == result) && bNotAccClose(buf))
             {
                 AddFGroupFItem(fgroup, ScanFItem(infile, in, buf));
-                result = fscanf(in, "%15s", buf);
+                result = std::fscanf(in, "%15s", buf);
             }
         }
         else if (strcmp(buf, "simple") == 0)
@@ -435,7 +435,7 @@ t_fgrid *FGridFromFile(const char *infile)
                 ReadDlgErr(infile, eTOOHIGH, "simple");
             }
             ReadAccOpen(infile, in);
-            result = fscanf(in, "%15s", buf);
+            result = std::fscanf(in, "%15s", buf);
             if (1 == result)
             {
                 fsimple->fitem = ScanFItem(infile, in, buf);
@@ -444,7 +444,7 @@ t_fgrid *FGridFromFile(const char *infile)
         }
         if (1 == result)
         {
-            result = fscanf(in, "%15s", buf);
+            result = std::fscanf(in, "%15s", buf);
         }
     }
     gmx_ffclose(in);
@@ -463,18 +463,18 @@ static void DumpFItem(t_fitem *fitem)
 {
     int i;
 
-    printf("  type: %s, set: '%s', get: '%s', def: '%s', help: '%s'\n  {",
-           type[fitem->edlg], fitem->set, fitem->get, fitem->def, fitem->help);
+    std::printf("  type: %s, set: '%s', get: '%s', def: '%s', help: '%s'\n  {",
+                type[fitem->edlg], fitem->set, fitem->get, fitem->def, fitem->help);
     for (i = 0; (i < fitem->nname); i++)
     {
-        printf("  '%s'", fitem->name[i]);
+        std::printf("  '%s'", fitem->name[i]);
     }
-    printf("  }\n");
+    std::printf("  }\n");
 }
 
 static void DumpFSimple(t_fsimple *fsimple)
 {
-    printf("Simple %dx%d at %d,%d\n", fsimple->w, fsimple->h, fsimple->x, fsimple->y);
+    std::printf("Simple %dx%d at %d,%d\n", fsimple->w, fsimple->h, fsimple->x, fsimple->y);
     DumpFItem(fsimple->fitem);
 }
 
@@ -482,7 +482,7 @@ static void DumpFGroup(t_fgroup *fgroup)
 {
     int i;
 
-    printf("Group %dx%d at %d,%d\n", fgroup->w, fgroup->h, fgroup->x, fgroup->y);
+    std::printf("Group %dx%d at %d,%d\n", fgroup->w, fgroup->h, fgroup->x, fgroup->y);
     for (i = 0; (i < fgroup->nfitem); i++)
     {
         DumpFItem(fgroup->fitem[i]);
@@ -493,7 +493,7 @@ void DumpFGrid(t_fgrid *fgrid)
 {
     int i;
 
-    printf("Grid %dx%d\n", fgrid->w, fgrid->h);
+    std::printf("Grid %dx%d\n", fgrid->w, fgrid->h);
     for (i = 0; (i < fgrid->nfgroup); i++)
     {
         DumpFGroup(fgrid->fgroup[i]);
index 82d583709f72ccf6dda7bad42d6d90e06692c623..8a6f00ac41682d6e3b6308caa357ecee86008982 100644 (file)
@@ -36,6 +36,7 @@
  */
 #include "gmxpre.h"
 
+#include <cstdio>
 #include <cstring>
 
 #include <algorithm>
@@ -94,7 +95,7 @@ static void FilterCB(t_x11 *x11, int dlg_mess, int /*item_id*/,
     f   = gmx->filter;
 
 #ifdef DEBUG
-    printf("item_id: %d, set: %s\n", item_id, set);
+    std::printf("item_id: %d, set: %s\n", item_id, set);
 #endif
     switch (dlg_mess)
     {
@@ -148,47 +149,47 @@ t_dlg *select_filter(t_x11 *x11, t_gmx *gmx)
     std::strcpy(tmpfile, "filterXXXXXX");
     gmx_tmpnam(tmpfile);
 #ifdef DEBUG
-    fprintf(stderr, "file: %s\n", tmpfile);
+    std::fprintf(stderr, "file: %s\n", tmpfile);
 #endif
-    if ((tmp = fopen(tmpfile, "w")) == NULL)
+    if ((tmp = std::fopen(tmpfile, "w")) == NULL)
     {
-        sprintf(tmpfile, "%ctmp%cfilterXXXXXX", DIR_SEPARATOR, DIR_SEPARATOR);
+        std::sprintf(tmpfile, "%ctmp%cfilterXXXXXX", DIR_SEPARATOR, DIR_SEPARATOR);
         gmx_tmpnam(tmpfile);
-        if ((tmp = fopen(tmpfile, "w")) == NULL)
+        if ((tmp = std::fopen(tmpfile, "w")) == NULL)
         {
             gmx_fatal(FARGS, "Can not open tmp file %s", tmpfile);
         }
     }
     tlen = 1+ncol*(1+len);
-    fprintf(tmp, "grid %d %d {\n\n", tlen, ht);
+    std::fprintf(tmp, "grid %d %d {\n\n", tlen, ht);
 
     for (k = j = 0, x0 = 1; (j < ncol); j++, x0 += len+1)
     {
-        fprintf(tmp, "group \"%s-%d\" %d 1 %d %d {\n", title, j+1, x0, len, ht-5);
+        std::fprintf(tmp, "group \"%s-%d\" %d 1 %d %d {\n", title, j+1, x0, len, ht-5);
         for (i = 0; (i < nrow) && (k < gmx->filter->grps->nr); i++, k++)
         {
             if (!gmx->filter->bDisable[k])
             {
-                fprintf(tmp, "checkbox \"%s\" \"%d\" %s %s %s\n",
-                        gmx->filter->grpnames[k], k, dummy, dummy, dummy);
+                std::fprintf(tmp, "checkbox \"%s\" \"%d\" %s %s %s\n",
+                             gmx->filter->grpnames[k], k, dummy, dummy, dummy);
             }
             else
             {
-                fprintf(tmp, "statictext { \"  %s\" } \"%d\" %s %s %s\n",
-                        gmx->filter->grpnames[k], k, dummy, dummy, dummy);
+                std::fprintf(tmp, "statictext { \"  %s\" } \"%d\" %s %s %s\n",
+                             gmx->filter->grpnames[k], k, dummy, dummy, dummy);
             }
         }
-        fprintf(tmp, "}\n\n");
+        std::fprintf(tmp, "}\n\n");
     }
-    fprintf(tmp, "simple 1 %d %d 2 {\n", ht-3, tlen-2);
-    fprintf(tmp, "defbutton %s %s %s %s %s\n", ok, ok, dummy, dummy, dummy);
-    fprintf(tmp, "}\n\n}\n");
-    fclose(tmp);
+    std::fprintf(tmp, "simple 1 %d %d 2 {\n", ht-3, tlen-2);
+    std::fprintf(tmp, "defbutton %s %s %s %s %s\n", ok, ok, dummy, dummy, dummy);
+    std::fprintf(tmp, "}\n\n}\n");
+    std::fclose(tmp);
 
     dlg = ReadDlg(x11, gmx->wd->self, title, tmpfile,
                   0, 0, true, false, FilterCB, gmx);
 
-    remove(tmpfile);
+    std::remove(tmpfile);
 
     return dlg;
 }
index ee182e2e235eff32d4c960064fd7523a17ca3fc5..657dcbe9af6a7fff4d480e9f38735fab74a10408 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,7 +38,8 @@
 
 #include "logo.h"
 
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
 
 #include "gromacs/legacyheaders/copyrite.h"
 #include "gromacs/legacyheaders/macros.h"
@@ -200,7 +201,7 @@ t_logo *init_logo(t_x11 *x11, Window parent, bool bQuitOnClick)
     logo->bQuitOnClick = bQuitOnClick;
     InitWin(&logo->wd, 0, 0, 360, 270, 1, "GROMACS");
     bg = LIGHTGREY;
-    if ((newcol = getenv("GMX_LOGO_COLOR")) != NULL)
+    if ((newcol = std::getenv("GMX_LOGO_COLOR")) != NULL)
     {
         GetNamedColor(x11, newcol, &bg);
     }
@@ -217,11 +218,11 @@ t_logo *init_logo(t_x11 *x11, Window parent, bool bQuitOnClick)
     }
     if (i == NBF)
     {
-        perror(bfname[i-1]);
-        exit(1);
+        std::perror(bfname[i-1]);
+        std::exit(1);
     }
 #ifdef DEBUG
-    fprintf(stderr, "Big Logofont: %s\n", bfname[i]);
+    std::fprintf(stderr, "Big Logofont: %s\n", bfname[i]);
 #endif
     for (i = 0, logo->smallfont = NULL; (i < NSF); i++)
     {
@@ -232,11 +233,11 @@ t_logo *init_logo(t_x11 *x11, Window parent, bool bQuitOnClick)
     }
     if (i == NSF)
     {
-        perror(sfname[i-1]);
-        exit(1);
+        std::perror(sfname[i-1]);
+        std::exit(1);
     }
 #ifdef DEBUG
-    fprintf(stderr, "Small Logofont: %s\n", sfname[i]);
+    std::fprintf(stderr, "Small Logofont: %s\n", sfname[i]);
 #endif
     x11->RegisterCallback(x11, logo->wd.self, parent, LogoCallBack, logo);
     x11->SetInputMask(x11, logo->wd.self, ButtonPressMask | ExposureMask);
index a2538f883f1e2e6d030e909f362f1c5119ce9991..a4f012cc8564d9efc5463974f0242e7eb6abfec0 100644 (file)
  */
 #include "gmxpre.h"
 
+#include "manager.h"
+
 #include "config.h"
 
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h> // for usleep()
 #endif
 
-#include "manager.h"
-
 #include "gromacs/fileio/tpxio.h"
 #include "gromacs/legacyheaders/copyrite.h"
 #include "gromacs/legacyheaders/macros.h"
@@ -85,7 +86,7 @@ static void add_bonds(t_manager *man, t_functype func[],
     int          i, delta, ftype;
 
 #ifdef DEBUG
-    fprintf(stderr, "Going to make bonds from an ilist with %d entries\n", b->nr);
+    std::fprintf(stderr, "Going to make bonds from an ilist with %d entries\n", b->nr);
 #endif
     ia = b->iatoms;
     for (i = 0; (i < b->nr); )
@@ -107,7 +108,7 @@ static void add_bonds(t_manager *man, t_functype func[],
         {
             aj = ia[2];
 #ifdef DEBUG
-            fprintf(stderr, "Adding bond from %d to %d\n", ai, aj);
+            std::fprintf(stderr, "Adding bond from %d to %d\n", ai, aj);
 #endif
             bB[ai] = bB[aj] = true;
             if (!(bH[ai] == bH[aj]))
@@ -120,7 +121,7 @@ static void add_bonds(t_manager *man, t_functype func[],
             }
         }
 #ifdef DEBUG
-        fprintf(stderr, "Type: %5d, delta: %5d\n", type, delta);
+        std::fprintf(stderr, "Type: %5d, delta: %5d\n", type, delta);
 #endif
         ia += delta+1;
         i  += delta+1;
@@ -148,7 +149,7 @@ static atom_id which_atom(t_manager *man, int x, int y)
 
     for (i = 0; (i < man->natom); i++)
     {
-        if ((abs(ix[i][XX]-x) < DELTA) && (abs(ix[i][YY]-y) < DELTA))
+        if ((std::abs(ix[i][XX]-x) < DELTA) && (std::abs(ix[i][YY]-y) < DELTA))
         {
             if (man->bVis[i])
             {
@@ -184,7 +185,7 @@ static void do_label(t_x11 *x11, t_manager *man, int x, int y, bool bSet)
         }
         XSetForeground(x11->disp, x11->gc, col);
         XDrawString(x11->disp, man->molw->wd.self, x11->gc, x+2, y-2, man->szLab[ai],
-                    strlen(man->szLab[ai]));
+                    std::strlen(man->szLab[ai]));
         XSetForeground(x11->disp, x11->gc, x11->fg);
     }
 }
@@ -242,7 +243,7 @@ void set_file(t_x11 *x11, t_manager *man, const char *trajectory,
     }
 
     cool_quote(quote, 255, NULL);
-    sprintf(buf, "%s: %s", *man->top.name, quote);
+    std::sprintf(buf, "%s: %s", *man->top.name, quote);
     man->title.text = gmx_strdup(buf);
     man->view       = init_view(man->box);
     at              = &(man->top.atoms);
@@ -256,11 +257,11 @@ void set_file(t_x11 *x11, t_manager *man, const char *trajectory,
         snew(man->szLab[i], 20);
         if (ri->ic != ' ')
         {
-            sprintf(man->szLab[i], "%s%d%c, %s", *ri->name, ri->nr, ri->ic, aname);
+            std::sprintf(man->szLab[i], "%s%d%c, %s", *ri->name, ri->nr, ri->ic, aname);
         }
         else
         {
-            sprintf(man->szLab[i], "%s%d, %s", *ri->name, ri->nr, aname);
+            std::sprintf(man->szLab[i], "%s%d, %s", *ri->name, ri->nr, aname);
         }
         man->bHydro[i] = (toupper(aname[0]) == 'H');
         if (man->bHydro[i])
@@ -354,8 +355,8 @@ static bool step_man(t_manager *man, int *nat)
 
     if (!man->natom)
     {
-        fprintf(stderr, "Not initiated yet!");
-        exit(1);
+        std::fprintf(stderr, "Not initiated yet!");
+        std::exit(1);
     }
     bEof = read_next_x(man->oenv, man->status, &man->time, man->x, man->box);
     *nat = man->natom;
@@ -562,7 +563,7 @@ void move_man(t_x11 *x11, t_manager *man, int width, int height)
     int th;
 
 #ifdef DEBUG
-    fprintf(stderr, "Move manager %dx%d\n", width, height);
+    std::fprintf(stderr, "Move manager %dx%d\n", width, height);
 #endif
     man->wd.width  = width;
     man->wd.height = height;
@@ -586,7 +587,7 @@ void move_man(t_x11 *x11, t_manager *man, int width, int height)
 
     if (y0 > height)
     {
-        printf("Error: Windows falling out of main window!\n");
+        std::printf("Error: Windows falling out of main window!\n");
     }
 
     /* Button Box */
index 977d3ae0b43537adf84fcca1a35cbe522320b193..ddfebf8ce214c0f558c3eae91af763c1b88d5de5 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -36,9 +36,7 @@
  */
 #include "gmxpre.h"
 
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
 
 #include "gromacs/fileio/writeps.h"
 #include "gromacs/legacyheaders/macros.h"
@@ -260,7 +258,7 @@ void ps_draw_mol(t_psdata ps, t_manager *man)
     nvis = filter_vis(man);
     if (nvis && man->bSort)
     {
-        qsort(man->obj, nvis, sizeof(man->obj[0]), compare_obj);
+        std::qsort(man->obj, nvis, sizeof(man->obj[0]), compare_obj);
     }
 
     /* Draw the objects */
index 3c1669d40bf86084b06941cf14b0d84490c8d143..9775ca357605deed8349f02f11e80f39f4d0b85a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,7 +38,7 @@
 
 #include "nleg.h"
 
-#include <string.h>
+#include <cstring>
 
 #include <algorithm>
 
@@ -78,7 +78,7 @@ int search_ac(const char *type)
     {
         for (i = 0; (i < NAC); i++)
         {
-            mij = std::min((int)strlen(type), (int)strlen(ac[i].tp));
+            mij = std::min(static_cast<int>(std::strlen(type)), static_cast<int>(std::strlen(ac[i].tp)));
             for (nb = 0; (nb < mij); nb++)
             {
                 if (type[nb] != ac[i].tp[nb])
index cca9b5fbdda791904a6a4eb5e4653a8fe45f0db7..92e068913a253b18208322ccbaffdccb8c1f7e03 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,9 +38,9 @@
 
 #include "nmol.h"
 
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/txtdump.h"
@@ -81,7 +81,7 @@ static bool MWCallBack(t_x11 *x11, XEvent *event, Window /*w*/, void *data)
             break;
         case ButtonPress:
 #ifdef DEBUG
-            printf("Molwindow: Buttonpress\n");
+            std::printf("Molwindow: Buttonpress\n");
 #endif
             letter.xclient.data.l[0] = IDLABEL;
             letter.xclient.data.l[1] = (long)event->xbutton.button;
@@ -154,7 +154,7 @@ void set_bond_type(t_x11 *x11, t_molwin *mw, int bt)
 void set_box_type (t_x11 *x11, t_molwin *mw, int bt)
 {
 #ifdef DEBUG
-    fprintf(stderr, "mw->boxtype = %d, bt = %d\n", mw->boxtype, bt);
+    std::fprintf(stderr, "mw->boxtype = %d, bt = %d\n", mw->boxtype, bt);
 #endif
     if (bt != mw->boxtype)
     {
@@ -165,7 +165,7 @@ void set_box_type (t_x11 *x11, t_molwin *mw, int bt)
         }
         else
         {
-            fprintf(stderr, "Can not change rectangular box to truncated octahedron\n");
+            std::fprintf(stderr, "Can not change rectangular box to truncated octahedron\n");
         }
     }
 }
@@ -586,8 +586,8 @@ void draw_mol(t_x11 *x11, t_manager *man)
     XClearWindow(x11->disp, win->self);
 
     /* Draw Time */
-    sprintf(tstr[ntime], "Time: %.3f ps", man->time);
-    if (strcmp(tstr[ntime], tstr[1-ntime]) != 0)
+    std::sprintf(tstr[ntime], "Time: %.3f ps", man->time);
+    if (std::strcmp(tstr[ntime], tstr[1-ntime]) != 0)
     {
         set_vbtime(x11, man->vbox, tstr[ntime]);
         ntime = 1-ntime;
@@ -602,7 +602,7 @@ void draw_mol(t_x11 *x11, t_manager *man)
     nvis = filter_vis(man);
     if (nvis && man->bSort)
     {
-        qsort(man->obj, nvis, sizeof(man->obj[0]), compare_obj);
+        std::qsort(man->obj, nvis, sizeof(man->obj[0]), compare_obj);
     }
 
     /* Draw the objects */
@@ -617,7 +617,7 @@ void draw_mol(t_x11 *x11, t_manager *man)
         if (man->bLabel[i] && man->bVis[i])
         {
             XDrawString(x11->disp, win->self, x11->gc, vec2[i][XX]+2, vec2[i][YY]-2,
-                        man->szLab[i], strlen(man->szLab[i]));
+                        man->szLab[i], std::strlen(man->szLab[i]));
         }
     }
 
index 5c8114129fd361fa62e72b919562a3ab5995acb4..a90ac11f7abda459db37a576eb3a4556505d4a8f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,8 +38,8 @@
 
 #include "popup.h"
 
-#include <math.h>
-#include <string.h>
+#include <cmath>
+#include <cstring>
 
 #include <algorithm>
 
@@ -142,7 +142,7 @@ t_menu *init_menu(t_x11 *x11, Window Parent, unsigned long fg, unsigned long bg,
     mlen = 0;
     for (i = 0; (i < nent); i++)
     {
-        mlen = std::max(mlen, XTextWidth(x11->font, ent[i].str, strlen(ent[i].str)));
+        mlen = std::max(mlen, XTextWidth(x11->font, ent[i].str, std::strlen(ent[i].str)));
     }
     mht = XTextHeight(x11->font);
     /* Now we have the biggest single box, add a border of 2 pixels */
@@ -150,7 +150,7 @@ t_menu *init_menu(t_x11 *x11, Window Parent, unsigned long fg, unsigned long bg,
     mht  += 4;
     /* Calculate the area of the menu */
     area = mlen*mht;
-    ht   = sqrt(area);
+    ht   = std::sqrt(area);
     /* No the number of rows per column, only beyond 8 rows */
     if (ncol == 0)
     {
index 5dd48058764902987c995e31b833c16db5b15b76..8ec0b9b12c020137a3b8bba886ea553dab29e8ed 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,7 +38,8 @@
 
 #include "pulldown.h"
 
-#include <string.h>
+#include <cstdio>
+#include <cstring>
 
 #include <algorithm>
 
@@ -63,7 +64,7 @@ static bool PDCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
             for (i = 0; (i < pd->nmenu); i++)
             {
                 XDrawString(x11->disp, pd->wd.self, x11->gc, pd->xpos[i], x11->font->ascent,
-                            pd->title[i], strlen(pd->title[i]));
+                            pd->title[i], std::strlen(pd->title[i]));
             }
             break;
         case ButtonPress:
@@ -105,11 +106,11 @@ t_pulldown *init_pd(t_x11 *x11, Window Parent, int width,
     for (i = 1; (i <= nmenu); i++)
     {
         pd->xpos[i] = 20+pd->xpos[i-1]+
-            XTextWidth(x11->font, title[i-1], strlen(title[i-1]));
+            XTextWidth(x11->font, title[i-1], std::strlen(title[i-1]));
     }
     if (pd->xpos[nmenu] > width)
     {
-        printf("Menu too wide\n");
+        std::printf("Menu too wide\n");
     }
 
     InitWin(&(pd->wd), 0, 0, width, XTextHeight(x11->font)+2, 0, "PullDown");
index 662ce57787db22efd7b26948757ea6fa9bb73bde..47630642e30c7a8fe266981cbe9902cb8f48adc9 100644 (file)
@@ -38,8 +38,7 @@
 
 #include "config.h"
 
-#include <stdio.h>
-#include <string.h>
+#include <cstdio>
 
 #include "gromacs/commandline/pargs.h"
 #include "gromacs/fileio/confio.h"
@@ -85,7 +84,7 @@ static void move_gmx(t_x11 *x11, t_gmx *gmx, int width, int height,
 {
     int y0, wl, hl;
 #ifdef DEBUG
-    fprintf(stderr, "Move gmx %dx%d\n", width, height);
+    std::fprintf(stderr, "Move gmx %dx%d\n", width, height);
 #endif
     y0 = XTextHeight(x11->font);
     /* Resize PD-Menu */
@@ -407,14 +406,14 @@ int gmx_view(int argc, char *argv[])
                           0, NULL, asize(desc), desc, asize(bugs), bugs, &oenv))
     {
 #if !GMX_X11
-        fprintf(stderr, "Compiled without X-Windows - can not run viewer.\n");
+        std::fprintf(stderr, "Compiled without X-Windows - can not run viewer.\n");
 #else
         t_x11 *x11;
 
         if ((x11 = GetX11(&argc, argv)) == NULL)
         {
-            fprintf(stderr, "Can't connect to X Server.\n"
-                    "Check your DISPLAY environment variable\n");
+            std::fprintf(stderr, "Can't connect to X Server.\n"
+                         "Check your DISPLAY environment variable\n");
         }
         else
         {
index cf3eb241bb91228781dfc702c55b1782397a612c..86d038b106cb609cf7c4cd65e86bd5895cb9cdf1 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,8 +38,9 @@
 
 #include "x11.h"
 
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 
 #include "gromacs/legacyheaders/typedefs.h"
 #include "gromacs/utility/cstringutil.h"
@@ -59,7 +60,7 @@ static XFontStruct *XLQF(FILE gmx_unused *err, Display *disp, const char *name)
 #ifdef DEBUG
     if (font != NULL)
     {
-        fprintf(err, "Loaded font %s\n", name);
+        std::fprintf(err, "Loaded font %s\n", name);
     }
 #endif
     return font;
@@ -128,7 +129,7 @@ void GetNamedColor(t_x11 *x11, const char *name, unsigned long *col)
     }
     else
     {
-        fprintf(x11->console, "No colour %s\n", name);
+        std::fprintf(x11->console, "No colour %s\n", name);
     }
 }
 
@@ -260,7 +261,7 @@ static void SetInputMask(t_x11 *x11, Window w, unsigned long mask)
     }
     else
     {
-        fprintf(x11->console, "No such window (%d)\n", (int)w);
+        std::fprintf(x11->console, "No such window (%d)\n", (int)w);
     }
 }
 
@@ -296,7 +297,7 @@ static void CleanUp(t_x11 *x11)
 
 static void Flush(t_x11 *x11)
 {
-    fflush(x11->console);
+    std::fflush(x11->console);
 }
 
 t_x11 *GetX11(int *argc, char *argv[])
@@ -324,8 +325,8 @@ t_x11 *GetX11(int *argc, char *argv[])
     title = gmx_strdup(argv[0]);
 
     /* First check environment */
-    fontname = getenv("GMX_FONT");
-    display  = getenv("DISPLAY");
+    fontname = std::getenv("GMX_FONT");
+    display  = std::getenv("DISPLAY");
 
     snew(ARGV, *argc);
     ARGC = 1;
@@ -389,7 +390,7 @@ t_x11 *GetX11(int *argc, char *argv[])
         x11->console = stderr;
     }
     else
-    if ((x11->console = fopen("/dev/null", "w")) == NULL)
+    if ((x11->console = std::fopen("/dev/null", "w")) == NULL)
     {
         x11->console = stderr;
     }
@@ -398,7 +399,7 @@ t_x11 *GetX11(int *argc, char *argv[])
     {
         if (bVerbose)
         {
-            fprintf(x11->console, "Display %s invalid\n", display);
+            std::fprintf(x11->console, "Display %s invalid\n", display);
         }
         return NULL;
     }
@@ -439,13 +440,13 @@ t_x11 *GetX11(int *argc, char *argv[])
         }
         if ((i == 4) || (i == 5))
         {
-            fprintf(x11->console, "Greyscale screen, using B & W only\n");
+            std::fprintf(x11->console, "Greyscale screen, using B & W only\n");
         }
         else
         {
             /* We have real color! */
-            fprintf(x11->console, "%s screen with depth %d.\n",
-                    (i == NCLASS) ? "Unknown" : v_name[i], x11->depth);
+            std::fprintf(x11->console, "%s screen with depth %d.\n",
+                         (i == NCLASS) ? "Unknown" : v_name[i], x11->depth);
             GetNamedColor(x11, "midnight blue", &BLUE);
             GetNamedColor(x11, "DarkGreen", &GREEN);
             GetNamedColor(x11, "SeaGreen", &CYAN);
@@ -464,7 +465,7 @@ t_x11 *GetX11(int *argc, char *argv[])
     }
     else
     {
-        fprintf(x11->console, "Monochrome screen.\n");
+        std::fprintf(x11->console, "Monochrome screen.\n");
     }
 
     /* We should use Xrm here... */
index 2719c42b80a95fef1b21a0f76e638639ca677f4a..525b58649f268cbf7d2d896a30e77f8df3778660 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,9 +38,9 @@
 
 #include "xdlg.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/utility/cstringutil.h"
@@ -180,9 +180,9 @@ bool SetDlgItemSize(t_dlg *dlg, t_id id, int w, int h)
             dlgitem->win.height = h;
         }
 #ifdef DEBUG
-        fprintf(dlg->x11->console,
-                "Size window from: %dx%d to %dx%d\n", old_w, old_h,
-                dlgitem->win.width, dlgitem->win.height);
+        std::fprintf(dlg->x11->console,
+                     "Size window from: %dx%d to %dx%d\n", old_w, old_h,
+                     dlgitem->win.width, dlgitem->win.height);
         dlg->x11->Flush(dlg->x11);
 #endif
         if (dlgitem->win.self)
@@ -221,8 +221,8 @@ bool SetDlgItemPos(t_dlg *dlg, t_id id, int x0, int y0)
         dlgitem->win.x = x0;
         dlgitem->win.y = y0;
 #ifdef DEBUG
-        fprintf(dlg->x11->console,
-                "Move window from: %d,%d to %d,%d\n", old_x, old_y, x0, y0);
+        std::fprintf(dlg->x11->console,
+                     "Move window from: %d,%d to %d,%d\n", old_x, old_y, x0, y0);
         dlg->x11->Flush(dlg->x11);
 #endif
         if (dlgitem->win.self)
@@ -296,7 +296,7 @@ int EditTextLen(t_dlg *dlg, t_id id)
     {
         if (dlgitem->type == edlgET)
         {
-            return strlen(dlgitem->u.edittext.buf);
+            return std::strlen(dlgitem->u.edittext.buf);
         }
     }
 
@@ -397,12 +397,12 @@ void HelpNow(t_dlg *dlg, t_dlgitem *dlgitem)
         return;
     }
 
-    printf("%s\n", dlgitem->help);
+    std::printf("%s\n", dlgitem->help);
     do
     {
         fgets2(buf, 79, stdin);
 #ifdef DEBUG
-        fprintf(dlg->x11->console, "buffer: '%s'\n", buf);
+        std::fprintf(dlg->x11->console, "buffer: '%s'\n", buf);
         dlg->x11->Flush(dlg->x11);
 #endif
         if (gmx_strcasecmp(buf, "nok") == 0)
@@ -476,8 +476,8 @@ static bool DlgCB(t_x11 *x11, XEvent *event, Window w, void *data)
     {
         nWndProc = (dlgitem->WndProc)(x11, dlgitem, event);
 #ifdef DEBUG
-        fprintf(x11->console,
-                "window: %s, nWndProc: %d\n", dlgitem->win.text, nWndProc);
+        std::fprintf(x11->console,
+                     "window: %s, nWndProc: %d\n", dlgitem->win.text, nWndProc);
         x11->Flush(x11);
 #endif
         switch (nWndProc)
@@ -524,7 +524,7 @@ static bool DlgCB(t_x11 *x11, XEvent *event, Window w, void *data)
                 int  gid = dlgitem->GroupID;
                 t_id tid = RBSelected(dlg, gid);
 #ifdef DEBUG
-                fprintf(stderr, "RBPRESSED\n");
+                std::fprintf(stderr, "RBPRESSED\n");
 #endif
                 if (tid != -1)
                 {
@@ -625,7 +625,7 @@ void DoCreateDlg(t_dlg *dlg)
 
     if (!CheckWindow(dlg->win.self))
     {
-        exit(1);
+        std::exit(1);
     }
     hints.x     = dlg->win.x;
     hints.y     = dlg->win.y;
@@ -687,8 +687,8 @@ void AddDlgItems(t_dlg *dlg, int nitem, t_dlgitem *item[])
     for (i = 0; (i < nitem); i++)
     {
 #ifdef DEBUG
-        fprintf(dlg->x11->console,
-                "Adding item: %d from group %d\n", item[i]->ID, item[i]->GroupID);
+        std::fprintf(dlg->x11->console,
+                     "Adding item: %d from group %d\n", item[i]->ID, item[i]->GroupID);
         dlg->x11->Flush(dlg->x11);
 #endif
         AddDlgItem(dlg, item[i]);
@@ -808,8 +808,8 @@ t_dlg *CreateDlg(t_x11 *x11, Window Parent, const char *title,
         XGetGeometry(x11->disp, Parent, &root, &x, &y,
                      &(dlg->xmax), &(dlg->ymax), &dum, &dum);
 #ifdef DEBUG
-        fprintf(x11->console,
-                "Daddy is %d x %d at %d, %d\n", dlg->xmax, dlg->ymax, x, y);
+        std::fprintf(x11->console,
+                     "Daddy is %d x %d at %d, %d\n", dlg->xmax, dlg->ymax, x, y);
         dlg->x11->Flush(dlg->x11);
 #endif
     }
@@ -849,8 +849,8 @@ void SetDlgSize(t_dlg *dlg, int w, int h, bool bAutoPosition)
     dlg->win.height = h;
 
 #ifdef DEBUG
-    fprintf(dlg->x11->console, "SetDlgSize: Dialog is %dx%d, at %d,%d\n",
-            dlg->win.width, dlg->win.height, dlg->win.x, dlg->win.y);
+    std::fprintf(dlg->x11->console, "SetDlgSize: Dialog is %dx%d, at %d,%d\n",
+                 dlg->win.width, dlg->win.height, dlg->win.x, dlg->win.y);
     dlg->x11->Flush(dlg->x11);
 #endif
     if (dlg->win.self)
index 7d79e3b8ccc50d6451731e2cff51675620a2c4ef..837f13b5fbe31cd73db30bb13ec6e64741581705 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,8 +38,8 @@
 
 #include "xdlghi.h"
 
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstring>
 
 #include <algorithm>
 
@@ -193,10 +193,10 @@ static void AddDlgItemGroups(t_dlg *dlg, int gridx, int gridy,
             {
                 if (!item->list)
                 {
-                    printf("Error: empty list with non-empty nitem (%d)\n", item->nitem);
-                    printf("       at grid point: %d,%d\n", x, y);
-                    printf("       with size: %dx%d\n", item->w, item->h);
-                    exit(1);
+                    std::printf("Error: empty list with non-empty nitem (%d)\n", item->nitem);
+                    std::printf("       at grid point: %d,%d\n", x, y);
+                    std::printf("       with size: %dx%d\n", item->w, item->h);
+                    std::exit(1);
                 }
                 else
                 {
@@ -213,8 +213,8 @@ static void AddDlgItemGroups(t_dlg *dlg, int gridx, int gridy,
     h1 = gridy*h;
     SetDlgSize(dlg, w1, h1, bAutoPosition);
 #ifdef DEBUG
-    printf("Dimensions of grid cell: %8.3f x %8.3f\n", w, h);
-    printf("Dimensions of window:    %d x %d\n", w1, h1);
+    std::printf("Dimensions of grid cell: %8.3f x %8.3f\n", w, h);
+    std::printf("Dimensions of window:    %d x %d\n", w1, h1);
 #endif
 
     for (x = 0; (x < gridx); x++)
@@ -229,7 +229,7 @@ static void AddDlgItemGroups(t_dlg *dlg, int gridx, int gridy,
                 w1 = item->w*w;
                 h1 = item->h*h;
 #ifdef DEBUG
-                printf("New size: %d x %d at %d, %d\n", w1, h1, x1, y1);
+                std::printf("New size: %d x %d at %d, %d\n", w1, h1, x1, y1);
 #endif
                 SetDlgItemSize(dlg, item->list[0]->ID, w1, h1);
                 SetDlgItemPos(dlg, item->list[0]->ID, x1, y1);
@@ -277,13 +277,13 @@ static void AddListFItem(t_x11 *x11, t_dlgitemlist *list,
                                     x, (*y), 0, 0, 0));
             break;
         case edlgRB:
-            strcpy(buf, fitem->def);
+            std::strcpy(buf, fitem->def);
             iSel = -1;
             for (i = 0; (i < fitem->nname); i++)
             {
                 char buf2[100];
 
-                strcpy(buf2, fitem->name[i]);
+                std::strcpy(buf2, fitem->name[i]);
                 buf2[strlen(buf)] = '\0'; /* truncate itemname */
                 if (gmx_strcasecmp(buf2, buf) == 0)
                 {
@@ -318,7 +318,7 @@ static void AddListFItem(t_x11 *x11, t_dlgitemlist *list,
                                          GroupID, x, (*y), 0, 0, 0));
             break;
         case edlgET:
-            slen = strlen(fitem->name[0])+strlen(fitem->def);
+            slen = std::strlen(fitem->name[0])+strlen(fitem->def);
             AddListItem(list, CreateEditText(x11, fitem->name[0], slen, fitem->def,
                                              (*ID)++, GroupID, x, (*y), 0, 0, 0));
             break;
index 2660ea31fb7c7b1ccb05c206f569128e4311e989..8b99781fa9d9b1c5ff32d35bdba1852f6bdacb15 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 
 #include "xdlgitem.h"
 
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cctype>
+#include <cstdio>
+#include <cstring>
 
 #include <algorithm>
 
@@ -77,7 +76,7 @@ static void ShowCaret(t_x11 *x11, t_dlgitem *dlgitem)
         int x, y1, y2;
 
         et = &(dlgitem->u.edittext);
-        x  = XTextWidth(x11->font, dlgitem->win.text, strlen(dlgitem->win.text))+XCARET+
+        x  = XTextWidth(x11->font, dlgitem->win.text, std::strlen(dlgitem->win.text))+XCARET+
             XTextWidth(x11->font, (char*) &(et->buf[et->strbegin]), et->pos);
         y1 = (dlgitem->win.height-XTextHeight(x11->font))/2;
         y2 = (dlgitem->win.height-y1);
@@ -102,7 +101,7 @@ static int DefWndProc(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
     char           c[BUFSIZE+1];
 
 #ifdef DEBUG
-    printf("DefWndProc\n");
+    std::printf("DefWndProc\n");
 #endif
     switch (event->type)
     {
@@ -148,7 +147,7 @@ static int WndProcBN(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
         gmx_incons("button processing");
     }
     win = &(dlgitem->win);
-    w   = XTextWidth(x11->font, win->text, strlen(win->text));
+    w   = XTextWidth(x11->font, win->text, std::strlen(win->text));
     x   = (win->width-w)/2;
     th  = XTextHeight(x11->font)+OFFS_Y;
     switch (event->type)
@@ -230,7 +229,7 @@ static int WndProcGB(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
     }
     win = &(dlgitem->win);
 
-    x = XTextWidth(x11->font, win->text, strlen(win->text));
+    x = XTextWidth(x11->font, win->text, std::strlen(win->text));
     y = XTextHeight(x11->font);
     switch (event->type)
     {
@@ -329,7 +328,7 @@ static bool insert(char *s, char c, int *pos)
 
     if (isprint(c))
     {
-        sl = strlen(s);
+        sl = std::strlen(s);
         /* +1 for zero termination */
         for (i = sl+1; (i > *pos); i--)
         {
@@ -346,7 +345,7 @@ static bool my_backspace(char *s, int *pos)
 {
     int i, sl;
 
-    sl = strlen(s);
+    sl = std::strlen(s);
     if ((sl > 0) && ((*pos) > 0))
     {
         for (i = *pos-1; (i < sl); i++)
@@ -363,7 +362,7 @@ static bool my_delete(char *s, int *pos)
 {
     int i, sl;
 
-    sl = strlen(s);
+    sl = std::strlen(s);
     if ((sl > 0) && ((*pos) < sl))
     {
         for (i = *pos; (i < sl); i++)
@@ -403,7 +402,7 @@ static int WndProcET(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
     {
         case Expose:
             XSetForeground(x11->disp, x11->gc, x11->fg);
-            xtitle = XTextWidth(x11->font, win->text, strlen(win->text));
+            xtitle = XTextWidth(x11->font, win->text, std::strlen(win->text));
             ewidth = win->width-xtitle;
             TextInRect(x11, win->self, win->text,
                        0, 0, xtitle-1, win->height, eXLeft, eYCenter);
@@ -411,7 +410,7 @@ static int WndProcET(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
             TextInRect(x11, win->self, scrbuf,
                        xtitle+XCARET, 0, ewidth, win->height, eXLeft, eYCenter);
 #ifdef DEBUG
-            printf("Expose\n");
+            std::printf("Expose\n");
 #endif
             if (win->bFocus)
             {
@@ -420,11 +419,11 @@ static int WndProcET(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
             break;
         case ButtonPress:
             /* Calculate new position for caret */
-            et->pos = strlen(et->buf);
+            et->pos = std::strlen(et->buf);
             bp      = gmx_strdup(et->buf);
-            xp      = event->xbutton.x-XTextWidth(x11->font, win->text, strlen(win->text))-
+            xp      = event->xbutton.x-XTextWidth(x11->font, win->text, std::strlen(win->text))-
                 XCARET;
-            while ((et->pos > 0) && (XTextWidth(x11->font, bp, strlen(bp)) > xp))
+            while ((et->pos > 0) && (XTextWidth(x11->font, bp, std::strlen(bp)) > xp))
             {
                 et->pos--;
                 bp[et->pos] = '\0';
@@ -440,7 +439,7 @@ static int WndProcET(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
             }
             XLookupString(&(event->xkey), c, BUFSIZE, &keysym, NULL);
 #ifdef DEBUG
-            printf("Keysym: %x\n", keysym);
+            std::printf("Keysym: %x\n", keysym);
 #endif
             switch (keysym)
             {
@@ -477,12 +476,12 @@ static int WndProcET(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
                 case XK_End:
                     if (strlen(et->buf) <= (unsigned int)et->buflen)
                     {
-                        et->pos = strlen(et->buf);
+                        et->pos = std::strlen(et->buf);
                     }
                     else
                     {
                         et->pos      = et->buflen;
-                        et->strbegin = strlen(et->buf)-et->buflen;
+                        et->strbegin = std::strlen(et->buf)-et->buflen;
                     }
                     et->bChanged = true;
                     return ETCHANGED;
@@ -563,12 +562,12 @@ t_dlgitem *CreateButton(t_x11 *x11,
     }
     if (w == 0)
     {
-        w = XTextWidth(x11->font, szLab, strlen(szLab))+2*OFFS_X;
+        w = XTextWidth(x11->font, szLab, std::strlen(szLab))+2*OFFS_X;
     }
     if (bDef)
     {
-        snew(lab, strlen(szLab)+7); /* 6 for >> << and 1 for \0 */
-        sprintf(lab, ">> %s <<", szLab);
+        snew(lab, std::strlen(szLab)+7); /* 6 for >> << and 1 for \0 */
+        std::sprintf(lab, ">> %s <<", szLab);
     }
     else
     {
@@ -599,7 +598,7 @@ t_dlgitem *CreateRadioButton(t_x11 *x11,
     }
     if (w == 0)
     {
-        w = XTextWidth(x11->font, szLab, strlen(szLab))+OFFS_X+h;
+        w = XTextWidth(x11->font, szLab, std::strlen(szLab))+OFFS_X+h;
     }
     InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
     dlgitem->ID                    = id;
@@ -625,7 +624,7 @@ t_dlgitem *CreateGroupBox(t_x11 *x11,
     }
     if (w == 0)
     {
-        w = XTextWidth(x11->font, szLab, strlen(szLab))+2*OFFS_X;
+        w = XTextWidth(x11->font, szLab, std::strlen(szLab))+2*OFFS_X;
     }
     InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
     dlgitem->GroupID           = id;
@@ -633,8 +632,8 @@ t_dlgitem *CreateGroupBox(t_x11 *x11,
     dlgitem->type              = edlgGB;
     dlgitem->u.groupbox.nitems = nitems;
     snew(dlgitem->u.groupbox.item, nitems);
-    memcpy((char *)dlgitem->u.groupbox.item, (char *)items,
-           nitems*sizeof(items[0]));
+    std::memcpy((char *)dlgitem->u.groupbox.item, (char *)items,
+                nitems*sizeof(items[0]));
     dlgitem->WndProc = WndProcGB;
 
     return dlgitem;
@@ -654,7 +653,7 @@ t_dlgitem *CreateCheckBox(t_x11 *x11,
     }
     if (w == 0)
     {
-        w = XTextWidth(x11->font, szLab, strlen(szLab))+OFFS_X+h;
+        w = XTextWidth(x11->font, szLab, std::strlen(szLab))+OFFS_X+h;
     }
     InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
     dlgitem->ID                  = id;
@@ -698,7 +697,7 @@ t_dlgitem *CreateStaticText(t_x11 *x11,
     {
         for (i = 0; (i < nlines); i++)
         {
-            w = std::max(w, XTextWidth(x11->font, lines[i], strlen(lines[i])));
+            w = std::max(w, XTextWidth(x11->font, lines[i], std::strlen(lines[i])));
         }
         w += 2*OFFS_X;
     }
@@ -735,9 +734,9 @@ t_dlgitem *CreateEditText(t_x11 *x11,
         char *test;
 
         snew(test, screenbuf);
-        memset(test, 'w', screenbuf);
+        std::memset(test, 'w', screenbuf);
         w = XTextWidth(x11->font, test, screenbuf)+
-            XTextWidth(x11->font, title, strlen(title))+
+            XTextWidth(x11->font, title, std::strlen(title))+
             2*XCARET+2*OFFS_X;
         sfree(test);
     }
@@ -747,7 +746,7 @@ t_dlgitem *CreateEditText(t_x11 *x11,
     dlgitem->type    = edlgET;
     et               = &(dlgitem->u.edittext);
     snew(et->buf, STRLEN);
-    strcpy(et->buf, buf);
+    std::strcpy(et->buf, buf);
     et->buflen       = screenbuf;
     et->strbegin     = 0;
     et->bChanged     = false;
@@ -766,6 +765,6 @@ void SetDlgitemOpts(t_dlgitem *dlgitem, bool bUseMon,
     dlgitem->get     = SC(get);
     dlgitem->help    = SC(help);
 #ifdef DEBUG
-    printf("Help is: '%s'\n", dlgitem->help);
+    std::printf("Help is: '%s'\n", dlgitem->help);
 #endif
 }
index 4999c431cde0c5cde0e49ff59519ea427c26ed25..fafd2bed82315efc84e63226a16482457692b990 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,9 +38,8 @@
 
 #include "xmb.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
 
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/typedefs.h"
@@ -89,8 +88,8 @@ t_dlg *MessageBox(t_x11 *x11, Window Parent, const char *title,
         ((Flags & MB_NO) && (Flags & MB_CANCEL))  ||
         (!(Flags & MB_OK) && !(Flags & MB_YES)))
     {
-        fprintf(stderr, "Invalid button selection in MessageBox\n");
-        exit(1);
+        std::fprintf(stderr, "Invalid button selection in MessageBox\n");
+        std::exit(1);
     }
     nicon = 0;
     if (Flags & MB_ICONSTOP)
index 8d11f70bf097a329285c1b88e8ed4db209880c9f..88f61c8ebe227bd73967015ac4ddd5b7242546c1 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -38,9 +38,8 @@
 
 #include "xutil.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstring>
 
 #include "gromacs/legacyheaders/typedefs.h"
 #include "gromacs/utility/cstringutil.h"
@@ -70,7 +69,7 @@ int CheckWin(Window win, const char *file, int line)
     {
         if (win == winerr[i].n)
         {
-            fprintf(stderr, "%s", winerr[i].s);
+            std::fprintf(stderr, "%s", winerr[i].s);
             break;
         }
     }
@@ -79,7 +78,7 @@ int CheckWin(Window win, const char *file, int line)
         return 1;
     }
 
-    fprintf(stderr, " in file %s, line %d\n", file, line);
+    std::fprintf(stderr, " in file %s, line %d\n", file, line);
     return 0;
 }
 
@@ -108,7 +107,7 @@ void SpecialTextInRect(t_x11 *x11, XFontStruct *font, Drawable win,
         f = x11->font;
     }
 
-    fw = XTextWidth(f, s, strlen(s));
+    fw = XTextWidth(f, s, std::strlen(s));
     fh = XTextHeight(f);
     switch (eX)
     {
@@ -136,7 +135,7 @@ void SpecialTextInRect(t_x11 *x11, XFontStruct *font, Drawable win,
             y0 = y+(height-fh)/2+f->ascent;
             break;
     }
-    XDrawString(x11->disp, win, x11->gc, x0, y0, s, strlen(s));
+    XDrawString(x11->disp, win, x11->gc, x0, y0, s, std::strlen(s));
     if (font)
     {
         XSetFont(x11->disp, x11->gc, x11->font->fid);
@@ -176,7 +175,7 @@ void InitWin(t_windata *win, int x0, int y0, int w, int h, int bw, const char *t
         win->text = NULL;
     }
 #ifdef DEBUG
-    printf("%s: %d x %d at %d, %d\n", text, w, h, x0, y0);
+    std::printf("%s: %d x %d at %d, %d\n", text, w, h, x0, y0);
 #endif
 }
 
@@ -276,7 +275,7 @@ void PushMouse(Display *disp, Window dest, int x, int y)
     mpos         = newpos;
     XWarpPointer(disp, None, dest, 0, 0, 0, 0, x, y);
 #ifdef DEBUG
-    fprintf(stderr, "Pushmouse %d, %d\n", x, y);
+    std::fprintf(stderr, "Pushmouse %d, %d\n", x, y);
 #endif
 }
 
@@ -292,7 +291,7 @@ void PopMouse(Display *disp)
 
     XWarpPointer(disp, None, DefaultRootWindow(disp), 0, 0, 0, 0, old->x, old->y);
 #ifdef DEBUG
-    fprintf(stderr, "Popmouse %d, %d\n", old->x, old->y);
+    std::fprintf(stderr, "Popmouse %d, %d\n", old->x, old->y);
 #endif
     mpos = old->prev;
     sfree(old);
@@ -317,13 +316,13 @@ bool GrabOK(FILE *out, int err)
         case GrabSuccess:
             return true;
         case GrabNotViewable:
-            fprintf(out, "GrabNotViewable\n"); break;
+            std::fprintf(out, "GrabNotViewable\n"); break;
         case AlreadyGrabbed:
-            fprintf(out, "AlreadyGrabbed\n"); break;
+            std::fprintf(out, "AlreadyGrabbed\n"); break;
         case GrabFrozen:
-            fprintf(out, "GrabFrozen\n"); break;
+            std::fprintf(out, "GrabFrozen\n"); break;
         case GrabInvalidTime:
-            fprintf(out, "GrabInvalidTime\n"); break;
+            std::fprintf(out, "GrabInvalidTime\n"); break;
         default:
             break;
     }