summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2002-09-05 20:44:36 +0000
committerMatthias Melcher <fltk@matthiasm.com>2002-09-05 20:44:36 +0000
commit6698be1be81a2c98707b4842022f1075e9b082a0 (patch)
treecb93b0d56124169d294dbb64ea2ff1b893fb4923 /src
parent32b9640e1ca9ce14f802309ad7818c23910dc62c (diff)
Mac OS X: modified Fl_Preferences::Node::search to correctly handle groups
inside the root group and to allow for relative and absolute path names. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2619 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Preferences.cxx43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx
index 0eb03d083..afe433762 100644
--- a/src/Fl_Preferences.cxx
+++ b/src/Fl_Preferences.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Preferences.cxx,v 1.1.2.19 2002/08/27 03:03:37 easysw Exp $"
+// "$Id: Fl_Preferences.cxx,v 1.1.2.20 2002/09/05 20:44:36 matthiaswm Exp $"
//
// Preferences methods for the Fast Light Tool Kit (FLTK).
//
@@ -1013,19 +1013,48 @@ Fl_Preferences::Node *Fl_Preferences::Node::find( const char *path )
}
// find a group somewhere in the tree starting here
+// caller must not set 'offset' argument
// - if the node does not exist, 'search' returns NULL
-Fl_Preferences::Node *Fl_Preferences::Node::search( const char *path )
+// - if the pathname is "." (current node) return this node
+// - if the pathname is "./" (root node) return the topmost node
+// - if the pathname starts with "./", start the search at the root node instead
+Fl_Preferences::Node *Fl_Preferences::Node::search( const char *path, int offset )
{
+
+ if ( offset == 0 )
+ {
+ if ( path[0] == '.' )
+ {
+ if ( path[1] == 0 )
+ {
+ return this; // user was searching for current node
+ }
+ else if ( path[1] == '/' )
+ {
+ Node *nn = this;
+ while ( nn->parent_ ) nn = nn->parent_;
+ if ( path[2]==0 )
+ { // user is searching for root ( "./" )
+ return nn;
+ }
+ return nn->search( path+2, 2 ); // do a relative search on the root node
+ }
+ }
+ offset = strlen( path_ ) + 1;
+ }
+
int len = strlen( path_ );
- if ( strncmp( path, path_, len ) == 0 )
+ if ( len < offset-1 ) return 0;
+ len -= offset;
+ if ( ( len <= 0 ) || ( strncmp( path, path_+offset, len ) == 0 ) )
{
- if ( path[ len ] == 0 )
+ if ( len > 0 && path[ len ] == 0 )
return this;
- if ( path[ len ] == '/' )
+ if ( len <= 0 || path[ len ] == '/' )
{
for ( Node *nd = child_; nd; nd = nd->next_ )
{
- Node *nn = nd->find( path );
+ Node *nn = nd->search( path, offset );
if ( nn ) return nn;
}
return 0;
@@ -1084,5 +1113,5 @@ char Fl_Preferences::Node::remove()
//
-// End of "$Id: Fl_Preferences.cxx,v 1.1.2.19 2002/08/27 03:03:37 easysw Exp $".
+// End of "$Id: Fl_Preferences.cxx,v 1.1.2.20 2002/09/05 20:44:36 matthiaswm Exp $".
//