*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,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 "gmxpre.h"
-#include <ctype.h>
-#include <string.h>
+#include <cctype>
+#include <cstring>
+
+#include <algorithm>
#include "gromacs/commandline/pargs.h"
#include "gromacs/fileio/confio.h"
+#include "gromacs/gmxana/gmx_ana.h"
#include "gromacs/legacyheaders/macros.h"
#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/math/vec.h"
*/
const char *spec = " !&|";
- return (c != '\0' && strchr(spec, c) == NULL);
+ return (c != '\0' && std::strchr(spec, c) == NULL);
}
static int parse_names(char **string, int *n_names, char **names)
*c = ' ';
- if (isdigit((*string)[0]))
+ if (std::isdigit((*string)[0]))
{
*nr = (*string)[0]-'0';
(*string)++;
- while (isdigit((*string)[0]))
+ while (std::isdigit((*string)[0]))
{
*nr = (*nr)*10+(*string)[0]-'0';
(*string)++;
}
- if (isalpha((*string)[0]))
+ if (std::isalpha((*string)[0]))
{
*c = (*string)[0];
(*string)++;
}
/* Check if there is at most one non-digit character */
- if (!isalnum((*string)[0]))
+ if (!std::isalnum((*string)[0]))
{
bRet = TRUE;
}
c = (*string)[0];
(*string)++;
s = gmx_strdup((*string));
- sp = strchr(s, c);
+ sp = std::strchr(s, c);
if (sp != NULL)
{
(*string) += sp-s + 1;
{
sprintf(buf, "a_%d-%d", n1, up);
}
- strcpy(gname, buf);
+ std::strcpy(gname, buf);
}
}
else
index[*nr] = i-1;
(*nr)++;
sprintf(buf, "_%d", i);
- strcat(gname, buf);
+ std::strcat(gname, buf);
}
else
{
{
sprintf(buf, "r_%d-%d", n1, up);
}
- strcpy(gname, buf);
+ std::strcpy(gname, buf);
}
else
{
}
}
sprintf(buf, "_%d", j);
- strcat(gname, buf);
+ std::strcat(gname, buf);
}
while (parse_int_char(string, &j, &c));
}
{
sprintf(buf, "r_%d-%d", n1, up);
}
- strcpy(gname, buf);
+ std::strcpy(gname, buf);
}
else
{
}
}
sprintf(buf, "_%d", j);
- strcat(gname, buf);
+ std::strcat(gname, buf);
}
while (parse_int_char(string, &j, &c));
}
break;
default:
/* Compare a single character */
- if (( bCase && strncmp(name, search, 1)) ||
+ if (( bCase && std::strncmp(name, search, 1)) ||
(!bCase && gmx_strncasecmp(name, search, 1)))
{
return FALSE;
{
int i;
- strcpy(gname, names[0]);
+ std::strcpy(gname, names[0]);
for (i = 1; i < n; i++)
{
- strcat(gname, "_");
- strcat(gname, names[i]);
+ std::strcat(gname, "_");
+ std::strcat(gname, names[i]);
}
}
while (ca_start < natoms)
{
- while ((ca_start < natoms) && strcmp(*atoms->atomname[ca_start], "CA"))
+ while ((ca_start < natoms) && std::strcmp(*atoms->atomname[ca_start], "CA"))
{
ca_start++;
}
{
i++;
}
- while ((i < natoms) && strcmp(*atoms->atomname[i], "CA"));
+ while ((i < natoms) && std::strcmp(*atoms->atomname[i], "CA"));
if (i < natoms)
{
rvec_sub(x[ca_end], x[i], vec);
if ((sel_nr1 >= 0) && (sel_nr1 < block->nr))
{
copy_group(sel_nr1, block, nr, index);
- strcpy(gname, (*gn)[sel_nr1]);
+ std::strcpy(gname, (*gn)[sel_nr1]);
printf("Copied index group %d '%s'\n", sel_nr1, (*gn)[sel_nr1]);
bRet = TRUE;
}
}
}
}
- else if (strncmp(*string, "res", 3) == 0)
+ else if (std::strncmp(*string, "res", 3) == 0)
{
(*string) += 3;
if (check_have_atoms(atoms, ostring) &&
sprintf(gname, "atom_%s", (*gn)[sel_nr1]);
}
}
- else if (strncmp(*string, "ri", 2) == 0)
+ else if (std::strncmp(*string, "ri", 2) == 0)
{
(*string) += 2;
if (check_have_atoms(atoms, ostring) &&
}
}
}
- else if (strncmp(*string, "chain", 5) == 0)
+ else if (std::strncmp(*string, "chain", 5) == 0)
{
(*string) += 5;
if (check_have_atoms(atoms, ostring) &&
sprintf(gname, "ch%s", names[0]);
for (i = 1; i < n_names; i++)
{
- strcat(gname, names[i]);
+ std::strcat(gname, names[i]);
}
}
}
}
sfree(index1);
- for (i = strlen(gname)+1; i > 0; i--)
+ for (i = std::strlen(gname)+1; i > 0; i--)
{
gname[i] = gname[i-1];
}
resind = atoms->atom[i].resind;
if ((resind != prev_resind) || (i == atoms->nr-1))
{
- if ((bDiff = strcmp(*atoms->resinfo[resind].name,
- *atoms->resinfo[start].name)) ||
+ if ((bDiff = std::strcmp(*atoms->resinfo[resind].name,
+ *atoms->resinfo[start].name)) ||
(i == atoms->nr-1))
{
if (bDiff)
{
gmx_fatal(FARGS, "Error reading user input");
}
- inp_string[strlen(inp_string)-1] = 0;
+ inp_string[std::strlen(inp_string)-1] = 0;
printf("\n");
string = inp_string;
while (string[0] == ' ')
getchar();
}
}
- else if (strncmp(string, "del", 3) == 0)
+ else if (std::strncmp(string, "del", 3) == 0)
{
string += 3;
if (parse_int(&string, &sel_nr))
}
}
}
- else if (strncmp(string, "keep", 4) == 0)
+ else if (std::strncmp(string, "keep", 4) == 0)
{
string += 4;
if (parse_int(&string, &sel_nr))
remove_group(0, sel_nr-1, block, gn);
}
}
- else if (strncmp(string, "name", 4) == 0)
+ else if (std::strncmp(string, "name", 4) == 0)
{
string += 4;
if (parse_int(&string, &sel_nr))
}
}
}
- else if (strncmp(string, "case", 4) == 0)
+ else if (std::strncmp(string, "case", 4) == 0)
{
bCase = !bCase;
printf("Switched to case %s\n", bCase ? "sensitive" : "insensitive");
list_residues(atoms);
}
}
- else if (strncmp(string, "splitch", 7) == 0)
+ else if (std::strncmp(string, "splitch", 7) == 0)
{
string += 7;
if (check_have_atoms(atoms, ostring) &&
split_chain(atoms, x, sel_nr, block, gn);
}
}
- else if (strncmp(string, "splitres", 8) == 0)
+ else if (std::strncmp(string, "splitres", 8) == 0)
{
string += 8;
if (check_have_atoms(atoms, ostring) &&
split_group(atoms, sel_nr, block, gn, FALSE);
}
}
- else if (strncmp(string, "splitat", 7) == 0)
+ else if (std::strncmp(string, "splitat", 7) == 0)
{
string += 7;
if (check_have_atoms(atoms, ostring) &&
}
else if (string[0] != 'q')
{
- nr1 = -1;
nr2 = -1;
if (parse_entry(&string, natoms, atoms, block, gn, &nr, index, gname))
{
{
index1[i] = index[i];
}
- strcpy(gname1, gname);
+ std::strcpy(gname1, gname);
if (parse_entry(&string, natoms, atoms, block, gn, &nr2, index2, gname2))
{
if (bOr)
natoms = 0;
for (i = 0; i < block->nra; i++)
{
- natoms = max(natoms, block->a[i]);
+ natoms = std::max(natoms, block->a[i]);
}
natoms++;