[gnome-commander/gcmd-1-10: 50/57] C++ cast, auto keyword, use nullptr instead of NULL
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/gcmd-1-10: 50/57] C++ cast, auto keyword, use nullptr instead of NULL
- Date: Thu, 11 Apr 2019 20:08:33 +0000 (UTC)
commit 5e3292ba3956e0f6d171ed83edc6858cb177f600
Author: Uwe Scholz <u scholz83 gmx de>
Date: Wed Apr 10 21:21:03 2019 +0200
C++ cast, auto keyword, use nullptr instead of NULL
src/intviewer/viewer-widget.cc | 10 ++++++----
src/ls_colors.cc | 22 ++++++++++-----------
src/plugin_manager.cc | 44 +++++++++++++++++++++---------------------
3 files changed, 39 insertions(+), 37 deletions(-)
---
diff --git a/src/intviewer/viewer-widget.cc b/src/intviewer/viewer-widget.cc
index f6cbb365..607ce6f5 100644
--- a/src/intviewer/viewer-widget.cc
+++ b/src/intviewer/viewer-widget.cc
@@ -120,7 +120,7 @@ GtkType gviewer_get_type ()
GtkWidget *gviewer_new ()
{
- GViewer *w = (GViewer *) g_object_new (gviewer_get_type (), NULL);
+ auto w = static_cast<GViewer*> (g_object_new (gviewer_get_type (), NULL));
return GTK_WIDGET (w);
}
@@ -155,7 +155,7 @@ static void gviewer_init (GViewer *w)
w->priv->img_initialized = FALSE;
w->priv->dispmode = DISP_MODE_TEXT_FIXED;
- w->priv->textr = (TextRender *) text_render_new();
+ w->priv->textr = reinterpret_cast<TextRender*> (text_render_new());
gviewer_set_tab_size(w, DEFAULT_TAB_SIZE);
gviewer_set_wrap_mode(w, DEFAULT_WRAP_MODE);
@@ -171,7 +171,7 @@ static void gviewer_init (GViewer *w)
gtk_widget_show (w->priv->tscrollbox);
g_object_ref (w->priv->tscrollbox);
- w->priv->imgr = (ImageRender *) image_render_new();
+ w->priv->imgr = reinterpret_cast<ImageRender*> (image_render_new());
gviewer_set_best_fit(w, DEFAULT_BEST_FIT);
gviewer_set_scale_factor(w, DEFAULT_SCALE_FACTOR);
w->priv->iscrollbox = scroll_box_new();
@@ -288,7 +288,9 @@ static void gviewer_destroy (GtkObject *widget)
}
if (GTK_OBJECT_CLASS(parent_class)->destroy)
- (*GTK_OBJECT_CLASS(parent_class)->destroy)(widget);
+ {
+ (*GTK_OBJECT_CLASS(parent_class)->destroy) (widget);
+ }
}
diff --git a/src/ls_colors.cc b/src/ls_colors.cc
index 54bf3120..13b4fb70 100644
--- a/src/ls_colors.cc
+++ b/src/ls_colors.cc
@@ -71,7 +71,7 @@ inline GdkColor *code2color (gint code)
default: break;
}
- return NULL;
+ return nullptr;
}
@@ -82,7 +82,7 @@ static LsColor *ext_color (gchar *key, gchar *val)
ret = sscanf (val, "%d;%d;%d", &n[0], &n[1], &n[2]);
if (ret < 1)
- return NULL;
+ return nullptr;
do
key++;
@@ -90,8 +90,8 @@ static LsColor *ext_color (gchar *key, gchar *val)
col = g_new (LsColor, 1);
col->type = GNOME_VFS_FILE_TYPE_REGULAR;
col->ext = g_strdup (key);
- col->fg = NULL;
- col->bg = NULL;
+ col->fg = nullptr;
+ col->bg = nullptr;
for (i=0; i<ret; i++)
{
@@ -110,9 +110,9 @@ static LsColor *type_color (gchar *key, gchar *val)
{
int i, n[3];
LsColor *col = g_new0 (LsColor, 1);
- // col->ext = NULL;
- // col->fg = NULL;
- // col->bg = NULL;
+ // col->ext = nullptr;
+ // col->fg = nullptr;
+ // col->bg = nullptr;
if (strcmp (key, "fi") == 0)
col->type = GNOME_VFS_FILE_TYPE_REGULAR;
@@ -131,7 +131,7 @@ static LsColor *type_color (gchar *key, gchar *val)
else
{
g_free (col);
- return NULL;
+ return nullptr;
}
int ret = sscanf (val, "%d;%d;%d", &n[0], &n[1], &n[2]);
@@ -150,7 +150,7 @@ static LsColor *type_color (gchar *key, gchar *val)
static LsColor *create_color (gchar *ls_color)
{
- LsColor *col = NULL;
+ LsColor *col = nullptr;
gchar **s = g_strsplit (ls_color, "=", 0);
gchar *key = s[0];
@@ -206,11 +206,11 @@ LsColor *ls_colors_get (GnomeCmdFile *f)
if (f->info->symlink_name)
return type_colors[GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK];
- LsColor *col = NULL;
+ LsColor *col = nullptr;
const gchar *ext = f->get_extension();
if (ext)
- col = (LsColor *) g_hash_table_lookup (::map, ext);
+ col = static_cast<LsColor*> (g_hash_table_lookup (::map, ext));
if (!col)
col = type_colors[f->info->type];
diff --git a/src/plugin_manager.cc b/src/plugin_manager.cc
index 3032a7e8..da623882 100644
--- a/src/plugin_manager.cc
+++ b/src/plugin_manager.cc
@@ -1,4 +1,4 @@
-/**
+/**
* @file plugin_manager.cc
* @copyright (C) 2001-2006 Marcus Bjurman\n
* @copyright (C) 2007-2012 Piotr Eljasiak\n
@@ -38,11 +38,11 @@ using namespace std;
#define MODULE_INFO_FUNC "get_plugin_info"
-static GList *plugins = NULL;
-static GdkPixmap *exec_pixmap = NULL;
-static GdkBitmap *exec_mask = NULL;
-static GdkPixmap *blank_pixmap = NULL;
-static GdkBitmap *blank_mask = NULL;
+static GList *plugins = nullptr;
+static GdkPixmap *exec_pixmap = nullptr;
+static GdkBitmap *exec_mask = nullptr;
+static GdkPixmap *blank_pixmap = nullptr;
+static GdkBitmap *blank_mask = nullptr;
gchar* get_plugin_config_location();
@@ -162,7 +162,7 @@ static void scan_plugins_in_dir (const gchar *dpath)
return;
}
- while ((ent = readdir (dir)) != NULL)
+ while ((ent = readdir (dir)) != nullptr)
{
struct stat buf;
@@ -176,10 +176,10 @@ static void scan_plugins_in_dir (const gchar *dpath)
// the direntry has the correct extension and is a regular file, let's accept it
PluginData *data = g_new0 (PluginData, 1);
data->fname = g_strdup (ent->d_name);
- data->fpath = g_build_filename (dpath, ent->d_name, NULL);
+ data->fpath = g_build_filename (dpath, ent->d_name, nullptr);
data->loaded = FALSE;
data->active = FALSE;
- data->menu = NULL;
+ data->menu = nullptr;
data->autoload = FALSE;
activate_plugin (data);
if (!data->loaded)
@@ -237,7 +237,7 @@ void plugin_manager_init ()
for (GList *l2 = plugins; l2; l2 = l2->next)
{
- PluginData *data = (PluginData *) l2->data;
+ auto data = static_cast<PluginData*> (l2->data);
if (strcmp (name, data->fname) == 0)
data->autoload = TRUE;
}
@@ -246,7 +246,7 @@ void plugin_manager_init ()
// inactivate plugins that shouldn't be autoloaded
for (GList *l=plugins; l; l=l->next)
{
- PluginData *data = (PluginData *) l->data;
+ auto data = static_cast<PluginData*> (l->data);
if (!data->autoload)
inactivate_plugin (data);
}
@@ -255,11 +255,11 @@ void plugin_manager_init ()
void plugin_manager_shutdown ()
{
- GList *out = NULL;
+ GList *out = nullptr;
for (GList *l=plugins; l; l=l->next)
{
- PluginData *data = (PluginData *) l->data;
+ auto data = static_cast<PluginData*> (l->data);
if (data->active)
out = g_list_append (out, data->fname);
}
@@ -276,7 +276,7 @@ GList *plugin_manager_get_all ()
static PluginData *get_selected_plugin (GtkCList *list)
{
- return (PluginData *) gtk_clist_get_row_data (list, list->focus_row);
+ return static_cast<PluginData*> (gtk_clist_get_row_data (list, list->focus_row));
}
@@ -288,14 +288,14 @@ static void update_plugin_list (GtkCList *list, GtkWidget *dialog)
for (GList *i=plugins; i; i=i->next, ++row)
{
- PluginData *data = (PluginData *) i->data;
+ auto data = static_cast<PluginData*> (i->data);
gchar *text[5];
- text[0] = NULL;
+ text[0] = nullptr;
text[1] = (gchar *) data->info->name;
text[2] = (gchar *) data->info->version;
text[3] = data->fname;
- text[4] = NULL;
+ text[4] = nullptr;
if (only_update)
gtk_clist_set_text (list, row, 1, text[1]);
@@ -337,7 +337,7 @@ static void on_plugin_selected (GtkCList *list, gint row, gint column, GdkEventB
GtkWidget *about_button = lookup_widget (dialog, "about_button");
PluginData *data = get_selected_plugin (list);
- g_return_if_fail (data != NULL);
+ g_return_if_fail (data != nullptr);
if (event && event->type == GDK_2BUTTON_PRESS && event->button == 1)
{
@@ -375,7 +375,7 @@ static void on_configure (GtkButton *button, GtkWidget *dialog)
GtkCList *list = GTK_CLIST (lookup_widget (dialog, "avail_list"));
PluginData *data = get_selected_plugin (list);
- g_return_if_fail (data != NULL);
+ g_return_if_fail (data != nullptr);
g_return_if_fail (data->active);
gnome_cmd_plugin_configure (data->plugin);
@@ -387,7 +387,7 @@ static void on_about (GtkButton *button, GtkWidget *dialog)
GtkCList *list = GTK_CLIST (lookup_widget (dialog, "avail_list"));
PluginData *data = get_selected_plugin (list);
- g_return_if_fail (data != NULL);
+ g_return_if_fail (data != nullptr);
GtkWidget *about = gnome_cmd_about_plugin_new (data->info);
@@ -412,7 +412,7 @@ void plugin_manager_show ()
g_object_ref (dialog);
hbox = create_vbox (dialog, FALSE, 6);
- avail_list = create_clist (dialog, "avail_list", 4, 20, GTK_SIGNAL_FUNC (on_plugin_selected), NULL);
+ avail_list = create_clist (dialog, "avail_list", 4, 20, GTK_SIGNAL_FUNC (on_plugin_selected), nullptr);
create_clist_column (avail_list, 0, 20, "");
create_clist_column (avail_list, 1, 200, _("Name"));
create_clist_column (avail_list, 2, 50, _("Version"));
@@ -467,7 +467,7 @@ void plugin_manager_show ()
gchar* get_plugin_config_location()
{
- gchar* returnString {NULL};
+ gchar* returnString {nullptr};
string userPluginConfigDir = get_package_config_dir();
userPluginConfigDir += (char*) "/plugins";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]