summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc2
-rw-r--r--apt-pkg/cdrom.cc2
-rw-r--r--apt-pkg/contrib/fileutl.cc14
-rw-r--r--apt-pkg/contrib/fileutl.h2
-rw-r--r--apt-pkg/sourcelist.cc2
5 files changed, 11 insertions, 11 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));