+2007-06-25 Bruno Haible <bruno@clisp.org>
+
+ Change boundary of extracted comments.
+ * x-perl.c (struct token_ty): Add comment field.
+ (free_token): Release tp->comment.
+ (extract_quotelike): Fill in tp->comment.
+ (x_perl_prelex): Set or release tp->comment when constructing tokens.
+ (x_perl_lex): Likewise.
+ (extract_balanced): Pass token's comment to remember_a_message.
+
+2007-06-18 Bruno Haible <bruno@clisp.org>
+
+ Change boundary of extracted comments.
+ * x-ycp.c (struct token_ty): Add comment field.
+ (free_token): New function.
+ (phase5_get): Fill in tp->comment.
+ (phase8_get): Use free_token.
+ (extract_parenthesized): Pass token's comment to remember_a_message.
+ Use free_token.
+ Reported by Karl Eichwalder <ke@suse.de>.
+
2007-06-09 Bruno Haible <bruno@clisp.org>
* format-java.c: Include xmalloca.h instead of xallocsa.h.
token_type_symbol ASCII
token_type_variable global_source_encoding
*/
+ refcounted_string_list_ty *comment; /* for token_type_string */
int line_number;
};
default:
break;
}
+ if (tp->type == token_type_string)
+ drop_reference (tp->comment);
free (tp);
}
string[len - 1] = '\0';
tp->string = xstrdup (string + 1);
free (string);
+ tp->comment = add_reference (savable_comment);
}
/* Extract the quotelike constructs with double delimiters, like
/* Perform pass 3 of quotelike extraction (interpolation).
*tp is a token of type token_type_string.
- This function replaces tp->string. */
+ This function replaces tp->string.
+ This function does not access tp->comment. */
/* FIXME: Currently may writes null-bytes into the string. */
static void
extract_quotelike_pass3 (token_ty *tp, int error_level)
token.type = token_type_string;
token.sub_type = string_type_qq;
token.line_number = line_number;
+ /* No need for token.comment = add_reference (savable_comment); here.
+ We can let token.comment uninitialized here, and use savable_comment
+ directly, because this function only parses the given string and does
+ not call phase2_getc. */
pos.file_name = logical_file_name;
pos.line_number = lineno;
if (delim != '\'')
interpolate_keywords (mlp, tp->string, line_number);
free (tp->string);
+ drop_reference (tp->comment);
tp->type = token_type_regex_op;
prefer_division_over_regexp = true;
interpolate_keywords (mlp, tp->string, line_number);
break;
case 'r':
+ drop_reference (tp->comment);
tp->type = token_type_regex_op;
break;
case 'w':
+ drop_reference (tp->comment);
tp->type = token_type_symbol;
tp->sub_type = symbol_type_none;
break;
tp->string = string;
tp->type = token_type_string;
tp->sub_type = string_type_qq;
+ tp->comment = add_reference (savable_comment);
tp->line_number = line_number + 1;
interpolate_keywords (mlp, tp->string, line_number + 1);
return;
extract_quotelike (tp, c);
interpolate_keywords (mlp, tp->string, line_number);
free (tp->string);
+ drop_reference (tp->comment);
tp->type = token_type_other;
prefer_division_over_regexp = true;
/* Eat the following modifiers. */
{
tp->type = token_type_string;
tp->sub_type = string_type_q;
+ tp->comment = add_reference (savable_comment);
#if DEBUG_PERL
fprintf (stderr,
"%s:%d: token %s mutated to token_type_string\n",
pos.file_name = logical_file_name;
pos.line_number = tp->line_number;
xgettext_current_source_encoding = po_charset_utf8;
- remember_a_message (mlp, NULL, string, inner_context, &pos, savable_comment);
+ remember_a_message (mlp, NULL, string, inner_context, &pos,
+ tp->comment);
xgettext_current_source_encoding = xgettext_global_source_encoding;
}
else if (!skip_until_comma)
arglist_parser_remember (argparser, arg,
string, inner_context,
logical_file_name, tp->line_number,
- savable_comment);
+ tp->comment);
xgettext_current_source_encoding = xgettext_global_source_encoding;
}
}
{
token_type_ty type;
char *string; /* for token_type_string_literal, token_type_symbol */
+ refcounted_string_list_ty *comment; /* for token_type_string_literal */
int line_number;
};
}
+/* Free the memory pointed to by a 'struct token_ty'. */
+static inline void
+free_token (token_ty *tp)
+{
+ if (tp->type == token_type_string_literal || tp->type == token_type_symbol)
+ free (tp->string);
+ if (tp->type == token_type_string_literal)
+ drop_reference (tp->comment);
+}
+
+
/* Combine characters into tokens. Discard whitespace. */
static token_ty phase5_pushback[1];
buffer[bufpos] = '\0';
tp->string = xstrdup (buffer);
tp->type = token_type_string_literal;
+ tp->comment = add_reference (savable_comment);
return;
case '(':
len = strlen (tp->string);
tp->string = xrealloc (tp->string, len + strlen (tmp.string) + 1);
strcpy (tp->string + len, tmp.string);
- free (tmp.string);
+ free_token (&tmp);
}
}
/* Seen an msgid. */
plural_mp = remember_a_message (mlp, NULL, token.string,
inner_context, &pos,
- savable_comment);
+ token.comment);
state = 2;
}
else
/* Seen an msgid_plural. */
remember_a_message_plural (plural_mp, token.string,
inner_context, &pos,
- savable_comment);
+ token.comment);
state = 0;
}
+ drop_reference (token.comment);
}
else
{
- free (token.string);
+ free_token (&token);
state = 0;
}
next_context_iter = null_context_list_iterator;
flag_context_list_table_lookup (
flag_context_list_table,
token.string, strlen (token.string)));
- free (token.string);
+ free_token (&token);
state = 0;
continue;