git: Line endings of README.txt
[projects/chimara/chimara.git] / interpreters / git.patch
1 diff -P'aurx.*' git-1.2.4/gestalt.c git-chimara/gestalt.c
2 --- git-1.2.4/gestalt.c 2009-04-03 00:54:50.000000000 +0200
3 +++ git-chimara/gestalt.c       2009-10-07 23:43:28.000000000 +0200
4 @@ -5,7 +5,7 @@
5      switch (sel)
6      {
7          case GESTALT_SPEC_VERSION:
8 -            return 0x00030100;
9 +            return 0x00030101;
10      
11          case GESTALT_TERP_VERSION:
12              return GIT_VERSION_NUM;
13 Only in git-1.2.4: git_mac.c
14 diff -P'aurx.*' git-1.2.4/git_unix.c git-chimara/git_unix.c
15 --- git-1.2.4/git_unix.c        2009-04-03 00:54:50.000000000 +0200
16 +++ git-chimara/git_unix.c      2009-10-07 23:59:58.000000000 +0200
17 @@ -25,23 +25,47 @@
18  #define CACHE_SIZE (256 * 1024L)
19  #define UNDO_SIZE (512 * 1024L)
20  
21 +int gHasInited = 0;
22 +
23 +#ifdef CHIMARA_EXTENSIONS
24 +
25 +void fatalError (const char * s)
26 +{
27 +       winid_t win;
28 +       if (!gHasInited)
29 +       {
30 +               win = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
31 +               glk_set_window(win);
32 +       }
33 +       /* pray that this goes somewhere reasonable... */
34 +       glk_put_string("\n*** fatal error: ");
35 +       glk_put_string((char*)s);
36 +       glk_put_string(" ***\n");
37 +       glk_exit();
38 +}
39 +
40 +#else
41 +
42  void fatalError (const char * s)
43  {
44      fprintf (stderr, "*** fatal error: %s ***\n", s);
45      exit (1);
46  }
47  
48 +#endif /* CHIMARA_EXTENSIONS */
49 +
50  #ifdef USE_MMAP
51  // Fast loader that uses some fancy Unix features.
52  
53  const char * gFilename = 0;
54 +char * gStartupError = 0;
55  
56  int glkunix_startup_code(glkunix_startup_t *data)
57  {
58      if (data->argc <= 1)
59      {
60 -        printf ("usage: git gamefile.ulx\n");
61 -        return 0;
62 +        gStartupError = "No file given";
63 +        return 1;
64      }
65      gFilename = data->argv[1];
66      return 1;
67 @@ -52,7 +76,10 @@
68      int          file;
69      struct stat  info;
70      const char * ptr;
71 -    
72 +
73 +       if (gStartupError)
74 +               fatalError(gStartupError);
75 +
76      file = open (gFilename, O_RDONLY);
77      if (file < 0)
78          goto error;
79 @@ -61,35 +88,35 @@
80          goto error;
81      
82      if (info.st_size < 256)
83 -    {
84 -        fprintf (stderr, "This is too small to be a glulx file.\n");
85 -        exit (1);
86 -    }
87 +               fatalError("This is too small to be a glulx file.");
88  
89      ptr = mmap (NULL, info.st_size, PROT_READ, MAP_PRIVATE, file, 0);
90      if (ptr == MAP_FAILED)
91          goto error;
92 +
93 +       gHasInited = 1;
94          
95      git (ptr, info.st_size, CACHE_SIZE, UNDO_SIZE);
96      munmap ((void*) ptr, info.st_size);
97      return;
98      
99  error:
100 -    perror ("git");
101 -    exit (errno);
102 +       sprintf(errmsg, "git: %s", strerror(errno));
103 +    fatalError(errmsg);
104  }
105  
106  #else
107  // Generic loader that should work anywhere.
108  
109  strid_t gStream = 0;
110 +char * gStartupError = 0;
111  
112  int glkunix_startup_code(glkunix_startup_t *data)
113  {
114      if (data->argc <= 1)
115      {
116 -        printf ("usage: git gamefile.ulx\n");
117 -        return 0;
118 +        gStartupError = "No file given";
119 +        return 1;
120      }
121      gStream = glkunix_stream_open_pathname ((char*) data->argv[1], 0, 0);
122      return 1;
123 @@ -97,9 +124,14 @@
124  
125  void glk_main ()
126  {
127 +       if (gStartupError)
128 +               fatalError(gStartupError);
129 +
130      if (gStream == NULL)
131          fatalError ("could not open game file");
132  
133 +       gHasInited = 1;
134 +
135      gitWithStream (gStream, CACHE_SIZE, UNDO_SIZE);
136  }
137  
138 Only in git-1.2.4: git_windows.c
139 Only in git-1.2.4: Makefile
140 diff -P'aurx.*' git-1.2.4/Makefile.am git-chimara/Makefile.am
141 --- git-1.2.4/Makefile.am       1970-01-01 01:00:00.000000000 +0100
142 +++ git-chimara/Makefile.am     2009-10-07 23:59:34.000000000 +0200
143 @@ -0,0 +1,48 @@
144 +PLUGIN_LIBTOOL_FLAGS=-module -avoid-version -export-symbols-regex "^glk"
145 +
146 +# Automatically generate version.h
147 +MAJOR = 1
148 +MINOR = 2
149 +PATCH = 4
150 +version.h: Makefile
151 +       echo "// Automatically generated file -- do not edit!" > version.h
152 +       echo "#define GIT_MAJOR" $(MAJOR) >> version.h
153 +       echo "#define GIT_MINOR" $(MINOR) >> version.h
154 +       echo "#define GIT_PATCH" $(PATCH) >> version.h
155 +
156 +pkglib_LTLIBRARIES = git.la
157 +BUILT_SOURCES = version.h
158 +git_la_SOURCES = version.h git.h config.h compiler.h memory.h opcodes.h \
159 +    labels.inc compiler.c gestalt.c git.c git_unix.c glkop.c heap.c memory.c \
160 +    opcodes.c operands.c peephole.c savefile.c saveundo.c search.c terp.c \
161 +    accel.c
162 +git_la_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/libchimara
163 +git_la_CFLAGS = -DCHIMARA_EXTENSIONS -DUSE_INLINE $(AM_CFLAGS)
164 +git_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
165 +
166 +gitdocdir = $(datadir)/doc/$(PACKAGE)/git
167 +dist_gitdoc_DATA = README.txt
168 +
169 +CLEANFILES = test/*.tmp
170 +
171 +#TESTS = test/test.sh \
172 +#      test/Alabaster.gblorb test/Alabaster.walk test/Alabaster.golden
173 +#
174 +#test: git
175 +#      sh test/test.sh
176 +
177 +# Memory mapping (-DUSE_MMAP) doesn't seem to work... FIXME
178 +
179 +# Best settings for GCC 2.95. This generates faster code than
180 +# GCC 3, so you should use this setup if possible.
181 +#CC = gcc -Wall -O3
182 +#OPTIONS = -DUSE_DIRECT_THREADING -DUSE_MMAP -DUSE_INLINE
183 +#
184 +# Best settings for GCC 3. The optimiser in this version of GCC
185 +# is somewhat broken, so we can't use USE_DIRECT_THREADING.
186 +#CC = gcc -Wall -O3
187 +#OPTIONS = -DUSE_MMAP -DUSE_INLINE
188 +#
189 +# Mac OS X (PowerPC) settings.
190 +#CC = gcc2 -Wall -O3 -no-cpp-precomp
191 +#OPTIONS = -DUSE_DIRECT_THREADING -DUSE_BIG_ENDIAN_UNALIGNED -DUSE_MMAP -DUSE_INLINE
192 Only in git-1.2.4: Makefile.win
193 Only in git-1.2.4: win