/* A general interface to the widgets of different toolkits.
+
Copyright (C) 1992, 1993 Lucid, Inc.
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+Copyright (C) 1994-1996, 1999-2013 Free Software Foundation, Inc.
This file is part of the Lucid Widget Library.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <setjmp.h>
-#include "../src/lisp.h"
+#include <lisp.h>
+#include <c-strcase.h>
#include <sys/types.h>
#include <stdio.h>
-#include <ctype.h>
#include "lwlib-int.h"
#include "lwlib-utils.h"
#include <X11/StringDefs.h>
widget_value *,
int, int *);
static void instantiate_widget_instance (widget_instance *);
-static int my_strcasecmp (const char *, const char *);
static void safe_free_str (char *);
static void free_widget_value_tree (widget_value *);
static widget_value *copy_widget_value_tree (widget_value *,
{
char *result;
if (! s) return 0;
- result = (char *) malloc (strlen (s) + 1);
- if (! result)
- return 0;
+ result = (char *) xmalloc (strlen (s) + 1);
strcpy (result, s);
return result;
}
-/* Like strcmp but ignore differences in case. */
-
-static int
-my_strcasecmp (const char *s1, const char *s2)
-{
- while (1)
- {
- int c1 = *s1++;
- int c2 = *s2++;
- if (isupper (c1))
- c1 = tolower (c1);
- if (isupper (c2))
- c2 = tolower (c2);
- if (c1 != c2)
- return (c1 > c2 ? 1 : -1);
- if (c1 == 0)
- return 0;
- }
-}
-
static void
safe_free_str (char *s)
{
- free (s);
+ xfree (s);
}
static widget_value *widget_value_free_list = 0;
}
else
{
- wv = (widget_value *) malloc (sizeof (widget_value));
+ wv = (widget_value *) xmalloc (sizeof (widget_value));
malloc_cpt++;
}
memset ((void*) wv, 0, sizeof (widget_value));
{
/* When the number of already allocated cells is too big,
We free it. */
- free (wv);
+ xfree (wv);
malloc_cpt--;
}
else
if (!wv)
return;
- free (wv->name);
- free (wv->value);
- free (wv->key);
+ xfree (wv->name);
+ xfree (wv->value);
+ xfree (wv->key);
wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;
lw_callback post_activate_cb,
lw_callback highlight_cb)
{
- widget_info* info = (widget_info*)malloc (sizeof (widget_info));
+ widget_info* info = (widget_info*) xmalloc (sizeof (widget_info));
info->type = safe_strdup (type);
info->name = safe_strdup (name);
info->id = id;
safe_free_str (info->name);
free_widget_value_tree (info->val);
memset ((void*)info, 0xDEADBEEF, sizeof (widget_info));
- free (info);
+ xfree (info);
}
static void
allocate_widget_instance (widget_info* info, Widget parent, Boolean pop_up_p)
{
widget_instance* instance =
- (widget_instance*)malloc (sizeof (widget_instance));
+ (widget_instance*) xmalloc (sizeof (widget_instance));
memset (instance, 0, sizeof *instance);
instance->parent = parent;
instance->pop_up_p = pop_up_p;
free_widget_instance (widget_instance *instance)
{
memset ((void*)instance, 0xDEADBEEF, sizeof (widget_instance));
- free (instance);
+ xfree (instance);
}
static widget_info *
(nc == STRUCTURAL_CHANGE ? "structural" : "???")))), \
nc, desc, a1, a2)
#else
-# define EXPLAIN(name, oc, nc, desc, a1, a2)
+# define EXPLAIN(name, oc, nc, desc, a1, a2) ((void) 0)
#endif
widget = XtNameToWidget (instance->widget, real_name);
- free (real_name);
+ xfree (real_name);
}
return widget;
}
{
const widget_creation_entry* cur;
for (cur = table; cur->type; cur++)
- if (!my_strcasecmp (type, cur->type))
+ if (!c_strcasecmp (type, cur->type))
return cur->function;
return NULL;
}
xaw_destroy_instance (instance);
else
#endif
- /* do not remove the empty statement */
- ;
+ {
+ /* Empty compound statement to terminate if-then-else chain. */
+ }
}
free_widget_instance (instance);
}
#ifdef USE_MOTIF
-extern Widget first_child (/* Widget */); /* garbage */
+extern Widget first_child (Widget); /* garbage */
#endif
Widget
/* To forbid recursive calls */
static Boolean lwlib_updating;
-/* This function can be used as a an XtCallback for the widgets that get
- modified to update other instances of the widgets. Closure should be the
- widget_instance. */
+/* This function can be used as an XtCallback for the widgets that get
+ modified to update other instances of the widgets. Closure should be the
+ widget_instance. */
void
lw_internal_update_other_instances (Widget widget,
XtPointer closure,
return separator_p;
}
-
-/* arch-tag: 3d730f36-a441-4a71-9971-48ef3b5a4d9f
- (do not change this comment) */