Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

directories return in resolve_filename instead of filenames #123

Closed
veripoolbot opened this issue Jan 26, 2005 · 0 comments
Closed

directories return in resolve_filename instead of filenames #123

veripoolbot opened this issue Jan 26, 2005 · 0 comments

Comments

@veripoolbot
Copy link
Collaborator

@veripoolbot veripoolbot commented Jan 26, 2005


Author Name: Wilson Snyder (@wsnyder)
Original Redmine Issue: 123 from https://www.veripool.org
Original Date: 2005-01-26


This bug was cloned from Perl-RT, rt11248.

Email addresses have have been truncated.

Id: 	11248
Status: 	resolved
Left: 	0 min
Queue: 	Verilog-Perl
Owner: 	WSNYDER <wsnyder@>
Requestors: 	jtseng@

Severity: 	Important
Broken in: 	2.302
X Attachments
Verilog-Perl-2.310.diff

     * Wed Jan 26 19:28:38 2005 (1.8k) by

Wed Jan 26 17:16:46 2005 guest - Ticket created

Subject: 	directories return in resolve_filename instead of filenames

resolve_filename can take either a filename or module. If a directory with the module name exists, then it is returned.

Example:
parent/top/top.v
Running the program in parent will return the "top" directory causing a input scanner error since it will try.

Running the program in any other directory will work. (assuming search paths are adjusted)

Solution:
Besides checking for "-r" we should make sure that it's not also a directory.

[jtseng@pagemill perl]$ diff -c Verilog-Perl-2.302/Getopt.pm Verilog-Perl-2.302-pasemi1/
*** Verilog-Perl-2.302/Getopt.pm 2004-11-10 09:56:43.000000000 -0800
--- Verilog-Perl-2.302-pasemi1/Getopt.pm 2005-01-26 14:03:55.000000000 -0800
***************
*** 309,315 ****

defined $filename or carp "%Error: Undefined filename,";
return $self->{_file_path_cache}{$filename} if defined $self->{_file_path_cache}{$filename};
! if (-r $filename) {
$self->{_file_path_cache}{$filename} = $filename;
$self->depend_files($filename);
return $filename;
--- 309,315 ----

defined $filename or carp "%Error: Undefined filename,";
return $self->{_file_path_cache}{$filename} if defined $self->{_file_path_cache}{$filename};
! if (-r $filename && (! -d $filename)) {
$self->{_file_path_cache}{$filename} = $filename;
$self->depend_files($filename);
return $filename;
***************
*** 324,330 ****
foreach my $postfix ("", @{$self->{libext}}) {
my $found = "$dir/$filename$postfix";
next if $checked{$found}; $checked{$found}=1; # -r can be quite slow
! if (-r $found) {
$self->{_file_path_cache}{$filename} = $found;
$self->depend_files($found);
return $found;
--- 324,330 ----
foreach my $postfix ("", @{$self->{libext}}) {
my $found = "$dir/$filename$postfix";
next if $checked{$found}; $checked{$found}=1; # -r can be quite slow
! if (-r $found && (! -d $found)) {
$self->{_file_path_cache}{$filename} = $found;
$self->depend_files($found);
return $found;

Wed Jan 26 19:28:38 2005 guest - Correspondence added

From: 	jtseng@

I've attached a better diff which correctly addresses the file caching
of directories.

-john

[guest - Wed Jan 26 17:16:46 2005]:

[text/x-patch 1.8k]
*** Verilog-Perl-2.310/Getopt.pm 2005-01-24 07:18:04.000000000 -0800
--- Verilog-Perl-2.310-pasemi/Getopt.pm 2005-01-26 16:20:06.000000000 -0800
***************
*** 312,318 ****

defined $filename or carp "%Error: Undefined filename,";
return $self->{_file_path_cache}{$filename} if defined $self->{_file_path_cache}{$filename};
! if (-r $filename) {
$self->{_file_path_cache}{$filename} = $filename;
$self->depend_files($filename);
return $filename;
--- 312,318 ----

defined $filename or carp "%Error: Undefined filename,";
return $self->{_file_path_cache}{$filename} if defined $self->{_file_path_cache}{$filename};
! if ((-r $filename) && (! -d $filename)) {
$self->{_file_path_cache}{$filename} = $filename;
$self->depend_files($filename);
return $filename;
***************
*** 324,332 ****
foreach my $dir (@{$self->incdir()}, @{$self->module_dir()}) {
next if $checked{$dir}; $checked{$dir}=1; # -r can be quite slow
1. Check each postfix added to the file
! foreach my $postfix ("", @{$self->{libext}}) {
my $found = "$dir/$filename$postfix";
! next if $checked{$found}; $checked{$found}=1; # -r can be quite slow
if (-r $found) {
$self->{_file_path_cache}{$filename} = $found;
$self->depend_files($found);
--- 324,335 ----
foreach my $dir (@{$self->incdir()}, @{$self->module_dir()}) {
next if $checked{$dir}; $checked{$dir}=1; # -r can be quite slow
1. Check each postfix added to the file
! # foreach my $postfix ("", @{$self->{libext}}) {
! foreach my $postfix (@{$self->{libext}}) { # remove "" for pasemi speedup only
my $found = "$dir/$filename$postfix";
! next if ($checked{$found} || (-d $found));
! $checked{$found}=1; # -r can be quite slow
!
if (-r $found) {
$self->{_file_path_cache}{$filename} = $found;
$self->depend_files($found);

Thu Jan 27 11:23:38 2005 WSNYDER - Correspondence added

Fixed in just-uploaded 2.311. Thanks much for giving a patch!

Thu Jan 27 11:23:39 2005 WSNYDER - Given to WSNYDER

Thu Jan 27 11:23:39 2005 WSNYDER - Status changed from 'new' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.