[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: add limited support for Solaris 10 ZFS-style ACLs to gnulib
From: |
Bruno Haible |
Subject: |
Re: add limited support for Solaris 10 ZFS-style ACLs to gnulib |
Date: |
Tue, 20 Mar 2007 02:12:21 +0100 |
User-agent: |
KMail/1.5.4 |
Paul Eggert wrote:
> +#if ENABLE_NLS
> +# include <libintl.h>
> +# define _(Text) gettext (Text)
> +#else
> +# define _(Text) Text
> +#endif
This can be abbreviated to
#include "gettext.h"
admitting a dependency to the 'gettext' module. (People who don't want
the gettext module can override it with a dummy one.)
> +#define ACL_NOT_WELL_SUPPORTED(Errno) \
> + (Errno == ENOTSUP || Errno == ENOSYS || Errno == EINVAL)
Here I would parenthesize (Errno).
> +/* Return the number of entries in ACL. */
> +
> +int
> +acl_entries (acl_t acl)
> +{
> + char *t;
> + int entries = 0;
> + char *text = acl_to_text (acl, NULL);
> + if (! text)
> + return -1;
> + for (t = text; *t; t++)
> + entries += (*t == '\n');
> + acl_free (text);
> + return entries;
> +}
It may be faster to use the libc's optimized strchr() function. (Untested.)
*** lib/acl_entries.c 19 Mar 2007 21:58:57 -0000 1.1
--- lib/acl_entries.c 20 Mar 2007 01:08:46 -0000
***************
*** 22,39 ****
#include "acl-internal.h"
/* Return the number of entries in ACL. */
int
acl_entries (acl_t acl)
{
char *t;
! int entries = 0;
char *text = acl_to_text (acl, NULL);
if (! text)
return -1;
! for (t = text; *t; t++)
! entries += (*t == '\n');
acl_free (text);
return entries;
}
--- 22,42 ----
#include "acl-internal.h"
+ #include <string.h>
+
/* Return the number of entries in ACL. */
int
acl_entries (acl_t acl)
{
char *t;
! int entries;
char *text = acl_to_text (acl, NULL);
if (! text)
return -1;
! entries = 0;
! for (t = text; (t = strchr (t, '\n')) != NULL; t++)
! entries++;
acl_free (text);
return entries;
}
Bruno