# HG changeset patch # User samer # Date 1329945472 0 # Node ID 27c10ed38592d43a9f0f3f38cfc8ce462a937963 # Parent bfef495cd52aa67f9f4be18591be28448a04a20b Added padd.m to remove external dependencies; Matlab output lines now prefixed with '| ' diff -r bfef495cd52a -r 27c10ed38592 cpp/plml.cpp --- 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 diff -r bfef495cd52a -r 27c10ed38592 matlab/Makefile --- 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) diff -r bfef495cd52a -r 27c10ed38592 matlab/padd.m --- /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; + diff -r bfef495cd52a -r 27c10ed38592 prolog/plml.pl --- 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)),