strncmp.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 2k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. /*****************************************************************/ 
  2. /**   Microsoft Windows for Workgroups **/
  3. /**   Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/ 
  5. /*
  6. strncmp.cxx
  7. NLS/DBCS-aware string class: strncmp method
  8. This file contains the implementation of the strncmp 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::strncmp
  28. SYNOPSIS: Case sensitve string compare up to index position istrLen
  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::strncmp(
  37. const NLS_STR & nls,
  38. const ISTR   & istrEnd ) const
  39. {
  40. if (QueryError() || !nls)
  41. return 0;
  42. CheckIstr( istrEnd );
  43. return ::strncmpf( QueryPch(), nls.QueryPch(), istrEnd.QueryIB() );
  44. }
  45. INT NLS_STR::strncmp(
  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 ::strncmpf( QueryPch(istrStart1),
  56.    nls.QueryPch(),
  57.    istrEnd - istrStart1 );
  58. }
  59. INT NLS_STR::strncmp(
  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 ::strncmpf( QueryPch(istrStart1),
  73.    nls.QueryPch(istrStart2),
  74.    istrEnd - istrStart1 );
  75. }