# HG changeset patch # User Kai T. Ohlhus # Date 1635734168 -32400 # Node ID 38ee67b5ec9f95f8a710b76879ed837d87915eb9 # Parent 3c60814448ea063ab891c8d89267264448bd3f49 input.cc: throw error if second argument does not equal 's' Same behavior with Matlab R2021a and is indeed confusing for users coming from the C-programming language. See for example Octave Discourse https://octave.discourse.group/t/calling-the-input-function-with-two-arguments/1749 diff -r 3c60814448ea -r 38ee67b5ec9f libinterp/corefcn/input.cc --- a/libinterp/corefcn/input.cc Sun Oct 31 18:25:33 2021 +0100 +++ b/libinterp/corefcn/input.cc Mon Nov 01 11:36:08 2021 +0900 @@ -695,12 +695,18 @@ { octave_value_list retval; - int read_as_string = 0; + std::string prompt = args(0).xstring_value ("input: unrecognized argument"); - if (args.length () == 2) - read_as_string++; + bool read_as_string = false; + if (args.length () == 2) // `input (..., "s")`? + { + std::string literal + = args(1).xstring_value ("input: second argument must be 's'."); + if (literal.length () != 1 || literal[0] != 's') + error ("input: second argument must be 's'."); - std::string prompt = args(0).xstring_value ("input: unrecognized argument"); + read_as_string = true; + } output_system& output_sys = m_interpreter.get_output_system ();