Commit 15760647 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Changed the way the end of file is detected in the uploaded CSV files, so that...

Changed the way the end of file is detected in the uploaded CSV files, so that files with no newline have the last line detected and returned properly (bug 652)
parent aa0ddd83
......@@ -174,6 +174,9 @@ class File_CSV
if (!$fp = File_CSV::getPointer($file, $conf, FILE_MODE_READ)) {
return false;
}
if (feof($fp)) {
return false;
}
$buff = $c = null;
$ret = array();
$i = 1;
......@@ -182,6 +185,7 @@ class File_CSV
$f = $conf['fields'];
while (($line = fgets($fp)) !== false) {
$line = preg_replace("/\r$/", "\n", $line);
$line = preg_replace("/([^\n])$/", "$1\n", $line);
$length = strlen($line);
for ($j = 0; $j < strlen($line); $j++) {
$prev = $c;
......@@ -238,7 +242,7 @@ class File_CSV
$buff .= $c;
}
}
return !feof($fp) ? $ret : false;
return $ret;
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment