You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
#include <config.h>
#include "var.h"
#include "misc.h"
#include "str.h"
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
/* Parses a name as a variable within VS and returns the
variable's index if successful. On failure emits an error
message and returns a null pointer. */
{
int i;
- included = xcalloc (var_set_get_cnt (vs));
+ included = xcalloc (var_set_get_cnt (vs), sizeof *included);
for (i = 0; i < *nv; i++)
included[(*v)[i]->index] = 1;
}
int d1, d2;
int n;
int nvar, mvar;
- char *name1, *name2;
- char *root1, *root2;
+ char name1[LONG_NAME_LEN + 1], name2[LONG_NAME_LEN + 1];
+ char root1[LONG_NAME_LEN + 1], root2[LONG_NAME_LEN + 1];
int success = 0;
assert (names != NULL);
*names = NULL;
}
- name1 = xmalloc (36);
- name2 = &name1[1 * 9];
- root1 = &name1[2 * 9];
- root2 = &name1[3 * 9];
do
{
if (token != T_ID)
|| !extract_num (name2, root2, &n2, &d2))
goto fail;
- if (strcmp (root1, root2))
+ if (strcasecmp (root1, root2))
{
msg (SE, _("Prefixes don't match in use of TO convention."));
goto fail;
for (n = n1; n <= n2; n++)
{
- (*names)[nvar] = xmalloc (9);
- sprintf ((*names)[nvar], "%s%0*d", root1, d1, n);
+ char name[LONG_NAME_LEN + 1];
+ sprintf (name, "%s%0*d", root1, d1, n);
+ (*names)[nvar] = xstrdup (name);
nvar++;
}
}
fail:
*nnames = nvar;
- free (name1);
if (!success)
{
int i;
{
assert (vs != NULL);
assert (name != NULL);
- assert (strlen (name) < 9);
+ assert (strlen (name) <= LONG_NAME_LEN );
return vs->lookup_var_idx (vs, name);
}