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.0 KiB

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