projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lexer: Reimplement for better testability and internationalization.
[pspp-builds.git]
/
src
/
language
/
utilities
/
host.c
diff --git
a/src/language/utilities/host.c
b/src/language/utilities/host.c
index ae344367252bc053a1945480513c5f9ccc102395..fbc9d208be7a08a1b4c518894f0e317d1413be5b 100644
(file)
--- a/
src/language/utilities/host.c
+++ b/
src/language/utilities/host.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2009, 2010
, 2011
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
@@
-30,9
+30,11
@@
#include "language/lexer/lexer.h"
#include "libpspp/assertion.h"
#include "libpspp/compiler.h"
#include "language/lexer/lexer.h"
#include "libpspp/assertion.h"
#include "libpspp/compiler.h"
+#include "libpspp/i18n.h"
#include "libpspp/message.h"
#include "libpspp/str.h"
#include "libpspp/message.h"
#include "libpspp/str.h"
+#include "gl/localcharset.h"
#include "gl/xalloc.h"
#include "gl/xmalloca.h"
#include "gl/xalloc.h"
#include "gl/xmalloca.h"
@@
-129,35
+131,41
@@
cmd_host (struct lexer *lexer, struct dataset *ds UNUSED)
return CMD_FAILURE;
}
return CMD_FAILURE;
}
- if (lex_token (lexer) ==
'.'
)
+ if (lex_token (lexer) ==
T_ENDCMD
)
return shell () ? CMD_SUCCESS : CMD_FAILURE;
else if (lex_match_id (lexer, "COMMAND"))
{
struct string command;
return shell () ? CMD_SUCCESS : CMD_FAILURE;
else if (lex_match_id (lexer, "COMMAND"))
{
struct string command;
+ char *locale_command;
bool ok;
bool ok;
- lex_match (lexer,
'='
);
- if (!lex_force_match (lexer,
'['
))
+ lex_match (lexer,
T_EQUALS
);
+ if (!lex_force_match (lexer,
T_LBRACK
))
return CMD_FAILURE;
ds_init_empty (&command);
return CMD_FAILURE;
ds_init_empty (&command);
- while (lex_
token (lexer) == T_STRING
)
+ while (lex_
is_string (lexer)
)
{
if (!ds_is_empty (&command))
{
if (!ds_is_empty (&command))
- ds_put_
char
(&command, '\n');
- ds_put_substring (&command,
ds_ss (lex_tokstr (lexer)
));
+ ds_put_
byte
(&command, '\n');
+ ds_put_substring (&command,
lex_tokss (lexer
));
lex_get (lexer);
}
lex_get (lexer);
}
- if (!lex_force_match (lexer,
']'
))
+ if (!lex_force_match (lexer,
T_RBRACK
))
{
ds_destroy (&command);
return CMD_FAILURE;
}
{
ds_destroy (&command);
return CMD_FAILURE;
}
- ok = run_command (ds_cstr (&command));
+ locale_command = recode_string (locale_charset (), "UTF-8",
+ ds_cstr (&command),
+ ds_length (&command));
ds_destroy (&command);
ds_destroy (&command);
- return ok ? lex_end_of_command (lexer) : CMD_FAILURE;
+ ok = run_command (locale_command);
+ free (locale_command);
+
+ return ok ? CMD_SUCCESS : CMD_FAILURE;
}
else
{
}
else
{