Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions Units/parser-php.r/subparser-crlf-bom.d/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
input.php text eol=crlf
2 changes: 2 additions & 0 deletions Units/parser-php.r/subparser-crlf-bom.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--extras=+g
3 changes: 3 additions & 0 deletions Units/parser-php.r/subparser-crlf-bom.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a input.php /^<?php function a() {} ?>$/;" f
b input.php /^<?php function b() {} ?>$/;" f
A input.php /^<h1>A<\/h1>$/;" h
3 changes: 3 additions & 0 deletions Units/parser-php.r/subparser-crlf-bom.d/input.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php function a() {} ?>
<h1>A</h1>
<?php function b() {} ?>
1 change: 1 addition & 0 deletions Units/parser-php.r/subparser-crlf.d/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
input.php text eol=crlf
2 changes: 2 additions & 0 deletions Units/parser-php.r/subparser-crlf.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--extras=+g
3 changes: 3 additions & 0 deletions Units/parser-php.r/subparser-crlf.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a input.php /^<?php function a() {} ?>$/;" f
b input.php /^<?php function b() {} ?>$/;" f
A input.php /^<h1>A<\/h1>$/;" h
3 changes: 3 additions & 0 deletions Units/parser-php.r/subparser-crlf.d/input.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php function a() {} ?>
<h1>A</h1>
<?php function b() {} ?>
45 changes: 24 additions & 21 deletions main/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,24 @@ extern long translateFileOffset (unsigned long offset)
return getAreaStartOffset () + offset;
}

static compoundPos* getInputFileCompoundPosForLine (unsigned int line)
{
int index;
if (line > 0)
{
if (File.lineFposMap.count > (line - 1))
index = line - 1;
else if (File.lineFposMap.count != 0)
index = File.lineFposMap.count - 1;
else
index = 0;
}
else
index = 0;

return File.lineFposMap.pos + index;
}

extern int getInputColumnNumber (void)
{
int ret;
Expand Down Expand Up @@ -315,14 +333,17 @@ extern int getInputColumnNumber (void)
* | |
* +-----------------+
*
* Q => getInputFileOffsetForLine(File.input.lineNumber)
* Q => getInputFileCompoundPosForLine(File.input.lineNumber)->offset - (File.bomFound? 3: 0)
*
* (File.bomFound? 3: 0) on each side cancel each other, so can be left out.
*
* dz = O + P - Q
*/
unsigned long ln = getInputLineNumber ();
compoundPos *cpos = getInputFileCompoundPosForLine (ln);
ret = getAreaStartOffset ()
+ mio_tell (File.mio) - (File.bomFound? 3: 0)
- getInputFileOffsetForLine(ln)
+ mio_tell (File.mio)
- cpos->offset
- File.ungetchIdx;
}
else
Expand Down Expand Up @@ -353,24 +374,6 @@ extern MIOPos getInputFilePosition (void)
return File.filePosition.pos;
}

static compoundPos* getInputFileCompoundPosForLine (unsigned int line)
{
int index;
if (line > 0)
{
if (File.lineFposMap.count > (line - 1))
index = line - 1;
else if (File.lineFposMap.count != 0)
index = File.lineFposMap.count - 1;
else
index = 0;
}
else
index = 0;

return File.lineFposMap.pos + index;
}


/* case areaCoord == AREA_COORD_CURRENT:
* return: [current],
Expand Down
Loading