Skip to content
Snippets Groups Projects
Commit ec151dcf authored by Qianqian Fang's avatar Qianqian Fang
Browse files

fixing everything for GNU octave

git-svn-id: http://svn.code.sf.net/p/iso2mesh/code/trunk/jsonlab@439 786e58fb-9377-0410-9ff7-e4ac0ac0635c
parent d310d10b
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
*Copyright (c) 2011-2014 Qianqian Fang <fangq at nmr.mgh.harvard.edu>
*License: BSD or GNU General Public License version 3 (GPL v3), see License*.txt
*Version: 0.9.9 (Optimus - beta)
*Version: 1.0.0-RC1 (Optimus - RC1)
-------------------------------------------------------------------------------
......
......@@ -19,8 +19,9 @@ for i=1:4
fprintf(1,'===============================================\n>> %s\n',fname);
json=saveubjson('data',loadjson(fname));
fprintf(1,'%s\n',json);
data=loadubjson(json);
data=loadubjson(json)
savejson('',data)
i
saveubjson('data',data,'selftest.ubj');
data=loadubjson('selftest.ubj');
end
......@@ -414,8 +414,20 @@ end
%%-------------------------------------------------------------------------
function newstr=escapejsonstring(str)
escapechars={'\a','\b','\f','\n','\r','\t','\v'};
newstr=str;
isoct=exist('OCTAVE_VERSION','builtin');
if(isoct)
vv=sscanf(OCTAVE_VERSION,'%f');
if(vv(1)>=3.8) isoct=0; end
end
if(isoct)
escapechars={'\a','\f','\n','\r','\t','\v'};
for i=1:length(escapechars);
newstr=regexprep(newstr,escapechars{i},escapechars{i});
end
else
escapechars={'\a','\b','\f','\n','\r','\t','\v'};
for i=1:length(escapechars);
newstr=regexprep(newstr,escapechars{i},regexprep(escapechars{i},'\\','\\\\'));
end
end
......@@ -155,7 +155,7 @@ end
for j=1:dim(2)
if(dim(1)>1) txt=[txt '[']; end
for i=1:dim(1)
txt=[txt obj2ubjson(name,item{i},level+(len>1),varargin{:})];
txt=[txt obj2ubjson(name,item{i,j},level+(len>1),varargin{:})];
end
if(dim(1)>1) txt=[txt ']']; end
end
......@@ -308,7 +308,7 @@ if(size(mat,1)==1)
end
type='';
hasnegtive=(mat<0);
if(isa(mat,'integer') || (isfloat(mat) && all(mod(mat(:),1) == 0)))
if(isa(mat,'integer') || isinteger(mat) || (isfloat(mat) && all(mod(mat(:),1) == 0)))
if(isempty(hasnegtive))
if(max(mat(:))<=2^8)
type='U';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment