99a686a409ffeea3ca09fbd09fcb6101e90696de
[platform/upstream/bash.git] / portbash / strings.sh
1 #! /bin/sh
2 CC=cc
3 export CC
4
5 if [ -f /usr/include/string.h ]; then
6         STRINGH='<string.h>'
7 elif [ -f /usr/include/strings.h ]; then
8         STRINGH='<strings.h>'
9 else
10         exit 1
11 fi
12
13 cat > x.c << EOF
14 #include $STRINGH
15
16 #ifndef strchr
17 extern char *strchr();
18 #endif
19
20 char *x = "12345";
21
22 main()
23 {
24         char    *s;
25
26         s = strchr(x, '2');
27         if (s)
28                 exit(0);
29         exit(1);
30 }
31 EOF
32
33 if ${CC} x.c >/dev/null 2>&1
34 then
35         if ./a.out
36         then
37                 echo '#define HAVE_STRCHR'
38         fi
39 fi
40
41 rm -f x.c x.o a.out
42
43 cat > x.c << EOF
44 extern char *strerror();
45
46 main()
47 {
48         char    *s;
49
50         s = strerror(2);
51         if (s)
52                 exit(0);
53         exit(1);
54 }
55 EOF
56
57 if ${CC} x.c >/dev/null 2>&1
58 then
59         if ./a.out
60         then
61                 echo '#define HAVE_STRERROR'
62         fi
63 fi
64
65 rm -f x.c x.o a.out
66
67
68 cat > x.c << EOF
69
70 main()
71 {
72         if (strcasecmp("abc", "AbC") == 0)
73                 exit(0);
74         exit(1);
75 }
76 EOF
77
78 if ${CC} x.c >/dev/null 2>&1
79 then
80         if ./a.out
81         then
82                 echo '#define HAVE_STRCASECMP'
83         fi
84 fi
85
86 rm -f x.c x.o a.out
87 exit 0