changeset 16212:d2b268936783 classdef

maint: periodic merge of default to classdef
author John W. Eaton <jwe@octave.org>
date Thu, 07 Mar 2013 10:25:39 -0500
parents 3449bf257514 (current diff) 78365c56a762 (diff)
children d8c0f46efaf0
files libinterp/octave.cc libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll libinterp/parse-tree/oct-parse.in.yy libinterp/parse-tree/parse.h
diffstat 9 files changed, 98 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/interp-core/txt-eng-ft.cc	Thu Mar 07 10:23:02 2013 -0500
+++ b/libinterp/interp-core/txt-eng-ft.cc	Thu Mar 07 10:25:39 2013 -0500
@@ -650,6 +650,7 @@
     case 1: box(1) = -box(3)/2; break;
     case 2: box(1) = -box(3); break;
     case 3: break;
+    case 4: box(1) = -box(3)-box(1); break;
     }
 
   switch (rot_mode)
--- a/libinterp/interpfcn/graphics.cc	Thu Mar 07 10:23:02 2013 -0500
+++ b/libinterp/interpfcn/graphics.cc	Thu Mar 07 10:25:39 2013 -0500
@@ -3904,7 +3904,7 @@
   xset (title.handle_value (), "horizontalalignment", "center");
   xset (title.handle_value (), "horizontalalignmentmode", "auto");
 
-  xset (xlabel.handle_value (), "verticalalignment", "cap");
+  xset (xlabel.handle_value (), "verticalalignment", "top");
   xset (xlabel.handle_value (), "verticalalignmentmode", "auto");
   xset (ylabel.handle_value (), "verticalalignment", "bottom");
   xset (ylabel.handle_value (), "verticalalignmentmode", "auto");
@@ -4412,7 +4412,7 @@
   xset (title.handle_value (), "horizontalalignment", "center");
   xset (title.handle_value (), "horizontalalignmentmode", "auto");
 
-  xset (xlabel.handle_value (), "verticalalignment", "cap");
+  xset (xlabel.handle_value (), "verticalalignment", "top");
   xset (xlabel.handle_value (), "verticalalignmentmode", "auto");
   xset (ylabel.handle_value (), "verticalalignment", "bottom");
   xset (ylabel.handle_value (), "verticalalignmentmode", "auto");
@@ -7022,12 +7022,14 @@
   else if (horizontalalignment_is ("right"))
     halign = 2;
 
-  if (verticalalignment_is ("top"))
+  if (verticalalignment_is ("middle"))
+    valign = 1;
+  else if (verticalalignment_is ("top"))
     valign = 2;
   else if (verticalalignment_is ("baseline"))
     valign = 3;
-  else if (verticalalignment_is ("middle"))
-    valign = 1;
+  else if (verticalalignment_is ("cap"))
+    valign = 4;
 
   Matrix bbox;
 
--- a/libinterp/interpfcn/input.cc	Thu Mar 07 10:23:02 2013 -0500
+++ b/libinterp/interpfcn/input.cc	Thu Mar 07 10:25:39 2013 -0500
@@ -94,21 +94,12 @@
 // Character to append after successful command-line completion attempts.
 static char Vcompletion_append_char = ' ';
 
-// TRUE means that stdin is a terminal, not a pipe or redirected file.
-bool stdin_is_tty = false;
-
 // TRUE means this is an interactive shell.
 bool interactive = false;
 
 // TRUE means the user forced this shell to be interactive (-i).
 bool forced_interactive = false;
 
-// Should we issue a prompt?
-int promptflag = 1;
-
-// The current line of input, from wherever.
-std::string current_input_line;
-
 // TRUE after a call to completion_matches.
 bool octave_completion_matches_called = false;
 
@@ -129,8 +120,8 @@
 // The filemarker used to separate filenames from subfunction names
 char Vfilemarker = '>';
 
-static void
-do_input_echo (const std::string& input_string)
+void
+octave_base_reader::do_input_echo (const std::string& input_string) const
 {
   int do_echo = CURR_LEXER->reading_script_file ?
     (Vecho_executing_commands & ECHO_SCRIPTS)
@@ -140,7 +131,7 @@
     {
       if (forced_interactive)
         {
-          if (promptflag > 0)
+          if (pflag > 0)
             octave_stdout << command_editor::decode_prompt_string (VPS1);
           else
             octave_stdout << command_editor::decode_prompt_string (VPS2);
@@ -165,8 +156,6 @@
 
   eof = false;
 
-  assert (line_editing);
-
   std::string retval = command_editor::readline (s, eof);
 
   if (! eof && retval.empty ())
@@ -209,7 +198,7 @@
 
   bool history_skip_auto_repeated_debugging_command = false;
 
-  std::string ps = (promptflag > 0) ? VPS1 : VPS2;
+  std::string ps = (pflag > 0) ? VPS1 : VPS2;
 
   std::string prompt = command_editor::decode_prompt_string (ps);
 
@@ -242,19 +231,17 @@
       history_skip_auto_repeated_debugging_command = true;
     }
 
-  current_input_line = retval;
-
-  if (! current_input_line.empty ())
+  if (! retval.empty ())
     {
       if (! history_skip_auto_repeated_debugging_command)
-        command_history::add (current_input_line);
+        command_history::add (retval);
 
-      octave_diary << current_input_line;
+      octave_diary << retval;
 
-      if (current_input_line[current_input_line.length () - 1] != '\n')
+      if (retval[retval.length () - 1] != '\n')
         octave_diary << "\n";
 
-      do_input_echo (current_input_line);
+      do_input_echo (retval);
     }
   else
     octave_diary << "\n";
@@ -560,11 +547,7 @@
 
   eof = false;
 
-  std::string retval = octave_gets (eof);
-
-  current_input_line = retval;
-
-  return retval;
+  return octave_gets (eof);
 }
 
 const std::string octave_file_reader::in_src ("file");
@@ -576,11 +559,7 @@
 
   eof = false;
 
-  std::string retval = octave_fgets (file, eof);
-
-  current_input_line = retval;
-
-  return retval;
+  return octave_fgets (file, eof);
 }
 
 const std::string octave_eval_string_reader::in_src ("eval_string");
@@ -603,8 +582,6 @@
   if (retval.empty ())
     eof = true;
 
-  current_input_line = retval;
-
   return retval;
 }
 
--- a/libinterp/interpfcn/input.h	Thu Mar 07 10:23:02 2013 -0500
+++ b/libinterp/interpfcn/input.h	Thu Mar 07 10:25:39 2013 -0500
@@ -37,21 +37,12 @@
 
 extern OCTINTERP_API FILE *get_input_from_stdin (void);
 
-// TRUE means that stdin is a terminal, not a pipe or redirected file.
-extern bool stdin_is_tty;
-
 // TRUE means this is an interactive shell.
 extern bool interactive;
 
 // TRUE means the user forced this shell to be interactive (-i).
 extern bool forced_interactive;
 
-// Should we issue a prompt?
-extern int promptflag;
-
-// A line of input.
-extern std::string current_input_line;
-
 // TRUE after a call to completion_matches.
 extern bool octave_completion_matches_called;
 
@@ -91,7 +82,7 @@
 
   friend class octave_input_reader;
 
-  octave_base_reader (void) : count (1) { }
+  octave_base_reader (void) : count (1), pflag (0) { }
 
   octave_base_reader (const octave_base_reader&) : count (1) { }
 
@@ -101,12 +92,31 @@
 
   virtual std::string input_source (void) const { return in_src; }
 
+  void reset (void) { promptflag (1); }
+
+  void increment_promptflag (void) { pflag++; }
+
+  void decrement_promptflag (void) { pflag--; }
+
+  int promptflag (void) const { return pflag; }
+
+  int promptflag (int n)
+  {
+    int retval = pflag;
+    pflag = n;
+    return retval;
+  }
+
   std::string octave_gets (bool& eof);
 
 private:
 
   int count;
 
+  int pflag;
+
+  void do_input_echo (const std::string&) const;
+
   static const std::string in_src;
 };
 
@@ -204,6 +214,16 @@
       delete rep;
   }
 
+  void reset (void) { return rep->reset (); }
+
+  void increment_promptflag (void) { rep->increment_promptflag (); }
+
+  void decrement_promptflag (void) { rep->decrement_promptflag (); }
+
+  int promptflag (void) const { return rep->promptflag (); }
+
+  int promptflag (int n) { return rep->promptflag (n); }
+
   std::string get_input (bool& eof)
   {
     return rep->get_input (eof);
--- a/libinterp/octave.cc	Thu Mar 07 10:23:02 2013 -0500
+++ b/libinterp/octave.cc	Thu Mar 07 10:25:39 2013 -0500
@@ -98,6 +98,10 @@
 // The last component of octave_program_invocation_name.
 static std::string octave_program_name;
 
+// TRUE means we are using readline.
+// (--no-line-editing)
+static bool line_editing = true;
+
 // TRUE means we read ~/.octaverc and ./.octaverc.
 // (--norc; --no-init-file; -f)
 static bool read_init_files = true;
@@ -901,7 +905,7 @@
 
   // If stdin is not a tty, then we are reading commands from a pipe or
   // a redirected file.
-  stdin_is_tty = gnulib::isatty (fileno (stdin));
+  bool stdin_is_tty = gnulib::isatty (fileno (stdin));
 
   interactive = (! embedded && stdin_is_tty
                  && gnulib::isatty (fileno (stdout)));
--- a/libinterp/parse-tree/lex.h	Thu Mar 07 10:23:02 2013 -0500
+++ b/libinterp/parse-tree/lex.h	Thu Mar 07 10:25:39 2013 -0500
@@ -179,9 +179,10 @@
       bracketflag (0), braceflag (0),
       looping (0), defining_func (0), looking_at_function_handle (0),
       block_comment_nesting_level (0), token_count (0),
-      help_text (), fcn_file_name (), fcn_file_full_name (),
-      looking_at_object_index (), parsed_function_name (),
-      pending_local_variables (), nesting_level (), token_stack ()
+      current_input_line (), help_text (), fcn_file_name (),
+      fcn_file_full_name (), looking_at_object_index (),
+      parsed_function_name (), pending_local_variables (),
+      nesting_level (), token_stack ()
   {
     init ();
   }
@@ -295,6 +296,9 @@
   // since the last reset.
   size_t token_count;
 
+  // The current line of input.
+  std::string current_input_line;
+
   // The current help text.
   std::string help_text;
 
@@ -500,6 +504,14 @@
 
   octave_input_reader input_reader;
 
+  void increment_promptflag (void) { input_reader.increment_promptflag (); }
+
+  void decrement_promptflag (void) { input_reader.decrement_promptflag (); }
+
+  int promptflag (void) const { return input_reader.promptflag (); }
+
+  int promptflag (int n) { return input_reader.promptflag (n); }
+
   std::string input_source (void) const
   {
     return input_reader.input_source ();
--- a/libinterp/parse-tree/lex.ll	Thu Mar 07 10:23:02 2013 -0500
+++ b/libinterp/parse-tree/lex.ll	Thu Mar 07 10:25:39 2013 -0500
@@ -538,7 +538,7 @@
     else
       curr_lexer->looking_at_matrix_or_assign_lhs = true;
 
-    promptflag--;
+    curr_lexer->decrement_promptflag ();
     curr_lexer->eat_whitespace ();
 
     curr_lexer->bracketflag++;
@@ -602,7 +602,7 @@
     if (yytext[0] == '\\')
       curr_lexer->gripe_matlab_incompatible_continuation ();
     curr_lexer->scan_for_comments (yytext);
-    promptflag--;
+    curr_lexer->decrement_promptflag ();
     curr_lexer->input_line_number++;
     curr_lexer->current_input_column = 1;
   }
@@ -781,7 +781,7 @@
     curr_lexer->input_line_number++;
     curr_lexer->current_input_column = 1;
     curr_lexer->block_comment_nesting_level++;
-    promptflag--;
+    curr_lexer->decrement_promptflag ();
 
     bool eof = false;
     curr_lexer->process_comment (true, eof);
@@ -852,7 +852,7 @@
     curr_lexer->at_beginning_of_statement = false;
 
     curr_lexer->nesting_level.paren ();
-    promptflag--;
+    curr_lexer->decrement_promptflag ();
 
     TOK_RETURN ('(');
   }
@@ -920,7 +920,7 @@
     curr_lexer->looking_for_object_index = false;
     curr_lexer->at_beginning_of_statement = false;
 
-    promptflag--;
+    curr_lexer->decrement_promptflag ();
     curr_lexer->eat_whitespace ();
 
     curr_lexer->braceflag++;
@@ -1339,6 +1339,7 @@
   looking_at_function_handle = 0;
   block_comment_nesting_level = 0;
   token_count = 0;
+  current_input_line = "";
   help_text = "";
   fcn_file_name = "";
   fcn_file_full_name = "";
@@ -1447,7 +1448,7 @@
   parser_symtab_context.clear ();
 
   // We do want a prompt by default.
-  promptflag = 1;
+  promptflag (1);
 
   // Only ask for input from stdin if we are expecting interactive
   // input.
@@ -1460,6 +1461,8 @@
             || input_from_eval_string ()))
     yyrestart (stdin, scanner);
 
+  input_reader.reset ();
+
   lexical_feedback::reset ();
 }
 
@@ -1479,8 +1482,8 @@
   if (input_buf.empty ())
     {
       bool eof = false;
-      std::string input = input_reader.get_input (eof);
-      input_buf.fill (input, eof);
+      current_input_line = input_reader.get_input (eof);
+      input_buf.fill (current_input_line, eof);
     }
 
   if (! input_buf.empty ())
