Hello,
In Octave 3.6.1, when installing a package with a DESCRIPTION file that
includes a line ending with a semicolon, installation fails with a
cryptic error message.
The problem may be easily reproduced by creating a get_description.m
file with functions get_description() and strip() from pkg.m (lines 1726
to 1778 and 1859 to 1866), and a DEScRITION file with contents such as
Author:
(Both files are attached to this message). When calling
> get_description('DESCRIPTION')
it fails with error message
error: structure has no member `keywords'
error: evaluating argument list element number 2
error: called from:
error: <path>/get_description.m at line 29, column 13
I'm attaching a patch that fixes the problem for me (even though the
error string could still be improved a bit).
Regards,
--
Miguel Bazdresch
Author:
function desc = get_description (filename)
[fid, msg] = fopen (filename, "r");
if (fid == -1)
error ("the DESCRIPTION file %s could not be read: %s", filename, msg);
endif
desc = struct ();
line = fgetl (fid);
while (line != -1)
if (line(1) == "#")
## Comments, do nothing.
elseif (isspace(line(1)))
## Continuation lines
if (exist ("keyword", "var") && isfield (desc, keyword))
desc.(keyword) = cstrcat (desc.(keyword), " ", rstrip(line));
endif
else
## Keyword/value pair
colon = find (line == ":");
if (length (colon) == 0)
disp ("skipping line");
else
colon = colon(1);
keyword = tolower (strip (line(1:colon-1)));
value = strip (line (colon+1:end));
if (length (value) == 0)
fclose (fid);
error ("the keyword %s has an empty value", keyword);
endif
desc.(keyword) = value;
endif
endif
line = fgetl (fid);
endwhile
fclose (fid);
## Make sure all is okay.
needed_fields = {"name", "version", "date", "title", ...
"author", "maintainer", "description"};
for f = needed_fields
if (! isfield (desc, f{1}))
error ("description is missing needed field %s", f{1});
endif
endfor
desc.version = fix_version (desc.version);
if (isfield (desc, "depends"))
desc.depends = fix_depends (desc.depends);
else
desc.depends = "";
endif
desc.name = tolower (desc.name);
endfunction
function text = strip (text)
chars = find (! isspace (text));
if (length (chars) > 0)
text = text(chars(1):chars(end));
else
text = "";
endif
endfunction
--- pkg.m.orig 2012-02-29 19:11:23.631600147 -0600
+++ pkg.m 2012-02-29 19:11:55.354761621 -0600
@@ -1751,7 +1751,7 @@
value = strip (line (colon+1:end));
if (length (value) == 0)
fclose (fid);
- error ("the keyword %s has an empty value", desc.keywords{end});
+ error ("the keyword %s has an empty value", keyword);
endif
desc.(keyword) = value;
endif
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev