Commit 060978e0 authored by Elliot Lee's avatar Elliot Lee Committed by Elliot Lee

I submitted this patch twice to gtk-devel-list, and received no comments,



I submitted this patch twice to gtk-devel-list, and received no comments, so
am committing it.  Although not exhaustively tested, I have been using this
gtk+ for a week w/o problems, and I did read the code to ensure that nothing
ever writes to these data structures. If by chance people encounter SEGV's in
gtk+ code that is setting values in global data structures, this patch could
be a possible culprit.

1998-11-30  Elliot Lee  <sopwith@cuc.ml.org>

	* {gdk,gtk}/*.c: Make read-only data structures "static const" to
	allow them to be shared, mainly including (but not limited to) the
	GtkTypeInfo structures for each class.

	* gtk/gtkfilesel.c: Add /net to the "leave me alone" directory listing.
parent 58ca2448
1998-11-30 Elliot Lee <sopwith@cuc.ml.org>
* {gdk,gtk}/*.c: Make read-only data structures "static const" to
allow them to be shared, mainly including (but not limited to) the
GtkTypeInfo structures for each class.
* gtk/gtkfilesel.c: Add /net to the "leave me alone" directory listing.
Mon Nov 30 12:17:10 1998 Jeff Garzik <jgarzik@pobox.com>
* gtk/gtknotebook.c (gtk_notebook_reorder_child):
......
1998-11-30 Elliot Lee <sopwith@cuc.ml.org>
* {gdk,gtk}/*.c: Make read-only data structures "static const" to
allow them to be shared, mainly including (but not limited to) the
GtkTypeInfo structures for each class.
* gtk/gtkfilesel.c: Add /net to the "leave me alone" directory listing.
Mon Nov 30 12:17:10 1998 Jeff Garzik <jgarzik@pobox.com>
* gtk/gtknotebook.c (gtk_notebook_reorder_child):
......
1998-11-30 Elliot Lee <sopwith@cuc.ml.org>
* {gdk,gtk}/*.c: Make read-only data structures "static const" to
allow them to be shared, mainly including (but not limited to) the
GtkTypeInfo structures for each class.
* gtk/gtkfilesel.c: Add /net to the "leave me alone" directory listing.
Mon Nov 30 12:17:10 1998 Jeff Garzik <jgarzik@pobox.com>
* gtk/gtknotebook.c (gtk_notebook_reorder_child):
......
1998-11-30 Elliot Lee <sopwith@cuc.ml.org>
* {gdk,gtk}/*.c: Make read-only data structures "static const" to
allow them to be shared, mainly including (but not limited to) the
GtkTypeInfo structures for each class.
* gtk/gtkfilesel.c: Add /net to the "leave me alone" directory listing.
Mon Nov 30 12:17:10 1998 Jeff Garzik <jgarzik@pobox.com>
* gtk/gtknotebook.c (gtk_notebook_reorder_child):
......
1998-11-30 Elliot Lee <sopwith@cuc.ml.org>
* {gdk,gtk}/*.c: Make read-only data structures "static const" to
allow them to be shared, mainly including (but not limited to) the
GtkTypeInfo structures for each class.
* gtk/gtkfilesel.c: Add /net to the "leave me alone" directory listing.
Mon Nov 30 12:17:10 1998 Jeff Garzik <jgarzik@pobox.com>
* gtk/gtknotebook.c (gtk_notebook_reorder_child):
......
1998-11-30 Elliot Lee <sopwith@cuc.ml.org>
* {gdk,gtk}/*.c: Make read-only data structures "static const" to
allow them to be shared, mainly including (but not limited to) the
GtkTypeInfo structures for each class.
* gtk/gtkfilesel.c: Add /net to the "leave me alone" directory listing.
Mon Nov 30 12:17:10 1998 Jeff Garzik <jgarzik@pobox.com>
* gtk/gtknotebook.c (gtk_notebook_reorder_child):
......
1998-11-30 Elliot Lee <sopwith@cuc.ml.org>
* {gdk,gtk}/*.c: Make read-only data structures "static const" to
allow them to be shared, mainly including (but not limited to) the
GtkTypeInfo structures for each class.
* gtk/gtkfilesel.c: Add /net to the "leave me alone" directory listing.
Mon Nov 30 12:17:10 1998 Jeff Garzik <jgarzik@pobox.com>
* gtk/gtknotebook.c (gtk_notebook_reorder_child):
......
......@@ -229,7 +229,7 @@ static gulong base_id;
static gint autorepeat;
#ifdef G_ENABLE_DEBUG
static GDebugKey gdk_debug_keys[] = {
static const GDebugKey gdk_debug_keys[] = {
{"events", GDK_DEBUG_EVENTS},
{"misc", GDK_DEBUG_MISC},
{"dnd", GDK_DEBUG_DND},
......@@ -1504,8 +1504,8 @@ gdk_pointer_grab (GdkWindow * window,
guint32 time)
{
/* From gdkwindow.c */
extern int nevent_masks;
extern int event_mask_table[];
extern const int nevent_masks;
extern const int event_mask_table[];
gint return_val;
GdkWindowPrivate *window_private;
......
......@@ -38,9 +38,9 @@ static GdkDevicePrivate *gdk_input_find_device (guint32 id);
/* Incorporate the specific routines depending on compilation options */
static GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
static const GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
static GdkDeviceInfo gdk_input_core_info =
static const GdkDeviceInfo gdk_input_core_info =
{
GDK_CORE_POINTER,
"Core Pointer",
......
......@@ -304,7 +304,7 @@ gdk_rgb_try_colormap (gint nr, gint ng, gint nb)
static gboolean
gdk_rgb_do_colormaps (void)
{
const gint sizes[][3] = {
static const gint sizes[][3] = {
/* { 6, 7, 6 }, */
{ 6, 6, 6 },
{ 6, 6, 5 },
......@@ -316,7 +316,7 @@ gdk_rgb_do_colormaps (void)
{ 3, 3, 3 },
{ 2, 2, 2 }
};
const gint n_sizes = sizeof(sizes) / (3 * sizeof(gint));
static const gint n_sizes = sizeof(sizes) / (3 * sizeof(gint));
gint i;
for (i = 0; i < n_sizes; i++)
......@@ -387,7 +387,7 @@ static guint32
gdk_rgb_score_visual (GdkVisual *visual)
{
guint32 quality, speed, sys, pseudo;
gchar* visual_names[] =
static const gchar* visual_names[] =
{
"static gray",
"grayscale",
......@@ -535,7 +535,7 @@ void
gdk_rgb_init (void)
{
gint i;
gint byte_order[1] = { 1 };
static const gint byte_order[1] = { 1 };
/* check endian sanity */
#if G_BYTE_ORDER == G_BIG_ENDIAN
......@@ -982,7 +982,7 @@ static const guchar DM[128][128] =
#define DM_WIDTH 8
#define DM_WIDTH_SHIFT 3
#define DM_HEIGHT 8
static guchar DM[8][8] =
static const guchar DM[8][8] =
{
{ 0, 32, 8, 40, 2, 34, 10, 42 },
{ 48, 16, 56, 24, 50, 18, 58, 26 },
......
......@@ -44,7 +44,7 @@ static gint navailable_types;
#ifdef G_ENABLE_DEBUG
static gchar* visual_names[] =
static const gchar* visual_names[] =
{
"static gray",
"grayscale",
......@@ -61,8 +61,8 @@ static GHashTable *visual_hash = NULL;
void
gdk_visual_init (void)
{
static gint possible_depths[7] = { 32, 24, 16, 15, 8, 4, 1 };
static GdkVisualType possible_types[6] =
static const gint possible_depths[7] = { 32, 24, 16, 15, 8, 4, 1 };
static const GdkVisualType possible_types[6] =
{
GDK_VISUAL_DIRECT_COLOR,
GDK_VISUAL_TRUE_COLOR,
......@@ -72,8 +72,8 @@ gdk_visual_init (void)
GDK_VISUAL_STATIC_GRAY
};
static gint npossible_depths = 7;
static gint npossible_types = 6;
static const gint npossible_depths = sizeof(possible_depths)/sizeof(gint);
static const gint npossible_types = sizeof(possible_types)/sizeof(GdkVisualType);
XVisualInfo *visual_list;
XVisualInfo visual_template;
......
......@@ -33,8 +33,7 @@
#include <X11/extensions/shape.h>
#endif
int nevent_masks = 20;
int event_mask_table[20] =
const int event_mask_table[20] =
{
ExposureMask,
PointerMotionMask,
......@@ -57,6 +56,7 @@ int event_mask_table[20] =
0, /* PROXIMTY_OUT */
SubstructureNotifyMask
};
const int nevent_masks = sizeof(event_mask_table)/sizeof(int);
static gboolean gdk_window_have_shape_ext (void);
......
......@@ -38,9 +38,9 @@ static GdkDevicePrivate *gdk_input_find_device (guint32 id);
/* Incorporate the specific routines depending on compilation options */
static GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
static const GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
static GdkDeviceInfo gdk_input_core_info =
static const GdkDeviceInfo gdk_input_core_info =
{
GDK_CORE_POINTER,
"Core Pointer",
......
......@@ -229,7 +229,7 @@ static gulong base_id;
static gint autorepeat;
#ifdef G_ENABLE_DEBUG
static GDebugKey gdk_debug_keys[] = {
static const GDebugKey gdk_debug_keys[] = {
{"events", GDK_DEBUG_EVENTS},
{"misc", GDK_DEBUG_MISC},
{"dnd", GDK_DEBUG_DND},
......@@ -1504,8 +1504,8 @@ gdk_pointer_grab (GdkWindow * window,
guint32 time)
{
/* From gdkwindow.c */
extern int nevent_masks;
extern int event_mask_table[];
extern const int nevent_masks;
extern const int event_mask_table[];
gint return_val;
GdkWindowPrivate *window_private;
......
......@@ -44,7 +44,7 @@ static gint navailable_types;
#ifdef G_ENABLE_DEBUG
static gchar* visual_names[] =
static const gchar* visual_names[] =
{
"static gray",
"grayscale",
......@@ -61,8 +61,8 @@ static GHashTable *visual_hash = NULL;
void
gdk_visual_init (void)
{
static gint possible_depths[7] = { 32, 24, 16, 15, 8, 4, 1 };
static GdkVisualType possible_types[6] =
static const gint possible_depths[7] = { 32, 24, 16, 15, 8, 4, 1 };
static const GdkVisualType possible_types[6] =
{
GDK_VISUAL_DIRECT_COLOR,
GDK_VISUAL_TRUE_COLOR,
......@@ -72,8 +72,8 @@ gdk_visual_init (void)
GDK_VISUAL_STATIC_GRAY
};
static gint npossible_depths = 7;
static gint npossible_types = 6;
static const gint npossible_depths = sizeof(possible_depths)/sizeof(gint);
static const gint npossible_types = sizeof(possible_types)/sizeof(GdkVisualType);
XVisualInfo *visual_list;
XVisualInfo visual_template;
......
......@@ -33,8 +33,7 @@
#include <X11/extensions/shape.h>
#endif
int nevent_masks = 20;
int event_mask_table[20] =
const int event_mask_table[20] =
{
ExposureMask,
PointerMotionMask,
......@@ -57,6 +56,7 @@ int event_mask_table[20] =
0, /* PROXIMTY_OUT */
SubstructureNotifyMask
};
const int nevent_masks = sizeof(event_mask_table)/sizeof(int);
static gboolean gdk_window_have_shape_ext (void);
......
......@@ -702,7 +702,7 @@ gboolean
gtk_accelerator_valid (guint keyval,
GdkModifierType modifiers)
{
guint invalid_accelerator_vals[] = {
static const guint invalid_accelerator_vals[] = {
GDK_BackSpace, GDK_Delete, GDK_KP_Delete,
GDK_Shift_L, GDK_Shift_R, GDK_Shift_Lock, GDK_Caps_Lock, GDK_ISO_Lock,
GDK_Control_L, GDK_Control_R, GDK_Meta_L, GDK_Meta_R,
......@@ -880,7 +880,7 @@ gtk_accelerator_parse (const gchar *accelerator,
}
else if (len >= 6 && is_modx (accelerator))
{
guint mod_vals[] = {
static const guint mod_vals[] = {
GDK_MOD1_MASK, GDK_MOD2_MASK, GDK_MOD3_MASK,
GDK_MOD4_MASK, GDK_MOD5_MASK
};
......
......@@ -57,7 +57,7 @@ gtk_accel_label_get_type (void)
if (!accel_label_type)
{
GtkTypeInfo accel_label_info =
static const GtkTypeInfo accel_label_info =
{
"GtkAccelLabel",
sizeof (GtkAccelLabel),
......
......@@ -41,7 +41,7 @@ gtk_adjustment_get_type (void)
if (!adjustment_type)
{
GtkTypeInfo adjustment_info =
static const GtkTypeInfo adjustment_info =
{
"GtkAdjustment",
sizeof (GtkAdjustment),
......
......@@ -50,7 +50,7 @@ gtk_alignment_get_type (void)
if (!alignment_type)
{
GtkTypeInfo alignment_info =
static const GtkTypeInfo alignment_info =
{
"GtkAlignment",
sizeof (GtkAlignment),
......
......@@ -47,7 +47,7 @@ gtk_arrow_get_type (void)
if (!arrow_type)
{
GtkTypeInfo arrow_info =
static const GtkTypeInfo arrow_info =
{
"GtkArrow",
sizeof (GtkArrow),
......
......@@ -44,7 +44,7 @@ gtk_aspect_frame_get_type (void)
if (!aspect_frame_type)
{
GtkTypeInfo aspect_frame_info =
static const GtkTypeInfo aspect_frame_info =
{
"GtkAspectFrame",
sizeof (GtkAspectFrame),
......
......@@ -36,7 +36,7 @@ gtk_button_box_get_type (void)
if (!button_box_type)
{
GtkTypeInfo button_box_info =
static const GtkTypeInfo button_box_info =
{
"GtkButtonBox",
sizeof (GtkButtonBox),
......
......@@ -48,7 +48,7 @@ gtk_bin_get_type (void)
if (!bin_type)
{
GtkTypeInfo bin_info =
static const GtkTypeInfo bin_info =
{
"GtkBin",
sizeof (GtkBin),
......
......@@ -76,7 +76,7 @@ gtk_box_get_type (void)
if (!box_type)
{
GtkTypeInfo box_info =
static const GtkTypeInfo box_info =
{
"GtkBox",
sizeof (GtkBox),
......
......@@ -100,7 +100,7 @@ gtk_button_get_type (void)
if (!button_type)
{
GtkTypeInfo button_info =
static const GtkTypeInfo button_info =
{
"GtkButton",
sizeof (GtkButton),
......
......@@ -43,13 +43,13 @@ typedef enum { false = FALSE , true = TRUE } boolean;
#define and && /* logical (boolean) operators: lower case */
#define or ||
static N_int month_length[2][13] =
static const N_int month_length[2][13] =
{
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};
static N_int days_in_months[2][14] =
static const N_int days_in_months[2][14] =
{
{ 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
{ 0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
......@@ -313,7 +313,7 @@ gtk_calendar_get_type (void)
if (!calendar_type)
{
GtkTypeInfo calendar_info =
static const GtkTypeInfo calendar_info =
{
"GtkCalendar",
sizeof (GtkCalendar),
......
......@@ -52,7 +52,7 @@ gtk_check_button_get_type (void)
if (!check_button_type)
{
GtkTypeInfo check_button_info =
static const GtkTypeInfo check_button_info =
{
"GtkCheckButton",
sizeof (GtkCheckButton),
......
......@@ -54,7 +54,7 @@ gtk_check_menu_item_get_type (void)
if (!check_menu_item_type)
{
GtkTypeInfo check_menu_item_info =
static const GtkTypeInfo check_menu_item_info =
{
"GtkCheckMenuItem",
sizeof (GtkCheckMenuItem),
......
......@@ -396,7 +396,7 @@ gtk_clist_get_type (void)
if (!clist_type)
{
GtkTypeInfo clist_info =
static const GtkTypeInfo clist_info =
{
"GtkCList",
sizeof (GtkCList),
......
......@@ -196,7 +196,7 @@ static const gchar *value_index_key = "gtk-value-index";
#define SF GtkSignalFunc
scale_val_type scale_vals[NUM_CHANNELS] =
static const scale_val_type scale_vals[NUM_CHANNELS] =
{
{"Hue:", 0.0, 360.0, 1.00, 10.00, (SF) gtk_color_selection_hsv_updater},
{"Saturation:", 0.0, 1.0, 0.01, 0.01, (SF) gtk_color_selection_hsv_updater},
......@@ -214,7 +214,7 @@ gtk_color_selection_get_type (void)
if (!color_selection_type)
{
GtkTypeInfo colorsel_info =
static const GtkTypeInfo colorsel_info =
{
"GtkColorSelection",
sizeof (GtkColorSelection),
......@@ -517,7 +517,7 @@ gtk_color_selection_realize (GtkWidget *widget)
{
GtkColorSelection *colorsel;
GtkTargetEntry targets[] = {
static const GtkTargetEntry targets[] = {
{ "application/x-color", 0 }
};
......
......@@ -725,7 +725,7 @@ gtk_combo_get_type (void)
if (!combo_type)
{
GtkTypeInfo combo_info =
static const GtkTypeInfo combo_info =
{
"GtkCombo",
sizeof (GtkCombo),
......
......@@ -112,7 +112,7 @@ gtk_container_get_type (void)
if (!container_type)
{
GtkTypeInfo container_info =
static const GtkTypeInfo container_info =
{
"GtkContainer",
sizeof (GtkContainer),
......
......@@ -298,7 +298,7 @@ gtk_ctree_get_type (void)
if (!ctree_type)
{
GtkTypeInfo ctree_info =
static const GtkTypeInfo ctree_info =
{
"GtkCTree",
sizeof (GtkCTree),
......
......@@ -58,7 +58,7 @@ gtk_curve_get_type (void)
if (!curve_type)
{
GtkTypeInfo curve_info =
static const GtkTypeInfo curve_info =
{
"GtkCurve",
sizeof (GtkCurve),
......
......@@ -39,7 +39,7 @@ gtk_data_get_type (void)
if (!data_type)
{
GtkTypeInfo data_info =
static const GtkTypeInfo data_info =
{
"GtkData",
sizeof (GtkData),
......
......@@ -34,7 +34,7 @@ gtk_dialog_get_type (void)
if (!dialog_type)
{
GtkTypeInfo dialog_info =
static const GtkTypeInfo dialog_info =
{
"GtkDialog",
sizeof (GtkDialog),
......
......@@ -302,10 +302,10 @@ static struct {
{ 0 , action_none_bits, action_none_mask_bits, NULL },
};
static gint n_drag_cursors = sizeof(drag_cursors) / sizeof(drag_cursors[0]);
static const gint n_drag_cursors = sizeof(drag_cursors) / sizeof(drag_cursors[0]);
/* XPM */
static char * drag_default_xpm[] = {
static const char * drag_default_xpm[] = {
"32 32 3 1",
" c None",
". c #000000",
......
......@@ -34,7 +34,7 @@ gtk_drawing_area_get_type (void)
if (!drawing_area_type)
{
GtkTypeInfo drawing_area_info =
static const GtkTypeInfo drawing_area_info =
{
"GtkDrawingArea",
sizeof (GtkDrawingArea),
......
......@@ -33,7 +33,7 @@ gtk_draw_window_get_type (void)
if (!draw_window_type)
{
GtkTypeInfo draw_window_info =
static const GtkTypeInfo draw_window_info =
{
"GtkDrawWindow",
sizeof (GtkDrawWindow),
......
......@@ -109,7 +109,7 @@ gtk_editable_get_type (void)
if (!editable_type)
{
GtkTypeInfo editable_info =
static const GtkTypeInfo editable_info =
{
"GtkEditable",
sizeof (GtkEditable),
......@@ -371,12 +371,12 @@ gtk_editable_get_arg (GtkObject *object,
static void
gtk_editable_init (GtkEditable *editable)
{
static GtkTargetEntry targets[] = {
static const GtkTargetEntry targets[] = {
{ "STRING", TARGET_STRING },
{ "TEXT", TARGET_TEXT },
{ "COMPOUND_TEXT", TARGET_COMPOUND_TEXT }
};
static gint n_targets = sizeof(targets) / sizeof(targets[0]);
static const gint n_targets = sizeof(targets) / sizeof(targets[0]);
GTK_WIDGET_SET_FLAGS (editable, GTK_CAN_FOCUS);
......
......@@ -153,7 +153,7 @@ static void gtk_entry_set_position_from_editable (GtkEditable *editable,
static GtkWidgetClass *parent_class = NULL;
static GdkAtom ctext_atom = GDK_NONE;
static GtkTextFunction control_keys[26] =