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.

143 lines
3.4 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. strcmp.cxx
  7. NLS/DBCS-aware string class: strcmp method and equality operator
  8. This file contains the implementation of the strcmp 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::operator==
  28. SYNOPSIS: Case-sensitive test for equality
  29. RETURNS: TRUE if the two operands are equal (case sensitive);
  30. else FALSE
  31. NOTES: An erroneous string matches nothing.
  32. HISTORY:
  33. johnl 11/11/90 Written
  34. beng 07/23/91 Allow on erroneous strings
  35. ********************************************************************/
  36. BOOL NLS_STR::operator==( const NLS_STR & nls ) const
  37. {
  38. if (QueryError() || !nls)
  39. return FALSE;
  40. return !::strcmpf( QueryPch(), nls.QueryPch() );
  41. }
  42. /*******************************************************************
  43. NAME: NLS_STR::operator!=
  44. SYNOPSIS: Case-sensitive test for inequality
  45. RETURNS: TRUE if the two operands are unequal (case sensitive);
  46. else FALSE
  47. NOTES: An erroneous string matches nothing.
  48. HISTORY:
  49. beng 07/23/91 Header added
  50. ********************************************************************/
  51. BOOL NLS_STR::operator!=( const NLS_STR & nls ) const
  52. {
  53. return ! operator==( nls );
  54. }
  55. /*******************************************************************
  56. NAME: NLS_STR::strcmp
  57. SYNOPSIS: Standard string compare with optional character indexes
  58. ENTRY: nls - string against which to compare
  59. istrStart1 (optional) - index into "this"
  60. istrStart2 (optional) - index into "nls"
  61. RETURNS: As the C runtime "strcmp".
  62. NOTES: If either string is erroneous, return "match."
  63. This runs contrary to the eqop.
  64. Glock doesn't allow default parameters which require
  65. construction; hence this member is overloaded multiply.
  66. HISTORY:
  67. johnl 11/15/90 Written
  68. johnl 11/19/90 Changed to use ISTR, overloaded for
  69. different number of ISTRs
  70. beng 07/23/91 Allow on erroneous strings;
  71. simplified CheckIstr
  72. ********************************************************************/
  73. int NLS_STR::strcmp( const NLS_STR & nls ) const
  74. {
  75. if (QueryError() || !nls)
  76. return 0;
  77. return ::strcmpf( QueryPch(), nls.QueryPch() );
  78. }
  79. int NLS_STR::strcmp(
  80. const NLS_STR & nls,
  81. const ISTR & istrStart1 ) const
  82. {
  83. if (QueryError() || !nls)
  84. return 0;
  85. CheckIstr( istrStart1 );
  86. return ::strcmpf( QueryPch(istrStart1) , nls.QueryPch() );
  87. }
  88. int NLS_STR::strcmp(
  89. const NLS_STR & nls,
  90. const ISTR & istrStart1,
  91. const ISTR & istrStart2 ) const
  92. {
  93. if (QueryError() || !nls)
  94. return 0;
  95. CheckIstr( istrStart1 );
  96. nls.CheckIstr( istrStart2 );
  97. return ::strcmpf( QueryPch(istrStart1), nls.QueryPch(istrStart2) );
  98. }