Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /* strncmp( const char *, const char *, size_t )
  2.  
  3.    This file is part of the Public Domain C Library (PDCLib).
  4.    Permission is granted to use, modify, and / or redistribute at will.
  5. */
  6.  
  7. #include <string.h>
  8.  
  9. int strncmp( const char * s1, const char * s2, size_t n )
  10. {
  11.     while ( n && *s1 && ( *s1 == *s2 ) )
  12.     {
  13.         ++s1;
  14.         ++s2;
  15.         --n;
  16.     }
  17.  
  18.     if ( n == 0 )
  19.     {
  20.         return 0;
  21.     }
  22.     else
  23.     {
  24.         return ( *( unsigned char * )s1 - * ( unsigned char * )s2 );
  25.     }
  26. }