POSIX.1 National Language Support API for MinGW
Revisión | bfb799dd8c9655d53b9e7aaf478b2112a06fd0ca (tree) |
---|---|
Tiempo | 2008-01-11 07:47:42 |
Autor | Keith Marshall <keithmarshall@user...> |
Commiter | Keith Marshall |
* gencat.c: Delay writing the catalogue header until *after* the message data has been fully committed; store the ultimate catalogue size in the header record, then rewind to write header and index records sequentially.
@@ -1,3 +1,10 @@ | ||
1 | +2008-01-10 Keith Marshall <keithmarshall@users.sourceforge.net> | |
2 | + | |
3 | + * gencat.c: Delay writing the catalogue header until *after* the | |
4 | + message data has been fully committed; store the ultimate catalogue | |
5 | + size in the header record, then rewind to write header and index | |
6 | + records sequentially. | |
7 | + | |
1 | 8 | 2008-01-09 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 9 | |
3 | 10 | * README: Some minor wording improvements. |
@@ -258,12 +258,11 @@ int main( int argc, char **argv ) | ||
258 | 258 | return EXIT_FAILURE; |
259 | 259 | } |
260 | 260 | |
261 | - /* Write out the standard message catalogue header record, | |
262 | - * then seek beyond the space required for the index image, | |
263 | - * to commence writing out the message data. | |
261 | + /* Seek forward in the temporary output file, | |
262 | + * to reserve space into which we will later write the message | |
263 | + * catalogue header record, and the message index. | |
264 | 264 | */ |
265 | - write( mc, &cat_index, sizeof( MSGCAT ) ); | |
266 | - offset = lseek( mc, offset, SEEK_CUR ); | |
265 | + offset = lseek( mc, sizeof( MSGCAT ) + offset, SEEK_SET ); | |
267 | 266 | |
268 | 267 | /* Compute the offset, ON DISK, for the start of the message |
269 | 268 | * index, within the composite set and message index image, in |
@@ -309,12 +308,18 @@ int main( int argc, char **argv ) | ||
309 | 308 | offset += write( mc, curr->base + curr->loc, curr->len ); |
310 | 309 | } |
311 | 310 | |
312 | - /* Rewind the catalogue, to the start of the reserved index space... | |
311 | + /* Store the effective data size of the catalogue into the header. | |
313 | 312 | */ |
314 | - lseek( mc, sizeof( MSGCAT ), SEEK_SET ); | |
315 | - /* | |
316 | - * Locate the start of the in-memory image of the index, once more, | |
317 | - * and copy it into the generated message catalogue. | |
313 | + cat_index.mc.extent = offset; | |
314 | + | |
315 | + /* Rewind, and write out the message catalogue header record, | |
316 | + * at the start of the file space reserved previously. | |
317 | + */ | |
318 | + lseek( mc, 0L, SEEK_SET ); | |
319 | + write( mc, &cat_index, sizeof( MSGCAT ) ); | |
320 | + | |
321 | + /* Locate the start of the in-memory image of the index, once more, | |
322 | + * and copy it into the remaining reserved space in the output file. | |
318 | 323 | */ |
319 | 324 | set_index = msg_index - numsets - msgcount; |
320 | 325 | write( mc, set_index, (numsets + msgcount) * sizeof( struct key ) ); |
@@ -388,4 +393,4 @@ int main( int argc, char **argv ) | ||
388 | 393 | return EXIT_SUCCESS; |
389 | 394 | } |
390 | 395 | |
391 | -/* $RCSfile$Revision: 1.4 $: end of file */ | |
396 | +/* $RCSfile$Revision: 1.5 $: end of file */ |