commit feb2d63aca6ed327e07939eed614d1ddba55b0c7
parent d91c9b6605bcba370a3e2e4644fd547a884fc0e8
Author: Andrew Laack <andrew@laack.co>
Date: Sat, 26 Sep 2026 09:45:34 -0500
Fixing compiler warnings
Diffstat:
6 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -24,7 +24,7 @@ void Browser::downloadPage() {
void dispatch(std::vector<Link>* targets, Browser& b, int threadIdx) {
std::vector<Link>& refT = *targets;
- for(int i = 0 ; i < refT.size() && i < SITE_CACHE_LIMIT; ++i) {
+ for(int i = 0 ; i < (int)refT.size() && i < SITE_CACHE_LIMIT; ++i) {
auto& target = refT[i];
auto id = b.getIdentity(target.getLinkDestination());
@@ -82,7 +82,7 @@ void Browser::goToSite(std::string url, bool addToHistory, bool refresh) {
Link* prior = nullptr;
- if(siteHistory.size() > previousIdx && previousIdx >= 0) {
+ if((int)siteHistory.size() > previousIdx && previousIdx >= 0) {
prior = siteHistory[previousIdx];
}
@@ -121,7 +121,7 @@ void Browser::goToSite(std::string url, bool addToHistory, bool refresh) {
Identity id = identityManager.getIdentityForURI(destination->getLinkDestination());
- if(urlString.find("gemini://") != -1 && !refresh) {
+ if(urlString.find("gemini://") != std::string::npos && !refresh) {
if(id.crtPath == "" && id.keyPath == "") {
site = findInCacheAndPromoteIfRelevant(urlString);
}
@@ -142,7 +142,7 @@ void Browser::goToSite(std::string url, bool addToHistory, bool refresh) {
}
if(addToHistory) {
- while(siteHistory.size() > previousIdx + 1) {
+ while((int)siteHistory.size() > previousIdx + 1) {
delete siteHistory[siteHistory.size() - 1];
siteHistory.pop_back();
}
@@ -155,7 +155,7 @@ void Browser::goToSite(std::string url, bool addToHistory, bool refresh) {
}
currentSite = site;
- if(urlString.find("gemini://") != -1) {
+ if(urlString.find("gemini://") != std::string::npos) {
if(id.keyPath == "" && id.crtPath == "") {
visitedCache->addSite(urlString, *site);
}
@@ -192,7 +192,7 @@ void Browser::justCacheSite(Link link) {
Site* site = nullptr;
- if(urlString.find("gemini://") != -1) {
+ if(urlString.find("gemini://") != std::string::npos) {
site = client.fetchSite(link);
}
@@ -296,7 +296,7 @@ std::vector<std::pair<std::string, TextRender>> Browser::renderSite() {
std::optional<uri> Browser::getPriorUri() {
- if(previousIdx < siteHistory.size() && previousIdx >= 0) {
+ if(previousIdx < (int)siteHistory.size() && previousIdx >= 0) {
return siteHistory[previousIdx]->getLinkDestination();
}
return std::nullopt;
@@ -313,9 +313,9 @@ std::vector<Link>* Browser::getLinkLines() {
void Browser::followLinkNumber(int linkToFollow) {
- if(links.size() > linkToFollow-1 && linkToFollow-1 >= 0) {
+ if((int)links.size() > linkToFollow-1 && linkToFollow-1 >= 0) {
std::size_t pos = links[linkToFollow-1];
- if(lines.size() > pos && pos >= 0) {
+ if(lines.size() > pos) {
Line* ptr = lines[pos];
Link* ptrLnk = dynamic_cast<Link*>(ptr);
goToSite(ptrLnk->getLinkDestination().to_string(), true);
@@ -330,12 +330,12 @@ void Browser::goBack() {
previousIdx -= 1;
- if(siteHistory.size() > previousIdx && previousIdx >= 0) {
+ if((int)siteHistory.size() > previousIdx && previousIdx >= 0) {
int prSC = previousStatusCodes[siteHistory[previousIdx]->getLinkDestination().to_string()];
while(!(prSC >= 20 && prSC <= 29)) {
previousIdx -= 1;
- if(siteHistory.size() > previousIdx && previousIdx >= 0) {
+ if((int)siteHistory.size() > previousIdx && previousIdx >= 0) {
prSC = previousStatusCodes[siteHistory[previousIdx]->getLinkDestination().to_string()];
} else {
previousIdx = original;
@@ -356,11 +356,11 @@ void Browser::goForward() {
previousIdx += 1;
- if(siteHistory.size() > previousIdx && previousIdx >= 0) {
+ if((int)siteHistory.size() > previousIdx && previousIdx >= 0) {
int prSC = previousStatusCodes[siteHistory[previousIdx]->getLinkDestination().to_string()];
while(!(prSC >= 20 && prSC <= 29)) {
previousIdx += 1;
- if(siteHistory.size() > previousIdx && previousIdx >= 0) {
+ if((int)siteHistory.size() > previousIdx && previousIdx >= 0) {
prSC = previousStatusCodes[siteHistory[previousIdx]->getLinkDestination().to_string()];
} else {
previousIdx = original;
@@ -375,7 +375,7 @@ void Browser::goForward() {
}
Link* Browser::getCurrentLink() {
- if(previousIdx >= 0 && previousIdx < siteHistory.size()) {
+ if(previousIdx >= 0 && previousIdx < (int)siteHistory.size()) {
return this->siteHistory[previousIdx];
}
return nullptr;
diff --git a/src/cache.cpp b/src/cache.cpp
@@ -20,7 +20,7 @@ std::optional<Site> Cache::getSite(const std::string& site) {
void Cache::addSite(std::string address, Site site) {
std::lock_guard<std::mutex> lock(mutex);
- assert(address.find("gemini://") != -1);
+ assert(address.find("gemini://") != std::string::npos);
auto it = cache.find(address);
if (it != cache.end()) {
diff --git a/src/gemini-client.cpp b/src/gemini-client.cpp
@@ -144,7 +144,7 @@ Site* GeminiClient::fetchSite(Link link, std::string crtPath, std::string keyPat
try {
fileStr = readFileToString(fsPath);
- } catch (FileReadError e ) {
+ } catch (FileReadError& e ) {
return new Site {"51 file not found", ""};
}
// TODO: how should I discern file types?
diff --git a/src/link.cpp b/src/link.cpp
@@ -21,7 +21,7 @@ Link::Link(std::string text, std::optional<uri> prior, int linkNumber) {
int highest = -1;
- for(int i = 0; i < afterPrefix.size(); ++i) {
+ for(int i = 0; i < (int)afterPrefix.size(); ++i) {
if(!(isWhiteSpace(afterPrefix, i))) {
break;
}
@@ -48,7 +48,7 @@ Link::Link(std::string text, std::optional<uri> prior, int linkNumber) {
uri Link::parseDestination(std::string destination, std::optional<uri> prior) {
// TODO: Not sure if this is right w/ how file paths work.
- if(destination.find(":") == -1) {
+ if(destination.find(":") == std::string::npos) {
if(prior != std::nullopt) {
// query parameter special casing
if(destination.substr(0,1) == "?") {
diff --git a/src/main.cpp b/src/main.cpp
@@ -42,7 +42,7 @@ void removeNonAscii(std::vector<std::pair<std::string, TextRender>>& strLs) {
std::string out;
for (int c: s)
- if (c >= 0x20 && c <= 0x7E || c == '\n') {
+ if ((c >= 0x20 && c <= 0x7E) || (c == '\n')) {
out += c;
} else if (c == '\t') {
out += " "; // \t is a larger character and fucks with breaklines.
@@ -97,7 +97,7 @@ void drawInputBox(std::string text, std::string userInput) {
int userInputSize = userInput.size();
int width = COLS/2;
- if(text.size() >= width) {
+ if((int)text.size() >= width) {
text = text.substr(0,width-6) + "...: ";
}
@@ -159,11 +159,11 @@ void draw(DrawState& ds) {
ds.y = std::max(0,std::min(ds.y,lowestPos(current)));
erase();
- move(0,(COLS / 2) - (ds.header.size() / 2) );
+ move(0,(COLS / 2) - ((int)ds.header.size() / 2) );
attron(A_BOLD);
- if(ds.header.size() < COLS) {
+ if((int)ds.header.size() < COLS) {
addstr(ds.header.c_str());
} else {
addstr((ds.header.substr(0,COLS-3) + "...").c_str());
@@ -173,7 +173,7 @@ void draw(DrawState& ds) {
addstr(std::string(COLS, ' ').c_str());
- for(int i = ds.y; i - ds.y < LINES - 2 && i < current.size(); ++i) {
+ for(int i = ds.y; i - ds.y < LINES - 2 && i < (int)current.size(); ++i) {
move(i - ds.y + 2, 0);
attron(COLOR_PAIR(current[i].second.color + 1));
@@ -401,8 +401,8 @@ int main(int argc, char** argv) {
b.followLinkNumber(std::stoi(locationToGo));
} catch (...) {
if(locationToGo != "") {
- if(locationToGo.find(":") == -1) { // TODO: Is this how we which scheme was specified?
- if(locationToGo.find('.') != -1 && urlEncode(locationToGo) == locationToGo) { // hmm, this feels weak. Like I can't search something if I add a period?
+ if(locationToGo.find(":") == std::string::npos) { // TODO: Is this how we which scheme was specified?
+ if(locationToGo.find('.') != std::string::npos && urlEncode(locationToGo) == locationToGo) { // hmm, this feels weak. Like I can't search something if I add a period?
locationToGo = "gemini://" + locationToGo;
} else {
locationToGo = DEFAULT_SEARCH_ENGINE + urlEncode(locationToGo);
diff --git a/src/utils.cpp b/src/utils.cpp
@@ -75,7 +75,7 @@ std::vector<std::string> stringToList(std::string input)
if (!input.empty()) {
int start = 0;
do {
- int idx = input.find('\n', start);
+ std::size_t idx = input.find('\n', start);
if (idx == std::string::npos) {
break;
}
@@ -194,14 +194,14 @@ std::vector<std::pair<std::string, TextRender>> breakLines(std::vector<std::pair
std::string current = "";
int lastSpace = -1;
- for(int x = 0; x < cstr.size(); ++x) {
+ for(int x = 0; x < (int)cstr.size(); ++x) {
if(cstr[x] == '\n') {
res.push_back(std::pair<std::string,TextRender> {leftPadStr + current, strLs[i].second});
current = "";
lastSpace = -1;
continue;
}
- if(current.size() < width) {
+ if((int)current.size() < width) {
current.push_back(cstr[x]);
if(cstr[x] == ' ') {
lastSpace = current.size()-1;
@@ -241,7 +241,7 @@ void writeStringToFile(std::string toWrite, std::string filePath) {
std::string encodeAsFilename(uri link) {
std::string base = link.to_string();
- assert(base.find(':') != -1);
+ assert(base.find(':') != std::string::npos);
base = base.substr(base.find(':')+1); // works for file:/// and gemini:///
while(base.size() > 0 && base[0] == '/') {