@@ -1785,25 +1788,25 @@
         case for_kw:
         case parfor_kw:
         case while_kw:
-          promptflag--;
+          decrement_promptflag ();
           looping++;
           break;
 
         case do_kw:
           at_beginning_of_statement = true;
-          promptflag--;
+          decrement_promptflag ();
           looping++;
           break;
 
         case try_kw:
         case unwind_protect_kw:
           at_beginning_of_statement = true;
-          promptflag--;
+          decrement_promptflag ();
           break;
 
         case if_kw:
         case switch_kw:
-          promptflag--;
+          decrement_promptflag ();
           break;
 
         case get_kw:
@@ -1826,7 +1829,7 @@
 
         case classdef_kw:
           // 'classdef' is always a keyword.
-          promptflag--;
+          decrement_promptflag ();
 
           if (! force_script && token_count == 0 && input_from_file ())
             {
@@ -1836,7 +1839,7 @@
           break;
 
         case function_kw:
-          promptflag--;
+          decrement_promptflag ();
 
           defining_func++;
           parsed_function_name.push (false);
@@ -1939,12 +1942,12 @@
                         if (type == '{')
                           {
                             block_comment_nesting_level++;
-                            promptflag--;
+                            decrement_promptflag ();
                           }
                         else
                           {
                             block_comment_nesting_level--;
-                            promptflag++;
+                            increment_promptflag ();
 
                             if (block_comment_nesting_level == 0)
                               {
@@ -2047,7 +2050,7 @@
                         done = true;
 
                         block_comment_nesting_level++;
-                        promptflag--;
+                        decrement_promptflag ();
 
                         buf += grab_block_comment (reader, eof);
 
@@ -2647,7 +2650,7 @@
               octave_comment_buffer::append (comment_buf);
             }
           current_input_column = 0;
-          promptflag--;
+          decrement_promptflag ();
           gripe_matlab_incompatible_continuation ();
           return true;
 
--- a/libinterp/parse-tree/oct-parse.in.yy	Thu Mar 07 10:23:02 2013 -0500
+++ b/libinterp/parse-tree/oct-parse.in.yy	Thu Mar 07 10:25:39 2013 -0500
@@ -97,10 +97,6 @@
 #define malloc GNULIB_NAMESPACE::malloc
 #endif
 
-// TRUE means we are using readline.
-// (--no-line-editing)
-bool line_editing = true;
-
 // TRUE means we printed messages about reading startup files.
 bool reading_startup_message_printed = false;
 
@@ -344,7 +340,6 @@
 input           : input1
                   {
                     curr_parser.stmt_list = $1;
-                    promptflag = 1;
                     YYACCEPT;
                   }
                 | simple_list parse_error
@@ -3366,16 +3361,18 @@
 
   output_buf << "\n\n";
 
-  if (! current_input_line.empty ())
+  std::string curr_line = curr_lexer->current_input_line;
+
+  if (! curr_line.empty ())
     {
-      size_t len = current_input_line.length ();
-
-      if (current_input_line[len-1] == '\n')
-        current_input_line.resize (len-1);
+      size_t len = curr_line.length ();
+
+      if (curr_line[len-1] == '\n')
+        curr_line.resize (len-1);
 
       // Print the line, maybe with a pointer near the error token.
 
-      output_buf << ">>> " << current_input_line << "\n";
+      output_buf << ">>> " << curr_line << "\n";
 
       if (err_col == 0)
         err_col = len;
@@ -3425,10 +3422,6 @@
 
   frame.add_fcn (command_editor::set_input_stream, in_stream);
 
-  frame.protect_var (line_editing);
-
-  line_editing = false;
-
   frame.add_fcn (command_history::ignore_entries,
                  command_history::ignoring_entries ());
 
@@ -4167,10 +4160,6 @@
 
   octave_parser curr_parser (eval_str);
 
-  frame.protect_var (line_editing);
-
-  line_editing = false;
-
   do
     {
       curr_parser.reset ();
--- a/libinterp/parse-tree/parse.h	Thu Mar 07 10:23:02 2013 -0500
+++ b/libinterp/parse-tree/parse.h	Thu Mar 07 10:25:39 2013 -0500
@@ -83,9 +83,6 @@
 // Nonzero means print parser debugging info (-d).
 extern int octave_debug;
 
-// TRUE means we are using readline.
-extern bool line_editing;
-
 // TRUE means we printed messages about reading startup files.
 extern bool reading_startup_message_printed;