#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
{
/* Limited variable column specifications. */
struct col_spec
{
- char name[SHORT_NAME_LEN + 1]; /* 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. */
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. */
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 ();
if (lex_match_id ("FILE"))
{
lex_match ('=');
- fh = fh_parse ();
+ fh = fh_parse (FH_REF_FILE | FH_REF_INLINE);
if (fh == NULL)
goto error;
}
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."));
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])
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)
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
{
\f
/* END FILE TYPE. */
+int cmd_end_file_type (void);
int
cmd_end_file_type (void)
{