-String::lastPos( char const* string ) const
-{
- // not binary safe
- assert( length_i() == strlen( ch_c_l() ) );
- int pos = 0;
- int length = strlen( string );
- if ( length_i() && length )
- {
- int nextpos = this->pos( string );
- while( nextpos )
- {
- pos += nextpos;
- nextpos = right( length_i() - pos - length + 1 ).pos( string );
- }
- }
- return pos;
-}
-
-// find c
-// return 0 if not found.
-
-// ? should return length_i()?, as in string.left(pos(delimiter))
-int
-String::pos(char c ) const
-{
- // not binary safe
- assert( length_i() == strlen( ch_c_l() ) );
- char const* me = strh_.ch_c_l();
- int pos = 0;
- if ( length_i() )
- {
- char const* p = strchr( me, c );
- if ( p )
- pos = p - me + 1;
- }
- return pos;
-}
-
-// find searchfor. (what if this == "" && searchfor == "") ???
+String::index_last (char const* string) const // UGK!
+{
+ assert (false); // broken
+ int len = strlen (string); // ugrh
+ if (!length () || !len)
+ return -1;
+
+ int next_i = index (string);
+ if (next_i == -1)
+ return -1;
+
+ int index_i = 0;
+ while (next_i >= 0)
+ {
+ index_i += next_i;
+ next_i = right_string (length () - index_i - len).index (string );
+ }
+ return index_i;
+}
+
+/** find a character.
+
+ @return
+ the index of the leftmost character #c# (0 <= return < length ()),
+ or -1 if not found.
+
+ ? should return length ()?, as in string.left_string (index (delimiter))
+*/