POK
strcmp.c
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 #include <core/dependencies.h>
18 #include <libc/string.h>
19 
20 #ifdef POK_CONFIG_NEEDS_FUNC_STRCMP
21 
22 __attribute__ ((weak))
23 int strcmp(const char *s1, const char *s2)
24 {
25  unsigned int i;
26  for (i = 0; ; i++)
27  {
28  if (s1[i] == '\0' && s2[i] == '\0')
29  return 0;
30  if (s1[i] < s2[i])
31  return -1;
32  if (s1[i] > s2[i])
33  return 1;
34  }
35 }
36 
37 #endif
38 
39 
40 #ifdef POK_CONFIG_NEEDS_FUNC_STRNCMP
41 
42 __attribute__ ((weak))
43 int strncmp(const char *s1, const char *s2, size_t size)
44 {
45  unsigned int i;
46  for (i = 0; i < size; i++)
47  {
48  if (s1[i] == '\0' && s2[i] == '\0')
49  return 0;
50  if (s1[i] < s2[i])
51  return -1;
52  if (s1[i] > s2[i])
53  return 1;
54  }
55  return 0;
56 }
57 
58 #endif
59 
60