From: fliep Date: Wed, 7 Oct 2009 22:07:11 +0000 (+0000) Subject: Applied patches to Git interpreter from Gargoyle source code X-Git-Tag: v0.9~329 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=42547067728cfe19d1302a6926fa9e4d5a1ca50f;p=projects%2Fchimara%2Fchimara.git Applied patches to Git interpreter from Gargoyle source code --- diff --git a/interpreters/git.patch b/interpreters/git.patch new file mode 100644 index 0000000..eb87fc5 --- /dev/null +++ b/interpreters/git.patch @@ -0,0 +1,193 @@ +diff -P'aurx.*' git-1.2.4/gestalt.c git-chimara/gestalt.c +--- git-1.2.4/gestalt.c 2009-04-03 00:54:50.000000000 +0200 ++++ git-chimara/gestalt.c 2009-10-07 23:43:28.000000000 +0200 +@@ -5,7 +5,7 @@ + switch (sel) + { + case GESTALT_SPEC_VERSION: +- return 0x00030100; ++ return 0x00030101; + + case GESTALT_TERP_VERSION: + return GIT_VERSION_NUM; +Only in git-1.2.4: git_mac.c +diff -P'aurx.*' git-1.2.4/git_unix.c git-chimara/git_unix.c +--- git-1.2.4/git_unix.c 2009-04-03 00:54:50.000000000 +0200 ++++ git-chimara/git_unix.c 2009-10-07 23:59:58.000000000 +0200 +@@ -25,23 +25,47 @@ + #define CACHE_SIZE (256 * 1024L) + #define UNDO_SIZE (512 * 1024L) + ++int gHasInited = 0; ++ ++#ifdef CHIMARA_EXTENSIONS ++ ++void fatalError (const char * s) ++{ ++ winid_t win; ++ if (!gHasInited) ++ { ++ win = glk_window_open(0, 0, 0, wintype_TextBuffer, 0); ++ glk_set_window(win); ++ } ++ /* pray that this goes somewhere reasonable... */ ++ glk_put_string("\n*** fatal error: "); ++ glk_put_string((char*)s); ++ glk_put_string(" ***\n"); ++ glk_exit(); ++} ++ ++#else ++ + void fatalError (const char * s) + { + fprintf (stderr, "*** fatal error: %s ***\n", s); + exit (1); + } + ++#endif /* CHIMARA_EXTENSIONS */ ++ + #ifdef USE_MMAP + // Fast loader that uses some fancy Unix features. + + const char * gFilename = 0; ++char * gStartupError = 0; + + int glkunix_startup_code(glkunix_startup_t *data) + { + if (data->argc <= 1) + { +- printf ("usage: git gamefile.ulx\n"); +- return 0; ++ gStartupError = "No file given"; ++ return 1; + } + gFilename = data->argv[1]; + return 1; +@@ -52,7 +76,10 @@ + int file; + struct stat info; + const char * ptr; +- ++ ++ if (gStartupError) ++ fatalError(gStartupError); ++ + file = open (gFilename, O_RDONLY); + if (file < 0) + goto error; +@@ -61,35 +88,35 @@ + goto error; + + if (info.st_size < 256) +- { +- fprintf (stderr, "This is too small to be a glulx file.\n"); +- exit (1); +- } ++ fatalError("This is too small to be a glulx file."); + + ptr = mmap (NULL, info.st_size, PROT_READ, MAP_PRIVATE, file, 0); + if (ptr == MAP_FAILED) + goto error; ++ ++ gHasInited = 1; + + git (ptr, info.st_size, CACHE_SIZE, UNDO_SIZE); + munmap ((void*) ptr, info.st_size); + return; + + error: +- perror ("git"); +- exit (errno); ++ sprintf(errmsg, "git: %s", strerror(errno)); ++ fatalError(errmsg); + } + + #else + // Generic loader that should work anywhere. + + strid_t gStream = 0; ++char * gStartupError = 0; + + int glkunix_startup_code(glkunix_startup_t *data) + { + if (data->argc <= 1) + { +- printf ("usage: git gamefile.ulx\n"); +- return 0; ++ gStartupError = "No file given"; ++ return 1; + } + gStream = glkunix_stream_open_pathname ((char*) data->argv[1], 0, 0); + return 1; +@@ -97,9 +124,14 @@ + + void glk_main () + { ++ if (gStartupError) ++ fatalError(gStartupError); ++ + if (gStream == NULL) + fatalError ("could not open game file"); + ++ gHasInited = 1; ++ + gitWithStream (gStream, CACHE_SIZE, UNDO_SIZE); + } + +Only in git-1.2.4: git_windows.c +Only in git-1.2.4: Makefile +diff -P'aurx.*' git-1.2.4/Makefile.am git-chimara/Makefile.am +--- git-1.2.4/Makefile.am 1970-01-01 01:00:00.000000000 +0100 ++++ git-chimara/Makefile.am 2009-10-07 23:59:34.000000000 +0200 +@@ -0,0 +1,48 @@ ++PLUGIN_LIBTOOL_FLAGS=-module -avoid-version -export-symbols-regex "^glk" ++ ++# Automatically generate version.h ++MAJOR = 1 ++MINOR = 2 ++PATCH = 4 ++version.h: Makefile ++ echo "// Automatically generated file -- do not edit!" > version.h ++ echo "#define GIT_MAJOR" $(MAJOR) >> version.h ++ echo "#define GIT_MINOR" $(MINOR) >> version.h ++ echo "#define GIT_PATCH" $(PATCH) >> version.h ++ ++pkglib_LTLIBRARIES = git.la ++BUILT_SOURCES = version.h ++git_la_SOURCES = version.h git.h config.h compiler.h memory.h opcodes.h \ ++ labels.inc compiler.c gestalt.c git.c git_unix.c glkop.c heap.c memory.c \ ++ opcodes.c operands.c peephole.c savefile.c saveundo.c search.c terp.c \ ++ accel.c ++git_la_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/libchimara ++git_la_CFLAGS = -DCHIMARA_EXTENSIONS -DUSE_INLINE $(AM_CFLAGS) ++git_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS) ++ ++gitdocdir = $(datadir)/doc/$(PACKAGE)/git ++dist_gitdoc_DATA = README.txt ++ ++CLEANFILES = test/*.tmp ++ ++#TESTS = test/test.sh \ ++# test/Alabaster.gblorb test/Alabaster.walk test/Alabaster.golden ++# ++#test: git ++# sh test/test.sh ++ ++# Memory mapping (-DUSE_MMAP) doesn't seem to work... FIXME ++ ++# Best settings for GCC 2.95. This generates faster code than ++# GCC 3, so you should use this setup if possible. ++#CC = gcc -Wall -O3 ++#OPTIONS = -DUSE_DIRECT_THREADING -DUSE_MMAP -DUSE_INLINE ++# ++# Best settings for GCC 3. The optimiser in this version of GCC ++# is somewhat broken, so we can't use USE_DIRECT_THREADING. ++#CC = gcc -Wall -O3 ++#OPTIONS = -DUSE_MMAP -DUSE_INLINE ++# ++# Mac OS X (PowerPC) settings. ++#CC = gcc2 -Wall -O3 -no-cpp-precomp ++#OPTIONS = -DUSE_DIRECT_THREADING -DUSE_BIG_ENDIAN_UNALIGNED -DUSE_MMAP -DUSE_INLINE +Only in git-1.2.4: Makefile.win +Only in git-1.2.4: win diff --git a/interpreters/git/Makefile.am b/interpreters/git/Makefile.am index b9881a6..051eeb3 100644 --- a/interpreters/git/Makefile.am +++ b/interpreters/git/Makefile.am @@ -17,7 +17,7 @@ git_la_SOURCES = version.h git.h config.h compiler.h memory.h opcodes.h \ opcodes.c operands.c peephole.c savefile.c saveundo.c search.c terp.c \ accel.c git_la_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/libchimara -git_la_CFLAGS = -DUSE_INLINE $(AM_CFLAGS) +git_la_CFLAGS = -DCHIMARA_EXTENSIONS -DUSE_INLINE $(AM_CFLAGS) git_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS) gitdocdir = $(datadir)/doc/$(PACKAGE)/git @@ -45,4 +45,4 @@ CLEANFILES = test/*.tmp # # Mac OS X (PowerPC) settings. #CC = gcc2 -Wall -O3 -no-cpp-precomp -#OPTIONS = -DUSE_DIRECT_THREADING -DUSE_BIG_ENDIAN_UNALIGNED -DUSE_MMAP -DUSE_INLINE \ No newline at end of file +#OPTIONS = -DUSE_DIRECT_THREADING -DUSE_BIG_ENDIAN_UNALIGNED -DUSE_MMAP -DUSE_INLINE diff --git a/interpreters/git/gestalt.c b/interpreters/git/gestalt.c index fb58280..0253433 100644 --- a/interpreters/git/gestalt.c +++ b/interpreters/git/gestalt.c @@ -5,7 +5,7 @@ git_uint32 gestalt (enum GestaltSelector sel, git_uint32 param) switch (sel) { case GESTALT_SPEC_VERSION: - return 0x00030100; + return 0x00030101; case GESTALT_TERP_VERSION: return GIT_VERSION_NUM; diff --git a/interpreters/git/git_unix.c b/interpreters/git/git_unix.c index 04cfe60..2b9c6e3 100644 --- a/interpreters/git/git_unix.c +++ b/interpreters/git/git_unix.c @@ -25,23 +25,47 @@ glkunix_argumentlist_t glkunix_arguments[] = #define CACHE_SIZE (256 * 1024L) #define UNDO_SIZE (512 * 1024L) +int gHasInited = 0; + +#ifdef CHIMARA_EXTENSIONS + +void fatalError (const char * s) +{ + winid_t win; + if (!gHasInited) + { + win = glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + glk_set_window(win); + } + /* pray that this goes somewhere reasonable... */ + glk_put_string("\n*** fatal error: "); + glk_put_string((char*)s); + glk_put_string(" ***\n"); + glk_exit(); +} + +#else + void fatalError (const char * s) { fprintf (stderr, "*** fatal error: %s ***\n", s); exit (1); } +#endif /* CHIMARA_EXTENSIONS */ + #ifdef USE_MMAP // Fast loader that uses some fancy Unix features. const char * gFilename = 0; +char * gStartupError = 0; int glkunix_startup_code(glkunix_startup_t *data) { if (data->argc <= 1) { - printf ("usage: git gamefile.ulx\n"); - return 0; + gStartupError = "No file given"; + return 1; } gFilename = data->argv[1]; return 1; @@ -52,7 +76,10 @@ void glk_main () int file; struct stat info; const char * ptr; - + + if (gStartupError) + fatalError(gStartupError); + file = open (gFilename, O_RDONLY); if (file < 0) goto error; @@ -61,35 +88,35 @@ void glk_main () goto error; if (info.st_size < 256) - { - fprintf (stderr, "This is too small to be a glulx file.\n"); - exit (1); - } + fatalError("This is too small to be a glulx file."); ptr = mmap (NULL, info.st_size, PROT_READ, MAP_PRIVATE, file, 0); if (ptr == MAP_FAILED) goto error; + + gHasInited = 1; git (ptr, info.st_size, CACHE_SIZE, UNDO_SIZE); munmap ((void*) ptr, info.st_size); return; error: - perror ("git"); - exit (errno); + sprintf(errmsg, "git: %s", strerror(errno)); + fatalError(errmsg); } #else // Generic loader that should work anywhere. strid_t gStream = 0; +char * gStartupError = 0; int glkunix_startup_code(glkunix_startup_t *data) { if (data->argc <= 1) { - printf ("usage: git gamefile.ulx\n"); - return 0; + gStartupError = "No file given"; + return 1; } gStream = glkunix_stream_open_pathname ((char*) data->argv[1], 0, 0); return 1; @@ -97,9 +124,14 @@ int glkunix_startup_code(glkunix_startup_t *data) void glk_main () { + if (gStartupError) + fatalError(gStartupError); + if (gStream == NULL) fatalError ("could not open game file"); + gHasInited = 1; + gitWithStream (gStream, CACHE_SIZE, UNDO_SIZE); }