changeset 24:27c10ed38592

Added padd.m to remove external dependencies; Matlab output lines now prefixed with '| '
author samer
date Wed, 22 Feb 2012 21:17:52 +0000
parents bfef495cd52a
children de95213cdcc2
files cpp/plml.cpp matlab/Makefile matlab/padd.m prolog/plml.pl
diffstat 4 files changed, 27 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cpp/plml.cpp	Wed Feb 15 17:50:14 2012 +0000
+++ b/cpp/plml.cpp	Wed Feb 22 21:17:52 2012 +0000
@@ -462,6 +462,15 @@
 }
 
 
+static void displayOutput(char *prefix,char *p) 
+{
+	while (*p) {
+		fputs(prefix,stdout); 
+		while (*p && *p!='\n') putchar(*p++); 
+		putchar('\n'); if (*p) p++;
+	}
+}
+
 /* 
  * Open a matlab engine using the given command and associate
  * it with the second term, which should be an atom.
@@ -482,7 +491,7 @@
         atom_t id;
         check(PL_get_atom(id_term,&id));
         engines[i].open(PlTerm(servercmd), id);
-		  fputs(engines[i].outbuf,stdout);
+		  displayOutput("| ",engines[i].outbuf);
         PL_succeed;
       }
     }
@@ -651,7 +660,7 @@
 	 }
 	
 	 // write whatever is in the output buffer now, starting after the "#\n"
-    fputs(eng->outbuf+5,stdout);
+    displayOutput("| ", eng->outbuf+5);
 
 #ifdef ALT_LASTERR
 
--- a/matlab/Makefile	Wed Feb 15 17:50:14 2012 +0000
+++ b/matlab/Makefile	Wed Feb 22 21:17:52 2012 +0000
@@ -1,5 +1,6 @@
 
 install:
 	install -d $(INSTALL_ML_TO)
+	install $(INSTALL_FLAGS) -m 644 padd.m $(INSTALL_ML_TO)
 	cp -pR db $(INSTALL_ML_TO)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/matlab/padd.m	Wed Feb 22 21:17:52 2012 +0000
@@ -0,0 +1,13 @@
+function padd(varargin)
+% padd - Add directories to Matlab path.
+%
+% Directories are interpreted relative to the directory where this
+% function is found.
+
+Root=fileparts(which('padd'));
+for i=1:nargin
+	arg = varargin{i};
+	disp(['adding path ' arg]);
+	path(fullfile(Root,arg),path);
+end;
+
--- a/prolog/plml.pl	Wed Feb 15 17:50:14 2012 +0000
+++ b/prolog/plml.pl	Wed Feb 22 21:17:52 2012 +0000
@@ -267,7 +267,7 @@
 %% matlab_path( -Key, -Path:list(atom)) is nondet.
 %  Each user-defined clause of matlab_path/2 causes the directories in Path
 %  to be added to the Matlab path of every new Matlab session. Directories
-%  are relative to the root directory as returned by Matlab function proot.
+%  are relative to the root directory where padd.m is found.
 
 %% pl2ml_hook(+X:term,-Y:ml_expr) is nondet.
 %  Clauses of pl2ml_hook/2 allow for extensions to the Matlab expression 
@@ -318,6 +318,7 @@
 	format(atom(Cmd),'~w ~w',[Exec1,Flags]),
 	debug(plml,'About to start Matlab with: ~w',[Cmd]),
 	mlOPEN(Cmd,Id),
+	addpath(db),
 	set_flag(ml(Id),open),
 	(	member(noinit,Options) -> true
 	;	forall( matlab_path(_,Dir), maplist(nofail(addpath),Dir)),