octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

urlwrite.m


From: John W. Eaton
Subject: urlwrite.m
Date: Wed, 21 Feb 2007 13:19:25 -0500

On 21-Feb-2007, Bob Weigel wrote:

| If Octave was not compiled with cURL, xmlwrite.oct is created and when
| called always returns an error.  This creates a problem when writing
| code to work for older versions of Octave in which I would want to
| test for xmlwrite using
| 
| if exist('xmlwrite')
|   [F,success] = xmlwrite(...)
| else
|   # Use alternantive
| end
| 
| Because xmlwrite may exist but always returns an error, I would need
| to put a try-catch clause
| 
| if exist('xmlwrite')
|   try
|    # Calling xmlwrite
|   catch
|    # Use alternative
|   end
| else
|   # Use alternantive
| end

You mean urlwrite, yes?

| Would it make sense to set the second output of urlwrite to zero
| instead of always returning error?

OK, I checked in the following change so that the behavior is more
consistent with other functions in Octave that may be missing on some
systems.

| Also, in configure, if the curl library is not found or if the version found 
| does not have curl_easy_escape, we are treated with the same warning as a 
| other missing libraries.  Could a warning be added that says "Octave will not 
| be able to use URL functions"?

Done.  The message was already in the configure script but not printed
in the summary.

Thanks,


jwe


src/ChangeLog:

2007-02-21  John W. Eaton  <address@hidden>

        * DLD-FUNCTIONS/urlwrite.cc (Furlwrite, Furlread): Return error
        code and message instead of throwing error if functionality is
        missing.


Index: src/DLD-FUNCTIONS/urlwrite.cc
===================================================================
RCS file: /cvs/octave/src/DLD-FUNCTIONS/urlwrite.cc,v
retrieving revision 1.1
diff -u -u -r1.1 urlwrite.cc
--- src/DLD-FUNCTIONS/urlwrite.cc       9 Oct 2006 19:49:04 -0000       1.1
+++ src/DLD-FUNCTIONS/urlwrite.cc       21 Feb 2007 18:17:29 -0000
@@ -314,7 +314,9 @@
     error ("urlwrite: curl: %s", curl_easy_strerror (res));
 
 #else
-  error ("urlwrite: not available in this version of Octave");
+  retval(2) = "urlwrite: not available in this version of Octave";
+  retval(1) = 0;
+  retval(0) = "";
 #endif
 
   return retval;
@@ -429,7 +431,9 @@
     error ("urlread: curl: %s", curl_easy_strerror (res));
 
 #else
-  error ("urlread: not available in this version of Octave");
+  retval(2) = "urlread: not available in this version of Octave";
+  retval(1) = 0;
+  retval(0) = "";
 #endif
 
   return retval;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]