mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Make Windows cross compile again
But this is broken as the utf8/utf16 conversions in windows.c are gone without glib. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
34db6dc2be
commit
475e058d40
5 changed files with 39 additions and 18 deletions
4
Rules.mk
4
Rules.mk
|
@ -144,6 +144,10 @@ create-macosx-bundle: all
|
|||
sign-macosx-bundle: all
|
||||
codesign -s "3A8CE62A483083EDEA5581A61E770EC1FA8BECE8" /Applications/$(CAPITALIZED_NAME).app/Contents/MacOS/$(NAME)-bin
|
||||
|
||||
$(RESFILE): packaging/windows/subsurface.rc
|
||||
@$(PRETTYECHO) ' WINDRES' $<
|
||||
@i686-w64-mingw32-windres -O coff -i $< -o $@
|
||||
|
||||
install-cross-windows: all
|
||||
$(INSTALL) -d -m 755 $(WINDOWSSTAGING)/share/locale
|
||||
for MSG in $(WINMSGDIRS); do\
|
||||
|
|
14
dive.h
14
dive.h
|
@ -5,7 +5,19 @@
|
|||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
/* Windows has no MIN/MAX macros - so let's just roll our own */
|
||||
#define MIN(x, y) ({ \
|
||||
typeof(x) _min1 = (x); \
|
||||
typeof(y) _min2 = (y); \
|
||||
(void) (&_min1 == &_min2); \
|
||||
_min1 < _min2 ? _min1 : _min2; })
|
||||
|
||||
#define MAX(x, y) ({ \
|
||||
typeof(x) _max1 = (x); \
|
||||
typeof(y) _max2 = (y); \
|
||||
(void) (&_max1 == &_max2); \
|
||||
_max1 > _max2 ? _max1 : _max2; })
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxslt/transform.h>
|
||||
|
|
|
@ -92,7 +92,7 @@ int get_maxdepth(struct plot_info *pi)
|
|||
md = ROUND_UP(mm+3000, 10000);
|
||||
} else {
|
||||
/* Minimum 30m, rounded up to 10m, with at least 3m to spare */
|
||||
md = MAX(30000, ROUND_UP(mm+3000, 10000));
|
||||
md = MAX((unsigned)30000, ROUND_UP(mm+3000, 10000));
|
||||
}
|
||||
md += pi->maxpp * 9000;
|
||||
return md;
|
||||
|
|
|
@ -148,9 +148,11 @@ static int number_of_file(char *path)
|
|||
|
||||
dirp = opendir(path);
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
if (entry->d_type == DT_REG) { /* If the entry is a regular file */
|
||||
#ifndef WIN32
|
||||
if (entry->d_type == DT_REG) /* If the entry is a regular file */
|
||||
#endif
|
||||
count++;
|
||||
}
|
||||
|
||||
}
|
||||
closedir(dirp);
|
||||
return count;
|
||||
|
|
31
windows.c
31
windows.c
|
@ -14,7 +14,8 @@ const char *system_default_filename(void)
|
|||
char *buffer;
|
||||
int len;
|
||||
|
||||
user = g_get_user_name();
|
||||
/* I don't think this works on Windows */
|
||||
user = getenv("LOGNAME");
|
||||
if (! SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, datapath))) {
|
||||
datapath[0] = '.';
|
||||
datapath[1] = '\0';
|
||||
|
@ -29,14 +30,14 @@ const char *system_default_filename(void)
|
|||
extern int __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
|
||||
|
||||
/* expand-convert the UTF-16 argument list to a list of UTF-8 strings */
|
||||
void subsurface_command_line_init(gint *argc, gchar ***argv)
|
||||
void subsurface_command_line_init(int *argc, char ***argv)
|
||||
{
|
||||
wchar_t **wargv, **wenviron, *p, path[MAX_PATH] = {0};
|
||||
gchar **argv_new;
|
||||
gchar *s;
|
||||
char **argv_new;
|
||||
char *s;
|
||||
/* for si we assume that a struct address will equal the address
|
||||
* of its first and only int member */
|
||||
gint i, n, ret, si;
|
||||
int i, n, ret, si;
|
||||
|
||||
/* change the current process path to the module path, so that we can
|
||||
* access relative folders such as ./share and ./xslt */
|
||||
|
@ -51,23 +52,25 @@ void subsurface_command_line_init(gint *argc, gchar ***argv)
|
|||
* lifespan as the process heap. */
|
||||
ret = __wgetmainargs(&n, &wargv, &wenviron, TRUE, &si);
|
||||
if (ret < 0) {
|
||||
g_warning("Cannot convert command line");
|
||||
fprintf(stderr, "Cannot convert command line");
|
||||
return;
|
||||
}
|
||||
argv_new = g_malloc(sizeof(gchar *) * (n + 1));
|
||||
argv_new = malloc(sizeof(char *) * (n + 1));
|
||||
|
||||
#if MISSING_GLIB_FUNCTIONS
|
||||
for (i = 0; i < n; ++i) {
|
||||
s = g_utf16_to_utf8((gunichar2 *)wargv[i], -1, NULL, NULL, NULL);
|
||||
if (!s) {
|
||||
g_warning("Cannot convert command line argument (%d) to UTF-8", (i + 1));
|
||||
fprintf(stderr, "Cannot convert command line argument (%d) to UTF-8", (i + 1));
|
||||
s = "\0";
|
||||
} else if (!g_utf8_validate(s, -1, NULL)) {
|
||||
g_warning("Cannot validate command line argument '%s' (%d)", s, (i + 1));
|
||||
g_free(s);
|
||||
} else if (!g_utf8_validate(s, -1, NULL)) {
|
||||
fprintf(stderr,"Cannot validate command line argument '%s' (%d)", s, (i + 1));
|
||||
free(s);
|
||||
s = "\0";
|
||||
}
|
||||
argv_new[i] = s;
|
||||
}
|
||||
#endif
|
||||
argv_new[n] = NULL;
|
||||
|
||||
/* update the argument list and count */
|
||||
|
@ -78,12 +81,12 @@ void subsurface_command_line_init(gint *argc, gchar ***argv)
|
|||
}
|
||||
|
||||
/* once done, free the argument list */
|
||||
void subsurface_command_line_exit(gint *argc, gchar ***argv)
|
||||
void subsurface_command_line_exit(int *argc, char ***argv)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < *argc; i++)
|
||||
g_free((*argv)[i]);
|
||||
g_free(*argv);
|
||||
free((*argv)[i]);
|
||||
free(*argv);
|
||||
}
|
||||
|
||||
/* check if we are running a newer OS version */
|
||||
|
|
Loading…
Reference in a new issue