[seed] [libseed] Reduced unneccessary libc string functions in favor of glib ones



commit f879de36b63568c9ab37e437067fd538fdc6c4df
Author: Matt ARSENAULT <arsenm2 rpi edu>
Date:   Fri Jul 10 23:08:31 2009 -0400

    [libseed] Reduced unneccessary libc string functions in favor of glib ones

 libseed/seed-builtins.c   |    4 +---
 libseed/seed-engine.c     |    7 +++----
 libseed/seed-exceptions.c |    3 +--
 libseed/seed-importer.c   |   28 ++++++++++++++--------------
 libseed/seed-signals.c    |    5 ++---
 libseed/seed-structs.c    |    6 ++----
 libseed/seed-types.c      |    3 +--
 m4/libtool.m4             |   24 ++++--------------------
 src/main.c                |    2 --
 9 files changed, 28 insertions(+), 54 deletions(-)
---
diff --git a/libseed/seed-builtins.c b/libseed/seed-builtins.c
index ea87929..d679472 100644
--- a/libseed/seed-builtins.c
+++ b/libseed/seed-builtins.c
@@ -19,8 +19,6 @@
 #include "seed-private.h"
 #include <sys/mman.h>
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 #include <signal.h>
 
 JSValueRef seed_print_ref;
@@ -446,7 +444,7 @@ seed_argv_get_property (JSContextRef ctx,
   cproperty_name = g_alloca (length * sizeof (gchar));
   JSStringGetUTF8CString (property_name, cproperty_name, length);
 
-  if (!strcmp (cproperty_name, "length"))
+  if (!g_strcmp0 (cproperty_name, "length"))
     {
       return seed_value_from_int (ctx, priv->argc, exception);
     }
diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index be8a52f..360d33f 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -20,8 +20,8 @@
 
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <string.h>
 #include <stdarg.h>
+#include <string.h>
 
 JSObjectRef seed_obj_ref;
 
@@ -616,7 +616,7 @@ seed_gobject_define_property_from_function_info (JSContextRef ctx,
 			     g_base_info_ref ((GIBaseInfo *) info));
 
   name = g_base_info_get_name ((GIBaseInfo *) info);
-  if (!strcmp (name, "new"))
+  if (!g_strcmp0 (name, "new"))
     name = "c_new";
   seed_object_set_property (ctx, object, name, method_ref);
   seed_object_set_property (ctx, method_ref, "info",
@@ -819,7 +819,6 @@ seed_gobject_get_property (JSContextRef context,
 
   if (!spec)
     {
-
       len = strlen (cproperty_name);
       for (i = 0; i < len - 1; i++)
 	{
@@ -855,7 +854,7 @@ seed_gobject_get_property (JSContextRef context,
 	      field = g_object_info_get_field ((GIObjectInfo *) info, i);
 	      name = g_base_info_get_name ((GIBaseInfo *) field);
 
-	      if (!strcmp (name, cproperty_name))
+	      if (!g_strcmp0 (name, cproperty_name))
 		goto found_field;
 	      else
 		{
diff --git a/libseed/seed-exceptions.c b/libseed/seed-exceptions.c
index 1b451f5..ed3cb93 100644
--- a/libseed/seed-exceptions.c
+++ b/libseed/seed-exceptions.c
@@ -16,7 +16,6 @@
  */
 
 #include "seed-private.h"
-#include <string.h>
 #include <stdarg.h>
 
 /**
@@ -101,7 +100,7 @@ seed_make_exception_from_gerror (JSContextRef ctx,
 	  *(string->str + i + 1) = g_unichar_toupper (*(string->str + i + 1));
 	  g_string_erase (string, i, 1);
 	}
-      else if (!strcmp (string->str + i - 1, "Quark"))
+      else if (!g_strcmp0 (string->str + i - 1, "Quark"))
 	g_string_truncate (string, i - 1);
 
     }
diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
index 41513f9..c9dddf4 100644
--- a/libseed/seed-importer.c
+++ b/libseed/seed-importer.c
@@ -1,6 +1,6 @@
-#include <string.h>
 
 #include <gio/gio.h>
+#include <string.h>
 
 #include "seed-private.h"
 
@@ -60,7 +60,7 @@ GHashTable *file_imports;
 static gboolean
 seed_gi_importer_is_init (GIFunctionInfo *info)
 {
-  if (strcmp (g_base_info_get_name ((GIBaseInfo *) info), "init"))
+  if (g_strcmp0 (g_base_info_get_name ((GIBaseInfo *) info), "init"))
     {
       return FALSE;
     }
@@ -186,9 +186,9 @@ seed_gi_importer_handle_object (JSContextRef ctx,
 						      finfo);
 	      const gchar *fname =
 		g_base_info_get_name ((GIBaseInfo *) finfo);
-	      if (strstr (fname, "new_") == fname)
+	      if (g_strrstr (fname, "new_") == fname)
 		fname += 4;
-	      else if (!strcmp (fname, "new"))
+	      else if (!g_strcmp0 (fname, "new"))
 		fname = "c_new";
 
 	      seed_object_set_property (ctx,
@@ -251,7 +251,7 @@ seed_gi_importer_handle_struct (JSContextRef ctx,
 	    g_base_info_get_name ((GIBaseInfo *) finfo);
 	  if (g_str_has_prefix (fname, "new_"))
 	    fname += 4;
-	  else if (!strcmp (fname, "new"))
+	  else if (!g_strcmp0 (fname, "new"))
 	    fname = "c_new";
 
 	  seed_object_set_property (ctx, struct_ref, fname, constructor);
@@ -464,12 +464,12 @@ seed_gi_importer_get_property (JSContextRef ctx,
 
   SEED_NOTE (IMPORTER, "seed_gi_importer_get_property with %s", prop);
 
-  if (!strcmp(prop, "versions"))
+  if (!g_strcmp0(prop, "versions"))
     return gi_importer_versions;
   // Nasty hack
-  else if (!strcmp(prop, "toString"))
+  else if (!g_strcmp0(prop, "toString"))
     return 0;
-  if (!strcmp (prop, "valueOf")) // HACK
+  if (!g_strcmp0 (prop, "valueOf")) // HACK
     return NULL;
 
 
@@ -691,7 +691,7 @@ seed_importer_search (JSContextRef ctx,
 	      if (mentry[i] == '.')
 		mentry[i] = '\0';
 	    }
-	  if (!strcmp (mentry, prop))
+	  if (!g_strcmp0 (mentry, prop))
 	    {
 	      JSObjectRef ret;
 
@@ -704,7 +704,7 @@ seed_importer_search (JSContextRef ctx,
 
 	      return ret;
 	    }
-	  else if (!strcmp(entry, prop_as_lib))
+	  else if (!g_strcmp0(entry, prop_as_lib))
 	    {
 	      JSObjectRef ret;
 
@@ -743,11 +743,11 @@ seed_importer_get_property (JSContextRef ctx,
   prop = g_alloca (len * sizeof (gchar));
   JSStringGetUTF8CString (property_name, prop, len);
 
-  if (!strcmp (prop, "gi"))
+  if (!g_strcmp0 (prop, "gi"))
     return gi_importer;
-  if (!strcmp (prop, "searchPath"))
+  if (!g_strcmp0 (prop, "searchPath"))
     return NULL;
-  if (!strcmp (prop, "toString")) // HACK
+  if (!g_strcmp0 (prop, "toString")) // HACK
     return NULL;
 
   ret = seed_importer_search (ctx, prop, exception);
@@ -794,7 +794,7 @@ seed_importer_dir_get_property (JSContextRef ctx,
 	    mentry[i] = '\0';
 	}
 
-      if (!strcmp (mentry, prop))
+      if (!g_strcmp0 (mentry, prop))
 	{
 	  JSObjectRef ret;
 
diff --git a/libseed/seed-signals.c b/libseed/seed-signals.c
index 749f3ad..808f788 100644
--- a/libseed/seed-signals.c
+++ b/libseed/seed-signals.c
@@ -15,8 +15,6 @@
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
  */
 
-#include <string.h>
-
 #include "seed-private.h"
 
 typedef struct _signal_privates
@@ -389,7 +387,7 @@ seed_signal_holder_get_property (JSContextRef ctx,
 
   JSStringGetUTF8CString (property_name, signal_name, length);
 
-  if (!strcmp (signal_name, "connect") || !strcmp (signal_name, "disconnect"))
+  if (!(g_strcmp0 (signal_name, "connect") && g_strcmp0 (signal_name, "disconnect")) )
     {
       g_free (signal_name);
       return NULL;
@@ -424,3 +422,4 @@ seed_get_signal_class (void)
 
   return &gobject_signal_def;
 }
+
diff --git a/libseed/seed-structs.c b/libseed/seed-structs.c
index 363c90f..a406266 100644
--- a/libseed/seed-structs.c
+++ b/libseed/seed-structs.c
@@ -16,8 +16,6 @@
  */
 
 #include "seed-private.h"
-#include <stdio.h>
-#include <string.h>
 JSClassRef seed_struct_class = 0;
 JSClassRef seed_union_class = 0;
 JSClassRef seed_pointer_class = 0;
@@ -94,7 +92,7 @@ seed_union_find_field (GIUnionInfo * info, gchar * field_name)
 
       field = g_union_info_get_field (info, i);
       name = g_base_info_get_name ((GIBaseInfo *) field);
-      if (!strcmp (name, field_name))
+      if (!g_strcmp0 (name, field_name))
 	return field;
       else
 	g_base_info_unref ((GIBaseInfo *) field);
@@ -116,7 +114,7 @@ seed_struct_find_field (GIStructInfo * info, gchar * field_name)
 
       field = g_struct_info_get_field (info, i);
       name = g_base_info_get_name ((GIBaseInfo *) field);
-      if (!strcmp (name, field_name))
+      if (!g_strcmp0 (name, field_name))
 	return field;
       else
 	g_base_info_unref ((GIBaseInfo *) field);
diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index 63fb60c..47379a6 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -17,7 +17,6 @@
 
 #include "seed-private.h"
 #include <dlfcn.h>
-#include <string.h>
 
 JSClassRef gobject_class;
 JSClassRef gobject_method_class;
@@ -1946,7 +1945,7 @@ seed_value_from_binary_string (JSContextRef ctx,
   JSValueRef ret;
 
   gchar *nstr = g_alloca ((n_bytes +1)*sizeof(gchar));
-  strncpy (nstr, bytes, n_bytes);
+  g_strlcpy (nstr, bytes, n_bytes);
   nstr[n_bytes] = '\0';
 
   ret = seed_value_from_string (ctx, nstr, exception);
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 2ca1c1f..39ba996 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -2485,18 +2485,6 @@ linux* | k*bsd*-gnu)
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-netbsdelf*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='NetBSD ld.elf_so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
@@ -3088,7 +3076,7 @@ linux* | k*bsd*-gnu)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-netbsd* | netbsdelf*-gnu)
+netbsd*)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
   else
@@ -3769,7 +3757,7 @@ m4_if([$1], [CXX], [
 	    ;;
 	esac
 	;;
-      netbsd* | netbsdelf*-gnu)
+      netbsd*)
 	;;
       *qnx* | *nto*)
         # QNX uses GNU C++, but need to define -shared option too, otherwise
@@ -4194,9 +4182,6 @@ m4_if([$1], [CXX], [
   cygwin* | mingw* | cegcc*)
     _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
-  linux* | k*bsd*-gnu)
-    _LT_TAGVAR(link_all_deplibs, $1)=no
-  ;;
   *)
     _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
@@ -4443,7 +4428,7 @@ _LT_EOF
       fi
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
@@ -4618,7 +4603,6 @@ _LT_EOF
 	if test "$aix_use_runtimelinking" = yes; then
 	  shared_flag="$shared_flag "'${wl}-G'
 	fi
-	_LT_TAGVAR(link_all_deplibs, $1)=no
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -4857,7 +4841,7 @@ _LT_EOF
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
       else
diff --git a/src/main.c b/src/main.c
index 5a64476..63ced75 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,8 +24,6 @@
 #include "../libseed/seed-debug.h"
 #include <girepository.h>
 
-#include <string.h>
-
 #define DEFAULT_PATH "."
 
 SeedEngine *eng;



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