# HG changeset patch # User jwe # Date 1034369841 0 # Node ID ea537559ab070bf4d0f473878cc8faae80256efe # Parent ed0090ecf80f3191e2b83778a311705895218f83 [project @ 2002-10-11 20:57:21 by jwe] diff -r ed0090ecf80f -r ea537559ab07 ChangeLog --- a/ChangeLog Fri Oct 11 16:37:45 2002 +0000 +++ b/ChangeLog Fri Oct 11 20:57:21 2002 +0000 @@ -1,3 +1,8 @@ +2002-10-11 John W. Eaton + + * configure.in (AH_BOTTOM): Maybe define OCTAVE_USE_WINDOWS_API + and OCTAVE_HAVE_WINDOWS_FILESYSTEM. + 2002-10-09 John W. Eaton * aclocal.m4 (OCTAVE_PROG_GNUPLOT): AC_DEFINE GNUPLOT_BINARY diff -r ed0090ecf80f -r ea537559ab07 configure.in --- a/configure.in Fri Oct 11 16:37:45 2002 +0000 +++ b/configure.in Fri Oct 11 20:57:21 2002 +0000 @@ -22,7 +22,7 @@ ### 02111-1307, USA. AC_INIT -AC_REVISION($Revision: 1.374 $) +AC_REVISION($Revision: 1.375 $) AC_PREREQ(2.52) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER(config.h) @@ -1288,6 +1288,20 @@ #if !defined(HAVE_SIGSET_T) typedef int sigset_t; #endif + +#define OCTAVE_HAVE_POSIX_FILESYSTEM 1 + +#if defined (__WIN32__) +#define OCTAVE_HAVE_WINDOWS_FILESYSTEM 1 +#if ! defined (__CYGWIN__) +#undef OCTAVE_HAVE_POSIX_FILESYSTEM +#endif +#endif + +/* Define if we expect to have , Sleep, etc. */ +#if defined (__WIN32__) || ! defined (__CYGWIN__) +#define OCTAVE_USE_WINDOWS_API 1 +#endif ]) ### Do the substitutions in all the Makefiles. diff -r ed0090ecf80f -r ea537559ab07 liboctave/ChangeLog --- a/liboctave/ChangeLog Fri Oct 11 16:37:45 2002 +0000 +++ b/liboctave/ChangeLog Fri Oct 11 20:57:21 2002 +0000 @@ -1,3 +1,29 @@ +2002-10-11 John W. Eaton + + * oct-time.cc: Use OCTAVE_USE_WINDOWS_API instead of __WIN32__ and + __CYGWIN__. + + * file-ops.cc (file_ops::dir_sep_char, file_ops::dir_sep_str, + file_ops::dir_sep_chars): New static functions to replace + OCTAVE_DIR_SEP_CHAR, OCTAVE_DIR_SEP_STR, OCTAVE_DIR_SEP_CHARS. + + * oct-env.cc (octave_env::do_set_program_name): + Use file_ops::dir_sep_chars instead of OCTAVE_DIR_SEP_CHARS. + (octave_env::do_base_pathname): Likewise. + (octave_env::do_make_absolute): Likewise. + + * oct-env.cc (octave_env::do_make_absolute): + Use file_ops::dir_sep_str instead of OCTAVE_DIR_SEP_STR. + (octave_env::do_get_home_directory): Likewise. + + * file-ops.cc (is_dir_sep): Use dir_sep_chars instead of embedding + that information here too. + (tilde_find_suffix, isolate_tilde_prefix, tilde_expand_word): + Use file_ops::dir_sep_char instead of OCTAVE_DIR_SEP_CHAR. + + * file-ops.h: Use OCTAVE_HAVE_WINDOWS_FILESYSTEM and + OCTAVE_HAVE_POSIX_FILESYSTEM instead of __WIN32__ and __CYGWIN__. + 2002-10-09 John W. Eaton * oct-env.h (octave_env::current_directory): Now mutable. diff -r ed0090ecf80f -r ea537559ab07 liboctave/file-ops.cc --- a/liboctave/file-ops.cc Fri Oct 11 16:37:45 2002 +0000 +++ b/liboctave/file-ops.cc Fri Oct 11 20:57:21 2002 +0000 @@ -49,6 +49,22 @@ #define NOT_SUPPORTED(nm) \ nm ": not supported on this system" +#if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \ + && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)) +char file_ops::dir_sep_char = '\\'; +std::string file_ops::dir_sep_str ("\\"); +#else +char file_ops::dir_sep_char = '/'; +std::string file_ops::dir_sep_str ("/"); +#endif + +#if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \ + && defined (OCTAVE_HAVE_POSIX_FILESYSTEM)) +std::string file_ops::dir_sep_chars ("/\\"); +#else +std::string file_ops::dir_sep_chars (file_ops::dir_sep_str); +#endif + // We provide a replacement for mkdir(). int @@ -324,9 +340,6 @@ // The following tilde-expansion code was stolen and adapted from // readline. -// XXX FIXME XXX -#define DIR_SEP_CHAR '/' - // The default value of tilde_additional_prefixes. This is set to // whitespace preceding a tilde so that simple programs which do not // perform any word separation get desired behaviour. @@ -412,7 +425,7 @@ for ( ; i < s_len; i++) { - if (s[i] == DIR_SEP_CHAR) + if (s[i] == file_ops::dir_sep_char) break; if (! suffixes.empty ()) @@ -439,7 +452,7 @@ size_t len = 1; - while (len < f_len && fname[len] != DIR_SEP_CHAR) + while (len < f_len && fname[len] != file_ops::dir_sep_char) len++; return fname.substr (1, len); @@ -460,7 +473,7 @@ // of $HOME or the home directory of the current user, regardless of // any preexpansion hook. - if (f_len == 1 || filename[1] == DIR_SEP_CHAR) + if (f_len == 1 || filename[1] == file_ops::dir_sep_char) return octave_env::get_home_directory () + filename.substr (1); std::string username = isolate_tilde_prefix (filename); @@ -623,11 +636,7 @@ bool file_ops::is_dir_sep (char c) { -#if defined (__WIN32__) || defined (__CYGWIN__) - return (c == '/' || c == '\\'); -#else - return (c == '/'); -#endif + return dir_sep_chars.find (c) != NPOS; } /* diff -r ed0090ecf80f -r ea537559ab07 liboctave/file-ops.h --- a/liboctave/file-ops.h Fri Oct 11 16:37:45 2002 +0000 +++ b/liboctave/file-ops.h Fri Oct 11 20:57:21 2002 +0000 @@ -78,16 +78,12 @@ static int unlink (const std::string&, std::string&); static bool is_dir_sep (char); + + static char dir_sep_char; + static std::string dir_sep_str; + static std::string dir_sep_chars; }; -#define OCTAVE_DIR_SEP_CHAR '/' -#define OCTAVE_DIR_SEP_STR "/" -#if defined (__WIN32__) || defined (__CYGWIN__) -#define OCTAVE_DIR_SEP_CHARS "/\\" -#else -#define OCTAVE_DIR_SEP_CHARS OCTAVE_DIR_SEP_STR -#endif - #endif /* diff -r ed0090ecf80f -r ea537559ab07 liboctave/oct-env.cc --- a/liboctave/oct-env.cc Fri Oct 11 16:37:45 2002 +0000 +++ b/liboctave/oct-env.cc Fri Oct 11 20:57:21 2002 +0000 @@ -201,7 +201,7 @@ { program_invocation_name = s; - size_t pos = program_invocation_name.find_last_of (OCTAVE_DIR_SEP_CHARS); + size_t pos = program_invocation_name.find_last_of (file_ops::dir_sep_chars); program_name = (pos == NPOS) ? program_invocation_name : program_invocation_name.substr (pos+1); @@ -242,7 +242,7 @@ if (file_ops::is_dir_sep (s[0])) return true; -#if defined (__WIN32__) || defined (__CYGWIN__) +#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) if ((len == 2 && isalpha (s[0]) && s[1] == ':') || (len > 2 && isalpha (s[0]) && s[1] == ':' && file_ops::is_dir_sep (s[2]))) @@ -262,7 +262,7 @@ if (! do_absolute_pathname (s)) return s; - size_t pos = s.find_last_of (OCTAVE_DIR_SEP_CHARS); + size_t pos = s.find_last_of (file_ops::dir_sep_chars); if (pos == NPOS) return s; @@ -293,7 +293,7 @@ size_t pos = current_dir.length () - 1; if (! file_ops::is_dir_sep (current_dir[pos])) - current_dir.append (OCTAVE_DIR_SEP_STR); + current_dir.append (file_ops::dir_sep_str); // XXX FIXME XXX -- this is probably not correct for all systems. @@ -327,7 +327,7 @@ } } - size_t tmp = s.find_first_of (OCTAVE_DIR_SEP_CHARS, i); + size_t tmp = s.find_first_of (file_ops::dir_sep_chars, i); if (tmp == NPOS) { @@ -370,7 +370,7 @@ { octave_passwd pw = octave_passwd::getpwuid (octave_syscalls::getuid ()); - hd = pw ? pw.dir () : std::string (OCTAVE_DIR_SEP_STR); + hd = pw ? pw.dir () : std::string (file_ops::dir_sep_str); } return hd; diff -r ed0090ecf80f -r ea537559ab07 liboctave/oct-time.cc --- a/liboctave/oct-time.cc Fri Oct 11 16:37:45 2002 +0000 +++ b/liboctave/oct-time.cc Fri Oct 11 20:57:21 2002 +0000 @@ -34,7 +34,7 @@ #include #endif -#if defined (__WIN32__) && ! defined (HAVE_GETTIMEOFDAY) +#if defined (OCTAVE_USE_WINDOWS_API) #include #endif @@ -93,7 +93,7 @@ ot_unix_time = tp.tv_sec; ot_usec = tp.tv_usec; -#elif defined (__WIN32__) +#elif defined (OCTAVE_USE_WINDOWS_API) // Loosely based on the code from Cygwin // Copyright 1996-2002 Red Hat, Inc. diff -r ed0090ecf80f -r ea537559ab07 src/ChangeLog --- a/src/ChangeLog Fri Oct 11 16:37:45 2002 +0000 +++ b/src/ChangeLog Fri Oct 11 20:57:21 2002 +0000 @@ -1,5 +1,18 @@ 2002-10-11 John W. Eaton + * lex.l (handle_identifier): Don't enter token in local symbol + table if the following token is a dot and it looks like a binary + operator. + (force_local_variable): If name is not a variable, clear it before + defining. + + * oct-procbuf.cc (Vkluge_procbuf_delay): Make default 0 for all + systems. + + * octave.cc (execute_startup_files, initialize_pathsearch): + Use file_ops::dir_sep_str instead of OCTAVE_DIR_SEP_STR. + (main): Use file_ops::dir_sep_chars instead of OCTAVE_DIR_SEP_CHARS. + * ov-re-mat.cc (octave_matrix::convert_to_str): Warn for out of range conversions. For negative values, set to 0. * ov-scalar.cc (octave_scalar:convert_to_str): Likewise. diff -r ed0090ecf80f -r ea537559ab07 src/file-io.cc --- a/src/file-io.cc Fri Oct 11 16:37:45 2002 +0000 +++ b/src/file-io.cc Fri Oct 11 20:57:21 2002 +0000 @@ -1137,7 +1137,7 @@ The default precision is @code{\"uchar\"}.\n\ \n\ The optional argument @var{skip} specifies the number of bytes to skip\n\ -before each element is read. If it is not specified, a value of 0 is\n\ +after each element is read. If it is not specified, a value of 0 is\n\ assumed.\n\ \n\ The optional argument @var{arch} is a string specifying the data format\n\ diff -r ed0090ecf80f -r ea537559ab07 src/lex.l --- a/src/lex.l Fri Oct 11 16:37:45 2002 +0000 +++ b/src/lex.l Fri Oct 11 20:57:21 2002 +0000 @@ -1247,6 +1247,9 @@ static void force_local_variable (const std::string& name) { + if (! is_variable (name)) + curr_sym_tab->clear (name); + symbol_record *sr = curr_sym_tab->lookup (name, true); if (sr) @@ -2313,7 +2316,6 @@ int c1 = yyinput (); - bool next_tok_is_dot = (c1 == '.'); bool next_tok_is_paren = (c1 == '('); bool next_tok_is_eq = false; @@ -2356,8 +2358,7 @@ if (next_tok_is_eq || lexer_flags.looking_at_return_list || lexer_flags.looking_at_parameter_list - || lexer_flags.looking_at_matrix_or_assign_lhs - || (next_tok_is_dot && next_token_is_bin_op (spc_gobbled))) + || lexer_flags.looking_at_matrix_or_assign_lhs) { force_local_variable (tok); } diff -r ed0090ecf80f -r ea537559ab07 src/oct-procbuf.cc --- a/src/oct-procbuf.cc Fri Oct 11 16:37:45 2002 +0000 +++ b/src/oct-procbuf.cc Fri Oct 11 20:57:21 2002 +0000 @@ -46,11 +46,7 @@ #include "utils.h" // Number of microseconds to delay in the parent after forking. -#if defined (__CYGWIN32__) -static int Vkluge_procbuf_delay = 500000; -#else static int Vkluge_procbuf_delay = 0; -#endif // This class is based on the procbuf class from libg++, written by // Per Bothner, Copyright (C) 1993 Free Software Foundation. diff -r ed0090ecf80f -r ea537559ab07 src/octave.cc --- a/src/octave.cc Fri Oct 11 16:37:45 2002 +0000 +++ b/src/octave.cc Fri Oct 11 20:57:21 2002 +0000 @@ -191,8 +191,8 @@ odb = octave_env::getenv ("OCTAVE_DB_DIR"); if (odb.empty ()) - odb = Vdata_dir + OCTAVE_DIR_SEP_STR + "octave:" - + Vlibexec_dir + OCTAVE_DIR_SEP_STR + "octave"; + odb = Vdata_dir + file_ops::dir_sep_str + "octave:" + + Vlibexec_dir + file_ops::dir_sep_str + "octave"; octave_original_texmfdbs = octave_env::getenv ("TEXMFDBS"); @@ -242,9 +242,9 @@ std::string home_dir = octave_env::get_home_directory (); - std::string home_rc = home_dir + OCTAVE_DIR_SEP_STR + initfile; + std::string home_rc = home_dir + file_ops::dir_sep_str + initfile; std::string local_rc - = octave_env::getcwd () + OCTAVE_DIR_SEP_STR + initfile; + = octave_env::getcwd () + file_ops::dir_sep_str + initfile; if (! home_dir.empty ()) { @@ -539,7 +539,8 @@ bind_builtin_variable ("program_invocation_name", curr_fcn_file_name); - size_t pos = curr_fcn_file_name.find_last_of (OCTAVE_DIR_SEP_CHARS); + size_t pos + = curr_fcn_file_name.find_last_of (file_ops::dir_sep_chars); std::string tmp = (pos != NPOS) ? curr_fcn_file_name.substr (pos+1) : curr_fcn_file_name;