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.

104 lines
2.3 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. strdss.cxx
  7. NLS/DBCS-aware string class: DelSubStr method
  8. This file contains the implementation of the DelSubStr 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::DelSubStr
  28. SYNOPSIS: Collapse the string by removing the characters from
  29. istrStart to:
  30. istrStart to the end of string
  31. istrStart + istrEnd
  32. The string is not reallocated
  33. ENTRY:
  34. EXIT: Modifies istrStart
  35. NOTES: The method DelSubStr( ISTR&, CB) is private and does
  36. the work.
  37. HISTORY:
  38. johnl 11/26/90 Created
  39. beng 04/26/91 Replaced CB with INT
  40. beng 07/23/91 Allow on erroneous strings; simplified CheckIstr
  41. ********************************************************************/
  42. VOID NLS_STR::DelSubStr( ISTR & istrStart, INT cbLen )
  43. {
  44. if (QueryError())
  45. return;
  46. CheckIstr( istrStart );
  47. // cbLen == -1 means delete to end of string
  48. if ( cbLen == -1 )
  49. *(_pchData + istrStart.QueryIB() ) = '\0';
  50. else
  51. {
  52. INT cbNewEOS = 1 + ::strlenf( QueryPch(istrStart) + cbLen );
  53. ::memmovef( (CHAR *)QueryPch(istrStart),
  54. (CHAR *)QueryPch(istrStart) + cbLen,
  55. cbNewEOS );
  56. }
  57. _cchLen = ::strlenf( QueryPch() );
  58. IncVers();
  59. UpdateIstr( &istrStart );
  60. }
  61. VOID NLS_STR::DelSubStr( ISTR & istrStart )
  62. {
  63. if (QueryError())
  64. return;
  65. DelSubStr( istrStart, -1 );
  66. }
  67. VOID NLS_STR::DelSubStr( ISTR & istrStart, const ISTR & istrEnd )
  68. {
  69. if (QueryError())
  70. return;
  71. CheckIstr( istrEnd );
  72. UIASSERT( istrEnd.QueryIB() >= istrStart.QueryIB() );
  73. DelSubStr( istrStart, istrEnd - istrStart );
  74. }