Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix promises at EOF #4097

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Units/parser-php.r/wp-guest.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--sort=no
--extras=+rg
--fields=+rln
14 changes: 14 additions & 0 deletions Units/parser-php.r/wp-guest.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
top input.php /^<div id="top">$/;" I line:3 language:HTML roles:def
inner input.php /^ <div class="inner">$/;" c line:4 language:HTML roles:attribute
logo input.php /^<div id="logo">$/;" I line:6 language:HTML roles:def
pages input.php /^<div id="pages">$/;" I line:12 language:HTML roles:def
menubar input.php /^<ul class="menubar" id="menubar">$/;" c line:13 language:HTML roles:attribute
menubar input.php /^<ul class="menubar" id="menubar">$/;" I line:13 language:HTML roles:def
body input.php /^<div id="body">$/;" I line:26 language:HTML roles:def
content input.php /^ <main id="content">$/;" I line:27 language:HTML roles:def
post input.php /^ <article class="post" id="post-<?p/;" c line:31 language:HTML roles:attribute
post-<?p input.php /^ <article class="post" id="post-<?p/;" I line:31 language:HTML roles:def
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a follow-up to fix the HTML promise range from the PHP lexer to fix this spurious <?p, but it currently depends on these changes so I'll post it after this is sorted out (no pressure, just saying that indeed, this tag is not exactly as it should be).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you paste this comment into the commit log for this commit?
So people can understand this commit from its log only with 'git log'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, but I'm not sure its so important to specify in the commit, it's just a note for review that it's not to be worried about, but I don't think it undermines the patch much.
Another option could be removing this line from the test case and add a new one for the other patch, I merely kept it like this because it's a "real" file and made me notice the issue.

Anyway, I can do either just fine, as you prefer :)

storybody input.php /^ <div class="storybody"><br \/><?p/;" c line:37 language:HTML roles:attribute
postmetadata input.php /^ <p class="postmetadata"><\/p>$/;" c line:38 language:HTML roles:attribute
storybody input.php /^ <div class="storybody"><?p/;" c line:41 language:HTML roles:attribute
left input.php /^ <aside id="left"><?p/;" I line:52 language:HTML roles:def
55 changes: 55 additions & 0 deletions Units/parser-php.r/wp-guest.d/input.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php get_header(); ?>

<div id="top">
<div class="inner">
<br clear="all" />
<div id="logo">
<h2><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h2>
<p>
<?php bloginfo('description'); ?>
</p>
</div>
<div id="pages">
<ul class="menubar" id="menubar">
<li><a href="<?php bloginfo('url'); ?>">Accueil</a></li>
<?php montheme_list_pages( array( 'depth' => 1 ) ); ?>
</ul>
<!--[if !IE]><-->
<script type="text/javascript">
initMenu (document.getElementById ('menubar'), 0);
</script>
<!--><![endif]-->
</div>
</div>
</div>

<div id="body">
<main id="content">

<?php if (have_posts()) : while (have_posts()) : the_post(); ?><br /><br />

<article class="post" id="post-<?php the_ID(); ?>">

<div class="storycontent">

<h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>

<div class="storybody"><br /><?php the_content(__('(more...)')); ?></div>
<p class="postmetadata"></p>

</div>
<div class="storybody"><?php comments_template(); // Get wp-comments.php template ?></div>
</article>


<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>

<?php posts_nav_link(' &#8212; ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?>

</main>
<aside id="left"><?php get_sidebar(); ?></aside>
</div>

<?php get_footer(); ?>
9 changes: 7 additions & 2 deletions main/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ typedef struct sInputFile {
vString *path; /* path of input file (if any) */
vString *line; /* last line read from file */
const unsigned char* currentLine; /* current line being worked on */
size_t currentLineEndOffset;
MIO *mio; /* MIO stream used for reading the file */
compoundPos filePosition; /* file position of current line */
unsigned int ungetchIdx;
Expand Down Expand Up @@ -159,8 +160,7 @@ extern int getInputLineOffset (void)
/* When EOF is saw, currentLine is set to NULL.
* So the way to calculate the offset at the end of file is tricky.
*/
ret = (mio_tell (File.mio) - (File.bomFound? 3: 0))
- getInputFileOffsetForLine(File.input.lineNumber);
ret = File.currentLineEndOffset - File.ungetchIdx;
}
else
{
Expand Down Expand Up @@ -766,6 +766,7 @@ extern bool openInputFile (const char *const fileName, const langType language,
mio_getpos (File.mio, &File.filePosition.pos);
File.filePosition.offset = StartOfLine.offset = mio_tell (File.mio);
File.currentLine = NULL;
File.currentLineEndOffset = 0;

File.line = vStringNewOrClear (File.line);
File.ungetchIdx = 0;
Expand Down Expand Up @@ -804,6 +805,7 @@ extern void resetInputFile (const langType language, bool resetLineFposMap_)
mio_getpos (File.mio, &File.filePosition.pos);
File.filePosition.offset = StartOfLine.offset = mio_tell (File.mio);
File.currentLine = NULL;
File.currentLineEndOffset = 0;

Assert (File.line);
vStringClear (File.line);
Expand Down Expand Up @@ -1032,7 +1034,10 @@ extern int getcFromInputFile (void)
{
vString* const line = iFileGetLine (false);
if (line != NULL)
{
File.currentLine = (unsigned char*) vStringValue (line);
File.currentLineEndOffset = vStringLength (line);
}
if (File.currentLine == NULL)
c = EOF;
else
Expand Down
Loading