Fix typos in comments
[pspp] / src / language / lexer / lexer.c
index 2bcb18c32854748d206d1c87909bddb27b5b8a9e..9c402e679a949837720ce3f2589b0306b44b05cb 100644 (file)
@@ -272,7 +272,7 @@ lex_next_error (struct lexer *lexer, int n0, int n1, const char *format, ...)
 /* Prints a syntax error message saying that OPTION0 or one of the other
    strings following it, up to the first NULL, is expected. */
 void
-lex_error_expecting (struct lexer *lexer, const char *option0, ...)
+(lex_error_expecting) (struct lexer *lexer, const char *option0, ...)
 {
   enum { MAX_OPTIONS = 8 };
   const char *options[MAX_OPTIONS + 1];
@@ -428,14 +428,14 @@ lex_end_of_command (struct lexer *lexer)
 
 /* Returns true if the current token is a number. */
 bool
-lex_is_number (struct lexer *lexer)
+lex_is_number (const struct lexer *lexer)
 {
   return lex_next_is_number (lexer, 0);
 }
 
 /* Returns true if the current token is a string. */
 bool
-lex_is_string (struct lexer *lexer)
+lex_is_string (const struct lexer *lexer)
 {
   return lex_next_is_string (lexer, 0);
 }
@@ -443,14 +443,14 @@ lex_is_string (struct lexer *lexer)
 /* Returns the value of the current token, which must be a
    floating point number. */
 double
-lex_number (struct lexer *lexer)
+lex_number (const struct lexer *lexer)
 {
   return lex_next_number (lexer, 0);
 }
 
 /* Returns true iff the current token is an integer. */
 bool
-lex_is_integer (struct lexer *lexer)
+lex_is_integer (const struct lexer *lexer)
 {
   return lex_next_is_integer (lexer, 0);
 }
@@ -458,7 +458,7 @@ lex_is_integer (struct lexer *lexer)
 /* Returns the value of the current token, which must be an
    integer. */
 long
-lex_integer (struct lexer *lexer)
+lex_integer (const struct lexer *lexer)
 {
   return lex_next_integer (lexer, 0);
 }
@@ -472,7 +472,7 @@ lex_integer (struct lexer *lexer)
 
 /* Returns true if the token N ahead of the current token is a number. */
 bool
-lex_next_is_number (struct lexer *lexer, int n)
+lex_next_is_number (const struct lexer *lexer, int n)
 {
   enum token_type next_token = lex_next_token (lexer, n);
   return next_token == T_POS_NUM || next_token == T_NEG_NUM;
@@ -480,7 +480,7 @@ lex_next_is_number (struct lexer *lexer, int n)
 
 /* Returns true if the token N ahead of the current token is a string. */
 bool
-lex_next_is_string (struct lexer *lexer, int n)
+lex_next_is_string (const struct lexer *lexer, int n)
 {
   return lex_next_token (lexer, n) == T_STRING;
 }
@@ -488,7 +488,7 @@ lex_next_is_string (struct lexer *lexer, int n)
 /* Returns the value of the token N ahead of the current token, which must be a
    floating point number. */
 double
-lex_next_number (struct lexer *lexer, int n)
+lex_next_number (const struct lexer *lexer, int n)
 {
   assert (lex_next_is_number (lexer, n));
   return lex_next_tokval (lexer, n);
@@ -496,7 +496,7 @@ lex_next_number (struct lexer *lexer, int n)
 
 /* Returns true if the token N ahead of the current token is an integer. */
 bool
-lex_next_is_integer (struct lexer *lexer, int n)
+lex_next_is_integer (const struct lexer *lexer, int n)
 {
   double value;
 
@@ -510,7 +510,7 @@ lex_next_is_integer (struct lexer *lexer, int n)
 /* Returns the value of the token N ahead of the current token, which must be
    an integer. */
 long
-lex_next_integer (struct lexer *lexer, int n)
+lex_next_integer (const struct lexer *lexer, int n)
 {
   assert (lex_next_is_integer (lexer, n));
   return lex_next_tokval (lexer, n);
@@ -588,7 +588,7 @@ lex_force_match_id (struct lexer *lexer, const char *identifier)
     return true;
   else
     {
-      lex_error_expecting (lexer, identifier, NULL_SENTINEL);
+      lex_error_expecting (lexer, identifier);
       return false;
     }
 }
@@ -609,11 +609,11 @@ lex_force_match (struct lexer *lexer, enum token_type type)
       if (type_string)
        {
          char *s = xasprintf ("`%s'", type_string);
-         lex_error_expecting (lexer, s, NULL_SENTINEL);
+         lex_error_expecting (lexer, s);
          free (s);
        }
       else
-       lex_error_expecting (lexer, token_type_to_name (type), NULL_SENTINEL);
+       lex_error_expecting (lexer, token_type_to_name (type));
 
       return false;
     }
@@ -1435,13 +1435,9 @@ lex_source_get__ (const struct lex_source *src_)
       if (copy_len > 0 && line[copy_len - 1] == '\r')
         copy_len--;
 
-      /* Make a copy of the line with \n end-of-line and null terminator. */
-      char *syntax = xmalloc (copy_len + 2);
-      memcpy (syntax, line, copy_len);
-      syntax[copy_len] = '\n';
-      syntax[copy_len + 1] = '\0';
-
-      text_item_submit (text_item_create_nocopy (TEXT_ITEM_SYNTAX, syntax));
+      /* Submit the line as syntax. */
+      text_item_submit (text_item_create_nocopy (TEXT_ITEM_SYNTAX,
+                                                 xmemdup0 (line, copy_len)));
 
       src->journal_pos += line_len;
     }