octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #48171] Third output argument of uiputfile und


From: Rik
Subject: [Octave-bug-tracker] [bug #48171] Third output argument of uiputfile undefined when user presses Cancel
Date: Wed, 8 Jun 2016 18:31:21 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0

Follow-up Comment #3, bug #48171 (project octave):

Is there any danger that Qt will return anything other than 2,3, or 3+
elements?  I coded a slightly different fix which I have attached where I
initialize all the outputs to 0.0 and override as necessary based on a switch
statement.


diff -r f250714c629d -r a0ab0551018b libinterp/corefcn/octave-link.cc
--- a/libinterp/corefcn/octave-link.cc  Tue Jun 07 16:00:45 2016 -0700
+++ b/libinterp/corefcn/octave-link.cc  Wed Jun 08 11:26:56 2016 -0700
@@ -230,32 +230,37 @@ Undocumented internal function.\n\
   // If 3, then retval is filename, directory, and selected index.
   if (nel <= 3)
     {
-      int idx = 0;
-      for (std::list<std::string>::iterator it = items_lst.begin ();
-           it != items_lst.end (); it++)
+      retval = (octave_value (0.0), octave_value (0.0), octave_value (0.0));
+
+      std::list<std::string>::reverse_iterator it = items_lst.rbegin ();
+
+      switch (nel)
         {
-          retval(idx++) = *it;
+        case 3:
+          if (! it->empty ())
+            retval(2) = atoi (it->c_str ());
+          it++;
 
-          if (idx == 1 && retval(0).string_value ().length () == 0)
-            retval(0) = 0;
+        case 2:
+          if (! it->empty ())
+            retval(1) = *it;
+          it++;
 
-          if (idx == 3)
-            retval(2) = atoi (retval(2).string_value ().c_str ());
+        case 1:
+          if (! it->empty ())
+            retval(0) = *it;
         }
     }
   else
     {
       // Multiple files.
-      nel = items_lst.size () - 2;
+      nel = nel - 2;
       Cell items (dim_vector (1, nel));
 
       std::list<std::string>::iterator it = items_lst.begin ();
 
-      for (int idx = 0; idx < nel; idx++)
-        {
-          items.xelem (idx) = *it;
-          it++;
-        }
+      for (int idx = 0; idx < nel; idx++, it++)
+        items.xelem (idx) = *it;
 
       retval = ovl (items, *it++, atoi (it->c_str ()));
     }




(file #37435)
    _______________________________________________________

Additional Item Attachment:

File name: octlink.diff                   Size:1 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48171>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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