Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.8.0)
cmake_minimum_required (VERSION 3.10)
project (pcurses)

if (NOT CMAKE_BUILD_TYPE)
Expand All @@ -20,7 +20,7 @@ find_package(Curses REQUIRED)

if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(
-Wall -Wextra -Werror -O2 -pedantic -fPIC -std=gnu++11
-Wall -Wextra -Werror -O2 -pedantic -fPIC -std=c++17
-D_FILE_OFFSET_BITS=64
)
endif(CMAKE_COMPILER_IS_GNUCXX)
Expand Down
12 changes: 6 additions & 6 deletions src/cursesframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using std::string;

CursesFrame::CursesFrame(FrameInfo *frameinfo)
: overflowind("..."), w_main(NULL), w_border(NULL), focused(false), finfo(frameinfo)
: overflowind("..."), w_main(nullptr), w_border(nullptr), focused(false), finfo(frameinfo)
{
if (finfo->gethasborder()) {
w_border = newwin(finfo->geth(), finfo->getw(), finfo->gety(), finfo->getx());
Expand All @@ -35,7 +35,7 @@ CursesFrame::CursesFrame(FrameInfo *frameinfo)

CursesFrame::~CursesFrame()
{
if (w_border != NULL) {
if (w_border != nullptr) {
delwin(w_border);
}
delwin(w_main);
Expand Down Expand Up @@ -88,15 +88,15 @@ string CursesFrame::fitstrtowin(string in, int x) const
}
void CursesFrame::refresh()
{
if (w_border != NULL) {
if (w_border != nullptr) {
box(w_border, ACS_VLINE, ACS_HLINE);

int headercol = focused ? C_INV : C_DEF;
wattron(w_border, A_BOLD | headercol);
mvwprintw(w_border, 0, 1, header.c_str());
wattroff(w_border, A_BOLD | headercol);

mvwprintw(w_border, w_border->_maxy, 1, footer.c_str());
mvwprintw(w_border, getmaxy(w_border) - 1, 1, footer.c_str());

wnoutrefresh(w_border);
}
Expand Down Expand Up @@ -144,12 +144,12 @@ void CursesFrame::clear()

int CursesFrame::usableheight() const
{
return w_main->_maxy;
return getmaxy(w_main);
}

int CursesFrame::usablewidth() const
{
return w_main->_maxx;
return getmaxx(w_main);
}

void CursesFrame::setfooter(string str)
Expand Down
6 changes: 3 additions & 3 deletions src/curseslistbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using std::vector;

CursesListBox::CursesListBox(FrameInfo *frameinfo)
: CursesFrame(frameinfo),
list(NULL),
list(nullptr),
windowpos(0),
cursorpos(0)
{
Expand Down Expand Up @@ -151,10 +151,10 @@ int CursesListBox::focusedindex() const
Package *CursesListBox::focusedpackage() const
{
if (list->size() == 0) {
return NULL;
return nullptr;
}
if (!isinbounds(focusedindex())) {
return NULL;
return nullptr;
}

return list->at(focusedindex());
Expand Down
4 changes: 3 additions & 1 deletion src/cursesui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

#include "cursesui.h"

#include <assert.h>
#include <cassert>
#include <clocale>
#include <cstdlib>
#include <ncurses.h>
#include <signal.h>
#include <sys/ioctl.h>
Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
************************************************************************* */

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <unistd.h>

#include "globals.h"
Expand Down
8 changes: 4 additions & 4 deletions src/package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Package::Package(alpm_pkg_t *pkg, alpm_db_t *localdb)

_signature = alpm_pkg_get_base64_sig(_pkg) ? "Yes" : "None";

if (_localpkg == NULL) {
if (_localpkg == nullptr) {
_updatestate = USE_NOTINSTALLED;
} else {
_localversion = alpm_pkg_get_version(_localpkg);
Expand All @@ -78,7 +78,7 @@ Package::Package(alpm_pkg_t *pkg, alpm_db_t *localdb)
alpm_list_free(optionalforlist);
}

_reason = ((_localpkg == NULL) ? IRE_NOTINSTALLED :
_reason = ((_localpkg == nullptr) ? IRE_NOTINSTALLED :
(alpm_pkg_get_reason(_localpkg) == ALPM_PKG_REASON_DEPEND) ? IRE_ASDEPS :
IRE_EXPLICIT);
}
Expand All @@ -105,7 +105,7 @@ string Package::size2str(off_t size)

string Package::trimstr(const char *c) const
{
if (c == NULL) {
if (c == nullptr) {
return "";
}

Expand All @@ -131,7 +131,7 @@ string Package::deplist2str(alpm_list_t *l, string delim) const
for (alpm_list_t *deps = l; deps != NULL; deps = alpm_list_next(deps)) {
alpm_depend_t *depend = (alpm_depend_t *)deps->data;
res += alpm_dep_compute_string(depend);
if (deps->next != NULL) {
if (deps->next != nullptr) {
res += delim;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/package.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

#include "attributeinfo.h"

typedef struct __alpm_pkg_t alpm_pkg_t;

enum InstallReasonEnum {
IRE_EXPLICIT,
IRE_ASDEPS,
Expand Down
8 changes: 3 additions & 5 deletions src/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ using boost::xpressive::regex_constants::icase;
using boost::xpressive::smatch;
using boost::xpressive::sregex;

typedef struct __alpm_list_t alpm_list_t;

#define PIPE_READ 0
#define PIPE_WRITE 1

Expand Down Expand Up @@ -81,7 +79,7 @@ void Program::run_cmd(const string &cmd) const
pid = fork();
if (pid == 0) {
/* child */
execlp("bash", "bash", "-ic", cmd.c_str(), (char *)NULL);
execlp("bash", "bash", "-ic", cmd.c_str(), (char *)nullptr);
} else {
/* parent (or error, which we blissfully ignore */

Expand Down Expand Up @@ -322,7 +320,7 @@ void Program::loadpkgs()

alpm_handle_t *handle =
alpm_initialize(conf.getrootdir().c_str(), conf.getdbpath().c_str(), &err);
if (handle == NULL) {
if (handle == nullptr) {
throw PcursesException(alpm_strerror(err));
}

Expand Down Expand Up @@ -383,7 +381,7 @@ void Program::clearfilter()

History *Program::gethis(FilterOperationEnum o)
{
History *v = NULL;
History *v = nullptr;

switch (o) {
case OP_FILTER:
Expand Down