X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fvector.c;h=558db4e047b055aac0d356abdf27e3e667576b2b;hb=05a2c3f6e9560a57e87206ac3358946bf6d43b42;hp=e63ac2153f6166eef9d1dcc0694ab539ac9308bc;hpb=3a7fba81ceae5b049d0f7d671e9e3c3c43bbf703;p=pspp-builds.git diff --git a/src/vector.c b/src/vector.c index e63ac215..558db4e0 100644 --- a/src/vector.c +++ b/src/vector.c @@ -14,15 +14,15 @@ 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 +#include "error.h" #include #include "alloc.h" -#include "cases.h" #include "command.h" +#include "dictionary.h" #include "error.h" #include "lexer.h" #include "misc.h" @@ -44,8 +44,6 @@ cmd_vector (void) /* Maximum allocated position for vecnames, plus one position. */ char *endp = NULL; - lex_match_id ("VECTOR"); - cp = vecnames = xmalloc (256); endp = &vecnames[256]; do @@ -64,7 +62,7 @@ cmd_vector (void) } for (cp2 = cp; cp2 < cp; cp2 += strlen (cp)) - if (!strcmp (cp2, tokid)) + if (!strcasecmp (cp2, tokid)) { msg (SE, _("Vector name %s is given twice."), tokid); goto fail; @@ -94,8 +92,8 @@ cmd_vector (void) { /* There's more than one vector name. */ msg (SE, _("A slash must be used to separate each vector " - "specification when using the long form. Commands " - "such as VECTOR A,B=Q1 TO Q20 are not supported.")); + "specification when using the long form. Commands " + "such as VECTOR A,B=Q1 TO Q20 are not supported.")); goto fail; } @@ -115,7 +113,7 @@ cmd_vector (void) int ndig; /* Name of an individual variable to be created. */ - char name[9]; + char name[SHORT_NAME_LEN + 1]; /* Vector variables. */ struct variable **v; @@ -133,13 +131,13 @@ cmd_vector (void) if (!lex_force_match (')')) goto fail; - /* First check that all the generated variable names are 8 - characters or shorter. */ + /* First check that all the generated variable names + are LONG_NAME_LEN characters or shorter. */ ndig = intlog10 (nv); for (cp = vecnames; *cp;) { int len = strlen (cp); - if (len + ndig > 8) + if (len + ndig > LONG_NAME_LEN) { msg (SE, _("%s%d is too long for a variable name."), cp, nv); goto fail; @@ -155,7 +153,8 @@ cmd_vector (void) sprintf (name, "%s%d", cp, i + 1); if (dict_lookup_var (default_dict, name)) { - msg (SE, _("There is already a variable named %s."), name); + msg (SE, _("There is already a variable named %s."), + name); goto fail; } } @@ -169,9 +168,7 @@ cmd_vector (void) for (i = 0; i < nv; i++) { sprintf (name, "%s%d", cp, i + 1); - v[i] = dict_create_var (default_dict, name, 0); - assert (v[i] != NULL); - envector (v[i]); + v[i] = dict_create_var_assert (default_dict, name, 0); } if (!dict_create_vector (default_dict, cp, v, nv)) assert (0);