Mercurial > hg > octave-lojdl > gnulib-hg
annotate lib/getgroups.c @ 8045:7dcf8a1f2f5e
* lib/regex.h (_Restrict_): Renamed from __restrict, to avoid
a circularity problem with HP-UX ia64 reported by Bob Proulx in
<http://lists.gnu.org/archive/html/bug-gnulib/2007-01/msg00394.html>.
All uses changed.
(_Restrict_arr_): Renamed from __restrict_arr, for similar reasons.
All uses changed.
* lib/regcomp.c, lib/regexec.c: Change all uses from __restrict
to _Restrict_.
* lib/regexec.c (regexec): Declare pmatch with _Restrict_arr_, so that
the parameter matches the prototype.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 29 Jan 2007 00:37:14 +0000 |
parents | 8a1a9361108c |
children | bbbbbf4cd1c5 |
rev | line source |
---|---|
818 | 1 /* provide consistent interface to getgroups for systems that don't allow N==0 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
2 |
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
3 Copyright (C) 1996, 1999, 2003, 2006 Free Software Foundation, Inc. |
818 | 4 |
5 This program is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 2, or (at your option) | |
8 any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software Foundation, | |
5848
a48fb0e98c8c
*** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents:
4891
diff
changeset
|
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
818 | 18 |
19 /* written by Jim Meyering */ | |
20 | |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
21 #include <config.h> |
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
22 |
818 | 23 #include <stdio.h> |
24 #include <sys/types.h> | |
4795
ac6111c4f643
Include <errno.h>, <stdlib.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4504
diff
changeset
|
25 #include <errno.h> |
ac6111c4f643
Include <errno.h>, <stdlib.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4504
diff
changeset
|
26 #include <stdlib.h> |
818 | 27 |
4504
66dca1409f3e
Include "xalloc.h" instead of declaring xalloc fns; from Dmitry V. Levin.
Paul Eggert <eggert@cs.ucla.edu>
parents:
2807
diff
changeset
|
28 #include "xalloc.h" |
818 | 29 |
834 | 30 /* On at least Ultrix 4.3 and NextStep 3.2, getgroups (0, 0) always fails. |
31 On other systems, it returns the number of supplemental groups for the | |
1732 | 32 process. This function handles that special case and lets the system- |
33 provided function handle all others. */ | |
818 | 34 |
35 int | |
4795
ac6111c4f643
Include <errno.h>, <stdlib.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4504
diff
changeset
|
36 getgroups (int n, GETGROUPS_T *group) |
818 | 37 { |
834 | 38 int n_groups; |
818 | 39 GETGROUPS_T *gbuf; |
4795
ac6111c4f643
Include <errno.h>, <stdlib.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4504
diff
changeset
|
40 int saved_errno; |
818 | 41 |
42 #undef getgroups | |
43 | |
44 if (n != 0) | |
45 return getgroups (n, group); | |
46 | |
47 n = 20; | |
48 while (1) | |
49 { | |
4795
ac6111c4f643
Include <errno.h>, <stdlib.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4504
diff
changeset
|
50 /* No need to worry about address arithmetic overflow here, |
ac6111c4f643
Include <errno.h>, <stdlib.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4504
diff
changeset
|
51 since the ancient systems that we're running on have low |
ac6111c4f643
Include <errno.h>, <stdlib.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4504
diff
changeset
|
52 limits on the number of secondary groups. */ |
4891
459ebb7c12d8
* getgroups.c (getgroups): xmalloc takes one argument, not two.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4824
diff
changeset
|
53 gbuf = xmalloc (n * sizeof *gbuf); |
834 | 54 n_groups = getgroups (n, gbuf); |
55 if (n_groups < n) | |
818 | 56 break; |
4824
b3e190d8e109
(getgroups): Don't use xrealloc, since we don't need the buffer
Paul Eggert <eggert@cs.ucla.edu>
parents:
4795
diff
changeset
|
57 free (gbuf); |
818 | 58 n += 10; |
59 } | |
60 | |
4795
ac6111c4f643
Include <errno.h>, <stdlib.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4504
diff
changeset
|
61 saved_errno = errno; |
818 | 62 free (gbuf); |
4795
ac6111c4f643
Include <errno.h>, <stdlib.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4504
diff
changeset
|
63 errno = saved_errno; |
818 | 64 |
834 | 65 return n_groups; |
818 | 66 } |