OSDN Git Service

* vax.h (ASM_SPEC): Pass `-J' to assembler.
[pf3gnuchains/gcc-fork.git] / texinfo / info / clib.c
1 /* clib.c: Functions which we normally expect to find in the C library.
2    $Id: clib.c,v 1.1.1.1 1997/08/21 22:57:59 jason Exp $
3
4    This file is part of GNU Info, a program for reading online documentation
5    stored in Info format.
6
7    Copyright (C) 1995 Free Software Foundation, Inc.
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2, or (at your option)
12    any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23    Written by Brian Fox (bfox@ai.mit.edu). */
24
25 #include <stdio.h>
26
27 #if defined (HAVE_UNISTD_H)
28 #include <unistd.h>
29 #endif
30
31 #if defined (HAVE_STDLIB_H)
32 #include <stdlib.h>
33 #endif
34
35 #if defined (HAVE_STRING_H)
36 #include <string.h>
37 #endif
38
39 #include <sys/errno.h>
40
41 extern void *xmalloc (), *xrealloc ();
42 #include "general.h"
43
44 #if !defined (errno)
45 extern int errno;
46 #endif
47
48 #if !defined (HAVE_STRERROR)
49 extern char *sys_errlist[];
50 extern int sys_nerr;
51
52 char *
53 strerror (num)
54      int num;
55 {
56   if (num >= sys_nerr)
57     return ("");
58   else
59     return (sys_errlist[num]);
60 }
61 #endif /* !HAVE_STRERROR */
62
63 #if !defined (HAVE_STRCASECMP)
64 /* This Unix doesn't have the strcasecmp () function. */
65 int
66 strcasecmp (string1, string2)
67      char *string1, *string2;
68 {
69   char ch1, ch2;
70
71   for (;;)
72     {
73       ch1 = *string1++;
74       ch2 = *string2++;
75
76       if (!(ch1 | ch2))
77         return (0);
78
79       ch1 = info_toupper (ch1);
80       ch2 = info_toupper (ch2);
81
82       if (ch1 != ch2)
83         return (ch1 - ch2);
84     }
85 }
86
87 /* Compare at most COUNT characters from string1 to string2.  Case
88    doesn't matter. */
89 int
90 strncasecmp (string1, string2, count)
91      char *string1, *string2;
92      int count;
93 {
94   register char ch1, ch2;
95
96   while (count)
97     {
98       ch1 = *string1++;
99       ch2 = *string2++;
100
101       ch1 = info_toupper (ch1);
102       ch2 = info_toupper (ch2);
103
104       if (ch1 == ch2)
105         count--;
106       else
107         break;
108     }
109   return (count);
110 }
111 #endif /* !STRCASECMP */
112