@@ -10,6 +10,8 @@ const char PathUtils::dir_sep = '\\';
1010const char * PathUtils::curr_dir_link = " ." ;
1111const char * PathUtils::up_dir_link = " .." ;
1212const char PathUtils::dir_list_sep = ' ;' ;
13+ const size_t PathUtils::curr_dir_link_len = strlen(curr_dir_link);
14+ const size_t PathUtils::up_dir_link_len = strlen(up_dir_link);
1315
1416class Win32DirItr : public PathUtils ::dir_iterator
1517{
@@ -121,7 +123,10 @@ void PathUtils::concatPath(Firebird::PathName& result,
121123
122124 for (Firebird::PathName::size_type pos = 0 ; cur_pos < second.length (); cur_pos = pos + 1 )
123125 {
124- pos = second.find_first_of (" /\\ " , cur_pos);
126+ static const char separators[] = " /\\ " ;
127+ static const Firebird::PathName::size_type separatorsLen = static_cast <Firebird::PathName::size_type>(strlen (separators));
128+
129+ pos = second.find_first_of (separators, cur_pos, separatorsLen);
125130 if (pos == Firebird::PathName::npos) // simple name, simple handling
126131 {
127132 pos = second.length ();
@@ -130,16 +135,16 @@ void PathUtils::concatPath(Firebird::PathName& result,
130135 {
131136 continue ;
132137 }
133- if (pos == cur_pos + 1 && memcmp (second.c_str () + cur_pos, PathUtils:: curr_dir_link, 1 ) == 0 ) // Current dir, ignore
138+ if (pos == cur_pos + curr_dir_link_len && memcmp (second.c_str () + cur_pos, curr_dir_link, curr_dir_link_len ) == 0 ) // Current dir, ignore
134139 {
135140 continue ;
136141 }
137- if (pos == cur_pos + 2 && memcmp (second.c_str () + cur_pos, PathUtils:: up_dir_link, 2 ) == 0 ) // One dir up
142+ if (pos == cur_pos + up_dir_link_len && memcmp (second.c_str () + cur_pos, up_dir_link, up_dir_link_len ) == 0 ) // One dir up
138143 {
139144 if (result.length () < 2 ) // We have nothing to cut off, ignore this piece (may be throw an error?..)
140145 continue ;
141146
142- const Firebird::PathName::size_type up_dir = result.find_last_of (" / \\ " , result.length () - 2 , 2 );
147+ const Firebird::PathName::size_type up_dir = result.find_last_of (separators , result.length () - 2 , separatorsLen );
143148 if (up_dir == Firebird::PathName::npos)
144149 continue ;
145150
0 commit comments