X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=blobdiff_plain;f=src%2Fgromacs%2Fgmxana%2Fgmx_make_ndx.cpp;fp=src%2Fgromacs%2Fgmxana%2Fgmx_make_ndx.c;h=4bd93584a5fe6de862d502c299639301e7c90a00;hb=c3f2d46e4047f0c465f7234b3784a2fa6f02a065;hp=55dc3ab47b4027dda9599d1634b2d3994fb9d124;hpb=0595b4a4c763a0bc574658992081abf8b0abc3fe;p=alexxy%2Fgromacs.git diff --git a/src/gromacs/gmxana/gmx_make_ndx.c b/src/gromacs/gmxana/gmx_make_ndx.cpp similarity index 95% rename from src/gromacs/gmxana/gmx_make_ndx.c rename to src/gromacs/gmxana/gmx_make_ndx.cpp index 55dc3ab47b..4bd93584a5 100644 --- a/src/gromacs/gmxana/gmx_make_ndx.c +++ b/src/gromacs/gmxana/gmx_make_ndx.cpp @@ -3,7 +3,7 @@ * * 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. @@ -36,11 +36,14 @@ */ #include "gmxpre.h" -#include -#include +#include +#include + +#include #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" @@ -149,7 +152,7 @@ static gmx_bool is_name_char(char c) */ 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) @@ -209,22 +212,22 @@ static gmx_bool parse_int_char(char **string, int *nr, char *c) *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; } @@ -278,7 +281,7 @@ static gmx_bool parse_string(char **string, int *nr, int ngrps, char **grpname) c = (*string)[0]; (*string)++; s = gmx_strdup((*string)); - sp = strchr(s, c); + sp = std::strchr(s, c); if (sp != NULL) { (*string) += sp-s + 1; @@ -325,7 +328,7 @@ static int select_atomnumbers(char **string, t_atoms *atoms, atom_id n1, { sprintf(buf, "a_%d-%d", n1, up); } - strcpy(gname, buf); + std::strcpy(gname, buf); } } else @@ -339,7 +342,7 @@ static int select_atomnumbers(char **string, t_atoms *atoms, atom_id n1, index[*nr] = i-1; (*nr)++; sprintf(buf, "_%d", i); - strcat(gname, buf); + std::strcat(gname, buf); } else { @@ -399,7 +402,7 @@ static int select_residuenumbers(char **string, t_atoms *atoms, { sprintf(buf, "r_%d-%d", n1, up); } - strcpy(gname, buf); + std::strcpy(gname, buf); } else { @@ -418,7 +421,7 @@ static int select_residuenumbers(char **string, t_atoms *atoms, } } sprintf(buf, "_%d", j); - strcat(gname, buf); + std::strcat(gname, buf); } while (parse_int_char(string, &j, &c)); } @@ -474,7 +477,7 @@ static int select_residueindices(char **string, t_atoms *atoms, { sprintf(buf, "r_%d-%d", n1, up); } - strcpy(gname, buf); + std::strcpy(gname, buf); } else { @@ -493,7 +496,7 @@ static int select_residueindices(char **string, t_atoms *atoms, } } sprintf(buf, "_%d", j); - strcat(gname, buf); + std::strcat(gname, buf); } while (parse_int_char(string, &j, &c)); } @@ -559,7 +562,7 @@ static gmx_bool comp_name(char *name, char *search) 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; @@ -698,11 +701,11 @@ static void make_gname(int n, char **names, char *gname) { 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]); } } @@ -817,7 +820,7 @@ static int split_chain(t_atoms *atoms, rvec *x, 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++; } @@ -841,7 +844,7 @@ static int split_chain(t_atoms *atoms, rvec *x, { 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); @@ -973,7 +976,7 @@ static gmx_bool parse_entry(char **string, int natoms, t_atoms *atoms, 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; } @@ -1015,7 +1018,7 @@ static gmx_bool parse_entry(char **string, int natoms, t_atoms *atoms, } } } - else if (strncmp(*string, "res", 3) == 0) + else if (std::strncmp(*string, "res", 3) == 0) { (*string) += 3; if (check_have_atoms(atoms, ostring) && @@ -1027,7 +1030,7 @@ static gmx_bool parse_entry(char **string, int natoms, t_atoms *atoms, 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) && @@ -1052,7 +1055,7 @@ static gmx_bool parse_entry(char **string, int natoms, t_atoms *atoms, } } } - else if (strncmp(*string, "chain", 5) == 0) + else if (std::strncmp(*string, "chain", 5) == 0) { (*string) += 5; if (check_have_atoms(atoms, ostring) && @@ -1062,7 +1065,7 @@ static gmx_bool parse_entry(char **string, int natoms, t_atoms *atoms, sprintf(gname, "ch%s", names[0]); for (i = 1; i < n_names; i++) { - strcat(gname, names[i]); + std::strcat(gname, names[i]); } } } @@ -1095,7 +1098,7 @@ static gmx_bool parse_entry(char **string, int natoms, t_atoms *atoms, } sfree(index1); - for (i = strlen(gname)+1; i > 0; i--) + for (i = std::strlen(gname)+1; i > 0; i--) { gname[i] = gname[i-1]; } @@ -1119,8 +1122,8 @@ static void list_residues(t_atoms *atoms) 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) @@ -1221,7 +1224,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha { 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] == ' ') @@ -1279,7 +1282,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha getchar(); } } - else if (strncmp(string, "del", 3) == 0) + else if (std::strncmp(string, "del", 3) == 0) { string += 3; if (parse_int(&string, &sel_nr)) @@ -1311,7 +1314,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha } } } - else if (strncmp(string, "keep", 4) == 0) + else if (std::strncmp(string, "keep", 4) == 0) { string += 4; if (parse_int(&string, &sel_nr)) @@ -1320,7 +1323,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha 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)) @@ -1333,7 +1336,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha } } } - 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"); @@ -1350,7 +1353,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha 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) && @@ -1360,7 +1363,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha 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) && @@ -1370,7 +1373,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha 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) && @@ -1386,7 +1389,6 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha } else if (string[0] != 'q') { - nr1 = -1; nr2 = -1; if (parse_entry(&string, natoms, atoms, block, gn, &nr, index, gname)) { @@ -1416,7 +1418,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha { index1[i] = index[i]; } - strcpy(gname1, gname); + std::strcpy(gname1, gname); if (parse_entry(&string, natoms, atoms, block, gn, &nr2, index2, gname2)) { if (bOr) @@ -1469,7 +1471,7 @@ static int block2natoms(t_blocka *block) natoms = 0; for (i = 0; i < block->nra; i++) { - natoms = max(natoms, block->a[i]); + natoms = std::max(natoms, block->a[i]); } natoms++;