+/* Return the comment table. The client may not make any assumption
+ about the ordering of the table. */
+cpp_comment_table *
+cpp_get_comments (cpp_reader *pfile)
+{
+ return &pfile->comments;
+}
+
+/* Append a comment to the end of the comment table. */
+static void
+store_comment (cpp_reader *pfile, cpp_token *token)
+{
+ int len;
+
+ if (pfile->comments.allocated == 0)
+ {
+ pfile->comments.allocated = 256;
+ pfile->comments.entries = (cpp_comment *) xmalloc
+ (pfile->comments.allocated * sizeof (cpp_comment));
+ }
+
+ if (pfile->comments.count == pfile->comments.allocated)
+ {
+ pfile->comments.allocated *= 2;
+ pfile->comments.entries = (cpp_comment *) xrealloc
+ (pfile->comments.entries,
+ pfile->comments.allocated * sizeof (cpp_comment));
+ }
+
+ len = token->val.str.len;
+
+ /* Copy comment. Note, token may not be NULL terminated. */
+ pfile->comments.entries[pfile->comments.count].comment =
+ (char *) xmalloc (sizeof (char) * (len + 1));
+ memcpy (pfile->comments.entries[pfile->comments.count].comment,
+ token->val.str.text, len);
+ pfile->comments.entries[pfile->comments.count].comment[len] = '\0';
+
+ /* Set source location. */
+ pfile->comments.entries[pfile->comments.count].sloc = token->src_loc;
+
+ /* Increment the count of entries in the comment table. */
+ pfile->comments.count++;
+}
+