projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Start work on testing and debugging AGGREGATE.
[pspp-builds.git]
/
src
/
file-type.c
diff --git
a/src/file-type.c
b/src/file-type.c
index 2b11a4abd21ce4deb551a893ad6d2e1a6c7efb41..cf0a3725673c2495ce7a6831a99f91ae847085aa 100644
(file)
--- a/
src/file-type.c
+++ b/
src/file-type.c
@@
-18,12
+18,14
@@
02111-1307, USA. */
#include <config.h>
02111-1307, USA. */
#include <config.h>
-#include "error.h"
#include <stdlib.h>
#include "alloc.h"
#include <stdlib.h>
#include "alloc.h"
+#include "case.h"
#include "command.h"
#include "data-in.h"
#include "command.h"
#include "data-in.h"
-#include "dfm.h"
+#include "dfm-read.h"
+#include "dictionary.h"
+#include "error.h"
#include "file-handle.h"
#include "format.h"
#include "lexer.h"
#include "file-handle.h"
#include "format.h"
#include "lexer.h"
@@
-74,7
+76,7
@@
struct record_type
struct file_type_pgm
{
int type; /* One of the FTY_* constants. */
struct file_type_pgm
{
int type; /* One of the FTY_* constants. */
- struct
file_handle *handle; /* File handle of input file
. */
+ struct
dfm_reader *reader; /* Data file to read
. */
struct col_spec record; /* RECORD subcommand. */
struct col_spec case_sbc; /* CASE subcommand. */
int wild; /* 0=NOWARN, 1=WARN. */
struct col_spec record; /* RECORD subcommand. */
struct col_spec case_sbc; /* CASE subcommand. */
int wild; /* 0=NOWARN, 1=WARN. */
@@
-96,13
+98,14
@@
static void create_col_var (struct col_spec *c);
int
cmd_file_type (void)
{
int
cmd_file_type (void)
{
- static struct file_type_pgm *fty;
+ static struct file_type_pgm *fty; /* FIXME: static? WTF? */
+ struct file_handle *fh = NULL;
/* Initialize. */
discard_variables ();
fty = xmalloc (sizeof *fty);
/* Initialize. */
discard_variables ();
fty = xmalloc (sizeof *fty);
- fty->
handle = inline_file
;
+ fty->
reader = NULL
;
fty->record.name[0] = 0;
fty->case_sbc.name[0] = 0;
fty->wild = fty->duplicate = fty->missing = fty->ordered = 0;
fty->record.name[0] = 0;
fty->case_sbc.name[0] = 0;
fty->wild = fty->duplicate = fty->missing = fty->ordered = 0;
@@
-132,8
+135,8
@@
cmd_file_type (void)
if (lex_match_id ("FILE"))
{
lex_match ('=');
if (lex_match_id ("FILE"))
{
lex_match ('=');
- f
ty->handle = fh_parse_file_handl
e ();
- if (
!fty->handle
)
+ f
h = fh_pars
e ();
+ if (
fh == NULL
)
goto error;
}
else if (lex_match_id ("RECORD"))
goto error;
}
else if (lex_match_id ("RECORD"))
@@
-269,9
+272,10
@@
cmd_file_type (void)
}
}
}
}
- if (!dfm_open_for_reading (fty->handle))
+ fty->reader = dfm_open_reader (fh);
+ if (fty->reader == NULL)
goto error;
goto error;
- default_handle = f
ty->handle
;
+ default_handle = f
h
;
create_col_var (&fty->record);
if (fty->case_sbc.name[0])
create_col_var (&fty->record);
if (fty->case_sbc.name[0])
@@
-369,7
+373,7
@@
parse_col_spec (struct col_spec *c, const char *def_name)
spec.type = c->fmt;
spec.w = c->nc;
spec.d = 0;
spec.type = c->fmt;
spec.w = c->nc;
spec.d = 0;
- return check_input_specifier (&spec);
+ return check_input_specifier (&spec
, 1
);
}
\f
/* RECORD TYPE. */
}
\f
/* RECORD TYPE. */
@@
-431,7
+435,7
@@
cmd_record_type (void)
{
int mv = 0;
{
int mv = 0;
- while (
token == T_NUM
|| token == T_STRING)
+ while (
lex_is_number ()
|| token == T_STRING)
{
if (rct->nv >= mv)
{
{
if (rct->nv >= mv)
{
@@
-625,25
+629,25
@@
file_type_source_read (struct case_source *source,
struct file_type_pgm *fty = source->aux;
struct fmt_spec format;
struct file_type_pgm *fty = source->aux;
struct fmt_spec format;
- dfm_push (fty->
handle
);
+ dfm_push (fty->
reader
);
format.type = fty->record.fmt;
format.w = fty->record.nc;
format.d = 0;
format.type = fty->record.fmt;
format.w = fty->record.nc;
format.d = 0;
- while (!dfm_eof (fty->
handle
))
+ while (!dfm_eof (fty->
reader
))
{
{
- struct
len
_string line;
+ struct
fixed
_string line;
struct record_type *iter;
union value v;
int i;
struct record_type *iter;
union value v;
int i;
- dfm_expand_tabs (fty->
handle
);
- dfm_get_record (fty->
handle
, &line);
+ dfm_expand_tabs (fty->
reader
);
+ dfm_get_record (fty->
reader
, &line);
if (formats[fty->record.fmt].cat & FCAT_STRING)
{
struct data_in di;
if (formats[fty->record.fmt].cat & FCAT_STRING)
{
struct data_in di;
- v.c = c
->data[fty->record.v->fv].
s;
+ v.c = c
ase_data_rw (c, fty->record.v->fv)->
s;
data_in_finite_line (&di, ls_c_str (&line), ls_length (&line),
fty->record.fc, fty->record.fc + fty->record.nc);
data_in_finite_line (&di, ls_c_str (&line), ls_length (&line),
fty->record.fc, fty->record.fc + fty->record.nc);
@@
-676,7
+680,7
@@
file_type_source_read (struct case_source *source,
di.format = format;
data_in (&di);
di.format = format;
data_in (&di);
-
memcpy (&c->data[fty->record.v->fv].f, &v.f, sizeof v.f)
;
+
case_data_rw (c, fty->record.v->fv)->f = v.f
;
for (iter = fty->recs_head; iter; iter = iter->next)
{
if (iter->flags & RCT_OTHER)
for (iter = fty->recs_head; iter; iter = iter->next)
{
if (iter->flags & RCT_OTHER)
@@
-688,13
+692,13
@@
file_type_source_read (struct case_source *source,
if (fty->wild)
msg (SW, _("Unknown record type %g."), v.f);
}
if (fty->wild)
msg (SW, _("Unknown record type %g."), v.f);
}
- dfm_forward_record (fty->
handle
);
+ dfm_forward_record (fty->
reader
);
continue;
found:
/* Arrive here if there is a matching record_type, which is in
iter. */
continue;
found:
/* Arrive here if there is a matching record_type, which is in
iter. */
- dfm_forward_record (fty->
handle
);
+ dfm_forward_record (fty->
reader
);
}
/* switch(fty->type)
}
/* switch(fty->type)
@@
-705,7
+709,7
@@
file_type_source_read (struct case_source *source,
default: assert(0);
} */
default: assert(0);
} */
- dfm_pop (fty->
handle
);
+ dfm_pop (fty->
reader
);
}
static void
}
static void
@@
-715,6
+719,7
@@
file_type_source_destroy (struct case_source *source)
struct record_type *iter, *next;
cancel_transformations ();
struct record_type *iter, *next;
cancel_transformations ();
+ dfm_close_reader (fty->reader);
for (iter = fty->recs_head; iter; iter = next)
{
next = iter->next;
for (iter = fty->recs_head; iter; iter = next)
{
next = iter->next;