]> git.draconx.ca Git - gob-dx.git/blobdiff - src/main.c
Use "remove" to delete files.
[gob-dx.git] / src / main.c
index 0e6c55c84c1709aeed581a94f1a7ac679a0bd689..16f59dda0591e06a8ed060bd07658d21def3d1f5 100644 (file)
@@ -28,9 +28,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
-#include <unistd.h>
 #include <stdlib.h>
-#include <sys/stat.h>
 #include <limits.h>
 #include <getopt.h>
 
@@ -133,11 +131,7 @@ gboolean no_lines = FALSE;
 gboolean no_self_alias = FALSE;
 gboolean always_private_struct = FALSE;
 gboolean gtk3_ok = FALSE;
-
-gint prealloc = 0;
-
-
-
+gint npreallocs = 0;
 gboolean use_m4 = FALSE; /* preprocess sources with m4 */
 char *m4_commandline = NULL;
 #define M4_INCLUDE_DIR  PKGDATADIR "/m4"
@@ -153,9 +147,9 @@ make_bases (void)
        filebase = replace_sep (((Class *)class)->otype, file_sep);
        gob_strdown (filebase);
 
-       if (output_dir != NULL &&
-           output_dir[0] != '\0') {
-               fullfilebase = g_build_filename (output_dir, filebase, NULL);
+       if (output_dir != NULL && output_dir[0] != '\0') {
+               fullfilebase = g_strdup_printf("%s%c%s", output_dir,
+                                              G_DIR_SEPARATOR, filebase);
        } else {
                fullfilebase = g_strdup (filebase);
        }
@@ -1269,7 +1263,7 @@ static void add_type_info(void)
                        "\t\t(GInstanceInitFunc) %s_init,\n"
                        "\t\tNULL\n"
                        "\t};\n\n",
-                       typebase, funcbase, typebase, prealloc, funcbase);
+                       typebase, funcbase, typebase, npreallocs, funcbase);
 }
 
 static void
@@ -3165,6 +3159,7 @@ static char *
 get_arg_names_for_macro (Method *m)
 {
        const char *sep;
+       char *ret;
        GList *li;
        GString *gs = g_string_new(NULL);
        sep = "";
@@ -3173,7 +3168,10 @@ get_arg_names_for_macro (Method *m)
                g_string_append_printf(gs, "%s___%s", sep, arg->name);
                sep = ",";
        }
-       return g_string_free (gs, FALSE);
+
+       ret = gs->str;
+       g_string_free(gs, FALSE);
+       return ret;
 }
 
 static gboolean method_is_void(Method *m)
@@ -4774,25 +4772,27 @@ compare_and_move (const char *old_filename)
                if (error)
                        goto end;
 
-               if (! equal && unlink (old_filename) != 0) {
-                       error_printf (GOB_ERROR, 0, "Can't remove %s: %s",
-                                     old_filename, g_strerror (errno));
+               if (!equal && remove(old_filename) != 0) {
+                       error_printf(GOB_ERROR, 0, "Can't remove %s: %s",
+                                    old_filename, g_strerror (errno));
                        goto end;
                }
        }
 
        if (equal) {
-               if (unlink (new_filename) != 0)
-                       error_printf (GOB_ERROR, 0, "Can't remove %s: %s",
-                                     new_filename, g_strerror (errno));
+               if (remove(new_filename) != 0) {
+                       error_printf(GOB_ERROR, 0, "Can't remove %s: %s",
+                                    new_filename, g_strerror(errno));
+               }
        } else {
-               if (rename (new_filename, old_filename) != 0)
-                       error_printf (GOB_ERROR, 0, "Can't rename %s to %s: %s",
-                                     new_filename, old_filename,
-                                     g_strerror (errno));
+               if (rename(new_filename, old_filename) != 0) {
+                       error_printf(GOB_ERROR, 0, "Can't rename %s to %s: %s",
+                                    new_filename, old_filename,
+                                    g_strerror(errno));
+               }
        }
 
- end:
+end:
        g_free (new_filename);
 }