diff --git a/Units/parser-php.r/subparser-crlf-bom.d/.gitattributes b/Units/parser-php.r/subparser-crlf-bom.d/.gitattributes
new file mode 100644
index 0000000000..cf715bd617
--- /dev/null
+++ b/Units/parser-php.r/subparser-crlf-bom.d/.gitattributes
@@ -0,0 +1 @@
+input.php text eol=crlf
diff --git a/Units/parser-php.r/subparser-crlf-bom.d/args.ctags b/Units/parser-php.r/subparser-crlf-bom.d/args.ctags
new file mode 100644
index 0000000000..f371192148
--- /dev/null
+++ b/Units/parser-php.r/subparser-crlf-bom.d/args.ctags
@@ -0,0 +1,2 @@
+--sort=no
+--extras=+g
diff --git a/Units/parser-php.r/subparser-crlf-bom.d/expected.tags b/Units/parser-php.r/subparser-crlf-bom.d/expected.tags
new file mode 100644
index 0000000000..1d5bdcefc9
--- /dev/null
+++ b/Units/parser-php.r/subparser-crlf-bom.d/expected.tags
@@ -0,0 +1,3 @@
+a input.php /^$/;" f
+b input.php /^$/;" f
+A input.php /^
A<\/h1>$/;" h
diff --git a/Units/parser-php.r/subparser-crlf-bom.d/input.php b/Units/parser-php.r/subparser-crlf-bom.d/input.php
new file mode 100644
index 0000000000..57055626b5
--- /dev/null
+++ b/Units/parser-php.r/subparser-crlf-bom.d/input.php
@@ -0,0 +1,3 @@
+
+A
+
diff --git a/Units/parser-php.r/subparser-crlf.d/.gitattributes b/Units/parser-php.r/subparser-crlf.d/.gitattributes
new file mode 100644
index 0000000000..cf715bd617
--- /dev/null
+++ b/Units/parser-php.r/subparser-crlf.d/.gitattributes
@@ -0,0 +1 @@
+input.php text eol=crlf
diff --git a/Units/parser-php.r/subparser-crlf.d/args.ctags b/Units/parser-php.r/subparser-crlf.d/args.ctags
new file mode 100644
index 0000000000..f371192148
--- /dev/null
+++ b/Units/parser-php.r/subparser-crlf.d/args.ctags
@@ -0,0 +1,2 @@
+--sort=no
+--extras=+g
diff --git a/Units/parser-php.r/subparser-crlf.d/expected.tags b/Units/parser-php.r/subparser-crlf.d/expected.tags
new file mode 100644
index 0000000000..1d5bdcefc9
--- /dev/null
+++ b/Units/parser-php.r/subparser-crlf.d/expected.tags
@@ -0,0 +1,3 @@
+a input.php /^$/;" f
+b input.php /^$/;" f
+A input.php /^A<\/h1>$/;" h
diff --git a/Units/parser-php.r/subparser-crlf.d/input.php b/Units/parser-php.r/subparser-crlf.d/input.php
new file mode 100644
index 0000000000..2c6ab6993a
--- /dev/null
+++ b/Units/parser-php.r/subparser-crlf.d/input.php
@@ -0,0 +1,3 @@
+
+A
+
diff --git a/main/read.c b/main/read.c
index 2118ec1e99..2b2b143c8c 100644
--- a/main/read.c
+++ b/main/read.c
@@ -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;
@@ -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
@@ -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],