The DLL of 1.6.8 (mswin32-ruby16.dll) does not show this behaviour.
Is that known, and if yes, how can I get rid of it? Any hints appreciated.
Thanks,
Christian
Christian Kaiser wrote:
I get that too, but often because I try to #write to something I cannot
write to. The error message is not descriptive, but there is often a cause.
When exactly do you get the message and why do you think you should not
be getting it ?
kaspar - code philosopher
- -- stolen off the net --
Ban the bomb. Save the world for conventional warfare.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFAf+NEFifl4CA0ImQRAtzMAJ9JH6wRoueiiFEecEN2Yk+S1FVCbACeMDcB
ayV3fiuaJtr89l9Ff+Kwv6w=
=z+Dy
-----END PGP SIGNATURE-----
because it is at a simple code like
logstring = "#{self.type}: hallo"
and the trace is then:
'write'
'type'
...
(why does 'type' call write? And why on an invalid descriptor?)
or at a Regexp comparison:
if sPart =~ "^--(?:[\r\n]|$)" # end of multi-part mail
I get it with a call stack of:
'write'
'=~'
...
Again, why does '=~' call 'write'? Strange, isn't it?
Christian
"Kaspar Schiess" <eu...@space.ch> wrote in message
news:407FE344...@space.ch...
| logstring = "#{self.type}: hallo"
| (why does 'type' call write? And why on an invalid descriptor?)
.. warning: Object#type is deprecated; use Object#class
| or at a Regexp comparison:
| if sPart =~ "^--(?:[\r\n]|$)" # end of multi-part mail
| Again, why does '=~' call 'write'? Strange, isn't it?
..warning: string =~ string will be obsolete; use explicit regexp
Ruby writes warnings to stdout. Did you close it somehow ?
kaspar - code philosopher
- -- stolen off the net --
"Having major planets disappear is always a bad sign."
-- Jim Blinn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFAf/9YFifl4CA0ImQRAsDjAKChViauyTnaT8FT0Gd6cGxUVz7FdACZASHW
DnfH/MOVjl1jFvi40RBRH3k=
=wqq/
-----END PGP SIGNATURE-----
Oh, I hoped Ruby code could be kept compatible between versions. Seems I
need to decide for one version. Hmmmm..... I did not expect this and I don't
like it. I come from the C/C++/Pascal/... side, and they keep newer versions
code compatible (as good as they can), so switching to a new version of a
compiler does not need much of code rewrites.
If they are changing it, I hope they change all the names of several
procedures (chomp, chop, ....) to ones that are memorizable and programmers
from other languages are used to or are more syntactically correct
(includes? instead of include?, ...) :))) My main problem with Ruby is that
I always need a reference manual helping me, as the routine names are not
easly memorizable :|
But that's not the topic I wanted to have solved, and I guess innumerable
mails have been posted concerning it.
Thanks for your help. I vote for a change that this stdout behaviour will
not raise an exception any more, as it makes no sense to get an exception
from this.
Christian
"Kaspar Schiess" <eu...@space.ch> wrote in message
news:407FFF5...@space.ch...
return true if sSubject =~ /abcxyz/
return true if sSubject =~ /d/
return true if sSubject =~ /ef/
...
Will that now need that I write
return true if /abcxyz/ =~ sSubject
return true if /d/ =~ sSubject
return true if /ef/ =~ sSubject
...
which is less readable as the formatting becomes ragged? OK, I can create an
array of Regexp's, but for 3 lines this is overkill.
Christian
return true if / abcxyz | ef | d /x.match(sSubject)
--
Simon Strandgaard
yes, but I have that many expressions that are 50-70 chars long, that I
would need hundreds of chars in one line for the expression, which is
neither good style nor readable. The text of my mail was just an example to
show the ruggedness:)))
And it's not even only ruggedness - in
if a =~ /.../
it's much faster (and "logical" for humans) to see that the variable "a" is
being tested as in
if /.../ =~ a
so in my eyes the new convention reduces readbility.
Real code looks now like
BADWORDS = []
# pharmacy
BADWORDS <<
/(?:vicodin|viagra|sildenafil|citrate|xanax|xnax|valium|norco|levsitra)/
BADWORDS <<
/(?:cialis|phentermine|aseptic|pharmacy|medication|pharmaceuticals?|medical)
/
BADWORDS << /\b(?:meds|drugs)\b/
# money
BADWORDS << /(?:mortgages?)/
BADWORDS << /\b(?:cable bils?|busines ofers?|casino|life insurance)\b/
# sex
BADWORDS << /(?:orgasms?)/
BADWORDS << /\b(?:\*\*\*\*\*|sex|enlarge it)\b/
...
and
sSubject = reduceSubjectToASCII(sSubjectIn)
BADWORDS.each { |re| return true if re =~ sSubject }
return false
Christian
"Simon Strandgaard" <neo...@adslhome.dk> wrote in message
news:pan.2004.04.16....@adslhome.dk...
Another option:
case aSubject when /abcxyz/, /d/, /ef/: return end
I made a few improvements.. what do you think?
server> ruby a.rb
BAD: do DrUgS.. experience new things
BAD: play on casino and win big money
OK: pleasure with Ruby. BTW: its free
BAD: buy viagra
BAD: christina agulera caught backstage
BAD: britney spears
BAD: get your university diploma here
server> expand -t2 a.rb
input = <<WORDS
# pharmacy
vicodin viagra sildenafil citrate xanax xnax valium norco levsitra
cialis phentermine aseptic pharmacy medication pharmaceuticals? medical
meds drugs
# money
mortgages? cable_bils? life_insurance busines_ofers? casino
# music
britney_spears christina_agulera
# misc
diploma
WORDS
lines = input.to_a
# remove comments
lines.delete_if {|line| line.match(/^\#/)}
# transform lines into words
words = lines.inject([]) {|result, line| result + line.split(/\s/) }
# replace underscores with spaces
words.map!{|word| word.gsub!(/_/, ' '); word}
words.delete_if {|word| word == ''}
#p words
# lets make a big regexp
regexp_str = words.map{|word| Regexp.escape(word)}.join('|')
regexp = Regexp.new(regexp_str, Regexp::IGNORECASE)
#p regexp.inspect
testdata = [
"do DrUgS.. experience new things",
"play on casino and win big money",
"pleasure with Ruby. BTW: its free",
"buy viagra",
"christina agulera caught backstage",
"britney spears",
"get your university diploma here"
]
testdata.each do |str|
res = regexp.match(str) ? "BAD" : " OK"
puts "#{res}: #{str}"
end
server>
--
Simon Strandgaard
thanks - that's a nice idea!
Christian
"Joel VanderWerf" <vj...@PATH.Berkeley.EDU> wrote in message
news:408035F7...@path.berkeley.edu...
May ways to rome... :)
Christian
"Simon Strandgaard" <neo...@adslhome.dk> wrote in message
news:pan.2004.04.16....@adslhome.dk...
The better one starts out, the better chances for success.
wish you luck. Just ask if you have any problems with it.
--
Simon Strandgaard
At Sat, 17 Apr 2004 01:59:11 +0900,
Christian Kaiser wrote in [ruby-talk:97372]:
> I don't ever open or close stdout - I wrote a DLL which itself loads the
> Ruby DLL. Strange that this exception is only thrown irregularly, once in
> hundreds of calls. I would have expected such a behaviour, if it were
> reproducable. It just happens sometimes, then a few minutes later again, ...
Your program may be GUI mode? stdin/stdout/stderr are not
opened for GUI mode program. By setting $VERBOSE to nil, all
warnings will be suppressed.
--
Nobu Nakada