1151497Sru/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2003
2151497Sru   Free Software Foundation, Inc.
375584Sru     Written by James Clark (jjc@jclark.com)
475584Sru
575584SruThis file is part of groff.
675584Sru
775584Srugroff is free software; you can redistribute it and/or modify it under
875584Sruthe terms of the GNU General Public License as published by the Free
975584SruSoftware Foundation; either version 2, or (at your option) any later
1075584Sruversion.
1175584Sru
1275584Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY
1375584SruWARRANTY; without even the implied warranty of MERCHANTABILITY or
1475584SruFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1575584Srufor more details.
1675584Sru
1775584SruYou should have received a copy of the GNU General Public License along
1875584Sruwith groff; see the file COPYING.  If not, write to the Free Software
19151497SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
2075584Sru
21104862Sru#ifdef HAVE_CONFIG_H
22104862Sru#include <config.h>
23104862Sru#endif
24104862Sru
2575584Sru#include <stdio.h>
26151497Sru#include <errno.h>
27151497Sru#include <stdlib.h>		/* for MinGW */
2875584Sru
2975584Sru#define INT_DIGITS 19		/* enough for 64 bit integer */
3075584Sru
3175584Sru#ifndef HAVE_SYS_NERR
3275584Sruextern int sys_nerr;
3375584Sru#endif
3475584Sru#ifndef HAVE_SYS_ERRLIST
3575584Sruextern char *sys_errlist[];
3675584Sru#endif
3775584Sru
3875584Sruchar *strerror(n)
3975584Sru     int n;
4075584Sru{
4175584Sru  static char buf[sizeof("Error ") + 1 + INT_DIGITS];
4275584Sru  if (n >= 0 && n < sys_nerr && sys_errlist[n] != 0)
4375584Sru    return sys_errlist[n];
4475584Sru  else {
4575584Sru    sprintf(buf, "Error %d", n);
4675584Sru    return buf;
4775584Sru  }
4875584Sru}
49