Mercurial > hg > xemacs-beta
annotate lib-src/insert-data-in-exec.c @ 4604:e0a8715fdb1f
Support new IGNORE-INVALID-SEQUENCESP argument, #'query-coding-region.
lisp/ChangeLog addition:
2009-02-07 Aidan Kehoe <kehoea@parhasard.net>
* coding.el (query-coding-clear-highlights):
Rename the BUFFER argument to BUFFER-OR-STRING, describe it as
possibly being a string in its documentation.
(default-query-coding-region):
Add a new IGNORE-INVALID-SEQUENCESP argument, document that this
function does not support it.
Bind case-fold-search to nil, we don't want this to influence what the
function thinks is encodable or not.
(query-coding-region):
Add a new IGNORE-INVALID-SEQUENCESP argument, document what it
does; reflect this new argument in the associated compiler macro.
(query-coding-string):
Add a new IGNORE-INVALID-SEQUENCESP argument, document what it
does. Support the HIGHLIGHT argument correctly.
* unicode.el (unicode-query-coding-region):
Add a new IGNORE-INVALID-SEQUENCESP argument, document what it
does, implement this. Document a potential problem.
Use #'query-coding-clear-highlights instead of reimplementing it
ourselves.
Remove some debugging messages.
* mule/arabic.el (iso-8859-6):
* mule/cyrillic.el (iso-8859-5):
* mule/greek.el (iso-8859-7):
* mule/hebrew.el (iso-8859-8):
* mule/latin.el (iso-8859-2):
* mule/latin.el (iso-8859-3):
* mule/latin.el (iso-8859-4):
* mule/latin.el (iso-8859-14):
* mule/latin.el (iso-8859-15):
* mule/latin.el (iso-8859-16):
* mule/latin.el (iso-8859-9):
* mule/latin.el (windows-1252):
* mule/mule-coding.el (iso-8859-1):
Avoid the assumption that characters not given an explicit mapping
in these coding systems map to the ISO 8859-1 characters
corresponding to the octets on disk; this makes it much more
reasonable to implement the IGNORE-INVALID-SEQUENCESP argument to
query-coding-region.
* mule/mule-cmds.el (set-language-info):
Correct the docstring.
* mule/mule-cmds.el (finish-set-language-environment):
Treat invalid Unicode sequences produced from
invalid-sequence-coding-system and corresponding to control
characters the same as control characters in redisplay.
* mule/mule-cmds.el:
Document that encode-coding-char is available in coding.el
* mule/mule-coding.el (make-8-bit-generate-helper):
Change to return the both the encode-program generated and the
relevant non-ASCII charset; update the docstring to reflect this.
* mule/mule-coding.el
(make-8-bit-generate-encode-program-and-skip-chars-strings):
Rename this function; have it return skip-chars-strings as well as
the encode program. Have these skip-chars-strings use ranges for
charsets, where possible.
* mule/mule-coding.el (make-8-bit-create-decode-encode-tables):
Revise this to allow people to specify explicitly characters that
should be undefined (= corresponding to keys in
unicode-error-default-translation-table), and treating unspecified
octets above #x7f as undefined by default.
* mule/mule-coding.el (8-bit-fixed-query-coding-region):
Add a new IGNORE-INVALID-SEQUENCESP argument, implement support
for it using the 8-bit-fixed-invalid-sequences-skip-chars coding
system property; remove some debugging messages.
* mule/mule-coding.el (make-8-bit-coding-system):
This function is dumped, autoloading it makes no sense.
Document what happens when characters above #x7f are not
specified, implement this.
* mule/vietnamese.el:
Correct spelling.
tests/ChangeLog addition:
2009-02-07 Aidan Kehoe <kehoea@parhasard.net>
* automated/query-coding-tests.el:
Add FAILING-CASE arguments to the Assert calls, making #'q-c-debug
mostly unnecessary. Remove #'q-c-debug.
Add new tests that use the IGNORE-INVALID-SEQUENCESP argument to
#'query-coding-region; rework the existing ones to respect it.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 07 Feb 2009 17:13:37 +0000 |
parents | 261c5cd19207 |
children | dfc9fe46c294 |
rev | line source |
---|---|
2015 | 1 /* Copies the dump file inside the xemacs executable */ |
2 | |
3 #include <stdio.h> | |
4 #include <stdlib.h> | |
5 #include <string.h> | |
6 | |
7 static const unsigned char key[] = { | |
8 255, | |
9 6, | |
10 1, | |
11 2, | |
12 3, | |
13 4, | |
14 255, | |
15 3, | |
16 9, | |
17 62, | |
18 255, | |
19 10, | |
20 4, | |
21 61, | |
22 255 | |
23 }; | |
24 | |
25 int main(int argc, char **argv) | |
26 { | |
27 FILE *te, *xe, *dump; | |
28 unsigned char *xed, *p; | |
29 long size, size_dump, size1, i; | |
30 long max_size, offset; | |
31 | |
32 char msg[65536]; | |
33 | |
34 if(argc != 6 && (argc != 3 || strcmp(argv[1], "-s"))) { | |
35 fprintf(stderr, "Usage:\n%s temacs xemacs.dmp xemacs size offset\n%s -s xemacs.dmp\n", argv[0], argv[0]); | |
36 exit(1); | |
37 } | |
38 | |
39 if(argc == 3) { | |
40 sprintf(msg, "Opening %s failed", argv[2]); | |
41 dump = fopen(argv[2], "rb+"); | |
42 if(!dump) { | |
43 perror(msg); | |
44 exit(1); | |
45 } | |
46 | |
47 if(fseek(dump, 0, SEEK_END)) { | |
48 perror("fseek end dump"); | |
49 exit(1); | |
50 } | |
51 | |
52 size = ftell(dump); | |
53 if(size == -1) { | |
54 perror("ftell dump"); | |
55 exit(1); | |
56 } | |
57 | |
58 printf("%ld\n", size); | |
59 exit(0); | |
60 } | |
61 | |
62 | |
63 max_size = strtol(argv[4], 0, 10); | |
64 offset = strtol(argv[5], 0, 10); | |
65 | |
66 sprintf(msg, "Opening %s failed", argv[1]); | |
67 te = fopen(argv[1], "rb"); | |
68 if(!te) { | |
69 perror(msg); | |
70 exit(1); | |
71 } | |
72 | |
73 if(fseek(te, 0, SEEK_END)) { | |
74 perror("fseek end"); | |
75 exit(1); | |
76 } | |
77 | |
78 size = ftell(te); | |
79 if(size == -1) { | |
80 perror("ftell"); | |
81 exit(1); | |
82 } | |
83 | |
84 if(fseek(te, 0, SEEK_SET)) { | |
85 perror("fseek beginning"); | |
86 exit(1); | |
87 } | |
88 | |
89 xed = malloc(size); | |
90 if(!xed) { | |
91 perror("malloc"); | |
92 exit(1); | |
93 } | |
94 | |
95 size1 = fread(xed, 1, size, te); | |
96 if(size1 != size) { | |
97 if(ferror(te)) { | |
98 perror("fread temacs"); | |
99 exit(1); | |
100 } | |
101 fprintf(stderr, "Fread returned %ld, expected %ld ?\n", size1, size); | |
102 exit(1); | |
103 } | |
104 | |
105 if(fclose(te)) { | |
106 perror("fclose temacs"); | |
107 exit(1); | |
108 } | |
109 | |
110 p = xed; | |
111 for(i=0; i<size-(long)sizeof(key); i++) { | |
112 if(!memcmp(p, key, sizeof(key))) | |
113 goto found; | |
114 p++; | |
115 } | |
116 | |
117 fprintf(stderr, "dumped_data key not found in executable.\n"); | |
118 exit(1); | |
119 | |
120 found: | |
121 fprintf(stderr, "dumped_data found at offset 0x%lx, patching.\n", i); | |
122 | |
123 sprintf(msg, "Opening %s failed", argv[2]); | |
2502 | 124 dump = fopen(argv[2], "rb"); |
2015 | 125 if(!dump) { |
126 perror(msg); | |
127 exit(1); | |
128 } | |
129 | |
130 if(fseek(dump, 0, SEEK_END)) { | |
131 perror("fseek end dump"); | |
132 exit(1); | |
133 } | |
134 | |
135 size_dump = ftell(dump); | |
136 if(size_dump == -1) { | |
137 perror("ftell dump"); | |
138 exit(1); | |
139 } | |
140 | |
141 if(size_dump > max_size) { | |
2022 | 142 fprintf(stderr, "Dump file too big for available space (max=%ld, dump=%ld)\n", max_size, size_dump); |
2015 | 143 exit(2); |
144 } | |
145 | |
146 if(fseek(dump, 0, SEEK_SET)) { | |
147 perror("fseek beginning dump"); | |
148 exit(1); | |
149 } | |
150 | |
151 size1 = fread(xed+i+offset, 1, size_dump, dump); | |
152 if(size1 != size_dump) { | |
153 if(ferror(dump)) { | |
154 perror("fread dump"); | |
155 exit(1); | |
156 } | |
157 fprintf(stderr, "Fread dump returned %ld, expected %ld ?\n", size1, size_dump); | |
158 exit(1); | |
159 } | |
160 | |
161 if(fclose(dump)) { | |
162 perror("fclose dump"); | |
163 exit(1); | |
164 } | |
165 | |
166 memset(xed+i, 0, offset); | |
167 | |
168 xed[i ] = size_dump; | |
169 xed[i+1] = size_dump >> 8; | |
170 xed[i+2] = size_dump >> 16; | |
171 xed[i+3] = size_dump >> 24; | |
172 | |
173 fprintf(stderr, "dumped_data found at offset 0x%lx, patching.\n", i); | |
174 | |
175 sprintf(msg, "Opening %s failed", argv[3]); | |
176 xe = fopen(argv[3], "wb"); | |
177 if(!xe) { | |
178 perror(msg); | |
179 exit(1); | |
180 } | |
181 | |
182 size1 = fwrite(xed, 1, size, xe); | |
183 if(size1 != size) { | |
184 if(ferror(xe)) { | |
185 perror("fwrite xemacs"); | |
186 exit(1); | |
187 } | |
188 fprintf(stderr, "Fwrite xemacs returned %ld, expected %ld ?\n", size1, size); | |
189 exit(1); | |
190 } | |
191 | |
192 if(fclose(xe)) { | |
193 perror("fclose xemacs"); | |
194 exit(1); | |
195 } | |
196 | |
197 exit(0); | |
198 } | |
199 |