diff options
| author | наб <nabijaczleweli@nabijaczleweli.xyz> | 2025-01-23 19:33:57 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-14 19:45:12 +0100 |
| commit | 2499d9ff0c55a445a62643028a9d3bc9faf1195a (patch) | |
| tree | 1bab22e439296982bb4cc380a2420a9d805d5a7a | |
| parent | 4f6d379124bc51a09608fa3f45d66713f927b959 (diff) | |
string{=> _view} flExtension(string{=> _view})
| -rw-r--r-- | apt-pkg/acquire-item.cc | 2 | ||||
| -rw-r--r-- | apt-pkg/cdrom.cc | 2 | ||||
| -rw-r--r-- | apt-pkg/contrib/fileutl.cc | 14 | ||||
| -rw-r--r-- | apt-pkg/contrib/fileutl.h | 2 | ||||
| -rw-r--r-- | apt-pkg/sourcelist.cc | 2 | ||||
| -rw-r--r-- | test/interactive-helper/aptwebserver.cc | 2 |
6 files changed, 12 insertions, 12 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index afd81b944..7e0dc25d2 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -3498,7 +3498,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *const Owner, pkgSourceList *const Sourc StoreFilename = QuoteString(Version.ParentPkg().Name(), "_:") + '_' + QuoteString(Version.VerStr(), "_:") + '_' + QuoteString(Version.Arch(), "_:.") + - "." + flExtension(poolfilename); + '.' += flExtension(poolfilename); Desc.URI = Index->ArchiveURI(poolfilename); Desc.Description = Index->ArchiveInfo(Version); diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 84ddae40c..e2823d900 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -129,7 +129,7 @@ bool pkgCdrom::FindPackages(string CD, for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin(); c != compressor.end(); ++c) { - string fileext = flExtension(file); + string fileext{flExtension(file)}; if (file == fileext) fileext.clear(); else if (fileext.empty() == false) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index e57662abc..1a417f7e2 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -485,7 +485,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c { if (RealFileExists(File) == false) { - string d_ext = flExtension(Ent->d_name); + auto d_ext = flExtension(Ent->d_name); // do not show ignoration warnings for directories if (( #ifdef _DIRENT_HAVE_D_TYPE @@ -505,7 +505,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c // extensions given -> "" extension allows no extension if (Ext.empty() == false) { - string d_ext = flExtension(Ent->d_name); + auto d_ext = flExtension(Ent->d_name); if (d_ext == Ent->d_name) // no extension { if (std::find(Ext.begin(), Ext.end(), "") == Ext.end()) @@ -694,13 +694,13 @@ string flNotFile(string File) // flExtension - Return the extension for the file /*{{{*/ // --------------------------------------------------------------------- /* */ -string flExtension(string File) +string_view flExtension(string_view File) { - string::size_type Res = File.rfind('.'); - if (Res == string::npos) + string_view::size_type Res = File.rfind('.'); + if (Res == string_view::npos) return File; - Res++; - return string(File,Res); + File.remove_prefix(Res + 1); + return File; } /*}}}*/ // flNoLink - If file is a symlink then deref it /*{{{*/ diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 4ecddbf86..52f9bc657 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -255,7 +255,7 @@ APT_PUBLIC bool DropPrivileges(); APT_PUBLIC std::string flNotDir(std::string File); APT_PUBLIC std::string flNotFile(std::string File); APT_PUBLIC std::string flNoLink(std::string File); -APT_PUBLIC std::string flExtension(std::string File); +APT_PUBLIC std::string_view flExtension(std::string_view File); APT_PUBLIC std::string flCombine(std::string Dir,std::string File); /** \brief Takes a file path and returns the absolute path diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 819344281..94fe02531 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -563,7 +563,7 @@ bool pkgSourceList::AddVolatileFile(std::string const &File, std::vector<std::st if (File.empty() || FileExists(File) == false) return false; - std::string const ext = flExtension(File); + auto const ext = flExtension(File); // udeb is not included as installing it is usually a mistake rather than intended if (ext == "deb" || ext == "ddeb") AddVolatileFile(new debDebPkgFileIndex(File)); diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index 7df4e87ac..a2637c668 100644 --- a/test/interactive-helper/aptwebserver.cc +++ b/test/interactive-helper/aptwebserver.cc @@ -147,7 +147,7 @@ static void addFileHeaders(std::list<std::string> &headers, FileFd &data)/*{{{*/ contentTypeSet(headers) == false) { std::string const name = data.Name(); - std::string ext = flExtension(name); + std::string ext{flExtension(name)}; if (name.empty() == false && ext.empty() == false && name != ext) { std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); |
