source: trunk/third/sed/lib/strerror.c @ 17271

Revision 17271, 1.5 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r17270, which included commits to RCS files with non-trunk default branches.
Line 
1/* strerror -- return a string corresponding to an error number.
2   This is a quickie version only intended as compatability glue
3   for systems which predate the ANSI C definition of the function;
4   the glibc version is recommended for more general use.
5
6   Copyright (C) 1998 Free Software Foundation, Inc.
7
8   This program is free software; you can redistribute it and/or modify it
9   under the terms of the GNU General Public License as published by the
10   Free Software Foundation; either version 2, or (at your option) any
11   later version.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18   You should have received a copy of the GNU General Public License
19   along with this program; if not, write to the Free Software
20   Foundation, 59 Temple Place - Suite 330,
21   Boston, MA 02111-1307, USA.  */
22
23#include "config.h"
24
25#ifndef HAVE_STRERROR
26
27# include <stdio.h>
28# ifdef HAVE_STRING_H
29#  include <string.h>
30# endif
31# include <errno.h>
32# undef strerror
33
34extern int sys_nerr;
35extern char *sys_errlist[];
36
37char *
38strerror(e)
39  int e;
40{
41  static char unknown_string[] =
42    "Unknown error code #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
43
44  if (0<=e && e<sys_nerr)
45    return sys_errlist[e];
46  sprintf(unknown_string+20, "%d", e);
47  return unknown_string;
48}
49
50#endif /* !HAVE_STRERROR */
Note: See TracBrowser for help on using the repository browser.