This commit is contained in:
John Cupitt 2009-11-26 16:52:27 +00:00
parent 8f2a3a6b67
commit 96c2204160
10 changed files with 80 additions and 62 deletions

View File

@ -1,3 +1,7 @@
26/11/09 started 7.20.3
- updated en_GB.po translation
- file_length is gint64 to avoid win32 breakage
23/11/09 started 7.20.2 23/11/09 started 7.20.2
- GETTEXT_PACKAGE now includes lib version number (thanks Jay) - GETTEXT_PACKAGE now includes lib version number (thanks Jay)

View File

@ -6,7 +6,7 @@ AC_CONFIG_MACRO_DIR(m4)
# user-visible library versioning # user-visible library versioning
IM_MAJOR_VERSION=7 IM_MAJOR_VERSION=7
IM_MINOR_VERSION=20 IM_MINOR_VERSION=20
IM_MICRO_VERSION=2 IM_MICRO_VERSION=3
IM_VERSION=$IM_MAJOR_VERSION.$IM_MINOR_VERSION.$IM_MICRO_VERSION IM_VERSION=$IM_MAJOR_VERSION.$IM_MINOR_VERSION.$IM_MICRO_VERSION
IM_VERSION_STRING=$IM_VERSION-`date` IM_VERSION_STRING=$IM_VERSION-`date`

View File

