projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
expressions: Make extract_min_valid() parameter const.
[pspp]
/
src
/
language
/
utilities
/
include.c
diff --git
a/src/language/utilities/include.c
b/src/language/utilities/include.c
index 26c718a42de419ada022a35cb07b199dc2fd7406..f152684d41f73c6ba2091262ab368f3da7526c50 100644
(file)
--- a/
src/language/utilities/include.c
+++ b/
src/language/utilities/include.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007
, 2010
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-15,19
+15,23
@@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
+
#include <ctype.h>
#include <ctype.h>
+#include <errno.h>
#include <stdlib.h>
#include <stdlib.h>
-#include <libpspp/alloc.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <data/file-name.h>
#include <language/command.h>
#include <language/command.h>
-#include <libpspp/message.h>
-#include <libpspp/getl.h>
-#include <language/syntax-file.h>
#include <language/lexer/lexer.h>
#include <language/lexer/lexer.h>
+#include <language/syntax-file.h>
+#include <libpspp/getl.h>
+#include <libpspp/message.h>
#include <libpspp/str.h>
#include <libpspp/str.h>
-#include <data/file-name.h>
-#include <dirname.h>
-#include <canonicalize.h>
+#include "dirname.h"
+#include "xalloc.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "gettext.h"
#define _(msgid) gettext (msgid)
@@
-76,25
+80,25
@@
cmd_insert (struct lexer *lexer, struct dataset *ds UNUSED)
lex_get (lexer);
lex_get (lexer);
- while (
'.'
!= lex_token (lexer))
+ while (
T_ENDCMD
!= lex_token (lexer))
{
if (lex_match_id (lexer, "SYNTAX"))
{
{
if (lex_match_id (lexer, "SYNTAX"))
{
- lex_match (lexer,
'='
);
+ lex_match (lexer,
T_EQUALS
);
if ( lex_match_id (lexer, "INTERACTIVE") )
syntax_mode = GETL_INTERACTIVE;
else if ( lex_match_id (lexer, "BATCH"))
syntax_mode = GETL_BATCH;
else
{
if ( lex_match_id (lexer, "INTERACTIVE") )
syntax_mode = GETL_INTERACTIVE;
else if ( lex_match_id (lexer, "BATCH"))
syntax_mode = GETL_BATCH;
else
{
- lex_error
(lexer
,
-
_("Expecting BATCH or INTERACTIVE after SYNTAX.")
);
+ lex_error
(lexer, _("expecting %s or %s after %s")
,
+
"BATCH", "INTERACTIVE", "SYNTAX"
);
return CMD_FAILURE;
}
}
else if (lex_match_id (lexer, "CD"))
{
return CMD_FAILURE;
}
}
else if (lex_match_id (lexer, "CD"))
{
- lex_match (lexer,
'='
);
+ lex_match (lexer,
T_EQUALS
);
if ( lex_match_id (lexer, "YES") )
{
cd = true;
if ( lex_match_id (lexer, "YES") )
{
cd = true;
@@
-105,13
+109,14
@@
cmd_insert (struct lexer *lexer, struct dataset *ds UNUSED)
}
else
{
}
else
{
- lex_error (lexer, _("Expecting YES or NO after CD."));
+ lex_error (lexer, _("expecting %s or %s after %s"),
+ "YES", "NO", "CD");
return CMD_FAILURE;
}
}
else if (lex_match_id (lexer, "ERROR"))
{
return CMD_FAILURE;
}
}
else if (lex_match_id (lexer, "ERROR"))
{
- lex_match (lexer,
'='
);
+ lex_match (lexer,
T_EQUALS
);
if ( lex_match_id (lexer, "CONTINUE") )
{
error_mode = ERRMODE_CONTINUE;
if ( lex_match_id (lexer, "CONTINUE") )
{
error_mode = ERRMODE_CONTINUE;
@@
-122,7
+127,8
@@
cmd_insert (struct lexer *lexer, struct dataset *ds UNUSED)
}
else
{
}
else
{
- lex_error (lexer, _("Expecting CONTINUE or STOP after ERROR."));
+ lex_error (lexer, _("expecting %s or %s after %s"),
+ "CONTINUE", "STOP", "ERROR");
return CMD_FAILURE;
}
}
return CMD_FAILURE;
}
}
@@
-164,21
+170,21
@@
cmd_insert (struct lexer *lexer, struct dataset *ds UNUSED)
static int
parse_insert (struct lexer *lexer, char **filename)
{
static int
parse_insert (struct lexer *lexer, char **filename)
{
- char *target_fn;
+ c
onst c
har *target_fn;
char *relative_filename;
/* Skip optional FILE=. */
if (lex_match_id (lexer, "FILE"))
char *relative_filename;
/* Skip optional FILE=. */
if (lex_match_id (lexer, "FILE"))
- lex_match (lexer,
'='
);
+ lex_match (lexer,
T_EQUALS
);
/* File name can be identifier or string. */
/* File name can be identifier or string. */
- if (lex_token (lexer) != T_ID &&
lex_token (lexer) != T_STRING
)
+ if (lex_token (lexer) != T_ID &&
!lex_is_string (lexer)
)
{
lex_error (lexer, _("expecting file name"));
return CMD_FAILURE;
}
{
lex_error (lexer, _("expecting file name"));
return CMD_FAILURE;
}
- target_fn =
ds_cstr (lex_tokstr (lexer)
);
+ target_fn =
lex_tokcstr (lexer
);
relative_filename =
fn_search_path (target_fn,
relative_filename =
fn_search_path (target_fn,
@@
-191,8
+197,14
@@
parse_insert (struct lexer *lexer, char **filename)
return CMD_FAILURE;
}
return CMD_FAILURE;
}
- *filename = canonicalize_file_name (relative_filename);
- free (relative_filename);
+ *filename = relative_filename;
+ if (*filename == NULL)
+ {
+ msg (SE, _("Unable to open `%s': %s."),
+ relative_filename, strerror (errno));
+ free (relative_filename);
+ return CMD_FAILURE;
+ }
return CMD_SUCCESS;
}
return CMD_SUCCESS;
}