[gjs] libgjs: Remove unused API



commit 3ce20324869c5126d1ccc696a5cc01344bb01858
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue Oct 4 22:00:59 2016 -0700

    libgjs: Remove unused API
    
    This removes API that was previously public, now private, and is not used
    anywhere inside libgjs.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772386

 Makefile-test.am        |    2 -
 Makefile.am             |    2 +-
 configure.ac            |    2 -
 gi/arg.cpp              |    2 +-
 gi/arg.h                |    4 -
 gi/boxed.h              |    3 +-
 gi/enumeration.cpp      |   24 ------
 gi/enumeration.h        |    2 -
 gi/function.h           |    2 -
 gi/fundamental.cpp      |    8 --
 gi/fundamental.h        |    3 -
 gi/gtype.h              |    5 -
 gi/keep-alive.cpp       |    2 +-
 gi/keep-alive.h         |    1 -
 gi/repo.h               |    3 +-
 gjs/byteArray.cpp       |   25 ------
 gjs/byteArray.h         |    2 -
 gjs/coverage-internal.h |    2 -
 gjs/coverage.cpp        |    2 +-
 gjs/jsapi-util.cpp      |  197 ++++++++++-------------------------------------
 gjs/jsapi-util.h        |   25 ------
 modules/console.cpp     |    2 +-
 modules/console.h       |    3 -
 util/crash.cpp          |   60 --------------
 util/crash.h            |    1 -
 util/glib.cpp           |   70 +----------------
 util/glib.h             |    5 -
 27 files changed, 53 insertions(+), 406 deletions(-)
---
diff --git a/Makefile-test.am b/Makefile-test.am
index 16cdc13..608b9cf 100644
--- a/Makefile-test.am
+++ b/Makefile-test.am
@@ -83,8 +83,6 @@ EXTRA_DIST +=                                                         \
        $(srcdir)/test/gjs-test-coverage/loadedJSFromResource.js \
        $(NULL)
 
-## -rdynamic makes backtraces work
-gjs_tests_LDFLAGS = -rdynamic
 gjs_tests_LDADD =              \
        libgjs.la               \
        $(GJSTESTS_LIBS)
diff --git a/Makefile.am b/Makefile.am
index f5fdc17..aace35d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -60,7 +60,7 @@ libgjs_la_CPPFLAGS =          \
 libgjs_la_LDFLAGS =            \
        -export-symbols-regex "^[^_]" -version-info 0:0:0       \
        -no-undefined \
-       -rdynamic
+       $(NULL)
 libgjs_la_LIBADD =             \
        $(GJS_LIBS)
 
diff --git a/configure.ac b/configure.ac
index be70e53..2b95534 100644
--- a/configure.ac
+++ b/configure.ac
@@ -133,8 +133,6 @@ AC_SUBST([READLINE_LIBS])
 # End of readline checks: restore LIBS
 LIBS=$LIBS_no_readline
 
-AC_CHECK_FUNCS([backtrace])
-
 AC_ARG_ENABLE(installed_tests,
   [AS_HELP_STRING([--enable-installed-tests],
     [Install test programs @<:@default: no@:>@])])
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 66a232d..5098153 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -79,7 +79,7 @@ _gjs_flags_value_is_valid(JSContext   *context,
     return true;
 }
 
-bool
+static bool
 _gjs_enum_value_is_valid(JSContext  *context,
                          GIEnumInfo *enum_info,
                          gint64      value)
diff --git a/gi/arg.h b/gi/arg.h
index eb7d30f..a0ab1b6 100644
--- a/gi/arg.h
+++ b/gi/arg.h
@@ -102,10 +102,6 @@ bool _gjs_flags_value_is_valid (JSContext   *context,
                                 GType        gtype,
                                 gint64       value);
 
-bool _gjs_enum_value_is_valid (JSContext  *context,
-                               GIEnumInfo *enum_info,
-                               gint64      value);
-
 gint64 _gjs_enum_from_int (GIEnumInfo *enum_info,
                            int         int_value);
 
