Clean-ups for #3616

This commit is contained in:
Flössie
2017-01-20 21:19:55 +01:00
parent 62451f471f
commit f25e161d16
4 changed files with 63 additions and 79 deletions

View File

@@ -76,7 +76,6 @@ void poke01_f(unsigned char* &dest, float r, float g, float b)
void bilinearInterp(const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh)
{
int ix = 0;
for (int i = 0; i < dh; i++) {
@@ -134,7 +133,6 @@ void bilinearInterp (const unsigned char* src, int sw, int sh, unsigned char* ds
void nearestInterp(const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh)
{
int ix = 0;
for (int i = 0; i < dh; i++) {
@@ -152,7 +150,6 @@ void nearestInterp (const unsigned char* src, int sw, int sh, unsigned char* dst
void rotate(unsigned char* img, int& w, int& h, int deg)
{
if (deg == 0) {
return;
}
@@ -192,7 +189,6 @@ void rotate (unsigned char* img, int& w, int& h, int deg)
void hflip(unsigned char* img, int w, int h)
{
unsigned char* flipped = new unsigned char[3 * w * h];
int ix = 0;
@@ -209,7 +205,6 @@ void hflip (unsigned char* img, int w, int h)
void vflip(unsigned char* img, int w, int h)
{
unsigned char* flipped = new unsigned char[3 * w * h];
int ix = 0;
@@ -224,34 +219,30 @@ void vflip (unsigned char* img, int w, int h)
delete[] flipped;
}
/**
* Return lower case extension without the "." or "" if the given name contains no "."
*/
Glib::ustring getFileExtension(const Glib::ustring &fname) {
// issue 3598 do not use casefold() to compare ignoring case - it seems to mangle sharp-s character and length of string
// simply get extension first, then use lowercase()
const Glib::ustring::size_type lastdot = fname.find_last_of ('.');
if( Glib::ustring::npos == lastdot ) {
return "";
}
return fname.substr(lastdot + 1).lowercase();
Glib::ustring getFileExtension(const Glib::ustring& filename)
{
const Glib::ustring::size_type lastdot_pos = filename.find_last_of('.');
return
lastdot_pos != Glib::ustring::npos
? filename.substr(lastdot_pos + 1).lowercase()
: Glib::ustring();
}
bool hasJpegExtension(const Glib::ustring &fname) {
const Glib::ustring extension = getFileExtension(fname);
return ((extension == "jpg") || (extension == "jpeg"));
bool hasJpegExtension(const Glib::ustring& filename)
{
const Glib::ustring extension = getFileExtension(filename);
return extension == "jpg" || extension == "jpeg";
}
bool hasTiffExtension(const Glib::ustring &fname) {
const Glib::ustring extension = getFileExtension(fname);
return ((extension == "tif") || (extension == "tiff"));
bool hasTiffExtension(const Glib::ustring& filename)
{
const Glib::ustring extension = getFileExtension(filename);
return extension == "tif" || extension == "tiff";
}
bool hasPngExtension(const Glib::ustring &fname) {
const Glib::ustring extension = getFileExtension(fname);
return (extension == "png");
bool hasPngExtension(const Glib::ustring& filename)
{
return getFileExtension(filename) == "png";
}
}

View File

@@ -19,16 +19,16 @@
#pragma once
#include <type_traits>
#include <glibmm.h>
#include <glibmm/ustring.h>
namespace rtengine
{
// update a point of a Cairo::Surface by accessing the raw data
// Update a point of a Cairo::Surface by accessing the raw data
void poke255_uc(unsigned char*& dest, unsigned char r, unsigned char g, unsigned char b);
// update a point of a Cairo::Surface by accessing the raw data
// Update a point of a Cairo::Surface by accessing the raw data
void poke01_d(unsigned char*& dest, double r, double g, double b);
// update a point of a Cairo::Surface by accessing the raw data
// Update a point of a Cairo::Surface by accessing the raw data
void poke01_f(unsigned char*& dest, float r, float g, float b);
void bilinearInterp(const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh);
@@ -43,24 +43,13 @@ typename std::underlying_type<ENUM>::type toUnderlying(ENUM value)
return static_cast<typename std::underlying_type<ENUM>::type>(value);
}
/**
* Return lower case extension without the "." or "" if the given name contains no "."
*/
Glib::ustring getFileExtension(const Glib::ustring &fname);
/**
* Return true if file has .jpeg or .jpg extension (ignoring case)
*/
bool hasJpegExtension(const Glib::ustring &fname);
/**
* Return true if file has .tiff or .tif extension (ignoring case)
*/
bool hasTiffExtension(const Glib::ustring &fname);
/**
* Return true if file has .png extension (ignoring case)
*/
bool hasPngExtension(const Glib::ustring &fname);
// Return lower case extension without the "." or "" if the given name contains no "."
Glib::ustring getFileExtension(const Glib::ustring& filename);
// Return true if file has .jpeg or .jpg extension (ignoring case)
bool hasJpegExtension(const Glib::ustring& filename);
// Return true if file has .tiff or .tif extension (ignoring case)
bool hasTiffExtension(const Glib::ustring& filename);
// Return true if file has .png extension (ignoring case)
bool hasPngExtension(const Glib::ustring& filename);
}

View File

@@ -2377,7 +2377,7 @@ bool Options::has_retained_extention (Glib::ustring fname)
bool Options::is_extention_enabled (Glib::ustring ext)
{
for (int j = 0; j < (int)parseExtensions.size(); j++)
if (parseExtensions[j].casefold() == ext.casefold()) { // issue 3598 REVIEW OK - no change required
if (parseExtensions[j].casefold() == ext.casefold()) {
return j >= (int)parseExtensionsEnabled.size() || parseExtensionsEnabled[j];
}

View File

@@ -269,7 +269,6 @@ int ProfileStore::findFolderId(const Glib::ustring &path)
*/
const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path)
{
if (path.empty()) {
return nullptr;
}
@@ -277,12 +276,17 @@ const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path
if (path == DEFPROFILE_INTERNAL) {
return internalDefaultEntry;
}
// consistently apply casefold() to make sure dot position is correct
const Glib::ustring::size_type lastdot = path.casefold().find_last_of ('.');
if ((lastdot != Glib::ustring::npos) && (lastdot <= path.casefold().size() - 4) && (!path.casefold().compare (lastdot, 4, paramFileExtension)))
// removing the extension
// consistently apply casefold() to make sure dot position is correct
const Glib::ustring casefolded_path = path.casefold();
const Glib::ustring::size_type lastdot_pos = casefolded_path.find_last_of('.');
if (
lastdot_pos != Glib::ustring::npos
&& lastdot_pos <= casefolded_path.size() - 4
&& !casefolded_path.compare(lastdot_pos, 4, paramFileExtension))
{
// removing the extension
// now use dot position without casefold()
path = path.substr(0, path.find_last_of('.'));
}