* [PATCH] Using `entry_of_file_with_name' returns incorrect result
@ 2022-04-25 17:01 Guillermo E. Martinez
2022-05-02 15:29 ` Dodji Seketeli
0 siblings, 1 reply; 2+ messages in thread
From: Guillermo E. Martinez @ 2022-04-25 17:01 UTC (permalink / raw)
To: libabigail
Hello libabigail team,
This patch corrects the returning value for `entry_of_file_with_name'
function when more than one file in a given directory has a same suffix,
Comments will be appreciated.
Kind Regards,
Guillermo
Function `entry_of_file_with_name' uses `string_ends_with' to test if a
given `fts_path' member of `FTSENT' structure match with `fname'
argument, this result is not correct when in the current directory there
are file with names: "./rmdir-xyx", "./dir-xyz" it returns true for both
files, this patch fixes this ambiguity using `basename' instead.
* src/abg-tools-utils.cc (entry_of_file_with_name): Replace
call `string_ends_with' by `basename'.
---
src/abg-tools-utils.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc
index e94c3003..1f0f6fa8 100644
--- a/src/abg-tools-utils.cc
+++ b/src/abg-tools-utils.cc
@@ -2141,8 +2141,8 @@ entry_of_file_with_name(const FTSENT *entry,
|| entry->fts_info == FTS_NS)
return false;
- string fpath = entry->fts_path;
- if (string_ends_with(fpath, fname))
+ string fpath = ::basename(entry->fts_path);
+ if (fpath == fname)
return true;
return false;
}
--
2.35.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Using `entry_of_file_with_name' returns incorrect result
2022-04-25 17:01 [PATCH] Using `entry_of_file_with_name' returns incorrect result Guillermo E. Martinez
@ 2022-05-02 15:29 ` Dodji Seketeli
0 siblings, 0 replies; 2+ messages in thread
From: Dodji Seketeli @ 2022-05-02 15:29 UTC (permalink / raw)
To: Guillermo E. Martinez via Libabigail
Hello Guillermo,
"Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> a
écrit:
[...]
> * src/abg-tools-utils.cc (entry_of_file_with_name): Replace
> call `string_ends_with' by `basename'.
Applied to master, thanks!
[...]
Cheers,
--
Dodji
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-02 15:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25 17:01 [PATCH] Using `entry_of_file_with_name' returns incorrect result Guillermo E. Martinez
2022-05-02 15:29 ` Dodji Seketeli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).