[#2529] concerns about Proc,lambda,block — "David A. Black" <dblack@...>

Hi --

39 messages 2004/03/01
[#2531] Re: concerns about Proc,lambda,block — ts <decoux@...> 2004/03/01

>>>>> "D" == David A Black <dblack@wobblini.net> writes:

[#2533] Re: concerns about Proc,lambda,block — "David A. Black" <dblack@...> 2004/03/01

Hi --

[#2537] Re: concerns about Proc,lambda,block — matz@... (Yukihiro Matsumoto) 2004/03/01

Hi,

[#2542] Re: concerns about Proc,lambda,block — Mathieu Bouchard <matju@...> 2004/03/02

[#2545] Re: concerns about Proc,lambda,block — matz@... (Yukihiro Matsumoto) 2004/03/02

Hi,

[#2550] Re: concerns about Proc,lambda,block — Mauricio Fern疣dez <batsman.geo@...> 2004/03/03

On Wed, Mar 03, 2004 at 07:51:10AM +0900, Yukihiro Matsumoto wrote:

[#2703] Proposed patch to add SSL support to net/pop.rb — Daniel Hobe <daniel@...>

This patch adds support to Net::POP for doing POP over SSL. Modeled on how

19 messages 2004/03/27
[#2704] Re: Proposed patch to add SSL support to net/pop.rb — Daniel Hobe <daniel@...> 2004/03/27

This is v2 of the patch. Cleaned up a bit and added some more docs.

[#2707] Re: Proposed patch to add SSL support to net/pop.rb — Daniel Hobe <daniel@...> 2004/03/28

v3 of the patch:

[#2721] Re: Proposed patch to add SSL support to net/pop.rb — Minero Aoki <aamine@...> 2004/03/30

Hi,

Re: patch to tempfile.rb to handle ENAMETOOLONG

From: Joel VanderWerf <vjoel@...>
Date: 2004-03-11 06:18:42 UTC
List: ruby-core #2643
Yukihiro Matsumoto wrote:
> Hi,
> 
> In message "patch to tempfile.rb to handle ENAMETOOLONG"
>     on 04/03/11, Joel VanderWerf <vjoel@PATH.Berkeley.EDU> writes:
> 
> |Can anyone think of a better way to handle ENAMETOOLONG on systems that 
> |have limited filename lengths?
> |
> |On QNX, filenames are limited to 48 bytes.
> 
> Handling ENAMETOOLONG sounds nice, but is it OK to chop off path name,
> or should we just raise exception?

Is the name of a tempfile significant, as long as it is unique? It looks 
like tempfile.rb makes an effort (10 tries) to find a unique name. Each 
try, it increments a counter at the end of the name:

	tmpname = sprintf('%s/%s%d.%d', tmpdir, basename, $$, n)
	lock = tmpname + '.lock'
	n += 1

The basename seems like the least important part of tmpname, which I why 
I chose to chop that part. But OTOH silently changing the user's input 
is not very nice. Also, I don't like the idea of chopping one char and 
retrying, until the string is short enough.

Actually, all I care about is that irb works. So maybe irb should catch 
the ENAMETOOLONG exception and retry with a different filename. The 
problem remains: how to shorten the filename?

In irb, the exception happens in locale.rb:

     def real_load(path, priv)
       tmp_base = path.tr("./:", "___")
       lc_file = Tempfile.new(tmp_base)

So you can see how the name can be very long. (Is such a long name 
really necessary?) What about this:

     def real_load(path, priv)
       tmp_base = path.tr("./:", "___")
       begin
         lc_file = Tempfile.new(tmp_base)
       rescue Errno::ENAMETOOLONG
         tmp_base = File.basename(path).tr("./:", "___")
         retry
       end

The retry should work, since File.basename(path) is known to be a legal 
filename.

The disadvantage here is that the problem is fixed only in irb, and not 
in Tempfile itself. However, all other uses of Tempfile in the standard 
library use short literal filenames.

The second approach seems to make sense. What do you think?

In This Thread