2006-08-20 Aaron Bockover <abockover@novell.com>
authorAaron Bockover <abockover@novell.com>
Sun, 20 Aug 2006 17:24:39 +0000 (17:24 -0000)
committerAaron Bockover <abockover@novell.com>
Sun, 20 Aug 2006 17:24:39 +0000 (17:24 -0000)
    * src/gmisc.c: added g_setenv, g_getenv, g_unsetenv

    * src/gstr.c: added g_snprintf, g_sprintf, g_fprintf, g_printf

    * src/glib.h: added macros for above va_args printf functions

    * src/Makefile.am: added gmisc.c

    * test/whats-implemented: script to see what needs to be implemented

svn path=/trunk/mono/; revision=64109

eglib/ChangeLog
eglib/src/Makefile.am
eglib/src/glib.h
eglib/src/gmisc.c [new file with mode: 0644]
eglib/src/gstr.c
eglib/test/whats-implemented [new file with mode: 0755]

index febd7ab29aa9b33b150bb11396d552e4b6004244..41fd82c5819dbdbf982955f5e090de0df942e3a0 100644 (file)
@@ -1,3 +1,15 @@
+2006-08-20  Aaron Bockover  <abockover@novell.com>
+
+       * src/gmisc.c: added g_setenv, g_getenv, g_unsetenv
+
+       * src/gstr.c: added g_snprintf, g_sprintf, g_fprintf, g_printf
+
+       * src/glib.h: added macros for above va_args printf functions
+
+       * src/Makefile.am: added gmisc.c
+
+       * test/whats-implemented: script to see what needs to be implemented
+
 2006-08-20  Chris Toshok  <toshok@ximian.com>
 
        * test/array.c (test_array_big): add a test from the glib
index 297ab71044a9d435216dfcbcb6cada83680fd063..5a88e9f507730f165d7b317cc414f03ee84e4bcc 100644 (file)
@@ -12,7 +12,8 @@ libeglib_la_SOURCES = \
        gslist.c        \
        gstring.c       \
        gptrarray.c     \
-       glist.c
+       glist.c                 \
+       gmisc.c
 
 libeglib_la_CFLAGS = -Wall -Werror -D_FORTIFY_SOURCE=2
 
index 3356e18845de7fdde967210b4f033a39c36cc268..ac161002ed40413aa3749d57a11c05f7190bdd38 100644 (file)
@@ -76,6 +76,11 @@ gpointer g_memdup (gconstpointer mem, guint byte_size);
  * Misc.
  */
 #define g_atexit(func) ((void) atexit (func))
+
+const gchar *    g_getenv(const gchar *variable);
+gboolean         g_setenv(const gchar *variable, const gchar *value, gboolean overwrite);
+void             g_unsetenv(const gchar *variable);
+
 /*
  * Precondition macros
  */
@@ -137,6 +142,17 @@ gchar       *g_strjoin        (const gchar *separator, ...);
 gchar       *g_strchug        (gchar *str);
 gchar       *g_strchomp       (gchar *str);
 
+gint         g_printf          (gchar const *format, ...);
+gint         g_fprintf         (FILE *file, gchar const *format, ...);
+gint         g_sprintf         (gchar *string, gchar const *format, ...);
+gint         g_snprintf        (gchar *string, gulong n, gchar const *format, ...);
+
+#define g_vprintf vprintf
+#define g_vfprintf vfprintf
+#define g_vsprintf vsprintf
+#define g_vsnprintf vsnprintf
+#define g_vasprintf vasprintf
+
 #define g_ascii_isspace(c) (isspace (c) != 0)
 #define g_ascii_isalpha(c) (isalpha (c) != 0)
 #define g_ascii_isprint(c) (isprint (c) != 0)
diff --git a/eglib/src/gmisc.c b/eglib/src/gmisc.c
new file mode 100644 (file)
index 0000000..0fbb6de
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * gmisc.c: Misc functions with no place to go (right now)
+ *
+ * Author:
+ *   Aaron Bockover (abockover@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <glib.h>
+
+const gchar *
+g_getenv(const gchar *variable)
+{
+       return getenv(variable);
+}
+
+gboolean
+g_setenv(const gchar *variable, const gchar *value, gboolean overwrite)
+{
+       return setenv(variable, value, overwrite) == 0;
+}
+
+void
+g_unsetenv(const gchar *variable)
+{
+       unsetenv(variable);
+}
+
index 725d18916f1e8ee3a3dce3e44b30ae5fda91dfc2..6d04199545375773cbb8b71f63bf55efc48e02eb 100644 (file)
@@ -304,3 +304,56 @@ g_strchomp (gchar *str)
        return str;
 }
 
