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.

84 lines
2.0 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. strtok.cxx
  7. NLS/DBCS-aware string class: strtok method
  8. This file contains the implementation of the strtok 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::strtok
  28. SYNOPSIS: Basic strtok functionality. Returns FALSE after the
  29. string has been traversed.
  30. ENTRY:
  31. EXIT:
  32. NOTES: We don't update the version on the string since the
  33. ::strtokf shouldn't cause DBCS problems. It would also
  34. be painful on the programmer if on each call to strtok
  35. they had to update all of the ISTR associated with this
  36. string
  37. fFirst is required to be TRUE on the first call to
  38. strtok, it is FALSE afterwards (is defaulted to FALSE)
  39. CAVEAT: Under windows, all calls to strtok must be done while
  40. processing a single message. Otherwise another process
  41. my confuse it.
  42. HISTORY:
  43. johnl 11/26/90 Created
  44. beng 07/23/91 Allow on erroneous string
  45. ********************************************************************/
  46. BOOL NLS_STR::strtok(
  47. ISTR *pistrPos,
  48. const NLS_STR& nlsBreak,
  49. BOOL fFirst )
  50. {
  51. if (QueryError())
  52. return FALSE;
  53. const CHAR * pchToken = ::strtokf( fFirst ? _pchData : NULL, (CHAR *)nlsBreak.QueryPch());
  54. if ( pchToken == NULL )
  55. {
  56. pistrPos->SetIB( strlen() );
  57. return FALSE;
  58. }
  59. pistrPos->SetIB((int) (pchToken - QueryPch()));
  60. return TRUE;
  61. }