X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvars-prs.c;h=7a6e8633c46eee3cefccca4b296443b546daf4d3;hb=4611b8e15a8286d4039ce64b59e5a891af549238;hp=9a559d2e0ca016f3bd894a9e4014c808dc986b9e;hpb=ae692b0ac5ceff417fa9e9fc136d95acae3e99e1;p=pspp diff --git a/src/vars-prs.c b/src/vars-prs.c index 9a559d2e0c..7a6e8633c4 100644 --- a/src/vars-prs.c +++ b/src/vars-prs.c @@ -14,8 +14,8 @@ 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 #include "var.h" @@ -30,6 +30,9 @@ #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. */ @@ -259,7 +262,7 @@ parse_var_set_vars (const struct var_set *vs, { 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; } @@ -391,8 +394,8 @@ parse_DATA_LIST_vars (char ***names, int *nnames, int pv_opts) 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); @@ -409,10 +412,6 @@ parse_DATA_LIST_vars (char ***names, int *nnames, int pv_opts) *names = NULL; } - name1 = xmalloc (36); - name2 = &name1[1 * 9]; - root1 = &name1[2 * 9]; - root2 = &name1[3 * 9]; do { if (token != T_ID) @@ -443,7 +442,7 @@ parse_DATA_LIST_vars (char ***names, int *nnames, int pv_opts) || !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; @@ -464,8 +463,9 @@ parse_DATA_LIST_vars (char ***names, int *nnames, int pv_opts) 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++; } } @@ -489,7 +489,6 @@ parse_DATA_LIST_vars (char ***names, int *nnames, int pv_opts) fail: *nnames = nvar; - free (name1); if (!success) { int i; @@ -594,7 +593,7 @@ var_set_lookup_var_idx (const struct var_set *vs, const char *name) { assert (vs != NULL); assert (name != NULL); - assert (strlen (name) < 9); + assert (strlen (name) <= LONG_NAME_LEN ); return vs->lookup_var_idx (vs, name); }