Functions4U: Removed some warnings

git-svn-id: svn://ultimatepp.org/upp/trunk@13615 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
koldo 2019-09-23 22:13:14 +00:00
parent 8bd1c05140
commit d4330f4923
9 changed files with 122 additions and 32 deletions

View file

@ -358,7 +358,7 @@ bool SetReadOnly(const char *path, bool readOnly) {
return SetReadOnly(path, readOnly, readOnly, readOnly);
}
bool SetReadOnly(const char *path, bool usr, bool , bool ) {
bool SetReadOnly(const char *path, bool usr, bool grp, bool oth) {
#if defined(PLATFORM_WIN32) || defined (PLATFORM_WIN64)
DWORD attr = GetFileAttributesW(ToSystemCharsetW(path));
@ -2597,7 +2597,7 @@ Dl::Dl() {
Dl::~Dl() {
if (hinstLib)
if (dlclose(hinstLib) == 0)
throw Exc(t_("Dl cannot be released"));
; // Dl cannot be released
}
bool Dl::Load(const String &fileDll) {

View file

@ -118,7 +118,7 @@ struct FileData : Moveable<FileData> {
String ToString() const { return Format("%s %0n", fileName, length); }
FileData(bool _isFolder, String _fileName, String _relFilename, int64 _length,
struct Upp::Time _t, uint64 _id) : isFolder(_isFolder), fileName(_fileName),
struct Upp::Time _t, int64 _id) : isFolder(_isFolder), fileName(_fileName),
relFilename(_relFilename), length(_length), t(_t), id(_id) {}
FileData() {}
};
@ -671,7 +671,20 @@ void Shuffle(C &data, int randomSeed = Null) {
}
template <class T>
bool Equal(const T& a, const T& b, const T& ratio) {
inline T TruncDecimals(T num, int decimals) {
long double val = num*10*decimals;
long int ival = static_cast<long int>(val);
val = ival;
return static_cast<T>(val/(10*decimals));
}
template <class T>
inline String RoundDecimals(T num, int decimals) {
return FormatDouble(num, decimals);
}
template <class T>
bool EqualRatio(const T& a, const T& b, const T& ratio) {
if (a == 0)
return b <= ratio;
if (b == 0)
@ -693,14 +706,13 @@ int FindAdd(Range& r, const V& value, int from = 0) {
template <class Range, class V>
void FindAddRatio(Range& r, const V& value, const V& ratio, int from = 0) {
for(int i = from; i < r.GetCount(); i++)
if(Equal(r[i], value, ratio))
if(EqualRatio(r[i], value, ratio))
return;
r.Add(value);
}
template <class Range, class V>
int FindIndexDelta(const Range& r, const V& value, const V& delta, int from = 0)
{
int FindIndexDelta(const Range& r, const V& value, const V& delta, int from = 0) {
for(int i = from; i < r.GetCount(); i++)
if(abs(r[i] - value) <= delta)
return i;
@ -708,10 +720,45 @@ int FindIndexDelta(const Range& r, const V& value, const V& delta, int from = 0)
}
template <class Range, class V>
int FindIndexRatio(const Range& r, const V& value, const V& ratio, int from = 0)
{
int FindIndexRoundDecimals(const Range& r, const V& value, int numDecimals, int from = 0) {
String svalue = RoundDecimals(value, numDecimals);
for(int i = from; i < r.GetCount(); i++) {
if (Equal(r[i], value, ratio))
String s = RoundDecimals(r[i], numDecimals);
if(s == svalue)
return i;
}
return -1;
}
template <class Range, class V>
int FindIndexTruncDecimals(const Range& r, const V& value, int numDecimals, int from = 0) {
V svalue = TruncDecimals(value, numDecimals);
for(int i = from; i < r.GetCount(); i++) {
V s = TruncDecimals(r[i], numDecimals);
if(s == svalue)
return i;
}
return -1;
}
template <class Range, class V>
int FindIndexCloser(const Range& r, const V& value, int from = 0) {
int minId = -1;
V minDiff = FLT_MAX;
for(int i = from; i < r.GetCount(); i++) {
V diff = abs(value - r[i]);
if (diff < minDiff) {
minDiff = diff;
minId = i;
}
}
return minId;
}
template <class Range, class V>
int FindIndexRatio(const Range& r, const V& value, const V& ratio, int from = 0) {
for(int i = from; i < r.GetCount(); i++) {
if (EqualRatio(r[i], value, ratio))
return i;
}
return -1;

View file

@ -150,6 +150,42 @@ esES("Imprimiendo documento")
euES("")
frFR("")
T_("Select all")
caES("Seleccionar tot")
esES("Seleccionar todo")
euES("")
frFR("")
T_("Select all rows")
caES("")
esES("")
euES("")
frFR("")
T_("No row selected")
caES("")
esES("")
euES("")
frFR("")
T_("Selected %d rows")
caES("")
esES("")
euES("")
frFR("")
T_("Copy")
caES("Copiar")
esES("Copiar")
euES("")
frFR("")
T_("Copy selected rows to clipboard")
caES("")
esES("")
euES("")
frFR("")
// GatherTpp.cpp

View file

@ -207,7 +207,7 @@ void ArrayCtrlWhenBar(Bar &menu, ArrayCtrl &array) {
}
}
void ArrayCtrlRowCopy(ArrayCtrl &array, bool header) {
void ArrayCtrlRowCopy(const ArrayCtrl &array, bool header) {
array.SetClipboard(true, header);
}
@ -215,4 +215,13 @@ void ArrayCtrlRowSelect(ArrayCtrl &array) {
array.Select(0, array.GetCount(), true);
}
Vector<int> ArrayCtrlGetSelected(const ArrayCtrl &array) {
Vector<int> selected;
for (int r = 0; r < array.GetCount(); ++r) {
if (array.IsSel(r))
selected << r;
}
return selected;
}
#endif

View file

@ -107,7 +107,8 @@ private:
};
void ArrayCtrlWhenBar(Bar &menu, ArrayCtrl &array);
void ArrayCtrlRowCopy(ArrayCtrl &array, bool header);
void ArrayCtrlRowCopy(const ArrayCtrl &array, bool header);
void ArrayCtrlRowSelect(ArrayCtrl &array);
Vector<int> ArrayCtrlGetSelected(const ArrayCtrl &array);
#endif

View file

@ -60,8 +60,8 @@ struct ScanTopicIterator : RichText::Iterator {
String link;
StaticCriticalSection reflink_lock;
ScanTopicIterator(VectorMap<String, String> *reflink) : reflink(reflink) {};
virtual bool operator()(int pos, const RichPara& para)
ScanTopicIterator(VectorMap<String, String> *_reflink) : reflink(_reflink) {};
virtual bool operator()(int , const RichPara& para)
{
if(!IsNull(para.format.label))
reflink->Add(para.format.label, link);
@ -102,8 +102,8 @@ struct GatherLinkIterator : RichText::Iterator {
VectorMap<String, String> *reflink;
Index<String> link;
GatherLinkIterator(VectorMap<String, String> *reflink) : reflink(reflink) {};
virtual bool operator()(int pos, const RichPara& para)
GatherLinkIterator(VectorMap<String, String> *_reflink) : reflink(_reflink) {};
virtual bool operator()(int , const RichPara& para)
{
for(int i = 0; i < para.GetCount(); i++) {
String l = para[i].format.link;
@ -175,11 +175,11 @@ bool EndsWith(const String &source, const String &pattern)
}
String GatherTpp::QtfAsHtml(const char *qtf, Index<String>& css,
const VectorMap<String, String>& links,
const VectorMap<String, String>& labels,
const VectorMap<String, String>& _links,
const VectorMap<String, String>& _labels,
const String& outdir, const String& fn)
{
return EncodeHtml(ParseQTF(qtf), css, links, labels, outdir, fn, Zoom(8, 40), escape, 40);
return EncodeHtml(ParseQTF(qtf), css, _links, _labels, outdir, fn, Zoom(8, 40), escape, 40);
}
String GetText(const char *s)
@ -187,7 +187,7 @@ String GetText(const char *s)
return GetTopic(s).text;
}
void GatherTpp::ExportPage(int i, String htmlFolder, String keywords)
void GatherTpp::ExportPage(int i, String htmlFolder, String _keywords)
{
Index<String> css;
String path = links.GetKey(i);
@ -244,7 +244,7 @@ void GatherTpp::ExportPage(int i, String htmlFolder, String keywords)
"a.l2:hover { color:#BC0624; }\n"
"a.l2:active { color:#BC0024; }\n",
"<META NAME=\"keywords\" "
"CONTENT=\"" + keywords + "\">"
"CONTENT=\"" + _keywords + "\">"
"<META name=\"robots\" content=\"index,follow\">"
)
.BgColor(bg)
@ -291,7 +291,7 @@ String GetTopicLanguage(const String &topic) {
return topic.Mid(pos+1, 5);
}
String GatherTpp::GatherTopics(const char *topic, String& title)
String GatherTpp::GatherTopics(const char *topic, String& _title)
{
static StaticCriticalSection mapl;
int q;
@ -299,15 +299,15 @@ String GatherTpp::GatherTopics(const char *topic, String& title)
q = tt.Find(topic);
if(q < 0) {
Topic p = ReadTopic(LoadFile(TopicFileName(topic)));
title = p.title;
_title = p.title;
String t = p;
if(IsNull(t)) {
String topicEng = ChangeTopicLanguage(topic, LNG_('E','N','U','S'));
p = ReadTopic(LoadFile(TopicFileName(topicEng)));
String tt = p;
if(IsNull(tt))
String _tt = p;
if(IsNull(_tt))
return "index.html";
title = p.title;
_title = p.title;
p.title += " (translated)";
String help = "topic://uppweb/www/contribweb$" + GetTopicLanguage(topic);
p.text = String("{{1f1t0/50b0/50@(240.240.240) [<A2 ") + t_("This page has not been translated yet") +
@ -327,7 +327,7 @@ String GatherTpp::GatherTopics(const char *topic, String& title)
#endif
} else {
INTERLOCKED_(mapl)
title = tt[q].title;
_title = tt[q].title;
}
return TopicFileNameHtml(topic);
}

View file

@ -5,8 +5,6 @@
using namespace Upp;
//NAMESPACE_UPP
inline bool iscidplus(int c) {
return iscib(c) || c == '.' || (c >= '0' && c <= '9');
}

View file

@ -2,7 +2,6 @@
#include "StaticPlugin.h"
//NAMESPACE_UPP
using namespace Upp;
Array<StaticPlugin::PluginData>& StaticPlugin::Plugins() {

View file

@ -151,7 +151,7 @@ Color GetSvgColor(const char *color) {
{"whitesmoke", 245, 245, 245},
{"yellow", 255, 255, 0},
{"yellowgreen", 154, 205, 50},
{""}};
{"", 0, 0, 0}};
for (int i = 0; colors[i].name[0] != '\0'; ++i) // Naive algorithm to get the color
if (strcmp(color, colors[i].name) == 0)