From 4d0a7466320e54f45f413efef09ef8e6ad21bb3e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 30 Nov 2007 16:02:04 +0000 Subject: Added some helpers to fstring, and fixed a bug in Bu::Process, it wasn't closing the pipes properly, resulting in the child process going defunct and not dying, it also wasn't buffering properly, it now collects as much data as it can before returning from a read operation. --- src/fstring.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/fstring.h') diff --git a/src/fstring.h b/src/fstring.h index 666480c..82e8b34 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -731,6 +731,39 @@ namespace Bu } return -1; } + + /** + * Find the index of the first occurrance of cChar + *@param sText (const chr *) The string to search for. + *@returns (long) The index of the first occurrance. -1 for not found. + */ + long find( long iStart, const chr cChar ) const + { + flatten(); + for( long j = iStart; j < pFirst->nLength; j++ ) + { + if( pFirst->pData[j] == cChar ) + return j; + } + return -1; + } + + /** + * Find the index of the first occurrance of sText + *@param cChar (const chr) The character to search for. + *@returns (long) The index of the first occurrance. -1 for not found. + */ + long find( long iStart, const chr *sText ) const + { + long nTLen = strlen( sText ); + flatten(); + for( long j = iStart; j < pFirst->nLength-nTLen; j++ ) + { + if( !strncmp( sText, pFirst->pData+j, nTLen ) ) + return j; + } + return -1; + } /** * Do a reverse search for (sText) -- cgit v1.2.3