octave segfault under AIX/shared

John W. Eaton jwe at bevo.che.wisc.edu
Wed Dec 5 15:34:36 CST 2007


On  5-Dec-2007, G.. wrote:

| 
| 
| John W. Eaton wrote:
| > 
| > | You're right. The error is not in file.length. It occurs in the function
| > | file_ops::is_dir_sep from liboctave:
| > | -----------
| > | bool
| > | file_ops::is_dir_sep (char c)
| > | {
| > |   return dir_sep_chars.find (c) != NPOS;                                                                                                                                      
| > | }
| > | -----------
| > | If that function generally returns 0 (for example) everything works.
| > 
| > So how is this function buggy?  On an AIX system, I would expect
| > dir_sep_chars to be a std::string object containing the single
| > character '/' and NPOS should be defined in config.h to be
| > std::string::npos.  The call to std::string::find should return NPOS
| > if the character C is not found and the function should return false
| > in that case and true if C is equal to '/'.  So how does this fail on
| > your system?
| > 
| 
| I don't know as my C++ skills are limited. But I know that if I add the
| definition of file_ops::is_dir_sep *before* it is called in
| default_history_file (see patch), then it works.
| 
| G.
| 
| -----------------------------------
| --- oct-hist.cc 2007-10-12 23:27:30.000000000 +0200
| +++ /tmp/oct-hist.cc    2007-12-05 13:37:06.000000000 +0100
| @@ -76,6 +76,16 @@
|  // TRUE means input is coming from temporary history file.
|  bool input_from_tmp_history_file = false;
|  
| +char file_ops::dir_sep_char = '/';
| +std::string file_ops::dir_sep_str ("/");
| +std::string file_ops::dir_sep_chars (file_ops::dir_sep_str);
| +
| +bool
| +file_ops::is_dir_sep (char c)
| +{
| +  return dir_sep_chars.find (c) != NPOS;
| +}
| +
|  static std::string
|  default_history_file (void)
|  {
| -----------------------------------------------

This makes no sense to me.  The oct-hist.cc file already includes
file-ops.h, which provides declarations for these functions.  There
should be no need to include redundant definitions for them in
oct-hist.cc itself.

jwe


More information about the Bug-octave mailing list