Craig Morris
2019-12-03 11:45:46 +00:00
committed by Fonata
parent 044122efb9
commit 62fc367c14

View File

@@ -640,7 +640,7 @@ class Csv {
// force the parser to process end of data as a character (false) when // force the parser to process end of data as a character (false) when
// data does not end with a line feed or carriage return character. // data does not end with a line feed or carriage return character.
$lch = $data{$strlen - 1}; $lch = $data[$strlen - 1];
if ($lch != "\n" && $lch != "\r") { if ($lch != "\n" && $lch != "\r") {
$data .= "\n"; $data .= "\n";
$strlen++; $strlen++;
@@ -648,8 +648,8 @@ class Csv {
// walk through each character // walk through each character
for ($i = 0; $i < $strlen; $i++) { for ($i = 0; $i < $strlen; $i++) {
$ch = isset($data{$i}) ? $data{$i} : false; $ch = isset($data[$i]) ? $data[$i] : false;
$nch = isset($data{$i + 1}) ? $data{$i + 1} : false; $nch = isset($data[$i + 1]) ? $data[$i + 1] : false;
// open/close quotes, and inline quotes // open/close quotes, and inline quotes
if ($ch == $this->enclosure) { if ($ch == $this->enclosure) {
@@ -679,10 +679,10 @@ class Csv {
$i++; $i++;
} elseif ($nch != $this->delimiter && $nch != "\r" && $nch != "\n") { } elseif ($nch != $this->delimiter && $nch != "\r" && $nch != "\n") {
$x = $i + 1; $x = $i + 1;
while (isset($data{$x}) && ltrim($data{$x}, $white_spaces) == '') { while (isset($data[$x]) && ltrim($data[$x], $white_spaces) == '') {
$x++; $x++;
} }
if ($data{$x} == $this->delimiter) { if ($data[$x] == $this->delimiter) {
$enclosed = false; $enclosed = false;
$i = $x; $i = $x;
} else { } else {
@@ -1324,9 +1324,9 @@ class Csv {
// walk specific depth finding possible delimiter characters // walk specific depth finding possible delimiter characters
for ($i = 0; $i < $strlen; $i++) { for ($i = 0; $i < $strlen; $i++) {
$ch = $data{$i}; $ch = $data[$i];
$nch = isset($data{$i + 1}) ? $data{$i + 1} : false; $nch = isset($data[$i + 1]) ? $data[$i + 1] : false;
$pch = isset($data{$i - 1}) ? $data{$i - 1} : false; $pch = isset($data[$i - 1]) ? $data[$i - 1] : false;
// open and closing quotes // open and closing quotes
$is_newline = ($ch == "\n" && $pch != "\r") || $ch == "\r"; $is_newline = ($ch == "\n" && $pch != "\r") || $ch == "\r";