projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
First step in making struct variable opaque: the boring mechanical
[pspp-builds.git]
/
src
/
language
/
data-io
/
inpt-pgm.c
diff --git
a/src/language/data-io/inpt-pgm.c
b/src/language/data-io/inpt-pgm.c
index f07e119a40808859f376d1f65d5157dbccdceed4..24a2e22968f1eccc0a3a23f9f0275f898470c228 100644
(file)
--- a/
src/language/data-io/inpt-pgm.c
+++ b/
src/language/data-io/inpt-pgm.c
@@
-103,15
+103,15
@@
emit_END_CASE (struct dataset *ds, struct input_program_pgm *inp)
}
int
}
int
-cmd_input_program (struct dataset *ds)
+cmd_input_program (struct
lexer *lexer, struct
dataset *ds)
{
struct input_program_pgm *inp;
size_t i;
bool saw_END_CASE = false;
discard_variables (ds);
{
struct input_program_pgm *inp;
size_t i;
bool saw_END_CASE = false;
discard_variables (ds);
- if (
token
!= '.')
- return lex_end_of_command ();
+ if (
lex_token (lexer)
!= '.')
+ return lex_end_of_command (
lexer
);
inp = xmalloc (sizeof *inp);
inp->trns_chain = NULL;
inp = xmalloc (sizeof *inp);
inp->trns_chain = NULL;
@@
-120,7
+120,7
@@
cmd_input_program (struct dataset *ds)
inside_input_program = true;
for (;;)
{
inside_input_program = true;
for (;;)
{
- enum cmd_result result = cmd_parse (ds, CMD_STATE_INPUT_PROGRAM);
+ enum cmd_result result = cmd_parse (
lexer,
ds, CMD_STATE_INPUT_PROGRAM);
if (result == CMD_END_INPUT_PROGRAM)
break;
else if (result == CMD_END_CASE)
if (result == CMD_END_INPUT_PROGRAM)
break;
else if (result == CMD_END_CASE)
@@
-161,13
+161,14
@@
cmd_input_program (struct dataset *ds)
for (i = 0; i < dict_get_var_cnt (dataset_dict (ds)); i++)
{
struct variable *var = dict_get_var (dataset_dict (ds), i);
for (i = 0; i < dict_get_var_cnt (dataset_dict (ds)); i++)
{
struct variable *var = dict_get_var (dataset_dict (ds), i);
+ size_t value_cnt = var_get_value_cnt (var);
enum value_init_type value_init;
size_t j;
enum value_init_type value_init;
size_t j;
- value_init = var
->type == NUMERIC
? INP_NUMERIC : INP_STRING;
- value_init |= var
->leave
? INP_INIT_ONCE : INP_REINIT;
+ value_init = var
_is_numeric (var)
? INP_NUMERIC : INP_STRING;
+ value_init |= var
_get_leave (var)
? INP_INIT_ONCE : INP_REINIT;
- for (j = 0; j < va
r->nv
; j++)
+ for (j = 0; j < va
lue_cnt
; j++)
inp->init[j + var->fv] = value_init;
}
for (i = 0; i < inp->init_cnt; i++)
inp->init[j + var->fv] = value_init;
}
for (i = 0; i < inp->init_cnt; i++)
@@
-181,7
+182,7
@@
cmd_input_program (struct dataset *ds)
}
int
}
int
-cmd_end_input_program (struct dataset *ds UNUSED)
+cmd_end_input_program (struct
lexer *lexer UNUSED, struct
dataset *ds UNUSED)
{
assert (in_input_program ());
return CMD_END_INPUT_PROGRAM;
{
assert (in_input_program ());
return CMD_END_INPUT_PROGRAM;
@@
-288,12
+289,12
@@
static const struct case_source_class input_program_source_class =
};
\f
int
};
\f
int
-cmd_end_case (struct dataset *ds UNUSED)
+cmd_end_case (struct
lexer *lexer, struct
dataset *ds UNUSED)
{
assert (in_input_program ());
{
assert (in_input_program ());
- if (
token
== '.')
+ if (
lex_token (lexer)
== '.')
return CMD_END_CASE;
return CMD_END_CASE;
- return lex_end_of_command ();
+ return lex_end_of_command (
lexer
);
}
/* Sends the current case as the source's output. */
}
/* Sends the current case as the source's output. */
@@
-319,7
+320,7
@@
struct reread_trns
/* Parses REREAD command. */
int
/* Parses REREAD command. */
int
-cmd_reread (struct dataset *ds)
+cmd_reread (struct
lexer *lexer, struct
dataset *ds)
{
struct file_handle *fh; /* File to be re-read. */
struct expression *e; /* Expression for column to set. */
{
struct file_handle *fh; /* File to be re-read. */
struct expression *e; /* Expression for column to set. */
@@
-327,11
+328,11
@@
cmd_reread (struct dataset *ds)
fh = fh_get_default_handle ();
e = NULL;
fh = fh_get_default_handle ();
e = NULL;
- while (
token
!= '.')
+ while (
lex_token (lexer)
!= '.')
{
{
- if (lex_match_id ("COLUMN"))
+ if (lex_match_id (
lexer,
"COLUMN"))
{
{
- lex_match ('=');
+ lex_match (
lexer,
'=');
if (e)
{
if (e)
{
@@
-340,14
+341,14
@@
cmd_reread (struct dataset *ds)
return CMD_CASCADING_FAILURE;
}
return CMD_CASCADING_FAILURE;
}
- e = expr_parse (ds, EXPR_NUMBER);
+ e = expr_parse (
lexer,
ds, EXPR_NUMBER);
if (!e)
return CMD_CASCADING_FAILURE;
}
if (!e)
return CMD_CASCADING_FAILURE;
}
- else if (lex_match_id ("FILE"))
+ else if (lex_match_id (
lexer,
"FILE"))
{
{
- lex_match ('=');
- fh = fh_parse (FH_REF_FILE | FH_REF_INLINE);
+ lex_match (
lexer,
'=');
+ fh = fh_parse (
lexer,
FH_REF_FILE | FH_REF_INLINE);
if (fh == NULL)
{
expr_free (e);
if (fh == NULL)
{
expr_free (e);
@@
-356,13
+357,14
@@
cmd_reread (struct dataset *ds)
}
else
{
}
else
{
- lex_error (NULL);
+ lex_error (
lexer,
NULL);
expr_free (e);
expr_free (e);
+ return CMD_CASCADING_FAILURE;
}
}
t = xmalloc (sizeof *t);
}
}
t = xmalloc (sizeof *t);
- t->reader = dfm_open_reader (fh);
+ t->reader = dfm_open_reader (fh
, lexer
);
t->column = e;
add_transformation (ds, reread_trns_proc, reread_trns_free, t);
t->column = e;
add_transformation (ds, reread_trns_proc, reread_trns_free, t);
@@
-405,13
+407,13
@@
reread_trns_free (void *t_)
/* Parses END FILE command. */
int
/* Parses END FILE command. */
int
-cmd_end_file (struct dataset *ds)
+cmd_end_file (struct
lexer *lexer, struct
dataset *ds)
{
assert (in_input_program ());
add_transformation (ds, end_file_trns_proc, NULL, NULL);
{
assert (in_input_program ());
add_transformation (ds, end_file_trns_proc, NULL, NULL);
- return lex_end_of_command ();
+ return lex_end_of_command (
lexer
);
}
/* Executes an END FILE transformation. */
}
/* Executes an END FILE transformation. */