#include <libpspp/getl.h>
#include <libpspp/str.h>
#include <output/journal.h>
+#include <output/text-item.h>
#include "xalloc.h"
return;
}
- /* If a token was pushed ahead, return it. */
- if (lexer->put_token)
- {
- restore_token (lexer);
+ /* If a token was pushed ahead, return it. */
+ if (lexer->put_token)
+ {
+ restore_token (lexer);
#if DUMP_TOKENS
dump_token (lexer);
#endif
- return;
- }
+ return;
+ }
- for (;;)
- {
- /* Skip whitespace. */
+ for (;;)
+ {
+ /* Skip whitespace. */
while (c_isspace ((unsigned char) *lexer->prog))
lexer->prog++;
else
{
unsigned char c = *lexer->prog++;
- if (c_isgraph (c))
- msg (SE, _("Bad character in input: `%c'."), c);
- else
- msg (SE, _("Bad character in input: `\\%o'."), c);
+ char *c_name = xasprintf (c_isgraph (c) ? "%c" : "\\%o", c);
+ msg (SE, _("Bad character in input: `%s'."), c_name);
+ free (c_name);
continue;
}
}
}
}
-/* Reads a line, without performing any preprocessing.
- Sets *SYNTAX, if SYNTAX is non-null, to the line's syntax
- mode. */
+/* Reads a line, without performing any preprocessing. */
bool
lex_get_line_raw (struct lexer *lexer)
{
bool ok = getl_read_line (lexer->ss, &lexer->line_buffer);
- enum syntax_mode mode = lex_current_syntax_mode (lexer);
- journal_write (mode == GETL_BATCH, ds_cstr (&lexer->line_buffer));
-
+ if (ok)
+ {
+ const char *line = ds_cstr (&lexer->line_buffer);
+ text_item_submit (text_item_create (TEXT_ITEM_SYNTAX, line));
+ }
return ok;
}
if (type != CHARACTER_STRING)
convert_numeric_string_to_char_string (lexer, type);
- if (ds_length (&lexer->tokstr) > 255)
- {
- msg (SE, _("String exceeds 255 characters in length (%zu characters)."),
- ds_length (&lexer->tokstr));
- ds_truncate (&lexer->tokstr, 255);
- }
-
return T_STRING;
}
\f