lexer: New function lex_ofs_representation().
[pspp] / src / language / utilities / cd.c
index 90a1bcf8db6a8ca71ac63167a8d898207ec4cb70..ec5e7646f4ee1bba3fb610d9aa7f45fc7ba1d43c 100644 (file)
 
 #include <config.h>
 
+#include "language/command.h"
+
 #include <errno.h>
 #include <unistd.h>
 
-#include "language/command.h"
-#include "libpspp/message.h"
 #include "language/lexer/lexer.h"
+#include "libpspp/i18n.h"
+#include "libpspp/message.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -32,20 +34,21 @@ cmd_cd (struct lexer *lexer, struct dataset *ds UNUSED)
 {
   char  *path = 0;
 
-  if ( ! lex_force_string (lexer))
+  if (! lex_force_string (lexer))
     goto error;
 
-  path = ss_xstrdup (lex_tokss (lexer));
+  path = utf8_to_filename (lex_tokcstr (lexer));
 
-  if ( -1 == chdir (path) )
+  if (-1 == chdir (path))
     {
       int err = errno;
-      msg (SE, _("Cannot change directory to %s:  %s "), path,
+      msg (SE, _("Cannot change directory to %s: %s"), path,
           strerror (err));
       goto error;
     }
 
   free (path);
+  lex_get (lexer);
 
   return CMD_SUCCESS;