# HG changeset patch # User jwe # Date 787427524 0 # Node ID 6aeb8fdc27d48be950c2acbc28ea830134d93e2a # Parent 3611f5b128263973bf527e9c1ead4a9b3073dc2a [project @ 1994-12-14 17:51:23 by jwe] diff --git a/src/load-save.cc b/src/load-save.cc --- a/src/load-save.cc +++ b/src/load-save.cc @@ -1923,9 +1923,7 @@ { load_save_format retval = LS_UNKNOWN; - ifstream file; - - file.open (fname); + ifstream file (fname); if (! file) { diff --git a/src/octave.cc b/src/octave.cc --- a/src/octave.cc +++ b/src/octave.cc @@ -568,7 +568,9 @@ } else if (remaining_args == 1) { - FILE *infile = get_input_from_file (argv[optind]); + reading_script_file = 1; + curr_fcn_file_name = argv[optind]; + FILE *infile = get_input_from_file (curr_fcn_file_name); if (infile) { rl_blink_matching_paren = 0; diff --git a/src/user-prefs.cc b/src/user-prefs.cc --- a/src/user-prefs.cc +++ b/src/user-prefs.cc @@ -43,7 +43,7 @@ init_user_prefs (void) { user_pref.automatic_replot = 0; - user_pref.commas_in_literal_matrix = 0; + user_pref.whitespace_in_literal_matrix = 0; user_pref.do_fortran_indexing = 0; user_pref.empty_list_elements_ok = 0; user_pref.ignore_function_time_stamp = 0; @@ -116,18 +116,24 @@ } -// Should commas be required to separate elements in a literal matrix -// list? +// Should whitespace in a literal matrix list be automatically +// converted to commas and semicolons? // // user specifies value of pref // -------------- ------------- -// "required" 2 +// "ignored" 2 // "traditional" 1 // anything else 0 // // Octave will never insert a comma in a literal matrix list if the -// user specifies "required". For example, the statement [1 2] will -// result in an error instead of being treated the same as [1, 2]. +// user specifies "ignored". For example, the statement [1 2] will +// result in an error instead of being treated the same as [1, 2], and +// the statement +// +// [ 1, 2, +// 3, 4 ] +// +// will result in the vector [1 2 3 4] instead of a matrix. // // Traditional behavior makes Octave convert spaces to a comma between // identifiers and `('. For example, the statement @@ -151,18 +157,18 @@ // will result in a call to `eye' with the argument `2'. int -commas_in_literal_matrix (void) +whitespace_in_literal_matrix (void) { int pref = 0; - char *val = builtin_string_variable ("commas_in_literal_matrix"); + char *val = builtin_string_variable ("whitespace_in_literal_matrix"); if (val) { - if (strncmp (val, "required", 8) == 0) + if (strncmp (val, "ignore", 6) == 0) pref = 2; else if (strncmp (val, "traditional", 11) == 0) pref = 1; } - user_pref.commas_in_literal_matrix = pref; + user_pref.whitespace_in_literal_matrix = pref; return 0; } diff --git a/src/user-prefs.h b/src/user-prefs.h --- a/src/user-prefs.h +++ b/src/user-prefs.h @@ -27,7 +27,7 @@ struct user_preferences { int automatic_replot; - int commas_in_literal_matrix; + int whitespace_in_literal_matrix; int do_fortran_indexing; int empty_list_elements_ok; int ignore_function_time_stamp; @@ -68,7 +68,7 @@ extern void init_user_prefs (void); extern int automatic_replot (void); -extern int commas_in_literal_matrix (void); +extern int whitespace_in_literal_matrix (void); extern int do_fortran_indexing (void); extern int empty_list_elements_ok (void); extern int ignore_function_time_stamp (void); diff --git a/src/variables.cc b/src/variables.cc --- a/src/variables.cc +++ b/src/variables.cc @@ -505,21 +505,38 @@ int c; while ((c = getc (ffile)) != EOF) { + current_input_column++; if (in_comment) { if (c == '\n') - in_comment = 0; + { + input_line_number++; + current_input_column = 0; + in_comment = 0; + } } else { - if (c == ' ' || c == '\t' || c == '\n') - continue; - else if (c == '%' || c == '#') - in_comment = 1; - else + switch (c) { + case ' ': + case '\t': + break; + + case '\n': + input_line_number++; + current_input_column = 0; + continue; + + case '%': + case '#': + in_comment = 1; + break; + + default: + current_input_column--; ungetc (c, ffile); - break; + return; } } } @@ -1397,9 +1414,9 @@ 0, 0, 1, automatic_replot, "if true, auto-insert a replot command when a plot changes"); - DEFVAR ("commas_in_literal_matrix", SBV_commas_in_literal_matrix, "", - 0, 0, 1, commas_in_literal_matrix, - "control auto-insertion of commas in literal matrices"); + DEFVAR ("whitespace_in_literal_matrix", SBV_whitespace_in_literal_matrix, "", + 0, 0, 1, whitespace_in_literal_matrix, + "control auto-insertion of commas and semicolons in literal matrices"); DEFVAR ("default_save_format", SBV_default_save_format, "ascii", 0, 0, 1, sv_default_save_format,