summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/fgrep/std.c
blob: fb98fe614847d7c2e95b74841e2ee006fc6abcc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* std.c - compensate for a few missing library functions.
   In the Public Domain; written by Mike Haertel. */

#include "std.h"
#include "unix.h"

#ifdef X_memmove
PTR
DEFUN(memmove, (d, s, n), PTR d AND PTRCONST s AND size_t n)
{
  char *dd;
  const char *ss;

  dd = d;
  ss = s;
  if (dd > ss && dd < ss + n)
    {
      dd += n;
      ss += n;
      while (n--)
	*--dd = *--ss;
    }
  else
    while (n--)
      *dd++ = *ss++;
  return d;
}
#endif /* X_memmove */

#ifdef X_remove
#if defined(unix) || defined(__unix__)
int
DEFUN(remove, (filename), const char *filename)
{
  extern int EXFUN(unlink, (const char *));

  return unlink(filename);
}
#endif /* unix */
#endif /* X_strerror */

#ifdef X_strerror
#if defined(unix) || defined(__unix__)
char *
DEFUN(strerror, (errnum), int errnum)
{
  extern int sys_nerr;
  extern char *sys_errlist[];

  if (errnum > 0 && errnum < sys_nerr)
    return sys_errlist[errnum];
  return "";
}
#endif /* unix */
#endif /* X_strerror */