home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / FGREP11.ZIP / STD.C < prev    next >
C/C++ Source or Header  |  1990-08-27  |  1KB  |  56 lines

  1. /* std.c - compensate for a few missing library functions.
  2.    In the Public Domain; written by Mike Haertel. */
  3.  
  4. #include "std.h"
  5. #include "unix.h"
  6.  
  7. #ifdef X_memmove
  8. PTR
  9. DEFUN(memmove, (d, s, n), PTR d AND PTRCONST s AND size_t n)
  10. {
  11.   char *dd;
  12.   const char *ss;
  13.  
  14.   dd = d;
  15.   ss = s;
  16.   if (dd > ss && dd < ss + n)
  17.     {
  18.       dd += n;
  19.       ss += n;
  20.       while (n--)
  21.     *--dd = *--ss;
  22.     }
  23.   else
  24.     while (n--)
  25.       *dd++ = *ss++;
  26.   return d;
  27. }
  28. #endif /* X_memmove */
  29.  
  30. #ifdef X_remove
  31. #if defined(unix) || defined(__unix__)
  32. int
  33. DEFUN(remove, (filename), const char *filename)
  34. {
  35.   extern int EXFUN(unlink, (const char *));
  36.  
  37.   return unlink(filename);
  38. }
  39. #endif /* unix */
  40. #endif /* X_strerror */
  41.  
  42. #ifdef X_strerror
  43. #if defined(unix) || defined(__unix__)
  44. char *
  45. DEFUN(strerror, (errnum), int errnum)
  46. {
  47.   extern int sys_nerr;
  48.   extern char *sys_errlist[];
  49.  
  50.   if (errnum > 0 && errnum < sys_nerr)
  51.     return sys_errlist[errnum];
  52.   return "";
  53. }
  54. #endif /* unix */
  55. #endif /* X_strerror */
  56.