Source code of Windows XP (NT5)
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.

96 lines
1.9 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. stristr.cxx
  7. NLS/DBCS-aware string class: stristr method
  8. This file contains the implementation of the stristr 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 11/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::stristr
  28. SYNOPSIS: Same as strstr on case insensitive
  29. ENTRY:
  30. EXIT:
  31. NOTES:
  32. HISTORY:
  33. johnl 11/16/90 Written
  34. beng 07/23/91 Allow on erroneous string; simplified CheckIstr
  35. ********************************************************************/
  36. BOOL NLS_STR::stristr( ISTR * pistrPos, const NLS_STR & nls ) const
  37. {
  38. if (QueryError() || !nls)
  39. return FALSE;
  40. UpdateIstr( pistrPos );
  41. CheckIstr( *pistrPos );
  42. const CHAR * pchStrRes = ::stristrf( QueryPch(), nls.QueryPch() );
  43. if ( pchStrRes == NULL )
  44. {
  45. pistrPos->SetIB( strlen() );
  46. return FALSE;
  47. }
  48. pistrPos->SetIB((int) (pchStrRes - QueryPch()));
  49. return TRUE;
  50. }
  51. BOOL NLS_STR::stristr( ISTR * pistrPos,
  52. const NLS_STR & nls,
  53. const ISTR & istrStart ) const
  54. {
  55. if (QueryError() || !nls)
  56. return FALSE;
  57. CheckIstr( istrStart );
  58. UpdateIstr( pistrPos );
  59. CheckIstr( *pistrPos );
  60. const CHAR * pchStrRes = ::stristrf(QueryPch(istrStart), nls.QueryPch() );
  61. if ( pchStrRes == NULL )
  62. {
  63. pistrPos->SetIB( strlen() );
  64. return FALSE;
  65. }
  66. pistrPos->SetIB((int) (pchStrRes - QueryPch()));
  67. return TRUE;
  68. }