A few assorted cleanups.

This commit is contained in:
2025-08-12 02:52:51 -04:00
parent b4600db393
commit a02ed91d3b
4 changed files with 31 additions and 35 deletions

View File

@ -39,6 +39,8 @@
#include "../dpip/dpip.h"
using namespace std::literals::string_literals;
#define DPI_EXT (".dpi" EXEEXT)
#define QUEUE 5
@ -52,10 +54,8 @@ char *SharedKey = NULL;
*/
void cleanup(void)
{
char *fname;
fname = dStrconcat(dGethomedir(), "/", dotDILLO_DPID_COMM_KEYS, NULL);
unlink(fname);
dFree(fname);
std::string fname = dGethomedir() + "/"s + dotDILLO_DPID_COMM_KEYS;
unlink(fname.c_str());
}
/*! Free memory used to describe

View File

@ -558,11 +558,6 @@ void DilloHtml::write(char *Buf, int BufSize, int Eof)
int bufsize = BufSize - Start_Ofs;
_MSG("DilloHtml::write BufSize=%d Start_Ofs=%d\n", BufSize, Start_Ofs);
#if 0
char *aux = dStrndup(Buf, BufSize);
MSG(" {%s}\n", aux);
dFree(aux);
#endif
/* Update Start_Buf. It may be used after the parser is stopped */
Start_Buf = Buf;

View File

@ -36,6 +36,8 @@
#include "history.hh"
#include "nav.hh"
using namespace std::literals::string_literals;
struct iconset {
Fl_Image *ImgMeterOK, *ImgMeterBug,
*ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools,
@ -239,19 +241,17 @@ static void search_cb(Fl_Widget *wid, void *data)
*/
static void help_cb(Fl_Widget *w, void *)
{
char *path = dStrconcat(DILLO_DOCDIR, "user_help.html", NULL);
std::string path = DILLO_DOCDIR + "user_help.html"s;
BrowserWindow *bw = a_UIcmd_get_bw_by_widget(w);
if (access(path, R_OK) == 0) {
char *urlstr = dStrconcat("file:", path, NULL);
a_UIcmd_open_urlstr(bw, urlstr);
dFree(urlstr);
if (access(path.c_str(), R_OK) == 0) {
std::string urlstr = "file:" + path;
a_UIcmd_open_urlstr(bw, urlstr.c_str());
} else {
MSG("Can't read local help file at \"%s\"."
" Getting remote help...\n", path);
" Getting remote help...\n", path.c_str());
a_UIcmd_open_urlstr(bw, "https://dillo-browser.github.io/user_help.html");
}
dFree(path);
}
/**

View File

@ -52,6 +52,8 @@
#include "nav.hh"
#include <algorithm>
//#define DEFAULT_TAB_LABEL "-.untitled.-"
#define DEFAULT_TAB_LABEL "-.new.-"
@ -63,6 +65,8 @@ using namespace dw::core;
// FLTK related
using namespace dw::fltk;
using namespace std::literals::string_literals;
/*
* Local data
@ -105,13 +109,13 @@ public:
void ui(UI *pui) { ui_ = pui; }
UI *ui(void) { return ui_; }
void focus_num(uint_t fn) { focus_num_ = fn; }
uint_t focus_num(void) { return focus_num_; }
uint_t focus_num() const { return focus_num_; }
};
static int btn_cmp(const void *p1, const void *p2)
static int
btn_cmp( const CustTabButton *const p1, const CustTabButton *const p2 )
{
return ((*(CustTabButton * const *)p1)->focus_num() -
(*(CustTabButton * const *)p2)->focus_num() );
return p1->focus_num() - p2->focus_num();
}
/**
@ -135,14 +139,13 @@ class CustTabs : public Fl_Group {
++focus_counter;
else {
/* wrap & normalize old numbers here */
CustTabButton **btns = dNew(CustTabButton*, num_tabs());
std::vector< CustTabButton * > btns;
for (int i = 0; i < num_tabs(); ++i)
btns[i] = (CustTabButton*)Pack->child(i);
qsort(btns, num_tabs(), sizeof(CustTabButton *), btn_cmp);
btns.push_back( (CustTabButton*)Pack->child( i ) ) ;
std::ranges::sort( btns, btn_cmp );
focus_counter = 0;
for (int i = 0; i < num_tabs(); ++i)
btns[i]->focus_num(focus_counter++);
dFree(btns);
for( auto *btn: btns )
btn->focus_num(focus_counter++);
}
}
@ -760,7 +763,7 @@ void a_UIcmd::a_UIcmd_open_urlstr(BrowserWindow *bw, const char *urlstr)
{
char *new_urlstr;
char *search_urlstr = NULL;
DilloUrl *url;
std::unique_ptr< DilloUrl > url;
int ch;
if ((search_urlstr = UIcmd_find_search_str(urlstr))) {
@ -774,20 +777,19 @@ void a_UIcmd::a_UIcmd_open_urlstr(BrowserWindow *bw, const char *urlstr)
/* file URI */
ch = new_urlstr[5];
if (!ch || ch == '.') {
url = a_Url_new(Paths::getOldWorkingDir(), "file:").release();
url = a_Url_new(Paths::getOldWorkingDir(), "file:");
} else {
url = a_Url_new(new_urlstr, "file:").release();
url = a_Url_new(new_urlstr, "file:");
}
} else {
/* common case */
url = a_Url_new(new_urlstr, NULL).release();
url = a_Url_new(new_urlstr, NULL);
}
dFree(new_urlstr);
if (url) {
a_UIcmd_open_url(bw, url);
delete url;
a_UIcmd_open_url(bw, url.release());
}
}
dFree(search_urlstr);
@ -1215,9 +1217,8 @@ const char *a_UIcmd::a_UIcmd_get_passwd(const char *user)
{
const char *passwd;
const char *title = "Flenser: Password";
char *msg = dStrconcat("Password for user \"", user, "\"", NULL);
passwd = a_Dialog_passwd(title, msg);
dFree(msg);
std::string msg= "Password for user \""s + user + "\"";
passwd = a_Dialog_passwd(title, msg.c_str());
return passwd;
}