Quentin Garnier | 5 Mar 2008 08:30

prop_dictionary_make_immutable

Any reason why that one isn't implemented?  It is in the man page and in
the include, but not in the actual code.

It should be simple enough though:

Index: common/lib/libprop/prop_dictionary.c
===================================================================
RCS file: /cvs/repository/src/common/lib/libprop/prop_dictionary.c,v
retrieving revision 1.20
diff -u -r1.20 prop_dictionary.c
--- common/lib/libprop/prop_dictionary.c	30 Aug 2007 12:23:54 -0000	1.20
+++ common/lib/libprop/prop_dictionary.c	1 Mar 2008 23:49:32 -0000
 <at>  <at>  -696,6 +696,20  <at>  <at> 
 }

 /*
+ * prop_dictionary_make_immutable --
+ *	Set the immutable flag on that dictionary.
+ */
+void
+prop_dictionary_make_immutable(prop_dictionary_t pd)
+{
+
+	_PROP_RWLOCK_WRLOCK(pd->pd_rwlock);
+	if (prop_dictionary_is_immutable(pd) == false)
+		pd->pd_flags |= PD_F_IMMUTABLE;
+	_PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
+}
+
+/*
(Continue reading)

Jason Thorpe | 5 Mar 2008 08:44

Re: prop_dictionary_make_immutable


On Mar 4, 2008, at 11:30 PM, Quentin Garnier wrote:

> Any reason why that one isn't implemented?  It is in the man page  
> and in
> the include, but not in the actual code.

Oversight, I guess.  Please go for it.

>
>
> It should be simple enough though:
>
> Index: common/lib/libprop/prop_dictionary.c
> ===================================================================
> RCS file: /cvs/repository/src/common/lib/libprop/prop_dictionary.c,v
> retrieving revision 1.20
> diff -u -r1.20 prop_dictionary.c
> --- common/lib/libprop/prop_dictionary.c	30 Aug 2007 12:23:54 -0000	 
> 1.20
> +++ common/lib/libprop/prop_dictionary.c	1 Mar 2008 23:49:32 -0000
>  <at>  <at>  -696,6 +696,20  <at>  <at> 
> }
>
> /*
> + * prop_dictionary_make_immutable --
> + *	Set the immutable flag on that dictionary.
> + */
> +void
> +prop_dictionary_make_immutable(prop_dictionary_t pd)
(Continue reading)

David Laight | 5 Mar 2008 08:45
Picon

Re: prop_dictionary_make_immutable

On Wed, Mar 05, 2008 at 08:30:21AM +0100, Quentin Garnier wrote:
> +	if (prop_dictionary_is_immutable(pd) == false)

Surely, if we are goig to use 'bool' this should be just:
	if (!prop_dictionary_is_immutable(pd))

	David

--

-- 
David Laight: david <at> l8s.co.uk

Quentin Garnier | 5 Mar 2008 08:56

Re: prop_dictionary_make_immutable

On Wed, Mar 05, 2008 at 07:45:18AM +0000, David Laight wrote:
> On Wed, Mar 05, 2008 at 08:30:21AM +0100, Quentin Garnier wrote:
> > +	if (prop_dictionary_is_immutable(pd) == false)
> 
> Surely, if we are goig to use 'bool' this should be just:
> 	if (!prop_dictionary_is_immutable(pd))

That's what I'd do, but I unashamedly copied prop_array_make_immutable
and kept that part for consistency.

--

-- 
Quentin Garnier - cube <at> cubidou.net - cube <at> NetBSD.org
"See the look on my face from staying too long in one place
[...] every time the morning breaks I know I'm closer to falling"
KT Tunstall, Saving My Face, Drastic Fantastic, 2007.
David Holland | 6 Mar 2008 04:31
Picon

Re: prop_dictionary_make_immutable

