Main Page | Alphabetical List | Class List | File List | Class Members | File Members

strncmp.h

Go to the documentation of this file.
00001 #ifndef __STRNCMP_H_
00002 #define __STRNCMP_H_
00003 
00004 #include <nlibc.h>
00005 #include <string/stringexpand.h>
00006 
00036 #ifndef __HAS_MAIN
00037 extern int strncmp(const char *s1, const char *s2, size_t n);
00038 #else
00039 #if !defined(__cflow_processed) || defined(_uses_strncmp_strncmp_h)
00040 int strncmp(const char *s1, const char *s2, size_t n) {
00041     int l1 = strlen(s1);
00042     int l2 = strlen(s2);
00043     int *a1 = (int *)stringexpand(s1, l1);
00044     int *a2 = (int *)stringexpand(s2, l2);
00045 
00046     if( n==0 ) 
00047         return 0;
00048     do {
00049         if (*a1 != *a2++)
00050               return (*a1 - *(--a2));
00051         if (*a1++ == 0)
00052               break;
00053     } while (--n != 0);
00054     return (0);
00055 }
00056 #endif  // _uses_strncmp
00057 #endif // Has Main
00058 
00059 #endif // __STRNCMP_H_

Generated on Fri Jul 14 10:51:32 2006 for nlibc by doxygen 1.3.5