From f0c27686e12f5fcd79a2001bcc10989690eeaab4 Mon Sep 17 00:00:00 2001
From: Marco Ratto <marco.ratto@jrc.ec.europa.eu>
Date: Fri, 5 Apr 2013 17:30:50 +0200
Subject: [PATCH] fixed output argument as a proper char matrix for both unix
 and windows OS. (cherry picked from commit
 844cbac2b3ecfdc7b047b6a703106e6cdb7da64d)

---
 matlab/parallel/dynareParallelDir.m | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/matlab/parallel/dynareParallelDir.m b/matlab/parallel/dynareParallelDir.m
index 654db89f3c..ac87807161 100644
--- a/matlab/parallel/dynareParallelDir.m
+++ b/matlab/parallel/dynareParallelDir.m
@@ -47,6 +47,12 @@ for indPC=1:length(Parallel),
             end
             if check ~= 0 || ~isempty(strfind(ax,'No such file or directory'));
                 ax=[];
+            else
+                indax=regexp(ax,'\n');
+                colax=indax(1);
+                rowax=length(indax);
+                ax=reshape(ax',[colax rowax])';
+                ax=ax(:,1:end-1);
             end
         else
 
@@ -67,7 +73,6 @@ for indPC=1:length(Parallel),
             end
 
         end
-        dirlist = char(dirlist, ax);
     else
         if exist('OCTAVE_VERSION'),     % Patch for peculiar behaviour of ls under Windows.
             if Parallel(indPC).Local==0,
@@ -92,6 +97,10 @@ for indPC=1:length(Parallel),
                 ax=ls(filename);
             end
         end
+    end
+    if isempty(dirlist),
+        dirlist=ax;
+    elseif ~isempty(ax),
         dirlist = char(dirlist, ax);
     end
 end
-- 
GitLab