]> granicus.if.org Git - fribidi/commitdiff
Remove glib dependancy from test.c and test-character.c .
authorDov Grobgeld <dov.grobgeld@gmail.com>
Sat, 10 Mar 2018 16:37:47 +0000 (18:37 +0200)
committerDov Grobgeld <dov.grobgeld@gmail.com>
Sat, 10 Mar 2018 16:37:47 +0000 (18:37 +0200)
configure.ac
meson_options.txt
test/unicode-conformance/Makefile.am
test/unicode-conformance/meson.build
test/unicode-conformance/test-character.c
test/unicode-conformance/test.c

index b3424da4b90ed0336f40f8795e6174611dddb46f..615d27d4334779abb25a822d6bf8b15da4b803ef 100644 (file)
@@ -147,26 +147,6 @@ if test x$enable_deprecated = xno; then
                  [Don not build deprecated functionality])
 fi
 
-# --with[out]-glib
-AC_ARG_WITH(glib,
-              AC_HELP_STRING([--with-glib=@<:@no/auto/yes@:>@],
-                             [use Glib @<:@default=auto@:>@]))
-GLIB_PACKAGE=glib-2.0
-GLIB_MINVERSION=2.4
-if test x$with_glib = xyes; then
-       PKG_CHECK_MODULES(GLIB,$GLIB_PACKAGE >= $GLIB_MINVERSION)
-       FRIBIDI_USE_GLIB=1
-else
-if test x$with_glib = xno; then
-       FRIBIDI_USE_GLIB=0
-else
-       PKG_CHECK_MODULES(GLIB,$GLIB_PACKAGE >= $GLIB_MINVERSION,
-               FRIBIDI_USE_GLIB=1,
-               FRIBIDI_USE_GLIB=0)
-fi
-fi
-AM_CONDITIONAL(FRIBIDI_USE_GLIB, test x$FRIBIDI_USE_GLIB = x1)
-
 # --disable-docs
 AC_ARG_ENABLE(docs,
              AC_HELP_STRING([--disable-docs],
index 8af9b9e5d0f3814224c3489f5505da3c29895800..c312fe8ea3507089fbceee20c7e020538c793d9f 100644 (file)
@@ -2,5 +2,3 @@ option('deprecated', type : 'boolean', value : true,
   description: 'Build deprecated functionality')
 option('docs', type : 'boolean', value : true,
   description: 'Build documentation')
-option('glib', type : 'boolean', value : true,
-  description: 'Use GLib (in unit tests)')
index 2c9304ccd56d8bf788c6f8b12cfc97e68488dbab..70961562a5807ae7cfcda1211ceb95a06c763db6 100644 (file)
@@ -21,10 +21,8 @@ AM_CPPFLAGS = \
                $(GLIB_CFLAGS)
 LDADD = $(top_builddir)/lib/libfribidi.la $(GLIB_LIBS)
 
-if FRIBIDI_USE_GLIB
 check_PROGRAMS = test test-character
 TESTS = $(TEST_DATAS)
-endif
 
 test_SOURCES = test.c
 test_character_SOURCES = test-character.c
index 9a77ea75ebbe2933857936938f7239d2cbd42443..25a3c1f4f706b54ebf84eb2c73a0f9fbc40fdd6b 100644 (file)
@@ -1,19 +1,12 @@
-with_glib = get_option('glib')
-if with_glib
-  glib_dep = dependency('glib-2.0', version: '>= 2.4', required: false)
-  if glib_dep.found()
-    tests = [
-      ['BidiTest', 'test.c'],
-      ['BidiCharacterTest', 'test-character.c'],
-    ]
-    foreach t : tests
-      exe = executable(t[0],
-        t[1], fribidi_unicode_version_h,
-        c_args: ['-DHAVE_CONFIG_H'],
-        include_directories: incs,
-        dependencies: glib_dep,
-        link_with: libfribidi)
-      test(t[0], exe, args: files('@0@.txt'.format(t[0])))
-    endforeach
-  endif
-endif
+tests = [
+  ['BidiTest', 'test.c'],
+  ['BidiCharacterTest', 'test-character.c'],
+]
+foreach t : tests
+  exe = executable(t[0],
+    t[1], fribidi_unicode_version_h,
+    c_args: ['-DHAVE_CONFIG_H'],
+    include_directories: incs,
+    link_with: libfribidi)
+  test(t[0], exe, args: files('@0@.txt'.format(t[0])))
+endforeach
index 75abe3413488e36f4f8990bbe65b74be981919b7..9f58e7975bbdb6152a441949c0d791dc2c117b20 100644 (file)
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
-#include <glib.h>
 #include <ctype.h>
 #include <errno.h>
 
+#define FALSE 0
+#define TRUE 1
+#define LINE_SIZE 2048 /* Size of biggest line in test file */
+
+/* Glib like arrays */
+typedef struct {
+  int capacity;
+  int len;
+  int *data;
+} int_array_t;
+
+typedef struct {
+  int capacity;
+  int len;
+  char *data;
+} char_array_t;
+
+#define ARRAY_CHUNK_SIZE 32
+int_array_t *new_int_array()
+{
+  int_array_t *arr = (int_array_t*)malloc(sizeof(int_array_t));
+  arr->len = 0;
+  arr->capacity = ARRAY_CHUNK_SIZE;
+  arr->data = (int*)malloc(arr->capacity * sizeof(int));
+
+  return arr;
+}
+
+void int_array_add(int_array_t *arr, int val)
+{
+  if (arr->len == arr->capacity)
+    {
+      arr->capacity += ARRAY_CHUNK_SIZE;
+      arr->data = (int*)realloc(arr->data, arr->capacity*sizeof(int));
+    }
+  arr->data[arr->len++] = val;
+}
+
+int *int_array_free(int_array_t *arr, int free_data)
+{
+  int *data = arr->data;
+  if (free_data) {
+    data = NULL;
+    free(arr->data);
+  }
+  free(arr);
+  return data;
+}
+
+char_array_t *new_char_array()
+{
+  char_array_t *arr = (char_array_t*)malloc(sizeof(char_array_t));
+  arr->len = 0;
+  arr->capacity = ARRAY_CHUNK_SIZE;
+  arr->data = (char*)malloc(arr->capacity);
+
+  return arr;
+}
+
+void char_array_add(char_array_t *arr, char val)
+{
+  if (arr->len == arr->capacity)
+    {
+      arr->capacity += ARRAY_CHUNK_SIZE;
+      arr->data = (char*)realloc(arr->data, arr->capacity * sizeof(char));
+    }
+  arr->data[arr->len++] = val;
+}
+
+char *char_array_free(char_array_t *arr, int free_data)
+{
+  char *data = arr->data;
+  if (free_data) {
+    data = NULL;
+    free(arr->data);
+  }
+  free(arr);
+  return data;
+}
+
 static void die(const char *fmt, ...)
 {
   va_list ap;
@@ -53,13 +132,13 @@ void parse_test_line (char *line,
                       int *visual_ordering_len
                       )
 {
-  GArray *code_points_array, *levels_array, *visual_ordering_array;
+  int_array_t *code_points_array, *visual_ordering_array;
+  char_array_t *levels_array;
   char *end;
   int level;
 
-
-  code_points_array = g_array_new (FALSE, FALSE, sizeof (FriBidiChar));
-  levels_array = g_array_new (FALSE, FALSE, sizeof (FriBidiLevel));
+  code_points_array = new_int_array ();
+  levels_array = new_char_array ();
 
   /* Field 0. Code points */
   for(;;)
@@ -74,13 +153,13 @@ void parse_test_line (char *line,
         break;
 
       c = parse_uni_char (line, end - line);
-      g_array_append_val (code_points_array, c);
+      int_array_add(code_points_array, c);
 
       line = end;
     }
 
   *code_points_len = code_points_array->len;
-  *code_points = (FriBidiChar *) g_array_free (code_points_array, FALSE);
+  *code_points = (FriBidiChar *) int_array_free (code_points_array, FALSE);
 
   if (*line == ';')
     line++;
@@ -120,7 +199,7 @@ void parse_test_line (char *line,
       level = strtol (line, &end, 10);
       if (errno != EINVAL && line != end)
         {
-          g_array_append_val (levels_array, level);
+          char_array_add (levels_array, level);
           line = end;
           continue;
         }
@@ -131,7 +210,7 @@ void parse_test_line (char *line,
       if (*line == 'x')
         {
           level = (FriBidiLevel) -1;
-          g_array_append_val (levels_array, level);
+          char_array_add (levels_array, level);
           line++;
           continue;
         }
@@ -139,13 +218,13 @@ void parse_test_line (char *line,
       if (*line == ';')
         break;
 
-      g_assert_not_reached ();
+      die("Oops! I shouldn't be here!\n");
     }
 
   if (levels_array->len != *code_points_len)
     die("Oops! Different lengths for levels and codepoints at line %d!\n", line_no);
 
-  *resolved_levels = (FriBidiLevel*)g_array_free (levels_array, FALSE);
+  *resolved_levels = (FriBidiLevel*)char_array_free (levels_array, FALSE);
 
   if (*line == ';')
     line++;
@@ -153,25 +232,22 @@ void parse_test_line (char *line,
     die("Oops! Didn't find expected ; at line %d\n", line_no);
 
   /* Field 4 - resulting visual ordering */
-  visual_ordering_array = g_array_new (FALSE, FALSE, sizeof(int));
+  visual_ordering_array = new_int_array ();
   for(; errno = 0, level = strtol (line, &end, 10), line != end && errno != EINVAL; line = end) {
-    g_array_append_val (visual_ordering_array, level);
+    int_array_add (visual_ordering_array, level);
   }
 
   *visual_ordering_len = visual_ordering_array->len;
-  *visual_ordering = (int*)g_array_free (visual_ordering_array, FALSE);
+  *visual_ordering = (int*)int_array_free (visual_ordering_array, FALSE);
 }
 
 int
 main (int argc, char **argv)
 {
-  GError *error;
   int next_arg;
-  GIOChannel *channel;
-  GIOStatus status;
+  FILE *channel;
   const char *filename;
-  gchar *line = NULL;
-  gsize length, terminator_pos;
+  char line[LINE_SIZE];
   int numerrs = 0;
   int line_no = 0;
   FriBidiChar *code_points = NULL;
@@ -186,11 +262,11 @@ main (int argc, char **argv)
   FriBidiBracketType *bracket_types = NULL;
   FriBidiStrIndex *ltor = NULL;
   int ltor_len;
-  gboolean debug = FALSE;
+  int debug = FALSE;
 
   if (argc < 2)
     {
-      g_printerr ("usage: %s [--debug] test-file-name\n", argv[0]);
+      fprintf (stderr, "usage: %s [--debug] test-file-name\n", argv[0]);
       exit (1);
     }
 
@@ -206,43 +282,21 @@ main (int argc, char **argv)
       die("Unknown option %s!\n", arg);
     }
 
-  filename = argv[next_arg++];
+    filename = argv[next_arg++];
 
-  error = NULL;
-  channel = g_io_channel_new_file (filename, "r", &error);
-  if (!channel)
-    {
-      g_printerr ("%s\n", error->message);
-      exit (1);
-    }
-
-  fribidi_set_debug(debug);
-
-  while (TRUE)
-    {
-      error = NULL;
-      g_free (line);
-      status = g_io_channel_read_line (channel, &line, &length, &terminator_pos, &error);
-      switch (status)
-        {
-        case G_IO_STATUS_ERROR:
-          g_printerr ("%s\n", error->message);
-          exit (1);
+    channel = fopen(filename, "r");
+    if (!channel) 
+       die ("Failed opening %s\n", filename);
 
-        case G_IO_STATUS_EOF:
-          goto done;
-
-        case G_IO_STATUS_AGAIN:
-          continue;
-
-        case G_IO_STATUS_NORMAL:
-          line[terminator_pos] = '\0';
-          break;
-       }
+    while (!feof(channel)) {
+      fgets(line, LINE_SIZE, channel);
+      int len = strlen(line);
+      if (len == LINE_SIZE-1)
+        die("LINE_SIZE=%d too small at line %d!\n", LINE_SIZE, line_no);
 
       line_no++;
 
-      if (line[0] == '#' || line[0] == '\0')
+      if (line[0] == '#' || line[0] == '\n')
         continue;
 
       parse_test_line (line,
@@ -257,23 +311,23 @@ main (int argc, char **argv)
                        );
 
       /* Test it */
-      g_free(bracket_types);
-      bracket_types = g_malloc ( sizeof(FriBidiBracketType) * code_points_len);
+      free(bracket_types);
+      bracket_types = malloc ( sizeof(FriBidiBracketType) * code_points_len);
 
-      g_free(types);
-      types = g_malloc ( sizeof(FriBidiCharType) * code_points_len);
+      free(types);
+      types = malloc ( sizeof(FriBidiCharType) * code_points_len);
 
-      g_free(levels);
-      levels = g_malloc (sizeof (FriBidiLevel) * code_points_len);
+      free(levels);
+      levels = malloc (sizeof (FriBidiLevel) * code_points_len);
 
-      g_free (ltor);
-      ltor = g_malloc (sizeof (FriBidiStrIndex) * code_points_len);
+      free (ltor);
+      ltor = malloc (sizeof (FriBidiStrIndex) * code_points_len);
 
 
       {
         FriBidiParType base_dir;
         int i, j;
-        gboolean matches;
+        int matches;
         int types_len = code_points_len;
         int levels_len = types_len;
         FriBidiBracketType NoBracket = FRIBIDI_NO_BRACKET;
@@ -347,31 +401,31 @@ main (int argc, char **argv)
           {
             numerrs++;
 
-            g_printerr ("failure on line %d\n", line_no);
-            g_printerr ("input is: %s\n", line);
-            g_printerr ("base dir: %s\n", paragraph_dir==0 ? "LTR"
+            fprintf (stderr, "failure on line %d\n", line_no);
+            fprintf (stderr, "input is: %s\n", line);
+            fprintf (stderr, "base dir: %s\n", paragraph_dir==0 ? "LTR"
                         : paragraph_dir==1 ? "RTL" : "AUTO");
 
-            g_printerr ("expected levels:");
+            fprintf (stderr, "expected levels:");
             for (i = 0; i < code_points_len; i++)
               if (expected_levels[i] == (FriBidiLevel) -1)
-                g_printerr (" x");
+                fprintf (stderr, " x");
               else
-                g_printerr (" %d", expected_levels[i]);
-            g_printerr ("\n");
-            g_printerr ("returned levels:");
+                fprintf (stderr, " %d", expected_levels[i]);
+            fprintf (stderr, "\n");
+            fprintf (stderr, "returned levels:");
             for (i = 0; i < levels_len; i++)
-              g_printerr (" %d", levels[i]);
-            g_printerr ("\n");
+              fprintf (stderr, " %d", levels[i]);
+            fprintf (stderr, "\n");
 
-            g_printerr ("expected order:");
+            fprintf (stderr, "expected order:");
             for (i = 0; i < expected_ltor_len; i++)
-              g_printerr (" %d", expected_ltor[i]);
-            g_printerr ("\n");
-            g_printerr ("returned order:");
+              fprintf (stderr, " %d", expected_ltor[i]);
+            fprintf (stderr, "\n");
+            fprintf (stderr, "returned order:");
             for (i = 0; i < ltor_len; i++)
-              g_printerr (" %d", ltor[i]);
-            g_printerr ("\n");
+              fprintf (stderr, " %d", ltor[i]);
+            fprintf (stderr, "\n");
 
             if (debug)
               {
@@ -396,17 +450,13 @@ main (int argc, char **argv)
                 fribidi_set_debug (0);
               }
 
-            g_printerr ("\n");
+            fprintf (stderr, "\n");
           }
       }
     }
 
-done:
-  if (error)
-    g_error_free (error);
-
   if (numerrs)
-    g_printerr ("%d errors\n", numerrs);
+    fprintf (stderr, "%d errors\n", numerrs);
   else
     printf("No errors found! :-)\n");
 
index 41521e102e4b308b0ae133d7d482e9d317fb67eb..12d0fbbfd1cae58f7c8368db89d31fe28d47865e 100644 (file)
  */
 
 #include <fribidi.h>
-#include <glib.h>
 
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <stdarg.h>
 #include <errno.h>
 #include <ctype.h>
 
+#define TRUE 1
+#define FALSE 0
+
+/* Glib array types */
+typedef struct {
+  int capacity;
+  int len;
+  int *data;
+} int_array_t;
+
+typedef struct {
+  int capacity;
+  int len;
+  char *data;
+} char_array_t;
+
+#define LINE_SIZE 2048 /* Size of largest example line in BidiTest */
+#define ARRAY_CHUNK_SIZE 32
+int_array_t *new_int_array()
+{
+  int_array_t *arr = (int_array_t*)malloc(sizeof(int_array_t));
+  arr->len = 0;
+  arr->capacity = ARRAY_CHUNK_SIZE;
+  arr->data = (int*)malloc(arr->capacity * sizeof(int));
+
+  return arr;
+}
+
+void int_array_add(int_array_t *arr, int val)
+{
+  if (arr->len == arr->capacity)
+    {
+      arr->capacity += ARRAY_CHUNK_SIZE;
+      arr->data = (int*)realloc(arr->data, arr->capacity*sizeof(int));
+    }
+  arr->data[arr->len++] = val;
+}
+
+int *int_array_free(int_array_t *arr, int free_data)
+{
+  int *data = arr->data;
+  if (free_data) {
+    data = NULL;
+    free(arr->data);
+  }
+  free(arr);
+  return data;
+}
+
+char_array_t *new_char_array()
+{
+  char_array_t *arr = (char_array_t*)malloc(sizeof(char_array_t));
+  arr->len = 0;
+  arr->capacity = ARRAY_CHUNK_SIZE;
+  arr->data = (char*)malloc(arr->capacity);
+
+  return arr;
+}
+
+void char_array_add(char_array_t *arr, char val)
+{
+  if (arr->len == arr->capacity)
+    {
+      arr->capacity += ARRAY_CHUNK_SIZE;
+      arr->data = (char*)realloc(arr->data, arr->capacity * sizeof(char));
+    }
+  arr->data[arr->len++] = val;
+}
+
+char *char_array_free(char_array_t *arr, int free_data)
+{
+  char *data = arr->data;
+  if (free_data) {
+    data = NULL;
+    free(arr->data);
+  }
+  free(arr);
+  return data;
+}
+
+static void die(const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap,fmt); 
+    
+    vfprintf(stderr, fmt, ap);
+    exit(-1);
+}
+
 static FriBidiCharType
 parse_char_type (const char *s, int len)
 {
@@ -56,19 +145,20 @@ parse_char_type (const char *s, int len)
     MATCH ("FSI", FRIBIDI_TYPE_FSI);
     MATCH ("PDI", FRIBIDI_TYPE_PDI);
 
-    g_assert_not_reached ();
+    die("Oops. I shouldn't reach here!\n");
+    return -1;
 }
 
 static FriBidiLevel *
 parse_levels_line (const char *line,
                   FriBidiLevel *len)
 {
-    GArray *levels;
+    char_array_t *levels;
 
     if (!strncmp (line, "@Levels:", 8))
        line += 8;
 
-    levels = g_array_new (FALSE, FALSE, sizeof (FriBidiLevel));
+    levels = new_char_array ();
 
     while (*line)
     {
@@ -79,7 +169,7 @@ parse_levels_line (const char *line,
        l = strtol (line, &end, 10);
        if (errno != EINVAL && line != end)
        {
-         g_array_append_val (levels, l);
+         char_array_add (levels, l);
          line = end;
          continue;
        }
@@ -89,8 +179,7 @@ parse_levels_line (const char *line,
 
        if (*line == 'x')
        {
-         l = (FriBidiLevel) -1;
-         g_array_append_val (levels, l);
+         char_array_add (levels, -1);
          line++;
          continue;
        }
@@ -98,32 +187,32 @@ parse_levels_line (const char *line,
        if (!*line)
          break;
 
-       g_assert_not_reached ();
+       die("Oops. I shouldn't be here!\n");
     }
 
     *len = levels->len;
-    return (FriBidiLevel *) g_array_free (levels, FALSE);
+    return (FriBidiLevel *) char_array_free(levels, FALSE);
 }
 
 static FriBidiStrIndex *
 parse_reorder_line (const char *line,
                    FriBidiStrIndex *len)
 {
-    GArray *map;
+    int_array_t *map;
     FriBidiStrIndex l;
     char *end;
 
     if (!strncmp (line, "@Reorder:", 9))
        line += 9;
 
-    map = g_array_new (FALSE, FALSE, sizeof (FriBidiStrIndex));
+    map = new_int_array ();
 
     for(; errno = 0, l = strtol (line, &end, 10), line != end && errno != EINVAL; line = end) {
-       g_array_append_val (map, l);
+       int_array_add (map, l);
     }
 
     *len = map->len;
-    return (FriBidiStrIndex *) g_array_free (map, FALSE);
+    return (FriBidiStrIndex *) int_array_free (map, FALSE);
 }
 
 static FriBidiCharType *
@@ -131,11 +220,11 @@ parse_test_line (const char *line,
                 FriBidiStrIndex *len,
                 int *base_dir_flags)
 {
-    GArray *types;
+    int_array_t *types;
     FriBidiCharType c;
     const char *end;
 
-    types = g_array_new (FALSE, FALSE, sizeof (FriBidiCharType));
+    types = new_int_array();
 
     for(;;) {
        while (isspace (*line))
@@ -147,7 +236,7 @@ parse_test_line (const char *line,
            break;
 
        c = parse_char_type (line, end - line);
-       g_array_append_val (types, c);
+       int_array_add (types, c);
 
        line = end;
     }
@@ -157,17 +246,14 @@ parse_test_line (const char *line,
     *base_dir_flags = strtol (line, NULL, 10);
 
     *len = types->len;
-    return (FriBidiCharType *) g_array_free (types, FALSE);
+    return (FriBidiCharType *) int_array_free (types, FALSE);
 }
 
 int
 main (int argc, char **argv)
 {
-    GIOChannel *channel;
-    GIOStatus status;
-    GError *error;
-    gchar *line = NULL;
-    gsize length, terminator_pos;
+    FILE *channel;
+    char line[LINE_SIZE];
     FriBidiStrIndex *expected_ltor = NULL;
     FriBidiStrIndex expected_ltor_len = 0;
     FriBidiStrIndex *ltor = NULL;
@@ -182,14 +268,12 @@ main (int argc, char **argv)
     int numerrs = 0;
     int numtests = 0;
     int line_no = 0;
-    gboolean debug = FALSE;
+    int debug = FALSE;
     const char *filename;
     int next_arg;
 
-    if (argc < 2) {
-       g_printerr ("usage: %s [--debug] test-file-name\n", argv[0]);
-       exit (1);
-    }
+    if (argc < 2) 
+       die ("usage: %s [--debug] test-file-name\n", argv[0]);
 
     next_arg = 1;
     if (!strcmp (argv[next_arg], "--debug")) {
@@ -199,47 +283,30 @@ main (int argc, char **argv)
 
     filename = argv[next_arg++];
 
-    error = NULL;
-    channel = g_io_channel_new_file (filename, "r", &error);
-    if (!channel) {
-       g_printerr ("%s\n", error->message);
-       exit (1);
-    }
-
-    while (TRUE) {
-       error = NULL;
-       g_free (line);
-       status = g_io_channel_read_line (channel, &line, &length, &terminator_pos, &error);
-       switch (status) {
-        case G_IO_STATUS_ERROR:
-            g_printerr ("%s\n", error->message);
-            exit (1);
-
-        case G_IO_STATUS_EOF:
-           goto done;
+    channel = fopen(filename, "r");
+    if (!channel) 
+       die ("Failed opening %s\n", filename);
 
-        case G_IO_STATUS_AGAIN:
-            continue;
-
-        case G_IO_STATUS_NORMAL:
-            line[terminator_pos] = '\0';
-            break;
-       }
+    while (!feof(channel)) {
+        fgets(line, LINE_SIZE, channel);
+        int len = strlen(line);
+        if (len == LINE_SIZE-1)
+          die("LINE_SIZE too small at line %d!\n", line_no);
 
        line_no++;
 
-       if (line[0] == '#' || line[0] == '\0')
+       if (line[0] == '#')
            continue;
 
        if (line[0] == '@')
        {
            if (!strncmp (line, "@Reorder:", 9)) {
-               g_free (expected_ltor);
+               free (expected_ltor);
                expected_ltor = parse_reorder_line (line, &expected_ltor_len);
                continue;
            }
            if (!strncmp (line, "@Levels:", 8)) {
-               g_free (expected_levels);
+               free (expected_levels);
                expected_levels = parse_levels_line (line, &expected_levels_len);
                continue;
            }
@@ -247,21 +314,21 @@ main (int argc, char **argv)
        }
 
        /* Test line */
-       g_free (types);
+       free (types);
        types = parse_test_line (line, &types_len, &base_dir_flags);
 
-       g_free (levels);
-       levels = g_malloc (sizeof (FriBidiLevel) * types_len);
+       free (levels);
+       levels = malloc (sizeof (FriBidiLevel) * types_len);
        levels_len = types_len;
 
-       g_free (ltor);
-       ltor = g_malloc (sizeof (FriBidiStrIndex) * types_len);
+       free (ltor);
+       ltor = malloc (sizeof (FriBidiStrIndex) * types_len);
 
        /* Test it */
        for (base_dir_mode = 0; base_dir_mode < 3; base_dir_mode++) {
            FriBidiParType base_dir;
            int i, j;
-           gboolean matches;
+           int matches;
 
            if ((base_dir_flags & (1<<base_dir_mode)) == 0)
                continue;
@@ -323,31 +390,32 @@ main (int argc, char **argv)
            {
                numerrs++;
 
-               g_printerr ("failure on line %d\n", line_no);
-               g_printerr ("input is: %s\n", line);
-               g_printerr ("base dir: %s\n", base_dir_mode==0 ? "auto"
-                                           : base_dir_mode==1 ? "LTR" : "RTL");
+               fprintf (stderr, "failure on line %d\n", line_no);
+               fprintf (stderr, "input is: %s\n", line);
+               fprintf (stderr, "base dir: %s\n",
+                         base_dir_mode==0 ? "auto"
+                         : base_dir_mode==1 ? "LTR" : "RTL");
 
-               g_printerr ("expected levels:");
+               fprintf (stderr, "expected levels:");
                for (i = 0; i < expected_levels_len; i++)
                    if (expected_levels[i] == (FriBidiLevel) -1)
-                       g_printerr (" x");
+                        fprintf (stderr," x");
                    else
-                       g_printerr (" %d", expected_levels[i]);
-               g_printerr ("\n");
-               g_printerr ("returned levels:");
+                        fprintf (stderr, " %d", expected_levels[i]);
+               fprintf (stderr, "\n");
+               fprintf (stderr, "returned levels:");
                for (i = 0; i < levels_len; i++)
-                   g_printerr (" %d", levels[i]);
-               g_printerr ("\n");
+                    fprintf (stderr, " %d", levels[i]);
+               fprintf (stderr, "\n");
 
-               g_printerr ("expected order:");
+               fprintf (stderr, "expected order:");
                for (i = 0; i < expected_ltor_len; i++)
-                   g_printerr (" %d", expected_ltor[i]);
-               g_printerr ("\n");
-               g_printerr ("returned order:");
+                    fprintf (stderr, " %d", expected_ltor[i]);
+               fprintf (stderr, "\n");
+               fprintf (stderr, "returned order:");
                for (i = 0; i < ltor_len; i++)
-                   g_printerr (" %d", ltor[i]);
-               g_printerr ("\n");
+                    fprintf (stderr, " %d", ltor[i]);
+               fprintf (stderr, "\n");
 
                if (debug)
                   {
@@ -371,23 +439,19 @@ main (int argc, char **argv)
                    fribidi_set_debug (0);
                }
 
-               g_printerr ("\n");
+               fprintf (stderr, "\n");
            }
        }
     }
 
-done:
-    g_free (ltor);
-    g_free (levels);
-    g_free (expected_ltor);
-    g_free (types);
-    g_free (line);
-    g_io_channel_unref (channel);
-    if (error)
-       g_error_free (error);
+    free (ltor);
+    free (levels);
+    free (expected_ltor);
+    free (types);
+    fclose(channel);
 
     if (numerrs)
-       g_printerr ("%d errors out of %d total tests\n", numerrs, numtests);
+        fprintf (stderr, "%d errors out of %d total tests\n", numerrs, numtests);
     else
         printf("No errors found! :-)\n");