X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffile-type.c;h=4c7c4a03075931aaa0bcf25f7b2e0b4e88f8cf15;hb=92fb12eb06716d14c05b781f5d9dcde956d77c30;hp=fee9ee5abd473f20348d184a9f49a9d161b38ef4;hpb=b321086267ad1014dc5d09886396cde30f094437;p=pspp diff --git a/src/file-type.c b/src/file-type.c index fee9ee5abd..4c7c4a0307 100644 --- a/src/file-type.c +++ b/src/file-type.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 @@ -33,6 +33,9 @@ #include "var.h" #include "vfm.h" +#include "gettext.h" +#define _(msgid) gettext (msgid) + /* Defines the three types of complex files read by FILE TYPE. */ enum { @@ -44,7 +47,7 @@ enum /* Limited variable column specifications. */ struct col_spec { - char name[9]; /* Variable name. */ + char name[LONG_NAME_LEN + 1]; /* Variable name. */ int fc, nc; /* First column (1-based), # of columns. */ int fmt; /* Format type. */ struct variable *v; /* Variable. */ @@ -71,8 +74,7 @@ struct record_type int ft, lt; /* First, last transformation index. */ }; /* record_type */ -/* Represents a FILE TYPE input program. Does not contain a - trns_header because it's never submitted as a transformation. */ +/* Represents a FILE TYPE input program. */ struct file_type_pgm { int type; /* One of the FTY_* constants. */ @@ -94,12 +96,14 @@ struct file_type_pgm static int parse_col_spec (struct col_spec *, const char *); static void create_col_var (struct col_spec *c); +int cmd_file_type (void); + /* Parses FILE TYPE command. */ int cmd_file_type (void) { static struct file_type_pgm *fty; /* FIXME: static? WTF? */ - struct file_handle *fh = NULL; + struct file_handle *fh = fh_inline_file (); /* Initialize. */ discard_variables (); @@ -135,7 +139,7 @@ cmd_file_type (void) if (lex_match_id ("FILE")) { lex_match ('='); - fh = fh_parse (); + fh = fh_parse (FH_REF_FILE | FH_REF_INLINE); if (fh == NULL) goto error; } @@ -264,7 +268,7 @@ cmd_file_type (void) goto error; } - if (!strcmp (fty->case_sbc.name, fty->record.name)) + if (!strcasecmp (fty->case_sbc.name, fty->record.name)) { msg (SE, _("CASE and RECORD must specify different variable " "names.")); @@ -275,12 +279,12 @@ cmd_file_type (void) fty->reader = dfm_open_reader (fh); if (fty->reader == NULL) goto error; - default_handle = fh; + fh_set_default_handle (fh); create_col_var (&fty->record); if (fty->case_sbc.name[0]) create_col_var (&fty->case_sbc); - vfm_source = create_case_source (&file_type_source_class, default_dict, fty); + vfm_source = create_case_source (&file_type_source_class, fty); return CMD_SUCCESS; @@ -373,7 +377,7 @@ parse_col_spec (struct col_spec *c, const char *def_name) spec.type = c->fmt; spec.w = c->nc; spec.d = 0; - return check_input_specifier (&spec); + return check_input_specifier (&spec, 1); } /* RECORD TYPE. */ @@ -435,12 +439,12 @@ cmd_record_type (void) { int mv = 0; - while (token == T_NUM || token == T_STRING) + while (lex_is_number () || token == T_STRING) { if (rct->nv >= mv) { mv += 16; - rct->v = xrealloc (rct->v, mv * sizeof *rct->v); + rct->v = xnrealloc (rct->v, mv, sizeof *rct->v); } if (formats[fty->record.fmt].cat & FCAT_STRING) @@ -448,8 +452,8 @@ cmd_record_type (void) if (!lex_force_string ()) goto error; rct->v[rct->nv].c = xmalloc (fty->record.nc + 1); - st_bare_pad_copy (rct->v[rct->nv].c, ds_c_str (&tokstr), - fty->record.nc + 1); + buf_copy_str_rpad (rct->v[rct->nv].c, fty->record.nc + 1, + ds_c_str (&tokstr)); } else { @@ -569,6 +573,7 @@ cmd_record_type (void) /* END FILE TYPE. */ +int cmd_end_file_type (void); int cmd_end_file_type (void) { @@ -636,7 +641,7 @@ file_type_source_read (struct case_source *source, format.d = 0; while (!dfm_eof (fty->reader)) { - struct len_string line; + struct fixed_string line; struct record_type *iter; union value v; int i;