@ -227,8 +227,11 @@ typedef struct _VipsImage {
/* Record the file length here. We use this to stop ourselves mapping /* Record the file length here. We use this to stop ourselves mapping
* things beyond the end of the file in the case that the file has * things beyond the end of the file in the case that the file has
* been truncated. * been truncated.
*
* gint64 so that we can guarantee to work even on systems with
* strange ideas about large files.
*/ */
size_t file_length; gint64 file_length;
/* Set this when im_demand_hint_array() is called, and check in any /* Set this when im_demand_hint_array() is called, and check in any
* operation that will demand pixels from the image. * operation that will demand pixels from the image.

View File

@ -128,7 +128,7 @@ im_binfile( const char *name, int xsize, int ysize, int bands, int offset )
im_close( im ); im_close( im );
return( NULL ); return( NULL );
} }
im->file_length = (size_t) rsize; im->file_length = rsize;
/* Very common, so special message. /* Very common, so special message.
*/ */

View File

@ -107,24 +107,26 @@ im__mmap( int fd, int writeable, size_t length, gint64 offset )
void *baseaddr; void *baseaddr;
#ifdef DEBUG #ifdef DEBUG
printf( "im__mmap: length = %d, offset = %lld\n", length, offset ); printf( "im__mmap: length = 0x%zx, offset = 0x%lx\n", length, offset );
#endif /*DEBUG*/ #endif /*DEBUG*/
printf( "** start\n" );
printf( "length = 0x%zx\n", length );
printf( "offset = 0x%lx\n", (guint64) offset );
#ifdef OS_WIN32 #ifdef OS_WIN32
{ {
HANDLE hFile = (HANDLE) _get_osfhandle( fd ); HANDLE hFile = (HANDLE) _get_osfhandle( fd );
HANDLE hMMFile;
DWORD flProtect; DWORD flProtect;
DWORD dwDesiredAccess; DWORD dwDesiredAccess;
HANDLE hMMFile;
ULARGE_INTEGER quad;
DWORD dwFileOffsetHigh; DWORD dwFileOffsetHigh;
DWORD dwFileOffsetLow; DWORD dwFileOffsetLow;
/* woah, slightly gross
*/
int dws = sizeof( DWORD );
int shift = 8 * dws;
gint64 mask = ((gint64) -1) >> shift;
if( writeable ) { if( writeable ) {
flProtect = PAGE_READWRITE; flProtect = PAGE_READWRITE;
dwDesiredAccess = FILE_MAP_WRITE; dwDesiredAccess = FILE_MAP_WRITE;
@ -134,20 +136,29 @@ im__mmap( int fd, int writeable, size_t length, gint64 offset )
dwDesiredAccess = FILE_MAP_READ; dwDesiredAccess = FILE_MAP_READ;
} }
quad.QuadPart = offset;
dwFileOffsetLow = quad.LowPart;
dwFileOffsetHigh = quad.HighPart;
printf( "flProtect = 0x%x\n", flProtect );
printf( "flProtect = 0x%x\n", flProtect );
printf( "dwDesiredAccess = 0x%x\n", dwDesiredAccess );
printf( "dwFileOffsetHigh = 0x%x\n", dwFileOffsetHigh );
printf( "dwFileOffsetLow = 0x%x\n", dwFileOffsetLow );
if( !(hMMFile = CreateFileMapping( hFile, if( !(hMMFile = CreateFileMapping( hFile,
NULL, flProtect, 0, 0, NULL )) ) { NULL, flProtect, 0, 0, NULL )) ) {
im_error_system( GetLastError(), "im_mapfile", im_error_system( GetLastError(), "im_mapfile",
"%s", _( "unable to CreateFileMapping" ) ); "%s", _( "unable to CreateFileMapping" ) );
printf( "CreateFileMapping failed: %s\n", im_error_buffer() );
return( NULL ); return( NULL );
} }
dwFileOffsetHigh = (offset >> shift) & mask;
dwFileOffsetLow = offset & mask;
if( !(baseaddr = (char *)MapViewOfFile( hMMFile, dwDesiredAccess, if( !(baseaddr = (char *)MapViewOfFile( hMMFile, dwDesiredAccess,
dwFileOffsetHigh, dwFileOffsetLow, length )) ) { dwFileOffsetHigh, dwFileOffsetLow, length )) ) {
im_error_system( GetLastError(), "im_mapfile", im_error_system( GetLastError(), "im_mapfile",
"%s", _( "unable to MapViewOfFile" ) ); "%s", _( "unable to MapViewOfFile" ) );
printf( "MapViewOfFile failed: %s\n", im_error_buffer() );
CloseHandle( hMMFile ); CloseHandle( hMMFile );
return( NULL ); return( NULL );
} }
@ -184,6 +195,8 @@ im__mmap( int fd, int writeable, size_t length, gint64 offset )
} }
#endif /*OS_WIN32*/ #endif /*OS_WIN32*/
printf( "** success\n" );
return( baseaddr ); return( baseaddr );
} }
@ -219,17 +232,17 @@ im_mapfile( IMAGE *im )
* an error. * an error.
*/ */
g_assert( im->file_length > 0 ); g_assert( im->file_length > 0 );
if( im->file_length < 64 ) {
im_error( "im_mapfile",
"%s", _( "file is less than 64 bytes" ) );
return( -1 );
}
if( fstat( im->fd, &st ) == -1 ) { if( fstat( im->fd, &st ) == -1 ) {
im_error( "im_mapfile", im_error( "im_mapfile",
"%s", _( "unable to get file status" ) ); "%s", _( "unable to get file status" ) );
return( -1 ); return( -1 );
} }
m = (mode_t) st.st_mode; m = (mode_t) st.st_mode;
if( im->file_length < 64 ) {
im_error( "im_mapfile",
"%s", _( "file is less than 64 bytes" ) );
return( -1 );
}
if( !S_ISREG( m ) ) { if( !S_ISREG( m ) ) {
im_error( "im_mapfile", im_error( "im_mapfile",
"%s", _( "not a regular file" ) ); "%s", _( "not a regular file" ) );

View File

@ -1203,8 +1203,7 @@ im_openin( IMAGE *image )
*/ */
size = (gint64) IM_IMAGE_SIZEOF_LINE( image ) * image->Ysize + size = (gint64) IM_IMAGE_SIZEOF_LINE( image ) * image->Ysize +
image->sizeof_header; image->sizeof_header;
if( size < im__mmap_limit && if( size < im__mmap_limit && image->file_length >= size ) {
(gint64) image->file_length >= size ) {
if( im_mapfile( image ) ) if( im_mapfile( image ) )
return( -1 ); return( -1 );
image->data = image->baseaddr + image->sizeof_header; image->data = image->baseaddr + image->sizeof_header;

View File

@ -225,13 +225,17 @@ im_window_set( im_window_t *window, int top, int height )
(gint64) IM_IMAGE_SIZEOF_LINE( window->im ) * top; (gint64) IM_IMAGE_SIZEOF_LINE( window->im ) * top;
length = (size_t) IM_IMAGE_SIZEOF_LINE( window->im ) * height; length = (size_t) IM_IMAGE_SIZEOF_LINE( window->im ) * height;
printf( "start = 0x%lx\n", (guint64) start );
pagestart = start - start % pagesize; pagestart = start - start % pagesize;
end = start + length; end = start + length;
pagelength = end - pagestart; pagelength = end - pagestart;
printf( "pagestart = 0x%lx\n", (guint64) pagestart );
/* Make sure we have enough file. /* Make sure we have enough file.
*/ */
if( end > (gint64) window->im->file_length ) { if( end > window->im->file_length ) {
im_error( "im_window_set", im_error( "im_window_set",
_( "unable to read data for \"%s\", %s" ), _( "unable to read data for \"%s\", %s" ),
window->im->filename, _( "file has been truncated" ) ); window->im->filename, _( "file has been truncated" ) );

View File

@ -28,7 +28,7 @@ cd vips-7.x.x ; find */* -name "*.h" >> po/POTFILES.in
intltool-update --pot intltool-update --pot
make a new vips7.pot translation template from the sources make a new vips-7.20.pot translation template from the sources
:%s/msgstr ""/msgstr "Malkovich"/ :%s/msgstr ""/msgstr "Malkovich"/
:%s/msgstr\[0\] ""/msgstr[0] "Malkovich"/ :%s/msgstr\[0\] ""/msgstr[0] "Malkovich"/

Binary file not shown.

View File

@ -1,11 +1,12 @@
# test translation file # en_GB translations for vips
# just swap color for colour
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vips 7.16.0\n" "Project-Id-Version: vips 7.20.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-11-23 21:24+0000\n" "POT-Creation-Date: 2009-11-26 16:43+0000\n"
"PO-Revision-Date: Fri Sep 5 10:27:43 BST 2008\n" "PO-Revision-Date: Thu Nov 26 12:08:20 GMT 2009\n"
"Last-Translator: john <jcupitt@gmail.com>\n" "Last-Translator: john <jcupitt@gmail.com>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -416,7 +417,7 @@ msgid "display unknown"
msgstr "" msgstr ""
#: libvips/conversion/im_zoom.c:332 libvips/format/im_vips2tiff.c:1589 #: libvips/conversion/im_zoom.c:332 libvips/format/im_vips2tiff.c:1589
#: libvips/format/im_file2vips.c:761 libvips/iofuncs/im_open_vips.c:1321 #: libvips/format/im_file2vips.c:761 libvips/iofuncs/im_open_vips.c:1320
#: libvips/mosaicing/im_tbmerge.c:634 libvips/mosaicing/im_lrmerge.c:812 #: libvips/mosaicing/im_tbmerge.c:634 libvips/mosaicing/im_lrmerge.c:812
#: libvips/resample/im_shrink.c:318 libvips/resample/im_affine.c:442 #: libvips/resample/im_shrink.c:318 libvips/resample/im_affine.c:442
msgid "unknown coding type" msgid "unknown coding type"
@ -493,9 +494,8 @@ msgid "vectors not same length"
msgstr "" msgstr ""
#: libvips/conversion/im_black.c:87 libvips/conversion/im_gaussnoise.c:124 #: libvips/conversion/im_black.c:87 libvips/conversion/im_gaussnoise.c:124
#, fuzzy
msgid "bad parameter" msgid "bad parameter"
msgstr "bad colourmap" msgstr ""
#: libvips/conversion/im_bandjoin.c:127 #: libvips/conversion/im_bandjoin.c:127
msgid "images not same size" msgid "images not same size"
@ -709,9 +709,8 @@ msgid "im_setupout failed"
msgstr "" msgstr ""
#: libvips/deprecated/im_slice.c:151 libvips/deprecated/im_thresh.c:127 #: libvips/deprecated/im_slice.c:151 libvips/deprecated/im_thresh.c:127
#, fuzzy
msgid "Unknown input format" msgid "Unknown input format"
msgstr "unsupported colourspace %d" msgstr ""
#. Name #. Name
#: libvips/deprecated/deprecated_dispatch.c:127 #: libvips/deprecated/deprecated_dispatch.c:127
@ -747,14 +746,12 @@ msgid "input must be uncoded"
msgstr "" msgstr ""
#: libvips/deprecated/im_printlines.c:85 #: libvips/deprecated/im_printlines.c:85
#, fuzzy
msgid "unsuitable image type" msgid "unsuitable image type"
msgstr "unsupported colourspace %d" msgstr ""
#: libvips/deprecated/im_printlines.c:144 libvips/deprecated/im_debugim.c:133 #: libvips/deprecated/im_printlines.c:144 libvips/deprecated/im_debugim.c:133
#, fuzzy
msgid "unknown input format" msgid "unknown input format"
msgstr "unsupported colourspace %d" msgstr ""
#: libvips/deprecated/im_convsub.c:82 #: libvips/deprecated/im_convsub.c:82
msgid "calloc failed (1)" msgid "calloc failed (1)"
@ -1069,9 +1066,9 @@ msgid "file \"%s\" not a known format"
msgstr "" msgstr ""
#: libvips/format/format.c:320 #: libvips/format/format.c:320
#, fuzzy, c-format #, c-format
msgid "\"%s\" is not a supported image format." msgid "\"%s\" is not a supported image format."
msgstr "unsupported colourspace %d" msgstr ""
#: libvips/format/im_analyze2vips.c:371 #: libvips/format/im_analyze2vips.c:371
#, c-format #, c-format
@ -1170,7 +1167,7 @@ msgstr ""
msgid "unable to read header for \"%s\", %s" msgid "unable to read header for \"%s\", %s"
msgstr "" msgstr ""
#: libvips/format/im_file2vips.c:644 libvips/iofuncs/window.c:237 #: libvips/format/im_file2vips.c:644 libvips/iofuncs/window.c:241
#: libvips/iofuncs/im_open_vips.c:965 libvips/iofuncs/im_open_vips.c:1160 #: libvips/iofuncs/im_open_vips.c:965 libvips/iofuncs/im_open_vips.c:1160
msgid "file has been truncated" msgid "file has been truncated"
msgstr "" msgstr ""
@ -1346,9 +1343,8 @@ msgid "mask sizes power of 2 only"
msgstr "" msgstr ""
#: libvips/freq_filt/im_freq_mask.c:194 #: libvips/freq_filt/im_freq_mask.c:194
#, fuzzy
msgid "unimplemented mask type" msgid "unimplemented mask type"
msgstr "unsupported colourspace %d" msgstr ""
#: libvips/freq_filt/fmaskcir.c:163 libvips/freq_filt/fmaskcir.c:308 #: libvips/freq_filt/fmaskcir.c:163 libvips/freq_filt/fmaskcir.c:308
#: libvips/freq_filt/fmaskcir.c:399 libvips/freq_filt/fmaskcir.c:481 #: libvips/freq_filt/fmaskcir.c:399 libvips/freq_filt/fmaskcir.c:481
@ -1571,9 +1567,8 @@ msgid "not uncoded"
msgstr "" msgstr ""
#: libvips/histograms_lut/im_histspec.c:97 #: libvips/histograms_lut/im_histspec.c:97
#, fuzzy
msgid "bad band format" msgid "bad band format"
msgstr "bad colourmap" msgstr ""
#: libvips/histograms_lut/im_histspec.c:102 #: libvips/histograms_lut/im_histspec.c:102
msgid "input histograms differ in number of bands" msgid "input histograms differ in number of bands"
@ -1681,7 +1676,7 @@ msgstr ""
msgid "unable to output to a %s image" msgid "unable to output to a %s image"
msgstr "" msgstr ""
#: libvips/iofuncs/window.c:236 libvips/iofuncs/im_open_vips.c:1159 #: libvips/iofuncs/window.c:240 libvips/iofuncs/im_open_vips.c:1159
#, c-format #, c-format
msgid "unable to read data for \"%s\", %s" msgid "unable to read data for \"%s\", %s"
msgstr "" msgstr ""
@ -1974,7 +1969,7 @@ msgstr ""
msgid "xml save error" msgid "xml save error"
msgstr "" msgstr ""
#: libvips/iofuncs/im_open_vips.c:1271 #: libvips/iofuncs/im_open_vips.c:1270
msgid "open for read-write for native format images only" msgid "open for read-write for native format images only"
msgstr "" msgstr ""
@ -2152,54 +2147,54 @@ msgstr ""
msgid "bad format" msgid "bad format"
msgstr "bad colourmap" msgstr "bad colourmap"
#: libvips/iofuncs/im_mapfile.c:140 libvips/iofuncs/im_mapfile.c:297 #: libvips/iofuncs/im_mapfile.c:152 libvips/iofuncs/im_mapfile.c:310
msgid "unable to CreateFileMapping" msgid "unable to CreateFileMapping"
msgstr "" msgstr ""
#: libvips/iofuncs/im_mapfile.c:150 libvips/iofuncs/im_mapfile.c:309 #: libvips/iofuncs/im_mapfile.c:160 libvips/iofuncs/im_mapfile.c:322
msgid "unable to MapViewOfFile" msgid "unable to MapViewOfFile"
msgstr "" msgstr ""
#: libvips/iofuncs/im_mapfile.c:178 #: libvips/iofuncs/im_mapfile.c:189
msgid "unable to mmap" msgid "unable to mmap"
msgstr "" msgstr ""
#: libvips/iofuncs/im_mapfile.c:179 #: libvips/iofuncs/im_mapfile.c:190
#, c-format #, c-format
msgid "" msgid ""
"map failed (%s), running very low on system resources, expect a crash soon" "map failed (%s), running very low on system resources, expect a crash soon"
msgstr "" msgstr ""
#: libvips/iofuncs/im_mapfile.c:196 libvips/iofuncs/im_mapfile.c:303 #: libvips/iofuncs/im_mapfile.c:209 libvips/iofuncs/im_mapfile.c:316
msgid "unable to UnmapViewOfFile" msgid "unable to UnmapViewOfFile"
msgstr "" msgstr ""
#: libvips/iofuncs/im_mapfile.c:202 #: libvips/iofuncs/im_mapfile.c:215
msgid "unable to munmap file" msgid "unable to munmap file"
msgstr "" msgstr ""
#: libvips/iofuncs/im_mapfile.c:224 libvips/iofuncs/im_mapfile.c:263 #: libvips/iofuncs/im_mapfile.c:237
msgid "unable to get file status"
msgstr ""
#: libvips/iofuncs/im_mapfile.c:230
msgid "file is less than 64 bytes" msgid "file is less than 64 bytes"
msgstr "" msgstr ""
#: libvips/iofuncs/im_mapfile.c:235 #: libvips/iofuncs/im_mapfile.c:242 libvips/iofuncs/im_mapfile.c:276
msgid "unable to get file status"
msgstr ""
#: libvips/iofuncs/im_mapfile.c:248
msgid "not a regular file" msgid "not a regular file"
msgstr "" msgstr ""
#: libvips/iofuncs/im_mapfile.c:269 #: libvips/iofuncs/im_mapfile.c:282
msgid "unable to read data" msgid "unable to read data"
msgstr "" msgstr ""
#: libvips/iofuncs/im_mapfile.c:329 #: libvips/iofuncs/im_mapfile.c:342
#, c-format #, c-format
msgid "unable to mmap: \"%s\" - %s" msgid "unable to mmap: \"%s\" - %s"
msgstr "" msgstr ""
#: libvips/iofuncs/im_mapfile.c:339 #: libvips/iofuncs/im_mapfile.c:352
#, c-format #, c-format
msgid "unable to mmap \"%s\" to same address" msgid "unable to mmap \"%s\" to same address"
msgstr "" msgstr ""
@ -2858,9 +2853,9 @@ msgstr ""
#: tools/mosaicing/mergeup.c:269 tools/mosaicing/mergeup.c:279 #: tools/mosaicing/mergeup.c:269 tools/mosaicing/mergeup.c:279
#: tools/mosaicing/mergeup.c:288 tools/mosaicing/mergeup.c:309 #: tools/mosaicing/mergeup.c:288 tools/mosaicing/mergeup.c:309
#: tools/mosaicing/mergeup.c:319 tools/mosaicing/mergeup.c:328 #: tools/mosaicing/mergeup.c:319 tools/mosaicing/mergeup.c:328
#, fuzzy, c-format #, c-format
msgid "bad file name format '%s'" msgid "bad file name format '%s'"
msgstr "bad colourmap" msgstr ""
#: tools/mosaicing/mergeup.c:380 #: tools/mosaicing/mergeup.c:380
msgid "allocation failure in mergeup" msgid "allocation failure in mergeup"