[#7055] More on VC++ 2005 — Austin Ziegler <halostatue@...>

Okay. I've got Ruby compiling. I'm attempting to get everything in

17 messages 2006/01/05
[#7058] Re: More on VC++ 2005 — nobuyoshi nakada <nobuyoshi.nakada@...> 2006/01/06

Hi,

[#7084] mathn: ugly warnings — hadmut@... (Hadmut Danisch)

Hi,

22 messages 2006/01/10
[#7097] Re: mathn: ugly warnings — Daniel Berger <Daniel.Berger@...> 2006/01/10

Hadmut Danisch wrote:

[#7098] Design contracts and refactoring (was Re: mathn: ugly warnings) — mathew <meta@...> 2006/01/10

Daniel Berger wrote:

[#7118] Re: Design contracts and refactoring (was Re: mathn: ugly warnings) — mathew <meta@...> 2006/01/12

*Dean Wampler *<deanwampler gmail.com> writes:

[#7226] Fwd: Re: Question about massive API changes — "Sean E. Russell" <ser@...>

Hello,

23 messages 2006/01/28
[#7228] Re: Question about massive API changes — Caleb Tennis <caleb@...> 2006/01/28

>

Re: [ ruby-Bugs-3344 ] RDoc.usage doesn't parse caller correctly on windows

From: Daniel Berger <Daniel.Berger@...>
Date: 2006-01-27 21:12:50 UTC
List: ruby-core #7224
noreply@rubyforge.org wrote:
> Bugs item #3344, was opened at 2006-01-27 14:26
> You can respond by visiting: 
> http://rubyforge.org/tracker/?func=detail&atid=1698&aid=3344&group_id=426
> 
> Category: Standard Library
> Group: None
> Status: Open
> Resolution: None
> Priority: 3
> Submitted By: Brent Northam (bnortham)
> Assigned to: Nobody (None)
> Summary: RDoc.usage doesn't parse caller correctly on windows
> 
> Initial Comment:
> In using rdoc/usage to output usage information for a commandline utility on Windows I came across this.
> 
> In RDoc.usage_no_exit, this code intends to parse out the filename of the calling script with:
> 
> main_program_file, = caller[-1].split(/:/,2)
> comment = File.open(main_program_file) do |file|
>      find_comment(file)
> end
> 
> The output for main_program_file on Windows is always simply the drive letter, since 2 colons are present in caller[-1].  My hack workaround, which is I'm sure 100% inapropriate as a real fix since I'm new to ruby was:
> 
> drive,main_program_file, = caller[-1].split(/:/,2)
>     comment = File.open(drive + ":" + main_program_file) do |file|
>       find_comment(file)
>     end
> 
> How are platform-specific issues like this handled?

A better solution is this: main_program_file = caller.last.split(":")[-2]

You'll always want the second to last argument.  Works on all platforms, and 
even works with Windows' UNC paths (which don't have a leading drive letter).

Regards,

Dan

In This Thread

Prev Next