diff --git a/gi/boxed.h b/gi/boxed.h
index 698ed59..85b7791 100644
--- a/gi/boxed.h
+++ b/gi/boxed.h
@@ -44,8 +44,7 @@ typedef GIStructInfo GIBoxedInfo;
 void      gjs_define_boxed_class       (JSContext             *context,
                                         JSObject              *in_object,
                                         GIBoxedInfo           *info);
-JSObject* gjs_lookup_boxed_prototype   (JSContext             *context,
-                                        GIBoxedInfo           *info);
+
 void*     gjs_c_struct_from_boxed      (JSContext             *context,
                                         JS::HandleObject       obj);
 JSObject* gjs_boxed_from_c_struct      (JSContext             *context,
diff --git a/gi/enumeration.cpp b/gi/enumeration.cpp
index ac22160..ab05128 100644
--- a/gi/enumeration.cpp
+++ b/gi/enumeration.cpp
@@ -36,30 +36,6 @@
 
 #include "enumeration.h"
 
-JSObject*
-gjs_lookup_enumeration(JSContext    *context,
-                       GIEnumInfo   *info)
-{
-    JSObject *in_object;
-    const char *enum_name;
-    JS::Value value;
-
-    in_object = gjs_lookup_namespace_object(context, (GIBaseInfo*) info);
-
-    if (G_UNLIKELY (!in_object))
-        return NULL;
-
-    enum_name = g_base_info_get_name((GIBaseInfo*) info);
-
-    if (!JS_GetProperty(context, in_object, enum_name, &value))
-        return NULL;
-
-    if (G_UNLIKELY (!value.isObject()))
-        return NULL;
-
-    return &value.toObject();
-}
-
 static bool
 gjs_define_enum_value(JSContext    *context,
                       JSObject     *in_object,
diff --git a/gi/enumeration.h b/gi/enumeration.h
index 70fe072..27b0e1d 100644
--- a/gi/enumeration.h
+++ b/gi/enumeration.h
@@ -42,8 +42,6 @@ bool    gjs_define_enum_static_methods (JSContext    *context,
 bool    gjs_define_enumeration         (JSContext    *context,
                                         JSObject     *in_object,
                                         GIEnumInfo   *info);
-JSObject* gjs_lookup_enumeration       (JSContext    *context,
-                                        GIEnumInfo   *info);
 
 G_END_DECLS
 
diff --git a/gi/function.h b/gi/function.h
index f86b815..507e553 100644
--- a/gi/function.h
+++ b/gi/function.h
@@ -81,8 +81,6 @@ bool      gjs_invoke_constructor_from_c(JSContext       *context,
                                         JS::Value       *argv,
                                         GArgument       *rvalue);
 
-void     gjs_init_cinvoke_profiling (void);
-
 G_END_DECLS
 
 #endif  /* __GJS_FUNCTION_H__ */
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index 383f2fa..22c7454 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -822,14 +822,6 @@ gjs_g_fundamental_from_object(JSContext       *context,
 }
 
 bool
-gjs_typecheck_is_fundamental(JSContext       *context,
-                             JS::HandleObject object,
-                             bool             throw_error)
-{
-    return do_base_typecheck(context, object, throw_error);
-}
-
-bool
 gjs_typecheck_fundamental(JSContext       *context,
                           JS::HandleObject object,
                           GType            expected_gtype,
diff --git a/gi/fundamental.h b/gi/fundamental.h
index dec8fcf..d67750c 100644
--- a/gi/fundamental.h
+++ b/gi/fundamental.h
@@ -53,9 +53,6 @@ bool      gjs_typecheck_fundamental(JSContext       *context,
                                     GType            expected_gtype,
                                     bool             throw_error);
 
-bool      gjs_typecheck_is_fundamental       (JSContext     *context,
-                                              JSObject      *object,
-                                              bool           throw_error);
 void*     gjs_fundamental_ref                (JSContext     *context,
                                               void          *fobj);
 void      gjs_fundamental_unref              (JSContext     *context,
diff --git a/gi/gtype.h b/gi/gtype.h
index f9fa179..0cdbff7 100644
--- a/gi/gtype.h
+++ b/gi/gtype.h
@@ -32,11 +32,6 @@
 
 G_BEGIN_DECLS
 
-JS::Value   gjs_gtype_create_proto         (JSContext       *context,
-                                            JSObject        *module,
-                                            const char      *proto_name,
-                                            JSObject        *parent);
-
 JSObject * gjs_gtype_create_gtype_wrapper (JSContext *context,
                                            GType      gtype);
 
diff --git a/gi/keep-alive.cpp b/gi/keep-alive.cpp
index c533a53..396741e 100644
--- a/gi/keep-alive.cpp
+++ b/gi/keep-alive.cpp
@@ -172,7 +172,7 @@ JSFunctionSpec gjs_keep_alive_proto_funcs[] = {
     JS_FS_END
 };
 
-JSObject*
+static JSObject *
 gjs_keep_alive_new(JSContext *context)
 {
     KeepAlive *priv;
diff --git a/gi/keep-alive.h b/gi/keep-alive.h
index 492294d..a9b479b 100644
--- a/gi/keep-alive.h
+++ b/gi/keep-alive.h
@@ -54,7 +54,6 @@ typedef void (* GjsUnrootedFunc) (JSObject *obj,
                                   void     *data);
 
 
-JSObject* gjs_keep_alive_new                       (JSContext         *context);
 void      gjs_keep_alive_add_child                 (JSObject          *keep_alive,
                                                     GjsUnrootedFunc    notify,
                                                     JSObject          *child,
diff --git a/gi/repo.h b/gi/repo.h
index 064c71c..867b8c1 100644
--- a/gi/repo.h
+++ b/gi/repo.h
@@ -43,8 +43,7 @@ JSObject*   gjs_lookup_namespace_object         (JSContext      *context,
                                                  GIBaseInfo     *info);
 JSObject*   gjs_lookup_namespace_object_by_name (JSContext      *context,
                                                  jsid            name);
-JSObject*   gjs_lookup_function_object          (JSContext      *context,
-                                                 GIFunctionInfo *info);
+
 JSObject *  gjs_lookup_generic_constructor      (JSContext      *context,
                                                  GIBaseInfo     *info);
 JSObject *  gjs_lookup_generic_prototype        (JSContext      *context,
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 6287b79..b9de83d 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -761,31 +761,6 @@ gjs_byte_array_from_byte_array (JSContext *context,
     return object;
 }
 
-JSObject *
-gjs_byte_array_from_bytes (JSContext *context,
-                           GBytes    *bytes)
-{
-    ByteArrayInstance *priv;
-
-    g_return_val_if_fail(context != NULL, NULL);
-    g_return_val_if_fail(bytes != NULL, NULL);
-
-    JS::RootedObject object(context,
-                            JS_NewObject(context, &gjs_byte_array_class,
-                                         byte_array_get_prototype(context), NULL));
-    if (!object) {
-        gjs_throw(context, "failed to create byte array");
-        return NULL;
-    }
-
-    priv = g_slice_new0(ByteArrayInstance);
-    g_assert(priv_from_js(context, object) == NULL);
-    JS_SetPrivate(object, priv);
-    priv->bytes = g_bytes_ref (bytes);
-
-    return object;
-}
-
 GBytes *
 gjs_byte_array_get_bytes (JSContext       *context,
                           JS::HandleObject object)
diff --git a/gjs/byteArray.h b/gjs/byteArray.h
index 72cb393..0c591a8 100644
--- a/gjs/byteArray.h
+++ b/gjs/byteArray.h
@@ -39,8 +39,6 @@ bool          gjs_define_byte_array_stuff    (JSContext  *context,
 
 JSObject *    gjs_byte_array_from_byte_array (JSContext  *context,
                                               GByteArray *array);
-JSObject *    gjs_byte_array_from_bytes (JSContext  *context,
-                                         GBytes *bytes);
 
 GByteArray *gjs_byte_array_get_byte_array(JSContext       *context,
                                           JS::HandleObject object);
diff --git a/gjs/coverage-internal.h b/gjs/coverage-internal.h
index 3f5f4c9..8ad59e5 100644
--- a/gjs/coverage-internal.h
+++ b/gjs/coverage-internal.h
@@ -26,8 +26,6 @@
 
 G_BEGIN_DECLS
 
-GArray * gjs_fetch_statistics_from_js(GjsCoverage *coverage,
-                                      char        **covered_paths);
 GBytes * gjs_serialize_statistics(GjsCoverage *coverage);
 
 JSString * gjs_deserialize_cache_to_object(GjsCoverage *coverage,
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 888a0aa..8f43942 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1107,7 +1107,7 @@ gjs_deserialize_cache_to_object(GjsCoverage *coverage,
     return gjs_deserialize_cache_to_object_for_compartment(context, global_object, cache_data);
 }
 
-GArray *
+static GArray *
 gjs_fetch_statistics_from_js(GjsCoverage *coverage,
                              gchar       **coverage_files)
 {
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 0cf09b3..8f39ea7 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -301,6 +301,45 @@ gjs_string_readable (JSContext   *context,
     return g_string_free(buf, false);
 }
 
+static char *
+_gjs_g_utf8_make_valid (const char *name)
+{
+    GString *string;
+    const char *remainder, *invalid;
+    int remaining_bytes, valid_bytes;
+
+    g_return_val_if_fail (name != NULL, NULL);
+
+    string = NULL;
+    remainder = name;
+    remaining_bytes = strlen (name);
+
+    while (remaining_bytes != 0) {
+        if (g_utf8_validate (remainder, remaining_bytes, &invalid))
+            break;
+        valid_bytes = invalid - remainder;
+
+        if (string == NULL)
+            string = g_string_sized_new (remaining_bytes);
+
+        g_string_append_len (string, remainder, valid_bytes);
+        /* append U+FFFD REPLACEMENT CHARACTER */
+        g_string_append (string, "\357\277\275");
+
+        remaining_bytes -= valid_bytes + 1;
+        remainder = invalid + 1;
+    }
+
+    if (string == NULL)
+        return g_strdup (name);
+
+    g_string_append (string, remainder);
+
+    g_assert (g_utf8_validate (string->str, -1, NULL));
+
+    return g_string_free (string, false);
+}
+
 /**
  * gjs_value_debug_string:
  * @context:
@@ -369,105 +408,6 @@ gjs_value_debug_string(JSContext      *context,
     return debugstr;
 }
 
-void
-gjs_log_object_props(JSContext      *context,
-                     JSObject       *obj,
-                     GjsDebugTopic   topic,
-                     const char     *prefix)
-{
-    JSObject *props_iter;
-    jsid prop_id;
-
-    JS_BeginRequest(context);
-
-    props_iter = JS_NewPropertyIterator(context, obj);
-    if (props_iter == NULL) {
-        gjs_log_exception(context);
-        goto done;
-    }
-
-    prop_id = JSID_VOID;
-    if (!JS_NextProperty(context, props_iter, &prop_id))
-        goto done;
-
-    while (!JSID_IS_VOID(prop_id)) {
-        JS::Value propval;
-        char *debugstr;
-        char *name = NULL;
-
-        if (!JS_GetPropertyById(context, obj, prop_id, &propval))
-            goto next;
-
-        if (!gjs_get_string_id(context, prop_id, &name))
-            goto next;
-
-        debugstr = gjs_value_debug_string(context, propval);
-        gjs_debug(topic,
-                  "%s%s = '%s'",
-                  prefix, name,
-                  debugstr);
-        g_free(debugstr);
-
-    next:
-        g_free(name);
-        prop_id = JSID_VOID;
-        if (!JS_NextProperty(context, props_iter, &prop_id))
-            break;
-    }
-
- done:
-    JS_EndRequest(context);
-}
-
-void
-gjs_explain_scope(JSContext  *context,
-                  const char *title)
-{
-    JSObject *global;
-    JSObject *parent;
-    GString *chain;
-    char *debugstr;
-
-    gjs_debug(GJS_DEBUG_SCOPE,
-              "=== %s ===",
-              title);
-
-    JS_BeginRequest(context);
-
-    gjs_debug(GJS_DEBUG_SCOPE,
-              "  Context: %p %s",
-              context,
-              "");
-
-    global = gjs_get_global_object(context);
-    debugstr = gjs_value_debug_string(context, JS::ObjectOrNullValue(global));
-    gjs_debug(GJS_DEBUG_SCOPE,
-              "  Global: %p %s",
-              global, debugstr);
-    g_free(debugstr);
-
-    parent = JS_GetGlobalForScopeChain(context);
-    chain = g_string_new(NULL);
-    while (parent != NULL) {
-        char *debug;
-        debug = gjs_value_debug_string(context, JS::ObjectOrNullValue(parent));
-
-        if (chain->len > 0)
-            g_string_append(chain, ", ");
-
-        g_string_append_printf(chain, "%p %s",
-                               parent, debug);
-        g_free(debug);
-        parent = JS_GetParent(parent);
-    }
-    gjs_debug(GJS_DEBUG_SCOPE,
-              "  Chain: %s",
-              chain->str);
-    g_string_free(chain, true);
-
-    JS_EndRequest(context);
-}
-
 static char *
 utf8_exception_from_non_gerror_value(JSContext *cx,
                                      JS::Value  exc)
@@ -586,9 +526,8 @@ gjs_log_exception_full(JSContext *context,
     return true;
 }
 
-static bool
-log_and_maybe_keep_exception(JSContext  *context,
-                             bool        keep)
+bool
+gjs_log_exception(JSContext  *context)
 {
     bool retval = false;
 
@@ -602,12 +541,6 @@ log_and_maybe_keep_exception(JSContext  *context,
 
     gjs_log_exception_full(context, exc, NULL);
 
-    /* We clear above and then set it back so any exceptions
-     * from the logging process don't overwrite the original
-     */
-    if (keep)
-        JS_SetPendingException(context, exc);
-
     retval = true;
 
  out:
@@ -616,18 +549,6 @@ log_and_maybe_keep_exception(JSContext  *context,
     return retval;
 }
 
-bool
-gjs_log_exception(JSContext  *context)
-{
-    return log_and_maybe_keep_exception(context, false);
-}
-
-bool
-gjs_log_and_keep_exception(JSContext *context)
-{
-    return log_and_maybe_keep_exception(context, true);
-}
-
 static void
 try_to_chain_stack_trace(JSContext *src_context,
                          JSContext *dst_context,
@@ -755,42 +676,6 @@ log_prop(JSContext  *context,
     return true;
 }
 
-bool
-gjs_get_prop_verbose_stub(JSContext *context,
-                          JSObject  *obj,
-                          JS::Value  id,
-                          JS::Value *value_p)
-{
-    return log_prop(context, obj, id, value_p, "get");
-}
-
-bool
-gjs_set_prop_verbose_stub(JSContext *context,
-                          JSObject  *obj,
-                          JS::Value  id,
-                          JS::Value *value_p)
-{
-    return log_prop(context, obj, id, value_p, "set");
-}
-
-bool
-gjs_add_prop_verbose_stub(JSContext *context,
-                          JSObject  *obj,
-                          JS::Value  id,
-                          JS::Value *value_p)
-{
-    return log_prop(context, obj, id, value_p, "add");
-}
-
-bool
-gjs_delete_prop_verbose_stub(JSContext *context,
-                             JSObject  *obj,
-                             JS::Value  id,
-                             JS::Value *value_p)
-{
-    return log_prop(context, obj, id, value_p, "delete");
-}
-
 /* get a debug string for type tag in JS::Value */
 const char*
 gjs_get_type_name(JS::Value value)
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 1c697d7..5e24093 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -356,23 +356,14 @@ void        gjs_throw_g_error                (JSContext       *context,
                                               GError          *error);
 
 bool        gjs_log_exception                (JSContext       *context);
-bool        gjs_log_and_keep_exception       (JSContext       *context);
 bool        gjs_move_exception               (JSContext       *src_context,
                                               JSContext       *dest_context);
 bool        gjs_log_exception_full           (JSContext       *context,
                                               JS::Value        exc,
                                               JSString        *message);
 
-#ifdef __GJS_UTIL_LOG_H__
-void        gjs_log_object_props             (JSContext       *context,
-                                              JSObject        *obj,
-                                              GjsDebugTopic    topic,
-                                              const char      *prefix);
-#endif
 char*       gjs_value_debug_string           (JSContext       *context,
                                               JS::Value        value);
-void        gjs_explain_scope                (JSContext       *context,
-                                              const char      *title);
 
 bool gjs_call_function_value(JSContext             *context,
                              JSObject              *obj,
@@ -385,22 +376,6 @@ void        gjs_error_reporter               (JSContext       *context,
                                               const char      *message,
                                               JSErrorReport   *report);
 JSObject*   gjs_get_global_object            (JSContext *cx);
-bool        gjs_get_prop_verbose_stub        (JSContext       *context,
-                                              JSObject        *obj,
-                                              JS::Value        id,
-                                              JS::Value       *value_p);
-bool        gjs_set_prop_verbose_stub        (JSContext       *context,
-                                              JSObject        *obj,
-                                              JS::Value        id,
-                                              JS::Value       *value_p);
-bool        gjs_add_prop_verbose_stub        (JSContext       *context,
-                                              JSObject        *obj,
-                                              JS::Value        id,
-                                              JS::Value       *value_p);
-bool        gjs_delete_prop_verbose_stub     (JSContext       *context,
-                                              JSObject        *obj,
-                                              JS::Value        id,
-                                              JS::Value       *value_p);
 
 JSBool      gjs_string_to_utf8               (JSContext       *context,
                                               const JS::Value  string_val,
diff --git a/modules/console.cpp b/modules/console.cpp
index 530d09c..7dde126 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -153,7 +153,7 @@ gjs_console_readline(JSContext *cx, char **bufp, FILE *file, const char *prompt)
 }
 #endif
 
-bool
+static bool
 gjs_console_interact(JSContext *context,
                      unsigned   argc,
                      JS::Value *vp)
diff --git a/modules/console.h b/modules/console.h
index 2d41d65..5607584 100644
--- a/modules/console.h
+++ b/modules/console.h
@@ -32,9 +32,6 @@ G_BEGIN_DECLS
 
 bool        gjs_define_console_stuff     (JSContext      *context,
                                           JSObject      **module_out);
-bool        gjs_console_interact         (JSContext      *context,
-                                          unsigned        argc,
-                                          JS::Value      *vp);
 
 G_END_DECLS
 
diff --git a/util/crash.cpp b/util/crash.cpp
index b1b85ae..569b941 100644
--- a/util/crash.cpp
+++ b/util/crash.cpp
@@ -26,9 +26,6 @@
 
 #include "crash.h"
 
-#ifdef HAVE_BACKTRACE
-#include <execinfo.h>
-#endif
 #include <stdio.h>
 #include <signal.h>
 #include <stdlib.h>
@@ -39,63 +36,6 @@
 #include <fcntl.h>
 #include <errno.h>
 
-#ifdef HAVE_BACKTRACE
-static void
-unbuffered_write_stderr(const char *s)
-{
-    size_t len;
-
-    len = strlen(s);
-    write(STDERR_FILENO, s, len);
-}
-
-static void
-gjs_print_maps(void)
-{
-    int fd;
-
-    fd = open("/proc/self/maps", O_RDONLY);
-    if (fd != -1) {
-        char buf[128];
-        size_t n;
-
-        while ((n = read(fd, buf, sizeof(buf))) > 0) {
-            write(STDERR_FILENO, buf, n);
-        }
-        (void)close(fd);
-
-        unbuffered_write_stderr("\n");
-    }
-}
-#endif
-
-/* this only works if we build with -rdynamic */
-void
-gjs_print_backtrace(void)
-{
-#ifdef HAVE_BACKTRACE
-    void *bt[500];
-    int bt_size;
-    char buf[128];
-
-    bt_size = backtrace(bt, 500);
-
-    /* Avoid dynamic allocations since we may in SIGSEGV signal handler, so use
-     * backtrace_symbols_fd */
-
-    unbuffered_write_stderr("\n");
-    backtrace_symbols_fd(bt, bt_size, STDERR_FILENO);
-    unbuffered_write_stderr("\n");
-
-    sprintf(buf, "backtrace pid %lu\n\n", (gulong) getpid());
-    unbuffered_write_stderr(buf);
-
-    /* best effort attempt to extract shared library relocations so that
-     * mapping backtrace addresses to symbols is possible after the fact */
-    gjs_print_maps();
-#endif
-}
-
 /* Fork a process that waits the given time then
  * sends us ABRT
  */
diff --git a/util/crash.h b/util/crash.h
index 1f46c0f..c6b3fc6 100644
--- a/util/crash.h
+++ b/util/crash.h
@@ -27,7 +27,6 @@
 
 G_BEGIN_DECLS
 
-void gjs_print_backtrace     (void);
 void gjs_crash_after_timeout (int seconds);
 
 G_END_DECLS
diff --git a/util/glib.cpp b/util/glib.cpp
index a2b71e0..f084e7f 100644
--- a/util/glib.cpp
+++ b/util/glib.cpp
@@ -46,11 +46,10 @@ get_first_one_predicate(void  *key,
     return true;
 }
 
-static bool
-remove_or_steal_one(GHashTable *hash,
-                    void      **key_p,
-                    void      **value_p,
-                    bool        steal)
+bool
+gjs_g_hash_table_steal_one(GHashTable *hash,
+                           void      **key_p,
+                           void      **value_p)
 {
     StoreOneData sod;
 
@@ -66,30 +65,11 @@ remove_or_steal_one(GHashTable *hash,
     if (value_p)
         *value_p = sod.value;
 
-    if (steal)
-        g_hash_table_steal(hash, sod.key);
-    else
-        g_hash_table_remove(hash, sod.key);
+    g_hash_table_steal(hash, sod.key);
 
     return sod.value != NULL;
 }
 
-bool
-gjs_g_hash_table_remove_one(GHashTable *hash,
-                            void      **key_p,
-                            void      **value_p)
-{
-    return remove_or_steal_one(hash, key_p, value_p, false);
-}
-
-bool
-gjs_g_hash_table_steal_one(GHashTable *hash,
-                           void      **key_p,
-                           void      **value_p)
-{
-    return remove_or_steal_one(hash, key_p, value_p, true);
-}
-
 /** gjs_g_strv_concat:
  *
  * Concate an array of string arrays to one string array. The strings in each
@@ -126,43 +106,3 @@ gjs_g_strv_concat(char ***strv_array, int len)
 
     return (char**)g_ptr_array_free(array, false);
 }
-
-gchar *
-_gjs_g_utf8_make_valid (const gchar *name)
-{
-  GString *string;
-  const gchar *remainder, *invalid;
-  gint remaining_bytes, valid_bytes;
-
-  g_return_val_if_fail (name != NULL, NULL);
-
-  string = NULL;
-  remainder = name;
-  remaining_bytes = strlen (name);
-
-  while (remaining_bytes != 0)
-    {
-      if (g_utf8_validate (remainder, remaining_bytes, &invalid))
-       break;
-      valid_bytes = invalid - remainder;
-
-      if (string == NULL)
-       string = g_string_sized_new (remaining_bytes);
-
-      g_string_append_len (string, remainder, valid_bytes);
-      /* append U+FFFD REPLACEMENT CHARACTER */
-      g_string_append (string, "\357\277\275");
-
-      remaining_bytes -= valid_bytes + 1;
-      remainder = invalid + 1;
-    }
-
-  if (string == NULL)
-    return g_strdup (name);
-
-  g_string_append (string, remainder);
-
-  g_assert (g_utf8_validate (string->str, -1, NULL));
-
-  return g_string_free (string, false);
-}
diff --git a/util/glib.h b/util/glib.h
index ac82b7f..393cc8a 100644
--- a/util/glib.h
+++ b/util/glib.h
@@ -28,11 +28,6 @@
 
 G_BEGIN_DECLS
 
-gchar * _gjs_g_utf8_make_valid (const gchar *name);
-
-bool     gjs_g_hash_table_remove_one (GHashTable  *hash,
-                                      void       **key_p,
-                                      void       **value_p);
 bool     gjs_g_hash_table_steal_one  (GHashTable  *hash,
                                       void       **key_p,
                                       void       **value_p);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]