Mercurial > hg > octave-lojdl
changeset 984:6aeb8fdc27d4
[project @ 1994-12-14 17:51:23 by jwe]
author | jwe |
---|---|
date | Wed, 14 Dec 1994 17:52:04 +0000 |
parents | 3611f5b12826 |
children | 4b483cf9f6b0 |
files | src/load-save.cc src/octave.cc src/user-prefs.cc src/user-prefs.h src/variables.cc |
diffstat | 5 files changed, 49 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- 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) {
--- 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;
--- 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; }
--- 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);
--- 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,