Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.1 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. strstr.cxx
  7. NLS/DBCS-aware string class: strstr method
  8. This file contains the implementation of the strstr method
  9. for the STRING class. It is separate so that clients of STRING which
  10. do not use this operator need not link to it.
  11. FILE HISTORY:
  12. beng 01/18/91 Separated from original monolithic .cxx
  13. beng 02/07/91 Uses lmui.hxx
  14. */
  15. #include "npcommon.h"
  16. extern "C"
  17. {
  18. #include <netlib.h>
  19. }
  20. #if defined(DEBUG)
  21. static const CHAR szFileName[] = __FILE__;
  22. #define _FILENAME_DEFINED_ONCE szFileName
  23. #endif
  24. #include <npassert.h>
  25. #include <npstring.h>
  26. /*******************************************************************
  27. NAME: NLS_STR::strstr
  28. SYNOPSIS: Returns TRUE if the passed string is found, false otherwise.
  29. pistrPos contains start of the specified string if TRUE
  30. is returned.
  31. ENTRY:
  32. EXIT:
  33. NOTES:
  34. HISTORY:
  35. johnl 11/16/90 Written
  36. beng 07/23/91 Allow on erroneous string; simplified CheckIstr
  37. ********************************************************************/
  38. BOOL NLS_STR::strstr( ISTR * pistrPos, const NLS_STR & nls ) const
  39. {
  40. if (QueryError() || !nls)
  41. return FALSE;
  42. UpdateIstr( pistrPos );
  43. CheckIstr( *pistrPos );
  44. const CHAR * pchStrRes = ::strstrf( QueryPch(), nls.QueryPch() );
  45. if ( pchStrRes == NULL )
  46. {
  47. pistrPos->SetIB( strlen() );
  48. return FALSE;
  49. }
  50. pistrPos->SetIB((int) (pchStrRes - QueryPch()));
  51. return TRUE;
  52. }
  53. BOOL NLS_STR::strstr( ISTR * pistrPos,
  54. const NLS_STR & nls,
  55. const ISTR & istrStart ) const
  56. {
  57. if (QueryError() || !nls)
  58. return FALSE;
  59. CheckIstr( istrStart );
  60. UpdateIstr( pistrPos );
  61. CheckIstr( *pistrPos );
  62. const CHAR * pchStrRes = ::strstrf(QueryPch(istrStart), nls.QueryPch() );
  63. if ( pchStrRes == NULL )
  64. {
  65. pistrPos->SetIB( strlen() );
  66. return FALSE;
  67. }
  68. pistrPos->SetIB((int)(pchStrRes - QueryPch()));
  69. return TRUE;
  70. }