#include "libpspp/cast.h"
#include "libpspp/hash-functions.h"
#include "libpspp/hmap.h"
+#include "libpspp/i18n.h"
#include "libpspp/message.h"
#include "libpspp/str.h"
+#include "libpspp/misc.h"
#include "gl/ftoastr.h"
#include "gl/minmax.h"
#include "gl/xalloc.h"
+#include "gl/xmemdup0.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
{
struct hmap_node hmap_node;
char *name;
+ size_t name_len;
char **values;
size_t n_values;
};
static unsigned int
hash_dummy (const char *name, size_t name_len)
{
- return hash_case_bytes (name, name_len, 0);
+ return utf8_hash_case_bytes (name, name_len, 0);
}
static const struct dummy_var *
HMAP_FOR_EACH_WITH_HASH (dv, struct dummy_var, hmap_node,
hash_dummy (name, name_len), hmap)
- if (strcasecmp (dv->name, name))
+ if (!utf8_strncasecmp (dv->name, dv->name_len, name, name_len))
return dv;
return NULL;
if (dict_lookup_var (dict, name))
msg (SW, _("Dummy variable name `%s' hides dictionary variable `%s'."),
name, name);
- if (find_dummy_var (dummies, name, strlen (name)))
+
+ size_t name_len = strlen (name);
+ if (find_dummy_var (dummies, name, name_len))
{
msg (SE, _("Dummy variable name `%s' is given twice."), name);
goto error;
/* Make a new macro. */
dv = xmalloc (sizeof *dv);
- dv->name = xstrdup (name);
+ dv->name = xmemdup0 (name, name_len);
+ dv->name_len = name_len;
dv->values = NULL;
dv->n_values = 0;
hmap_insert (dummies, &dv->hmap_node, hash_dummy (name, strlen (name)));
enum segment_type type;
int n;
- n = segmenter_push (&segmenter, s.string, s.length, &type);
+ n = segmenter_push (&segmenter, s.string, s.length, true, &type);
assert (n >= 0);
if (type == SEG_DO_REPEAT_COMMAND)
int k;
k = segmenter_push (&segmenter, s.string + n, s.length - n,
- &type);
+ true, &type);
if (type != SEG_NEWLINE && type != SEG_DO_REPEAT_COMMAND)
break;
ds_put_byte (&input, '\n');
lex_get (lexer);
}
- if (ds_is_empty (&input))
- ds_put_byte (&input, '\n');
- ds_put_byte (&input, '\0');
n_values = count_values (dummies);
outputs = xmalloc (n_values * sizeof *outputs);
for (i = 0; i < n_values; i++)
{
struct string *output = &outputs[n_values - i - 1];
- struct lex_reader *reader;
-
- reader = lex_reader_for_substring_nocopy (ds_ss (output));
+ const char *encoding = lex_get_encoding (lexer);
+ struct lex_reader *reader = lex_reader_for_substring_nocopy (ds_ss (output), encoding);
lex_reader_set_file_name (reader, file_name);
reader->line_number = line_number;
lex_include (lexer, reader);
{
char s[DBL_BUFSIZE_BOUND];
- dtoastr (s, sizeof s, 0, 0, lex_number (lexer));
+ c_dtoastr (s, sizeof s, 0, 0, lex_number (lexer));
add_replacement (dv, xstrdup (s), &allocated);
lex_get (lexer);
}
int
cmd_end_repeat (struct lexer *lexer UNUSED, struct dataset *ds UNUSED)
{
- msg (SE, _("No matching DO REPEAT."));
+ msg (SE, _("No matching %s."), "DO REPEAT");
return CMD_CASCADING_FAILURE;
}