|
View:
New views
15 Messages
—
Rating Filter:
Alert me
|
|
|
windows native Octave-2.9.9+ does not read ./.octaverc at startupHi list,
I have installed michael's Octave 2.9.9+ windows binary from http://www.dbateman.org/?page=octave&lang=EN and found, that at startup octave does not load a .octaverc file in the current directory. The startup file in the home directory and the system-wide startup files are loaded. I do not see this behaviour with version 2.9.9 under linux&cygwin and neither with 2.9.10 under cygwin, so i guess this is a bug in the windows port? I am testing this on a P4 w2k sp4 machine. regards benjamin -- "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startupBenjamin Lindner wrote:
> Hi list, > > I have installed michael's Octave 2.9.9+ windows binary from > http://www.dbateman.org/?page=octave&lang=EN and found, that at > startup octave does not load a .octaverc file in the current directory. > The startup file in the home directory and the system-wide startup files > are loaded. > I do not see this behaviour with version 2.9.9 under linux&cygwin and > neither with 2.9.10 under cygwin, so i guess this is a bug in the windows > port? > > I am testing this on a P4 w2k sp4 machine. > > regards > benjamin I don't think .octaverc in the current directory should ever be run on start-up. The matlab compatible behavior would be run the system wide ones (global + site) then the one in the users directory, and then finally any startup.m file in the current directory. I don't thing octave looks for a startup.m file in the current directory at the moment. Regards David _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startup> Benjamin Lindner wrote: > > Hi list, > > > > I have installed michael's Octave 2.9.9+ windows binary from > > http://www.dbateman.org/?page=octave&lang=EN and found, that at > > startup octave does not load a .octaverc file in the current directory. > > The startup file in the home directory and the system-wide startup files > > are loaded. > > I do not see this behaviour with version 2.9.9 under linux&cygwin and > > neither with 2.9.10 under cygwin, so i guess this is a bug in the > windows > > port? > > > > I am testing this on a P4 w2k sp4 machine. > > > > regards > > benjamin > > I don't think .octaverc in the current directory should ever be run on > start-up. The matlab compatible behavior would be run the system wide > ones (global + site) then the one in the users directory, and then > finally any startup.m file in the current directory. > > I don't thing octave looks for a startup.m file in the current directory > at the moment. Well, the manual states: When Octave starts, it looks for commands to execute from the following files: octave-home/share/octave/site/m/startup/octaverc octave-home/share/octave/version/m/startup/octaverc ~/.octaverc .octaverc so I would assume, that octave does load a .octaverc in the current directory. (Yes, I checked that after executing ~/.octaverc the pwd is still the one Octave was started in, so the .octaverc file should be found) I would also not like to see such behaviour abandoned just because the other party names their startup files differently. If required, then octave could also check and execute a startup.m file, but why throw away useful features and break compatibility to oneself? (BTW, setting the envireonment variable OCTAVE_INITFILE to "startup.m" would get you the other party's behaviour anyway...) I had a look at the execute_startup_files (void) function in octave.cc. I found nothing suspicious that would work not under win32 except the line if (fs_dot_rc && fs_home_rc.ino () == fs_dot_rc.ino ()) home_rc_already_executed = true; I guess this should read if (fs_dot_rc && (fs_home_rc.ino () == fs_dot_rc.ino ()) ) home_rc_already_executed = true; but I do not see why MSVC should interpret this differently from gcc? I do not have a MSVC build environment at hand, so i cannot check. benjamin -- "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startup> Hi list,
> > I have installed michael's Octave 2.9.9+ windows binary from > http://www.dbateman.org/?page=octave&lang=EN and found, that at > startup octave does not load a .octaverc file in the current directory. > The startup file in the home directory and the system-wide startup files > are loaded. > I do not see this behaviour with version 2.9.9 under linux&cygwin and > neither with 2.9.10 under cygwin, so i guess this is a bug in the windows > port? > > I am testing this on a P4 w2k sp4 machine. I think I found the bug striking on windows native builds. In octave.cc in function execute_startup_files (void) line 343 reads if (fs_dot_rc && fs_home_rc.ino () == fs_dot_rc.ino ()) home_rc_already_executed = true; Now in windows inode numbers returned by stat() are always set to 0, so the comparison of the inode numbers of two different files will always return TRUE. in octave 2.9.10 (cygwin) > s1=stat("~/.octaverc"); s2=stat("/cygdrive/c/Userdata/.octaverc"); s1.ino==s2.ino ans = 0 in octave 2.9.9+ (windows build) > s1=stat("~\\.octaverc"); s2=stat("c:\\Userdata\\.octaverc"); s1.ino==s2.ino ans = 1 So the startup code will always assume that ~/.octaverc and $OCTAVE_INITFILE in the current directory are the same file and will therefore not load the local startup file. benjamin -- "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startupBenjamin Lindner wrote:
>> Benjamin Lindner wrote: >> >>> Hi list, >>> >>> I have installed michael's Octave 2.9.9+ windows binary from >>> http://www.dbateman.org/?page=octave&lang=EN and found, that at >>> startup octave does not load a .octaverc file in the current directory. >>> The startup file in the home directory and the system-wide startup files >>> are loaded. >>> I do not see this behaviour with version 2.9.9 under linux&cygwin and >>> neither with 2.9.10 under cygwin, so i guess this is a bug in the >>> >> windows >> >>> port? >>> >>> I am testing this on a P4 w2k sp4 machine. >>> >>> regards >>> benjamin >>> >> I don't think .octaverc in the current directory should ever be run on >> start-up. The matlab compatible behavior would be run the system wide >> ones (global + site) then the one in the users directory, and then >> finally any startup.m file in the current directory. >> >> I don't thing octave looks for a startup.m file in the current directory >> at the moment. >> > > Well, the manual states: > When Octave starts, it looks for commands to execute from the following files: > octave-home/share/octave/site/m/startup/octaverc > octave-home/share/octave/version/m/startup/octaverc > ~/.octaverc > .octaverc > > so I would assume, that octave does load a .octaverc in the current directory. > (Yes, I checked that after executing ~/.octaverc the pwd is still the one > Octave was started in, so the .octaverc file should be found) > > I would also not like to see such behaviour abandoned just because the other party names their startup files differently. > If required, then octave could also check and execute a startup.m file, > but why throw away useful features and break compatibility to oneself? > (BTW, setting the envireonment variable OCTAVE_INITFILE to "startup.m" would get you the other party's behaviour anyway...) > when the desired behavior is really ~/.octaverc `pwd`/startup.m to be matlab compatible. Unfortunately, many of us have to share our code with matlab users whether we like it or not, and so having octave's behavior as close as possible to "the other party's" is highly desirable. Sure supporting .octaverc and startup.m in the local directory makes sense. Regards David -- David Bateman David.Bateman@... Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob) 91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax) The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startupOn 12-Apr-2007, Benjamin Lindner wrote:
| > Hi list, | > | > I have installed michael's Octave 2.9.9+ windows binary from | > http://www.dbateman.org/?page=octave&lang=EN and found, that at | > startup octave does not load a .octaverc file in the current directory. | > The startup file in the home directory and the system-wide startup files | > are loaded. | > I do not see this behaviour with version 2.9.9 under linux&cygwin and | > neither with 2.9.10 under cygwin, so i guess this is a bug in the windows | > port? | > | > I am testing this on a P4 w2k sp4 machine. | | I think I found the bug striking on windows native builds. | In octave.cc in function execute_startup_files (void) line 343 reads | if (fs_dot_rc && fs_home_rc.ino () == fs_dot_rc.ino ()) | home_rc_already_executed = true; | | Now in windows inode numbers returned by stat() are always set to 0, so | the comparison of the inode numbers of two different files will always | return TRUE. On a Windows system, what is the proper way to tell whether to files are the same? jwe _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startupOn 12-Apr-2007, David Bateman wrote:
| Benjamin Lindner wrote: | | > I would also not like to see such behaviour abandoned just because the other party names their startup files differently. | > If required, then octave could also check and execute a startup.m file, | > but why throw away useful features and break compatibility to oneself? | > (BTW, setting the envireonment variable OCTAVE_INITFILE to "startup.m" would get you the other party's behaviour anyway...) | > | No that would make it look for ~/startup.m and then `pwd`/startup.m, | when the desired behavior is really ~/.octaverc `pwd`/startup.m to be | matlab compatible. Unfortunately, many of us have to share our code with | matlab users whether we like it or not, and so having octave's behavior | as close as possible to "the other party's" is highly desirable. Sure | supporting .octaverc and startup.m in the local directory makes sense. According to the Matlab docs: At startup time, MATLAB automatically executes the master M-file matlabrc.m and, if it exists, startup.m. On multiuser or networked systems, matlabrc.m is reserved for use by the system manager. The file matlabrc.m invokes the file startup.m if it exists on the MATLAB search path. [...] Algorithm Only matlabrc is actually invoked by MATLAB at startup. However, matlabrc.m contains the statements if exist('startup') == 2 startup end that invoke startup.m. Extend this process to create additional startup M-files, if required. so it seems that by default it runs the first startup.m script found in the path. In any case, I'm not sure Octave should be running startup.m as that could cause some trouble for Matlab users who have startup.m files that are appropriate for Matlab but might fail in Octave and who are trying Octave for the first time. Do we want the initial reaction of those users to be that Octave can't even start up without an error message? It should not be too hard for experienced users to figure out what to do if they want Octave and Matlab to share a startup file. jwe _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startup> On 12-Apr-2007, Benjamin Lindner wrote:
I am not a expert programmer on windows api, so I did some research at
> > | > Hi list, > | > > | > I have installed michael's Octave 2.9.9+ windows binary from > | > http://www.dbateman.org/?page=octave&lang=EN and found, that at > | > startup octave does not load a .octaverc file in the current > directory. > | > The startup file in the home directory and the system-wide startup > files > | > are loaded. > | > I do not see this behaviour with version 2.9.9 under linux&cygwin and > | > neither with 2.9.10 under cygwin, so i guess this is a bug in the > windows > | > port? > | > > | > I am testing this on a P4 w2k sp4 machine. > | > | I think I found the bug striking on windows native builds. > | In octave.cc in function execute_startup_files (void) line 343 reads > | if (fs_dot_rc && fs_home_rc.ino () == fs_dot_rc.ino ()) > | home_rc_already_executed = true; > | > | Now in windows inode numbers returned by stat() are always set to 0, so > | the comparison of the inode numbers of two different files will always > | return TRUE. > > On a Windows system, what is the proper way to tell whether to files > are the same? MSDN and found the following links http://msdn2.microsoft.com/en-us/library/aa364952.aspx http://msdn2.microsoft.com/en-us/library/aa363788.aspx Here windows fills a Information Structure that contains a volume serial number, and a unique file identifer. In the second link microsoft states that these indicators can be used to determine if two file handles refer to one and the same (pyhsical) file. I created an attached patch for octave.cc, but I do not have the setup to build a octave version using MSVC so this patch is not tested within the octave framework. I verified that the equal_files() function in the patch builds seperately and works correctly. I was not sure what is the correct preprocessor macro to check for to indicate a windows build. I looked in the config.h header and found the OCTAVE_USE_WINDOWS_API, so I used this one. feedback welcome regards benjamin -- "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail --- octave.cc.orig 2007-04-24 10:07:25.878075000 +0200 +++ octave.cc 2007-04-24 12:24:30.250622000 +0200 @@ -76,6 +76,10 @@ #include "variables.h" #include <version.h> +#ifdef OCTAVE_USE_WINDOWS_API +#include <windows.h> +#endif + // Kluge. extern "C" F77_RET_T F77_FUNC (xerbla, XERBLA) (F77_CONST_CHAR_ARG_DECL, const octave_idx_type& @@ -279,6 +283,73 @@ // Initialize by reading startup files. +#ifdef OCTAVE_USE_WINDOWS_API +// Check if thw two file names file1 and file2 refer to the same physical file +// +// Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx +// +// "The identifier (low and high parts) and the volume serial number that +// uniquely identify a file on a single computer. To determine whether two open +// handles represent the same file, combine this identifier and the volume +// serial number for each file and compare them." +// +bool equal_files( const char* file1, const char* file2 ) +{ + HANDLE hfile1; + HANDLE hfile2; + + BY_HANDLE_FILE_INFORMATION fi1; + BY_HANDLE_FILE_INFORMATION fi2; + + hfile1 = CreateFile( file1, // File Name + 0, // desired access: we only want to query, so NULL + FILE_SHARE_READ, // Share access + NULL, // Security Attibutes + OPEN_EXISTING, // Creation Disposition + FILE_ATTRIBUTE_NORMAL, // Flags and Attributes + NULL // Template + ); + + if( hfile1 == INVALID_HANDLE_VALUE ) + return false; + + hfile2 = CreateFile( file2, // File Name + 0, // desired access: we only want to query, so NULL + FILE_SHARE_READ, // Share access + NULL, // Security Attibutes + OPEN_EXISTING, // Creation Disposition + FILE_ATTRIBUTE_NORMAL, // Flags and Attributes + NULL // Template + ); + + if( hfile2 == INVALID_HANDLE_VALUE ) { + CloseHandle(hfile1); + return false; + } + + if( !GetFileInformationByHandle( hfile1, &fi1 ) ) { + CloseHandle(hfile1); + CloseHandle(hfile2); + return false; + } + + if( !GetFileInformationByHandle( hfile2, &fi2 ) ) { + CloseHandle(hfile1); + CloseHandle(hfile2); + return false; + } + + bool are_equal = ( fi1.dwVolumeSerialNumber == fi2.dwVolumeSerialNumber ) && + ( fi1.nFileIndexHigh == fi2.nFileIndexHigh ) && + ( fi1.nFileIndexLow == fi2.nFileIndexLow ); + + CloseHandle(hfile1); + CloseHandle(hfile2); + + return are_equal; +} +#endif + static void execute_startup_files (void) { @@ -337,11 +408,16 @@ std::string curr_dir = octave_env::getcwd (); local_rc = octave_env::make_absolute (initfile, curr_dir); + #ifdef OCTAVE_USE_WINDOWS_API + // Windows requires special treatments, since there is no such thing as inode numbers + home_rc_already_executed = equal_files( local_rc.c_str(), home_rc.c_str() ); + #else file_stat fs_dot_rc (local_rc); if (fs_dot_rc && fs_home_rc.ino () == fs_dot_rc.ino ()) home_rc_already_executed = true; + #endif } } _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startupOn 24-Apr-2007, Benjamin Lindner wrote:
| I am not a expert programmer on windows api, so I did some research at | MSDN and found the following links | http://msdn2.microsoft.com/en-us/library/aa364952.aspx | http://msdn2.microsoft.com/en-us/library/aa363788.aspx | Here windows fills a Information Structure that contains a volume serial | number, and a unique file identifer. In the second link microsoft states | that these indicators can be used to determine if two file handles refer | to one and the same (pyhsical) file. | | I created an attached patch for octave.cc, but I do not have the setup | to build a octave version using MSVC so this patch is not tested within | the octave framework. | I verified that the equal_files() function in the patch builds seperately | and works correctly. | | I was not sure what is the correct preprocessor macro to check for | to indicate a windows build. I looked in the config.h header and found | the OCTAVE_USE_WINDOWS_API, so I used this one. | | feedback welcome OK, I think the function should go in sysdep.cc, not directly in octave.cc, it should take const std::string& arguments, and it should be defined for all systems so the #ifdefs are hidden in sysdep.cc. Then the code in octave.cc can be modified to [...] // Names alone are not enough. file_stat fs_home_rc (home_rc); if (fs_home_rc) { // We want to check for curr_dir after executing home_rc // because doing that may change the working directory. std::string curr_dir = octave_env::getcwd (); local_rc = octave_env::make_absolute (initfile, curr_dir); home_rc_already_executed = same_file (local_rc, home_rc); } } I also suggest renaming it same_file. Please also follow the coding style of the rest of Octave and submit a ChangeLog entry. Thanks, jwe _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startup> OK, I think the function should go in sysdep.cc, not directly in > octave.cc, it should take const std::string& arguments, and it should > be defined for all systems so the #ifdefs are hidden in sysdep.cc. > > ... > > I also suggest renaming it same_file. I found that in src/utils.cc there is already a function same_file() which performs the check as it is done currently in src/octave.cc. Should we use and modify this function to adapt for win32, and call it in octatve.cc or should there be a seperate function in sysdep.cc (in this case, the function cannot be named same_file)? I would vote for the already existing function, because this would avoid code duplication. Is there a reason that it is currently placed in utils.cc? Would it be ok to move it from utils.cc to sysdep.cc? benjamin -- "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startupOn 26-Apr-2007, Benjamin Lindner wrote:
| | > OK, I think the function should go in sysdep.cc, not directly in | > octave.cc, it should take const std::string& arguments, and it should | > be defined for all systems so the #ifdefs are hidden in sysdep.cc. | > | > ... | > | > I also suggest renaming it same_file. | | I found that in src/utils.cc there is already a function | same_file() which performs the check as it is done currently | in src/octave.cc. | | Should we use and modify this function to adapt for win32, and call it | in octatve.cc or should there be a seperate function in sysdep.cc | (in this case, the function cannot be named same_file)? Move it to sysdep.cc and write it like this: bool same_file (...) { #if defined (platform_1) code for platform_1 here #else posix code here #endif } or similar. | I would vote for the already existing function, because this would avoid | code duplication. Is there a reason that it is currently placed in | utils.cc? The fool who wrote it wasn't thinking about system dependence of that function and thought POSIX features would be good enough? jwe _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startup> On 26-Apr-2007, Benjamin Lindner wrote:
Ok, consider the following patch:
> > | > | > OK, I think the function should go in sysdep.cc, not directly in > | > octave.cc, it should take const std::string& arguments, and it should > | > be defined for all systems so the #ifdefs are hidden in sysdep.cc. > | > > | > ... > | > > | > I also suggest renaming it same_file. > | > | I found that in src/utils.cc there is already a function > | same_file() which performs the check as it is done currently > | in src/octave.cc. > | > | Should we use and modify this function to adapt for win32, and call it > | in octatve.cc or should there be a seperate function in sysdep.cc > | (in this case, the function cannot be named same_file)? > > Move it to sysdep.cc and write it like this: > > bool > same_file (...) > { > #if defined (platform_1) > code for platform_1 here > #else > posix code here > #endif > } > > or similar. 2007-04-27 Benjamin Lindner <lindnerb@...> * src/sysdep.cc, src/utils.cc: Move same_file() to sysdep.cc and add win32 specific code. * src/octave.cc: Use same_file() in execute_startup_files() as check for already executed init files benjamin -- "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startupOn 27-Apr-2007, Benjamin Lindner wrote:
| > On 26-Apr-2007, Benjamin Lindner wrote: | > | > | | > | > OK, I think the function should go in sysdep.cc, not directly in | > | > octave.cc, it should take const std::string& arguments, and it should | > | > be defined for all systems so the #ifdefs are hidden in sysdep.cc. | > | > | > | > ... | > | > | > | > I also suggest renaming it same_file. | > | | > | I found that in src/utils.cc there is already a function | > | same_file() which performs the check as it is done currently | > | in src/octave.cc. | > | | > | Should we use and modify this function to adapt for win32, and call it | > | in octatve.cc or should there be a seperate function in sysdep.cc | > | (in this case, the function cannot be named same_file)? | > | > Move it to sysdep.cc and write it like this: | > | > bool | > same_file (...) | > { | > #if defined (platform_1) | > code for platform_1 here | > #else | > posix code here | > #endif | > } | > | > or similar. | | Ok, consider the following patch: | | 2007-04-27 Benjamin Lindner <lindnerb@...> | | * src/sysdep.cc, src/utils.cc: Move same_file() to sysdep.cc and add | win32 specific code. | * src/octave.cc: Use same_file() in execute_startup_files() as check | for already executed init files OK. To avoid having to touch the files that used same_file (to include sysdep.h in addition to utils.h), I checked in the following changes instead. Thanks, jwe src/ChangeLog: 2007-04-27 Benjamin Lindner <lindnerb@...>. * octave.cc (execute_startup_files): Call same_file to check for already executed init files. 2007-04-27 John W. Eaton <jwe@...> * sysdep.cc (same_file_internal): New function. POSIX code from same_file in utils.cc. Windows code from Benjamin Lindner <lindnerb@...>. Don't canonicalize file names. Also return false if stat calls fail. * sysdep.h: Provide decl. * utils.cc (same_file): Use same_file_internal. Index: src/octave.cc =================================================================== RCS file: /cvs/octave/src/octave.cc,v retrieving revision 1.230 diff -u -u -r1.230 octave.cc --- src/octave.cc 6 Apr 2007 15:33:45 -0000 1.230 +++ src/octave.cc 27 Apr 2007 17:13:56 -0000 @@ -338,10 +338,7 @@ local_rc = octave_env::make_absolute (initfile, curr_dir); - file_stat fs_dot_rc (local_rc); - - if (fs_dot_rc && fs_home_rc.ino () == fs_dot_rc.ino ()) - home_rc_already_executed = true; + home_rc_already_executed = same_file (home_rc, local_rc); } } Index: src/sysdep.cc =================================================================== RCS file: /cvs/octave/src/sysdep.cc,v retrieving revision 1.126 diff -u -u -r1.126 sysdep.cc --- src/sysdep.cc 21 Mar 2007 13:15:03 -0000 1.126 +++ src/sysdep.cc 27 Apr 2007 17:13:57 -0000 @@ -89,6 +89,7 @@ #include "sysdep.h" #include "toplev.h" #include "utils.h" +#include "file-stat.h" #ifndef STDIN_FILENO #define STDIN_FILENO 1 @@ -224,6 +225,69 @@ } #endif +// Return TRUE if FILE1 and FILE2 refer to the same (physical) file. + +bool +same_file_internal (const std::string& file1, const std::string& file2) +{ +#ifdef OCTAVE_USE_WINDOWS_API + + // Windows native code + // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx + + HANDLE hfile1; + HANDLE hfile2; + + BY_HANDLE_FILE_INFORMATION hfi1; + BY_HANDLE_FILE_INFORMATION hfi2; + + hfile1 = CreateFile (file1.c_str (), 0, FILE_SHARE_READ, 0, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + + if (hfile1 == INVALID_FILE_HANDLE) + return false; + + hfile2 = CreateFile (file2.c_str (), 0, FILE_SHARE_READ, 0, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + + if (hfile2 == INVALID_FILE_HANDLE) + { + CloseHandle (hfile1); + return false; + } + + if (! GetFileInformationByHandle (hfile1, &hfi1)) + { + CloseHandle (hfile1); + CloseHandle (hfile2); + return false; + } + + if (! GetFileInformationByHandle (hfile2, &hfi2)) + { + CloseHandle (hfile1); + CloseHandle (hfile2); + return false; + } + + return (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber + && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh + && hfi1.nFileIndexLow == hfi2.nFileIndexLow); + +#else + + // POSIX Code + + file_stat fs_file1 (file1); + file_stat fs_file2 (file2); + + return (fs_file1 && fs_file2 + && fs_file1.ino () == fs_file2.ino () + && fs_file1.dev () == fs_file2.dev ()); + +#endif +} + #if defined (__DECCXX) // These don't seem to be instantiated automatically... Index: src/sysdep.h =================================================================== RCS file: /cvs/octave/src/sysdep.h,v retrieving revision 1.31 diff -u -u -r1.31 sysdep.h --- src/sysdep.h 17 Sep 2005 00:50:58 -0000 1.31 +++ src/sysdep.h 27 Apr 2007 17:13:57 -0000 @@ -47,6 +47,8 @@ #define MINGW_SIGNAL_CLEANUP() do { } while (0) #endif +extern bool same_file_internal (const std::string&, const std::string&); + #endif /* Index: src/utils.cc =================================================================== RCS file: /cvs/octave/src/utils.cc,v retrieving revision 1.197 diff -u -u -r1.197 utils.cc --- src/utils.cc 2 Mar 2007 18:43:21 -0000 1.197 +++ src/utils.cc 27 Apr 2007 17:13:57 -0000 @@ -118,13 +118,7 @@ bool same_file (const std::string& f, const std::string& g) { - std::string c_f = file_ops::canonicalize_file_name (f); - std::string c_g = file_ops::canonicalize_file_name (g); - - file_stat f_fs (c_f); - file_stat g_fs (c_g); - - return (f_fs.ino () == g_fs.ino () && f_fs.dev () == g_fs.dev ()); + return same_file_internal (f, g); } int _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startupA possible way to get around the problem in Windows is to patch the script "c:\Program Files\Octave\share\octave\version\m\startup\octaverc". I added to my copy of octaverc the following: # Execute the current User's startup.m and .octaverc on a Windows System # ( Added by Kenneth H. Cate on 2008-06-19 ) # users_path = getenv("USERPROFILE"); if ~isempty(users_path) users_path = [users_path, filesep]; # Windows: p1 = [users_path, "Application Data", filesep, "octave"]; # Some users might prefer this path p2 = [p1, filesep]; if (exist ([p2, "startup.m"], "file")), addpath (p1, "-end"); elseif (exist ([p2, ".octaverc"], "file")), addpath (p1, "-end"); end # Windows Vista: p1 = [users_path, "AppData", filesep, "Roaming", filesep, "octave"]; p2 = [p1, filesep]; if (exist ([p2, "startup.m"], "file")), addpath (p1, "-end"); elseif (exist ([p2, ".octaverc"], "file")), addpath (p1, "-end"); end p1 = [users_path, "octave"]; p2 = [p1, filesep]; if (exist ([p2, "startup.m"], "file")); addpath (p1, "-end"); elseif (exist ([p2, ".octaverc"], "file")), addpath (p1, "-end"); end if (exist ("startup.m", "file")) startup end clear p1 p2 end clear users_path This goes ahead of the final fprintf ("\n") This allows Octave to find the startup.m or .octaverc scripts for the current user. |
|
|
Re: windows native Octave-2.9.9+ does not read ./.octaverc at startupKenneth Cate wrote:
> Benjamin Lindner wrote: > >> I have installed michael's Octave 2.9.9+ windows binary from >> http://www.dbateman.org/?page=octave&lang=EN and found, that at >> startup octave does not load a .octaverc file in the current directory. >> The startup file in the home directory and the system-wide startup files >> are loaded. >> I do not see this behaviour with version 2.9.9 under linux&cygwin and >> neither with 2.9.10 under cygwin, so i guess this is a bug in the windows >> port? > > A possible way to get around the problem in Windows is to patch the script > "c:\Program Files\Octave\share\octave\version\m\startup\octaverc". > I added to my copy of octaverc the following: > > # Execute the current User's startup.m and .octaverc on a Windows System > # ( Added by Kenneth H. Cate on 2008-06-19 ) > # > users_path = getenv("USERPROFILE"); > if ~isempty(users_path) > users_path = [users_path, filesep]; > > # Windows: > p1 = [users_path, "Application Data", filesep, "octave"]; # Some users > might prefer this path > p2 = [p1, filesep]; > if (exist ([p2, "startup.m"], "file")), addpath (p1, "-end"); > elseif (exist ([p2, ".octaverc"], "file")), addpath (p1, "-end"); end > > # Windows Vista: > p1 = [users_path, "AppData", filesep, "Roaming", filesep, "octave"]; > p2 = [p1, filesep]; > if (exist ([p2, "startup.m"], "file")), addpath (p1, "-end"); > elseif (exist ([p2, ".octaverc"], "file")), addpath (p1, "-end"); end > > p1 = [users_path, "octave"]; > p2 = [p1, filesep]; > if (exist ([p2, "startup.m"], "file")); addpath (p1, "-end"); > elseif (exist ([p2, ".octaverc"], "file")), addpath (p1, "-end"); end > if (exist ("startup.m", "file")) > startup > end > clear p1 p2 > end > clear users_path > > This goes ahead of the final fprintf ("\n") > This allows Octave to find the startup.m or .octaverc scripts for the > current user. > A simpler version would be (using the APPDATA environmental variable, fullfile, and source): # Execute the current User's .octaverc or startup.m on a Windows System # ( Added by Kenneth H. Cate on 2008-06-19 ) # users_path = getenv ("APPDATA"); if ~isempty (users_path) ## Some users might prefer this path users_path = fullfile (users_path, "octave"); if exist (fullfile (users_path, ".octaverc"), "file") source (fullfile (users_path, ".octaverc")); elseif exist (fullfile (users_path, "startup.m"), "file") source (fullfile (users_path, "startup.m")); endif end clear users_path Have a good day, Bill _______________________________________________ Bug-octave mailing list Bug-octave@... https://www.cae.wisc.edu/mailman/listinfo/bug-octave |
| Free embeddable forum powered by Nabble | Forum Help |