bugLaTeX semantic checker - Bugs: bug #31724, very long lines break the line...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #31724: very long lines break the line numbering

Submitted by:  Kirk Kelsey <kirkkelsey>
Submitted on:  Sun 21 Nov 2010 07:34:11 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Baruch Even <baruch>
Open/Closed: Closed

Fri 17 Dec 2010 10:10:07 PM UTC, comment #2:

I used a different method to achieve the same result, I look at the line that we got from fgets and if it doesn't end with \n I assume it will be continued and the line number is not incremented.

Baruch Even <baruch>
Project AdministratorIn charge of this item.
Sun 21 Nov 2010 08:03:20 PM UTC, comment #1:

Somehow, patches look different after posting.

I'm afraid I botched the logic a bit. While the patch gets the total line numbering correct, it will still be off when an error appears on the long line.

This patch gives correct line numbering in all cases. Sorry for the noise.

===================================================================
--- Utility.c (revision 144)
+++ Utility.c (working copy)
@@ -713,14 +713,29 @@
{
struct FileNode *fn;
char *Retval = NULL;
+ static char LongLine = 0;

if ((fn = StkTop(stack)))
{
+ if (LongLine)
+ {
+ fn->Line--;
+ LongLine = 0;
+ }
+
do
{
+ /* If fgets didn't encounter a newline before exhausting the
+ * buffer, then we need to reduce the line numbering when we return
+ * to this file. We set a sentinel to see if the buffer is filled,
+ * and if so set a flag to reduce the line number on next call. */
+ char sentinel = '\0';
+ Dest[len-2] = sentinel;
if ((Retval = fgets(Dest, (int) len, fn->fh)))
{
fn->Line++;
+ if (Dest[len-2] != sentinel && Dest[len-2] != '\n')
+ LongLine = 1;
break;
}

Kirk Kelsey <kirkkelsey>
Sun 21 Nov 2010 07:34:11 PM UTC, original submission:

If a line in the input LaTeX file is longer than the buffer space, ChkTeX will incorrectly increment the line numbering. The patch below detects such cases.

===================================================================
--- Utility.c (revision 144)
+++ Utility.c (working copy)
@@ -718,8 +718,15 @@
{
do
{
+ /* We don't want to increment the line count if fgets didn't
+ * encounter a newline before exhausting the buffer. By specifying
+ * the final characters, we can detect this case. */
+ char sentinel = '\0';
+ Dest[len-2] = sentinel;
+ Dest[len-3] = sentinel;
if ((Retval = fgets(Dest, (int) len, fn->fh)))
{
+ if (Dest[len-2] == sentinel && Dest[len-3] != '\n')
fn->Line++;
break;
}

Kirk Kelsey <kirkkelsey>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by baruch (Posted a comment)
  • -unavailable- added by kirkkelsey (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 17 Dec 2010 10:10:07 PM UTCbaruchStatusNone=>Fixed
      Assigned toNone=>baruch
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1