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.

86 lines
2.1 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. strcspn.cxx
  7. NLS/DBCS-aware string class: strcspn method
  8. This file contains the implementation of the strcspn 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::strcspn
  28. SYNOPSIS: Set membership. Finds the first matching character
  29. in the passed string
  30. ENTRY: pistrPos - destination for results
  31. nls - set of sought characters
  32. EXIT: *pistrPos contains offset within "this" of element
  33. found (assuming it was successful); otherwise it
  34. is moved to the end of the string.
  35. RETURNS: TRUE if any character found; FALSE otherwise
  36. NOTES:
  37. HISTORY:
  38. johnl 11/16/90 Written
  39. beng 07/23/91 Allow on erroneous strings; simplified CheckIstr
  40. ********************************************************************/
  41. BOOL NLS_STR::strcspn( ISTR* pistrPos, const NLS_STR & nls ) const
  42. {
  43. if (QueryError() || !nls)
  44. return FALSE;
  45. UpdateIstr( pistrPos );
  46. CheckIstr( *pistrPos );
  47. pistrPos->SetIB( ::strcspnf( QueryPch(), nls.QueryPch() ) );
  48. return *QueryPch( *pistrPos ) != '\0';
  49. }
  50. BOOL NLS_STR::strcspn( ISTR * pistrPos, const NLS_STR & nls,
  51. const ISTR& istrStart ) const
  52. {
  53. if (QueryError() || !nls)
  54. return FALSE;
  55. UpdateIstr( pistrPos );
  56. CheckIstr( *pistrPos );
  57. CheckIstr( istrStart );
  58. pistrPos->SetIB( ::strcspnf( QueryPch(istrStart), nls.QueryPch() )
  59. + istrStart.QueryIB() );
  60. return *QueryPch( *pistrPos ) != '\0';
  61. }