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.

103 lines
2.3 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. strnicmp.cxx
  7. NLS/DBCS-aware string class: strnicmp method
  8. This file contains the implementation of the strnicmp 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::strnicmp
  28. SYNOPSIS: Case insensitve string compare up to index position istrEnd
  29. ENTRY:
  30. EXIT:
  31. NOTES:
  32. HISTORY:
  33. johnl 11/15/90 Written
  34. beng 07/23/91 Allow on erroneous string; simplified CheckIstr
  35. ********************************************************************/
  36. int NLS_STR::strnicmp(
  37. const NLS_STR & nls,
  38. const ISTR & istrEnd ) const
  39. {
  40. if (QueryError() || !nls)
  41. return 0;
  42. CheckIstr( istrEnd );
  43. return ::strnicmpf( QueryPch(), nls.QueryPch(), istrEnd.QueryIB() );
  44. }
  45. int NLS_STR::strnicmp(
  46. const NLS_STR & nls,
  47. const ISTR & istrEnd,
  48. const ISTR & istrStart1 ) const
  49. {
  50. if (QueryError() || !nls)
  51. return 0;
  52. UIASSERT( istrEnd.QueryIB() >= istrStart1.QueryIB() );
  53. CheckIstr( istrEnd );
  54. CheckIstr( istrStart1 );
  55. return ::strnicmpf( QueryPch(istrStart1),
  56. nls.QueryPch(),
  57. istrEnd - istrStart1 );
  58. }
  59. int NLS_STR::strnicmp(
  60. const NLS_STR & nls,
  61. const ISTR & istrEnd,
  62. const ISTR & istrStart1,
  63. const ISTR & istrStart2 ) const
  64. {
  65. if (QueryError() || !nls)
  66. return 0;
  67. UIASSERT( istrEnd.QueryIB() >= istrStart1.QueryIB() );
  68. UIASSERT( istrEnd.QueryIB() >= istrStart2.QueryIB() );
  69. CheckIstr( istrEnd );
  70. CheckIstr( istrStart1 );
  71. nls.CheckIstr( istrStart2 );
  72. return ::strnicmpf( QueryPch(istrStart1),
  73. nls.QueryPch(istrStart2),
  74. istrEnd - istrStart1 );
  75. }