/*
+ * This file is part of the GROMACS molecular simulation package.
*
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2013, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
+ * Copyright (c) 2001-2013, The GROMACS development team.
+ * Copyright (c) 2013,2014, 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * For more info, check our website at http://www.gromacs.org
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
*
- * And Hey:
- * Gyas ROwers Mature At Cryogenic Speed
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
-#include "string2.h"
-#include "smalloc.h"
+
#include "fgrid.h"
-#include "futil.h"
+
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/utility/smalloc.h"
static const char *type[] = {
"button", "radiobuttons", "groupbox", "checkbox",
static void ReadAccOpen(const char *infile, FILE *in)
{
char buf[STRLEN];
+ int result;
- fscanf(in, "%4s", buf);
- if (strcmp(buf, "{") != 0)
+ result = fscanf(in, "%4s", buf);
+ if ((1 != result) || strcmp(buf, "{") != 0)
{
ReadDlgErr(infile, eACCOEXP, buf);
}
static void ReadAccClose(const char *infile, FILE *in)
{
char buf[STRLEN];
+ int result;
- fscanf(in, "%4s", buf);
- if (strcmp(buf, "}") != 0)
+ result = fscanf(in, "%4s", buf);
+ if ((1 != result) || strcmp(buf, "}") != 0)
{
ReadDlgErr(infile, eACCCEXP, buf);
}
static void AddFItemName(t_fitem *fitem, char *name)
{
srenew(fitem->name, ++fitem->nname);
- fitem->name[fitem->nname-1] = strdup(name);
+ fitem->name[fitem->nname-1] = gmx_strdup(name);
}
static t_fgroup *NewFGroup(void)
static t_fitem *ScanFItem(const char *infile, FILE *in, char *buf)
{
char set[STRLEN], get[STRLEN], help[STRLEN], def[STRLEN];
- edlgitem edlg;
+ int edlg;
t_fitem *fitem;
fitem = NewFItem();
- for (edlg = (edlgitem)0; (edlg < edlgNR+1); edlg = (edlgitem)(edlg + 1))
+ for (edlg = 0; (edlg < edlgNR+1); edlg++)
{
if (strcmp(buf, type[edlg]) == 0)
{
ReadDlgErr(infile, eITEMEXP, buf);
}
- fitem->edlg = edlg;
+ fitem->edlg = (edlgitem)edlg;
switch (edlg)
{
case edlgBN:
ReadQuoteString(infile, in, get);
ReadQuoteString(infile, in, def);
ReadQuoteString(infile, in, help);
- fitem->set = strdup(set);
- fitem->get = strdup(get);
- fitem->def = strdup(def);
- fitem->help = strdup(help);
+ fitem->set = gmx_strdup(set);
+ fitem->get = gmx_strdup(get);
+ fitem->def = gmx_strdup(def);
+ fitem->help = gmx_strdup(help);
return fitem;
}
{
FILE *in;
char buf[STRLEN];
+ int result;
t_fgrid *fgrid;
t_fgroup *fgroup;
t_fsimple *fsimple;
int gridx, gridy;
- in = libopen(infile);
- fscanf(in, "%6s", buf);
- if (strcmp(buf, "grid") != 0)
+ in = libopen(infile);
+ result = fscanf(in, "%6s", buf);
+ if ((1 != result) || strcmp(buf, "grid") != 0)
{
ReadDlgErr(infile, eGRIDEXP, buf);
}
fgrid->w = gridx;
fgrid->h = gridy;
ReadAccOpen(infile, in);
- fscanf(in, "%15s", buf);
- while (bNotAccClose(buf))
+ result = fscanf(in, "%15s", buf);
+ while ((1 == result) && bNotAccClose(buf))
{
if (strcmp(buf, "group") == 0)
{
fgroup = AddFGridFGroup(fgrid);
ReadQuoteString(infile, in, buf);
- fgroup->name = strdup(buf);
+ fgroup->name = gmx_strdup(buf);
if ((fscanf(in, "%5d%5d%5d%5d", &fgroup->x, &fgroup->y, &fgroup->w, &fgroup->h)) != 4)
{
ReadDlgErr(infile, eNOVALS, "group x,y,w,h");
ReadDlgErr(infile, eTOOHIGH, buf);
}
ReadAccOpen(infile, in);
- fscanf(in, "%15s", buf);
- while (bNotAccClose(buf))
+ result = fscanf(in, "%15s", buf);
+ while ((1 == result) && bNotAccClose(buf))
{
AddFGroupFItem(fgroup, ScanFItem(infile, in, buf));
- fscanf(in, "%15s", buf);
+ result = fscanf(in, "%15s", buf);
}
}
else if (strcmp(buf, "simple") == 0)
ReadDlgErr(infile, eTOOHIGH, "simple");
}
ReadAccOpen(infile, in);
- fscanf(in, "%15s", buf);
- fsimple->fitem = ScanFItem(infile, in, buf);
- ReadAccClose(infile, in);
+ result = fscanf(in, "%15s", buf);
+ if (1 == result)
+ {
+ fsimple->fitem = ScanFItem(infile, in, buf);
+ ReadAccClose(infile, in);
+ }
}
- fscanf(in, "%15s", buf);
+ if (1 == result)
+ {
+ result = fscanf(in, "%15s", buf);
+ }
+ }
+ gmx_ffclose(in);
+ /* Since we always read one variable at a time the result from
+ * fscanf should always be 1.
+ */
+ if (1 != result)
+ {
+ ReadDlgErr(infile, eNOVALS, "fgrid");
}
- ffclose(in);
return fgrid;
}