On Wed, Mar 05, 2008 at 07:45:18AM +0000, David Laight wrote:
 > On Wed, Mar 05, 2008 at 08:30:21AM +0100, Quentin Garnier wrote:
 > > +	if (prop_dictionary_is_immutable(pd) == false)
 > 
 > Surely, if we are goig to use 'bool' this should be just:
 > 	if (!prop_dictionary_is_immutable(pd))

Uh, what's the difference?

--

-- 
David A. Holland
dholland <at> netbsd.org

der Mouse | 6 Mar 2008 04:37
Picon

Re: prop_dictionary_make_immutable

>>> +	if (prop_dictionary_is_immutable(pd) == false)
>> Surely, if we are goig to use 'bool' this should be just:
>> 	if (!prop_dictionary_is_immutable(pd))
> Uh, what's the difference?

The same as the difference between return(0); and return 0;, or between

	if (something())
	 { printf("strangeness %d\n",reason());
	 }
and
	if (something ())
		printf ("strangeness %d\n", reason ());

That is to say, source-code aesthetics.  Presumably David thinks that
the if (! ...) style is preferable for use with a routine that
conceptually returns a boolean value (a position I agree with).

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse <at> rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Valentin Nechayev | 7 Mar 2008 23:30

Re: glob(3) extension

 Wed, Feb 13, 2008 at 21:35:37, mouse wrote about "glob(3) extension": 

> I propose an addition to glob(3): GLOB_HIDE_DOTDIRS, which makes . and
> .. vanish when matching wildcards, even if GLOB_PERIOD is set.

> Comments?  (I'm going to implement it for my own use, but would find it
> convenient to have it in the tree.)

I would prefer flag with the following result:

pattern.startswith("*") => match any name except one starting with '.'
  (i.e. set GLOB_PERIOD implicitly)
pattern.startswith("**") => match any name except "." and ".."
  (i.e. set GLOB_HIDE_DOTDIRS implicitly)
pattern.startswith("***") => match any name
pattern.startswith(".*") => match any name starting with '.' except "." and ".."
  (i.e. set GLOB_HIDE_DOTDIRS implicitly)
pattern.startswith(".**") => match any name starting with '.'

 ... and make it default for /bin/sh except Posix compatible mode is requested.

(of course, its result shall be limited according to tail of the pattern)

In this way we will cure innate patology of glob matching.

-netch-

David Holland | 8 Mar 2008 04:48
Picon

Re: glob(3) extension

On Sat, Mar 08, 2008 at 12:30:55AM +0200, Valentin Nechayev wrote:
 > I would prefer flag with the following result:
 > [...]

Unfortunately, that's incompatible with what ** means in zsh.

--

-- 
David A. Holland
dholland <at> netbsd.org

Valentin Nechayev | 8 Mar 2008 08:49

Re: glob(3) extension

 Sat, Mar 08, 2008 at 03:48:24, dholland-tech wrote about "Re: glob(3) extension": 

 >> I would prefer flag with the following result:
 >> [...]
> Unfortunately, that's incompatible with what ** means in zsh.

For zsh, it's declared as "shorthand" for another canonic form, so
isn't so fatal.
OTOH, having compact form for most useful cases and in the same time ability
to construct any set of names.

-netch-

der Mouse | 8 Mar 2008 19:15
Picon

Re: glob(3) extension

>> I propose an addition to glob(3): GLOB_HIDE_DOTDIRS, which makes .
>> and .. vanish when matching wildcards, even if GLOB_PERIOD is set.

(I actually called it GLOB_NO_DOTDIRS...for the trivial reason that
saving two characters made things line up without changing existing
definitions.)

>> Comments?  (I'm going to implement it for my own use, but would find
>> it convenient to have it in the tree.)
> I would prefer flag with the following result: [...]

Well, if you want to implement it, I certainly wouldn't oppose it.  It
won't do what I want, though, so I have no particular interest in doing
it myself, and am unlikely to use that flag, but I'm hardly opposed to
its being available to you.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse <at> rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Gmane