|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
WHINY_USERS=0I was making some WHINY_USERS performance tests, following the example at http://awk.info/?tip/whinyUsers It looks to me that not only WHINY_USERS=1, but also WHINY_USERS=0 or even WHINY_USERS= are leading to sorted processing of arrays. I have to actually unset WHINY_USERS in order to get back to default array processing. The corresponding test in AWK source code (main.c) is: if (getenv("WHINY_USERS") != NULL) whiny_users = TRUE; I am wondering if this is rather a feature or something else? Regards, Hermann |
|
|
|
|
|
Re: WHINY_USERS=0Aharon Robbins scripsit:
> The feature as coded means "if WHINY_USERS exists in the environment, > enable the whiny user related features." (There are at least two.) Three, but I concede that I can't figure out how to trigger the third use of the feature, which appears to print a warning that a file is unopenable just before printing a fatal error that it's unopenable. -- I now introduce Professor Smullyan, John Cowan who will prove to you that either cowan@... he doesn't exist or you don't exist, http://www.ccil.org/~cowan but you won't know which. --Melvin Fitting |
|
|
Re: WHINY_USERS=0Aharon Robbins wrote:
> It's what programmer types call an "easter egg", meaning an undocumented > feature with unusual or interesting behavior, and I intend to keep it > that way (but see the gawk.texi file :-). > > The feature as coded means "if WHINY_USERS exists in the environment, > enable the whiny user related features." (There are at least two.) > > So, the behavior you're seeing is what I wanted. I don't intend to > change it. > > Personally, I think you should use asort or asorti if you want array > sorting. The code is much clearer that way. Aharon, Thanks for the explanations, which confirms my observation that WHINY_USERS=0 isn't enough to unset the variable. About asort() and asorti(): I use these functions occasionally, but what I actually need most are simply sorted *original* array indices (which almost always have some meaning, like country code, or similar, so I don't want to destroy them). IMO, there is nothing better and cleaner than WHINY_USERS to achieve this gawk behaviour. The built-in asorti() function forces me to copy src array into dest array in order to avoid the loss of original indices. This makes the code more complicated, as I see it. Anyway: I actually didn't want to start a discussion here. Thanks again for the WHINY_USERS easter egg!. Hermann PS for Tim: You might want to re-visit your WHINY_USERS performance test described in http://awk.info/?tip/whinyUsers |
|
|
|
|
|
Re: WHINY_USERS=0Hermann Peifer <peifer@...> writes:
> $ gawk '1' somedir/ somefile > gawk: cmd. line:1: fatal: cannot open file `somedir/' for reading (Success) 2009-10-26 Andreas Schwab <schwab@...> * io.c (iop_open): Set errno when rejecting a directory. --- io.c.~1.25.~ 2009-10-16 08:50:33.000000000 +0200 +++ io.c 2009-10-26 13:26:52.000000000 +0100 @@ -1673,6 +1673,8 @@ strictopen: if (isdir) *isdir = TRUE; (void) close(openfd); /* don't leak fds */ + /* Set useful error number. */ + errno = EISDIR; return NULL; } } Andreas. -- Andreas Schwab, schwab@... GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." |
|
|
Re: WHINY_USERS=0so the default (undocumented) behavior is that for(i in a) processes i
in sorted order? i'm puzzled by that. i remember Kerningham saying they had that in awk 1.0 then pulled it our cause it made everything too slow. aharon- did you come up with some neat incremental sorting trick? t On Mon, Oct 26, 2009 at 5:26 AM, Hermann Peifer <peifer@...> wrote: > Aharon Robbins wrote: >> >> It's what programmer types call an "easter egg", meaning an undocumented >> feature with unusual or interesting behavior, and I intend to keep it >> that way (but see the gawk.texi file :-). >> >> The feature as coded means "if WHINY_USERS exists in the environment, >> enable the whiny user related features." (There are at least two.) >> >> So, the behavior you're seeing is what I wanted. I don't intend to >> change it. >> >> Personally, I think you should use asort or asorti if you want array >> sorting. The code is much clearer that way. > > Aharon, > > Thanks for the explanations, which confirms my observation that > WHINY_USERS=0 isn't enough to unset the variable. > > About asort() and asorti(): I use these functions occasionally, but what I > actually need most are simply sorted *original* array indices (which almost > always have some meaning, like country code, or similar, so I don't want to > destroy them). IMO, there is nothing better and cleaner than WHINY_USERS to > achieve this gawk behaviour. The built-in asorti() function forces me to > copy src array into dest array in order to avoid the loss of original > indices. This makes the code more complicated, as I see it. > > Anyway: I actually didn't want to start a discussion here. Thanks again for > the WHINY_USERS easter egg!. > > Hermann > > PS for Tim: You might want to re-visit your WHINY_USERS performance test > described in http://awk.info/?tip/whinyUsers > -- there are those who call me... (dr) timm (menzies)? morgantown (39.6n, -79w), usa assoc prof csee, wvu http://menzies.us 'Hydrogen is a light, odorless gas, which, given enough time, turns into people.' |
|
|
Re: WHINY_USERS=0Tim Menzies scripsit:
> so the default (undocumented) behavior is that for(i in a) processes i > in sorted order? No, the default behavior is to process in random order. The undocumented environment variable WHINY_USERS uses sorted order instead. -- John Cowan cowan@... http://ccil.org/~cowan Heckler: "Go on, Al, tell 'em all you know. It won't take long." Al Smith: "I'll tell 'em all we *both* know. It won't take any longer." |
|
|
Re: WHINY_USERS=0On Monday 26 October 2009, Tim Menzies wrote:
> so the default (undocumented) behavior is that for(i in a) processes i > in sorted order? No, the default is unspecified order. If the variable WHINY_USERS exists in the environment (with any value, including 0) then the indices are returned in order. -- D. |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |