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.

82 lines
1.9 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. strspn.cxx
  7. NLS/DBCS-aware string class: strspn method
  8. This file contains the implementation of the strspn 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::strspn
  28. SYNOPSIS: Find first char in *this that is not a char in arg. and puts
  29. the position in pistrPos.
  30. Returns FALSE when no characters do not match
  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::strspn( ISTR * pistrPos, const NLS_STR & nls ) const
  39. {
  40. if (QueryError() || !nls)
  41. return FALSE;
  42. UpdateIstr( pistrPos );
  43. CheckIstr( *pistrPos );
  44. pistrPos->SetIB( ::strspnf( QueryPch(), nls.QueryPch() ) );
  45. return *QueryPch( *pistrPos ) != '\0';
  46. }
  47. BOOL NLS_STR::strspn( ISTR * pistrPos,
  48. const NLS_STR & nls,
  49. const ISTR & istrStart ) const
  50. {
  51. if (QueryError() || !nls)
  52. return FALSE;
  53. UpdateIstr( pistrPos );
  54. CheckIstr( istrStart );
  55. pistrPos->SetIB( ::strspnf(QueryPch( istrStart ), nls.QueryPch() ) +
  56. istrStart.QueryIB() );
  57. return *QueryPch( *pistrPos ) != '\0';
  58. }