Implement G_STRLOC
authorMiguel de Icaza <miguel@gnome.org>
Sun, 8 Oct 2006 20:50:23 +0000 (20:50 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sun, 8 Oct 2006 20:50:23 +0000 (20:50 -0000)
svn path=/trunk/mono/; revision=66426

eglib/TODO
eglib/src/glib.h
eglib/test/string.c

index a5d87289f15a730be93182b65d3ee88725088d5e..703bbce86a0157888ecff69e1bb3c5aeba6416a8 100644 (file)
@@ -1,15 +1,4 @@
-
-* Code that we will drop from Mono, because we do not really need this:
-
-  Locking:
-
-      5 G_LOCK
-      5 G_UNLOCK
-
-      These are currently only used for the GC-safe hash table, and 
-      we will be replacing that with a copy of our own hashtable.
-
-Important Groups:
+* Missing code
 
        * Process launching
              3 g_shell_quote
@@ -19,22 +8,16 @@ Important Groups:
              3 g_thread_supported
              3 g_thread_init
 
-       * String manipulation
-             1 g_filename_from_utf8    [LIMITATION: UTF8 only today]
-       
        * Miscelaneous
              3 g_spaced_primes_closest
 
-Remove code from Mono:
-
-       Multi-threaded aware GHashTable.
-       utils/mono-uri.c
-
 Macros:
       6 G_UNLIKELY
       4 G_LIKELY
       2 G_STRLOC
 
+---------------------------------------------------------------------- 
+
 * Unimplemented, not supported currently:
 
                g_unichar_tolower       Used for deprecated unmanaged string collation
index b64f945ff1135faa80f5eec4131b4f58dbe94f42..b542ce6c09bda79249c53e9f5f4d45b93cc9f2bf 100644 (file)
@@ -62,7 +62,9 @@ typedef uint16_t       gunichar2;
 #define G_STRUCT_OFFSET(p_type,field) \
         ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
 
-
+#define EGLIB_STRINGIFY(x) #x
+#define EGLIB_TOSTRING(x) EGLIB_STRINGIFY(x)
+#define G_STRLOC __FILE__ ":" EGLIB_TOSTRING(__LINE__) ":"
 /*
  * Allocation
  */
index 73fb86488eed65296dd0c19f6d921d044e9965b5..2fffcbc32084b86e4ca45db5de644b32b8cbc8cb 100644 (file)
@@ -201,14 +201,36 @@ test_appendlen ()
        return NULL;
 }
 
+RESULT
+test_macros ()
+{
+       char *s = g_strdup (G_STRLOC);
+       char *p = strchr (s, ':');
+       int n;
+       
+       if (p == NULL)
+               return FAILED ("Did not find a separator");
+       n = atoi (p+1);
+       if (n <= 0)
+               return FAILED ("did not find a valid line number");
+
+       *p = 0;
+       if (strcmp (s, "string.c") != 0)
+               return FAILED ("This did not store the filename on G_STRLOC");
+       
+       g_free (s);
+       return NULL;
+}
+
 static Test string_tests [] = {
        {"append-speed", test_append_speed},
-    {"append_c-speed", test_append_c_speed},
+       {"append_c-speed", test_append_c_speed},
        {"ctor+append", test_gstring },
        {"ctor+sized", test_sized },
        {"truncate", test_truncate },
        {"prepend", test_prepend },
        {"append_len", test_appendlen },
+       {"macros", test_macros },
        {NULL, NULL}
 };