small cleanups

found a few little things
This commit is contained in:
John Cupitt 2011-03-25 20:16:09 +00:00
parent 3b2416fb0e
commit c95aa263dd
7 changed files with 54 additions and 51 deletions

View File

@ -200,8 +200,6 @@ int vips_mapfilerw( VipsImage * );
int vips_remapfilerw( VipsImage * );
int im__write( int, const void *, size_t );
void im__change_suffix( const char *name, char *out, int mx,
const char *new_suff, const char **olds, int nolds );
int im__trigger_callbacks( GSList *cblist );
int im__close( VipsImage * );
int im__fft_sp( float *rvec, float *ivec, int logrows, int logcols );

View File

@ -8,20 +8,20 @@
extern "C" {
#endif /*__cplusplus*/
const char *im__gettext( const char *msgid );
const char *im__ngettext( const char *msgid,
const char *vips__gettext( const char *msgid );
const char *vips__ngettext( const char *msgid,
const char *plural, unsigned long int n );
#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) im__gettext(String)
#define _(String) vips__gettext(String)
/* ngettext may be defined as a macro if we're optimised.
*/
#ifdef ngettext
#undef ngettext
#endif /*ngettext*/
#define ngettext(String,Plural,number) im__ngettext(String,Plural,number)
#define ngettext(String,Plural,number) vips__ngettext(String,Plural,number)
#ifdef gettext_noop
#define N_(String) gettext_noop(String)
#else

View File

@ -239,6 +239,9 @@ int im_amiMSBfirst( void );
char *im__temp_name( const char *format );
void vips__change_suffix( const char *name, char *out, int mx,
const char *new_suff, const char **olds, int nolds );
#ifdef __cplusplus
}
#endif /*__cplusplus*/

View File

@ -350,6 +350,8 @@ VipsDemandStyle im_char2dhint( const char *str );
#define vips_bandfmt_isfloat vips_band_format_isfloat
#define vips_bandfmt_iscomplex vips_band_format_iscomplex
#define im__change_suffix vips__change_suffix
/* Buffer processing.
*/
typedef void (*im_wrapone_fn)( void *in, void *out, int width,

View File

@ -143,13 +143,13 @@ vips_get_argv0( void )
* int main( int argc, char **argv )
* {
* if( vips_init( argv[0] ) )
* error_exit( "unable to start VIPS" );
* vips_error_exit( "unable to start VIPS" );
*
* return( 0 );
* }
* ]|
*
* See also: im_get_option_group(), im_version(), vips_guess_prefix(),
* See also: vips_get_option_group(), vips_version(), vips_guess_prefix(),
* vips_guess_libdir().
*
* Returns: 0 on success, -1 otherwise
@ -249,7 +249,7 @@ vips_init( const char *argv0 )
}
const char *
im__gettext( const char *msgid )
vips__gettext( const char *msgid )
{
/* Pass in a nonsense name for argv0 ... this init path is only here
* for old programs which are missing an vips_init() call. We need
@ -262,7 +262,7 @@ im__gettext( const char *msgid )
}
const char *
im__ngettext( const char *msgid, const char *plural, unsigned long int n )
vips__ngettext( const char *msgid, const char *plural, unsigned long int n )
{
if( vips_init( "giant_banana" ) )
vips_error_clear();
@ -321,45 +321,6 @@ vips_get_option_group( void )
return( option_group );
}
/* Strip off any of a set of old suffixes (eg. [".v", ".jpg"]), add a single
* new suffix (eg. ".tif").
*/
void
im__change_suffix( const char *name, char *out, int mx,
const char *new, const char **olds, int nolds )
{
char *p;
int i;
int len;
/* Copy start string.
*/
im_strncpy( out, name, mx );
/* Drop all matching suffixes.
*/
while( (p = strrchr( out, '.' )) ) {
/* Found suffix - test against list of alternatives. Ignore
* case.
*/
for( i = 0; i < nolds; i++ )
if( g_ascii_strcasecmp( p, olds[i] ) == 0 ) {
*p = '\0';
break;
}
/* Found match? If not, break from loop.
*/
if( *p )
break;
}
/* Add new suffix.
*/
len = strlen( out );
im_strncpy( out + len, new, mx - len );
}
static char *
get_current_dir( void )
{
@ -622,7 +583,7 @@ vips_guess_prefix( const char *argv0, const char *env_name )
if( strlen( IM_EXEEXT ) > 0 ) {
const char *olds[] = { IM_EXEEXT };
im__change_suffix( p, name, PATH_MAX, IM_EXEEXT, olds, 1 );
vips__change_suffix( p, name, PATH_MAX, IM_EXEEXT, olds, 1 );
}
else
im_strncpy( name, p, PATH_MAX );

View File

@ -101,7 +101,7 @@
* over an image's fields, including all metadata.
*
* Items of metadata are identified by strings. Some strings are reserved, for
* example the ICC pofile for an image is known by convention as
* example the ICC profile for an image is known by convention as
* "icc-profile-data".
*
* If you save an image in VIPS format, all metadata (with a restriction, see

View File

@ -1396,3 +1396,42 @@ im__temp_name( const char *format )
return( name );
}
/* Strip off any of a set of old suffixes (eg. [".v", ".jpg"]), add a single
* new suffix (eg. ".tif").
*/
void
vips__change_suffix( const char *name, char *out, int mx,
const char *new, const char **olds, int nolds )
{
char *p;
int i;
int len;
/* Copy start string.
*/
im_strncpy( out, name, mx );
/* Drop all matching suffixes.
*/
while( (p = strrchr( out, '.' )) ) {
/* Found suffix - test against list of alternatives. Ignore
* case.
*/
for( i = 0; i < nolds; i++ )
if( g_ascii_strcasecmp( p, olds[i] ) == 0 ) {
*p = '\0';
break;
}
/* Found match? If not, break from loop.
*/
if( *p )
break;
}
/* Add new suffix.
*/
len = strlen( out );
im_strncpy( out + len, new, mx - len );
}