+gint
+g_printf(gchar const *format, ...)
+{
+       va_list args;
+       gint ret;
+
+       va_start(args, format);
+       ret = vprintf(format, args);
+       va_end(args);
+
+       return ret;
+}
+
+gint
+g_fprintf(FILE *file, gchar const *format, ...)
+{
+       va_list args;
+       gint ret;
+
+       va_start(args, format);
+       ret = vfprintf(file, format, args);
+       va_end(args);
+
+       return ret;
+}
+
+gint
+g_sprintf(gchar *string, gchar const *format, ...)
+{
+       va_list args;
+       gint ret;
+
+       va_start(args, format);
+       ret = vsprintf(string, format, args);
+       va_end(args);
+
+       return ret;
+}
+
+gint
+g_snprintf(gchar *string, gulong n, gchar const *format, ...)
+{
+       va_list args;
+       gint ret;
+       
+       va_start(args, format);
+       ret = vsnprintf(string, n, format, args);
+       va_end(args);
+
+       return ret;
+}
+
+
diff --git a/eglib/test/whats-implemented b/eglib/test/whats-implemented
new file mode 100755 (executable)
index 0000000..e376a61
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+# Author: Aaron Bockover
+# Licensed under MIT/X11
+# (C) 2006 Novell
+
+if [ "x$1" = "x--help" ]; then
+       echo "Usage: $0 [--show-only-mono]"
+       echo ""
+       echo "This script prints a sorted list of GLib functions used in Mono"
+       echo "that have not yet been implemented in EGlib."
+       echo ""
+       echo "If --show-only-mono is passed, then the script will print all"
+       echo "GLib functions used in Mono, whether or not they have been"
+       echo "implemented in EGlib yet."
+       echo ""
+       echo "This script relies on the MONO_CHECKOUT environment variable."
+       echo "MONO_CHECKOUT should be set to the location of a mono checkout."
+       echo ""
+       exit 1
+fi
+
+if [ -z $MONO_CHECKOUT ]; then
+       MONO_CHECKOUT=~/cvs/mono/mono
+fi
+
+if [ ! -d $MONO_CHECKOUT ]; then 
+       echo "Cannot find mono checkout; set MONO_CHECKOUT"
+       exit 1
+fi
+
+MONO_CHECKOUT="$MONO_CHECKOUT/mono"
+RESULTS_FILE=.results
+
+(for i in `find $MONO_CHECKOUT -iregex \.*.c$`; do 
+       grep -oP "[ \t\(\)]+g_[a-z_]+[ ]{0,1}\([A-Za-z_\&\*\,\(\) ]+\)" $i | 
+               awk 'BEGIN { FS="(" } { print $1 }' |
+               sed -e 's/[^A-Za-z_]//g' 
+       done
+) > $RESULTS_FILE
+
+if [ ! "x$1" = "x--show-only-mono" ]; then
+       IMPLEMENTED_FUNCTIONS=`grep -oP "g_[a-z_]+[ ]{0,1}" ../src/glib.h | awk 'BEGIN { FS="(" } { print $1 }'`
+
+       rm -f $RESULTS_FILE.tmp
+
+       for mono_function in `cat $RESULTS_FILE`; do
+               matched="no"
+               for implemented_function in $IMPLEMENTED_FUNCTIONS; do
+                       if [ "x$mono_function" = "x$implemented_function" ]; then
+                               matched="yes"
+                               break
+                       fi
+               done
+
+               if [ "x$matched" = "xno" ]; then
+                       echo $mono_function >> $RESULTS_FILE.tmp
+               fi
+       done
+
+       mv $RESULTS_FILE.tmp $RESULTS_FILE
+fi
+
+(for i in `cat $RESULTS_FILE | sort -u`; do 
+               echo "`grep -c $i $RESULTS_FILE` $i"; 
+       done;
+) | sort -nr
+
+rm $RESULTS_FILE
+