Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/strerror.c @ 7581:45c727466eb8
Move stat.h-substitute stuff from lib/stat-macros.h to lib/stat_.h.
stat-macros.h is now for our own macros, whereas stat_h is for
macros in the <sys/stat.h> name space.
* lib/stat-macros.h: Remove copyright notice, as this file is now tiny.
(STAT_MACROS_H): Remove.
(S_IFMT, S_ISBLK, S_ISCHR, S_ISDIR, S_ISFIFO, S_ISLNK, S_ISNAM):
(S_ISMPB, S_ISMPC, S_ISNWK, S_ISREG, S_ISSOCK, S_ISDOOR, S_ISPORT):
(S_TYPEISMQ, S_TYPEISTMO, S_TYPEISSEM, S_TYPEISSHM, S_ISCTG, S_ISOFD):
(S_ISOFL, S_ISWHT, S_ISUID, S_ISGID, S_ISVTX, S_IRUSR, S_IRGRP):
(S_IROTH, S_IWUSR, S_IWGRP, S_IWOTH, S_IXUSR, S_IXGRP, S_IXOTH):
(S_IRWXU, S_IRWXG, S_IRWXO, S_IXUGO, S_IRWXUGO):
Move these macros to ...
* lib/stat_.h: here. Don't include stat-macros.h.
* lib/canonicalize.c: Don't include stat-macros.h.
* lib/chown.c: Likewise.
* lib/euidaccess.c: Likewise.
* lib/file-type.c: Likewise.
* lib/filemode.c: Likewise.
* lib/glob.c: Likewise.
* lib/isapipe.c: Likewise.
* lib/lchown.c: Likewise.
* lib/lstat.c: Likewise.
* lib/mkdir-p.c: Likewise.
* lib/rmdir.c: Likewise.
* m4/lchown.m4 (gl_FUNC_LCHOWN): Don't require gl_STAT_MACROS.
* m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Don't check for io.h
unless mkdir isn't declared, to speed up 'configure'.
Always create sys/stat.h, since it's unlikely any real sys/stat.h
would define all the S_* symbols.
* modules/canonicalize (Depends-on):
Depend on sys_stat, not stat-macros.
* modules/chown: Likewise.
* modules/euidaccess: Likewise.
* modules/filemode: Likewise.
* modules/file-type: Likewise.
* modules/glob: Likewise.
* modules/isapipe: Likewise.
* modules/lchown: Likewise.
* modules/lstat: Likewise.
* modules/mkancesdirs: Likewise.
* modules/rmdir: Likewise.
* modules/mkdir-p (Depends-on): Also depend on sys_stat.
* modules/modechange: Likewise.
* modules/stat-macros (Files): Remove m4/stat-macros.m4.
(configure.ac): Remove gl_STAT_MACROS.
* modules/sys_stat (Depends-on): Remove stat-macros.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 27 Oct 2006 20:46:43 +0000 |
parents | 8a1a9361108c |
children | e5ee9891c553 |
rev | line source |
---|---|
3928 | 1 /* strerror.c --- ANSI C compatible system error routine |
2 | |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
3 Copyright (C) 1986, 1988, 1989, 1991, 2002, 2003, 2006 Free |
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
4 Software Foundation, Inc. |
3928 | 5 |
6 This program is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2, or (at your option) | |
9 any later version. | |
10 | |
11 This program is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with this program; if not, write to the Free Software Foundation, | |
5848
a48fb0e98c8c
*** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents:
4487
diff
changeset
|
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
3928 | 19 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
20 #include <config.h> |
3928 | 21 |
4487
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
22 #include <limits.h> |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
23 |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
24 /* Don't include <stdio.h>, since it may or may not declare |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
25 sys_errlist and its declarations may collide with ours. Just |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
26 declare the stuff that we need directly. Standard hosted C89 |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
27 implementations define strerror and they don't need this strerror |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
28 function, so take some liberties with the standard to cater to |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
29 ancient or limited freestanding implementations. */ |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
30 int sprintf (char *, char const *, ...); |
3928 | 31 extern int sys_nerr; |
32 extern char *sys_errlist[]; | |
33 | |
34 char * | |
4487
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
35 strerror (int n) |
3928 | 36 { |
4487
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
37 static char const fmt[] = "Unknown error (%d)"; |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
38 static char mesg[sizeof fmt + sizeof n * CHAR_BIT / 3]; |
3928 | 39 |
4487
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
40 if (n < 0 || n >= sys_nerr) |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
41 { |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
42 sprintf (mesg, fmt, n); |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
43 return mesg; |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
44 } |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
45 else |
e9cc723f9777
Include config.h, limits.h. Declare sprintf.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3928
diff
changeset
|
46 return sys_errlist[n]; |
3928 | 47 } |