Changeset: 186c2b953b20 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=186c2b953b20
Modified Files:
        clients/mapiclient/ReadlineTools.c
        clients/mapiclient/dotmonetdb.c
Branch: default
Log Message:

Port to Cygwin.


diffs (112 lines):

diff --git a/clients/mapiclient/ReadlineTools.c 
b/clients/mapiclient/ReadlineTools.c
--- a/clients/mapiclient/ReadlineTools.c
+++ b/clients/mapiclient/ReadlineTools.c
@@ -18,12 +18,13 @@
 #include <readline/readline.h>
 #include <readline/history.h>
 #include "ReadlineTools.h"
+#include "mutils.h"
 
 #ifdef HAVE_STRINGS_H
 #include <strings.h>           /* for strncasecmp */
 #endif
 
-#ifndef WIN32
+#ifndef NATIVE_WIN32
 /* for umask */
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -309,10 +310,6 @@ readline_show_error(const char *msg) {
 #define BUFFER_SIZE 1024
 #endif
 
-#ifdef WIN32
-#define unlink _unlink
-#endif
-
 static int
 invoke_editor(int cnt, int key) {
        char editor_command[BUFFER_SIZE];
@@ -325,14 +322,14 @@ invoke_editor(int cnt, int key) {
        (void) cnt;
        (void) key;
 
-#ifdef WIN32
+#ifdef NATIVE_WIN32
        char *mytemp;
        char template[] = "mclient_temp_XXXXXX";
        if ((mytemp = _mktemp(template)) == NULL) {
                readline_show_error("invoke_editor: Cannot create temp file\n");
                goto bailout;
        }
-       if ((fp = fopen(mytemp, "r+")) == NULL) {
+       if ((fp = MT_fopen(mytemp, "r+")) == NULL) {
                // Notify the user that we cannot create temp file
                readline_show_error("invoke_editor: Cannot create temp file\n");
                goto bailout;
@@ -408,7 +405,7 @@ invoke_editor(int cnt, int key) {
        }
 
        fclose(fp);
-       unlink(template);
+       MT_remove(template);
 
        return 0;
 
@@ -416,7 +413,7 @@ bailout:
        if (fp)
                fclose(fp);
        free(read_buff);
-       unlink(template);
+       MT_remove(template);
        return 1;
 }
 
@@ -462,7 +459,7 @@ init_readline(Mapi mid, const char *lang
                        case ENOENT:
                                /* history file didn't exist, so try to create
                                 * it and then try again */
-                               if ((f = fopen(_history_file, "w")) == NULL) {
+                               if ((f = MT_fopen(_history_file, "w")) == NULL) 
{
                                        /* failed to create, don't
                                         * bother saving */
                                        _save_history = 0;
diff --git a/clients/mapiclient/dotmonetdb.c b/clients/mapiclient/dotmonetdb.c
--- a/clients/mapiclient/dotmonetdb.c
+++ b/clients/mapiclient/dotmonetdb.c
@@ -8,6 +8,7 @@
 
 #include "monetdb_config.h"
 #include "dotmonetdb.h"
+#include "mutils.h"
 #include <string.h>
 
 void
@@ -30,7 +31,7 @@ parse_dotmonetdb(DotMonetdb *dotfile)
        if ((cfile = getenv("DOTMONETDBFILE")) == NULL) {
                /* no environment variable: use a default */
                cfile = ".monetdb";
-               if ((config = fopen(cfile, "r")) == NULL) {
+               if ((config = MT_fopen(cfile, "r")) == NULL) {
                        const char *xdg = getenv("XDG_CONFIG_HOME");
                        const char *home = getenv("HOME");
                        int len = -1;
@@ -39,15 +40,15 @@ parse_dotmonetdb(DotMonetdb *dotfile)
                                len = snprintf(buf, sizeof(buf), "%s%cmonetdb", 
xdg, DIR_SEP);
                        else if (home != NULL)
                                len = snprintf(buf, sizeof(buf), 
"%s%c.config%cmonetdb", home, DIR_SEP, DIR_SEP);
-                       if (len == -1 || len >= FILENAME_MAX || (config = 
fopen(buf, "r")) == NULL) {
+                       if (len == -1 || len >= FILENAME_MAX || (config = 
MT_fopen(buf, "r")) == NULL) {
                                if (home) {
                                        len = snprintf(buf, sizeof(buf), 
"%s%c.monetdb", home, DIR_SEP);
                                        if (len >= 0 && len < FILENAME_MAX)
-                                               config = fopen(buf, "r");
+                                               config = MT_fopen(buf, "r");
                                }
                        }
                }
-       } else if (*cfile != 0 && (config = fopen(cfile, "r")) == NULL) {
+       } else if (*cfile != 0 && (config = MT_fopen(cfile, "r")) == NULL) {
                fprintf(stderr, "failed to open file '%s': %s\n",
                        cfile, strerror(errno));
        }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to