From: <and...@us...> - 2011-10-14 07:08:02
|
Revision: 11965 http://plplot.svn.sourceforge.net/plplot/?rev=11965&view=rev Author: andrewross Date: 2011-10-14 07:07:52 +0000 (Fri, 14 Oct 2011) Log Message: ----------- Fix a number of warnings when compiling with -std=c99 -pedantic. These mostly include - missing / incomplete function prototype - local variables shadowing global variable / types. - missing const attribute for char * Modified Paths: -------------- trunk/lib/csa/csa.c trunk/lib/csa/csa.h trunk/lib/csa/version.h trunk/lib/nn/delaunay.c trunk/lib/nn/hash.c trunk/lib/nn/istack.h trunk/lib/nn/nn.h trunk/lib/nn/nnai.c trunk/lib/nn/nncommon.c trunk/lib/nn/nnpi.c trunk/lib/nn/version.h trunk/lib/qsastime/deltaT-gen.c trunk/lib/qsastime/qsastime.c trunk/lib/qsastime/tai-utc-gen.c Modified: trunk/lib/csa/csa.c =================================================================== --- trunk/lib/csa/csa.c 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/csa/csa.c 2011-10-14 07:07:52 UTC (rev 11965) @@ -132,7 +132,9 @@ int nppc; // average number of points per square }; -static void csa_quit( char* format, ... ) +void csa_setnppc( csa* a, double nppc ); + +static void csa_quit( const char* format, ... ) { va_list args; @@ -671,8 +673,8 @@ for ( ii = 0; ii < t->npoints; ++ii ) { point * p = t->points[ii]; - int i = (int) floor( ( p->x - xmin ) / h ); - int j = (int) floor( ( p->y - ymin ) / h ); + i = (int) floor( ( p->x - xmin ) / h ); + j = (int) floor( ( p->y - ymin ) / h ); square* s = squares[j][i]; if ( s->npoints == 0 ) @@ -1040,8 +1042,8 @@ s = -f * h; for ( j = 0; j < m; j++ ) { - double y = a[j][l1]; - double z = a[j][i]; + y = a[j][l1]; + z = a[j][i]; a[j][l1] = y * c + z * s; a[j][i] = z * c - y * s; Modified: trunk/lib/csa/csa.h =================================================================== --- trunk/lib/csa/csa.h 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/csa/csa.h 2011-10-14 07:07:52 UTC (rev 11965) @@ -35,13 +35,13 @@ #endif extern int csa_verbose; -extern char* csa_version; +extern const char* csa_version; struct csa; typedef struct csa csa; CSADLLIMPEXP -csa* csa_create(); +csa* csa_create( void ); CSADLLIMPEXP void csa_destroy( csa* a ); CSADLLIMPEXP Modified: trunk/lib/csa/version.h =================================================================== --- trunk/lib/csa/version.h 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/csa/version.h 2011-10-14 07:07:52 UTC (rev 11965) @@ -14,6 +14,6 @@ #if !defined ( _VERSION_H ) #define _VERSION_H -char* csa_version = "0.23"; +const char* csa_version = "0.23"; #endif Modified: trunk/lib/nn/delaunay.c =================================================================== --- trunk/lib/nn/delaunay.c 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/nn/delaunay.c 2011-10-14 07:07:52 UTC (rev 11965) @@ -44,6 +44,8 @@ int circle_build( circle* c, point* p0, point* p1, point* p2 ); int circle_contains( circle* c, point* p ); +int delaunay_xytoi( delaunay* d, point* p, int id ); +void delaunay_circles_find( delaunay* d, point* p, int* n, int** out ); #ifdef USE_QHULL static int cw( delaunay *d, triangle *t ); Modified: trunk/lib/nn/hash.c =================================================================== --- trunk/lib/nn/hash.c 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/nn/hash.c 2011-10-14 07:07:52 UTC (rev 11965) @@ -47,6 +47,8 @@ ht_bucket ** table; }; +int d1eq( void* key1, void* key2 ); + // Creates a hashtable of specified size. // hashtable* ht_create( int size, ht_keycp cp, ht_keyeq eq, ht_key2hash hash ) Modified: trunk/lib/nn/istack.h =================================================================== --- trunk/lib/nn/istack.h 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/nn/istack.h 2011-10-14 07:07:52 UTC (rev 11965) @@ -26,7 +26,7 @@ } istack; int istack_contains( istack* s, int v ); -istack* istack_create(); +istack* istack_create( void ); void istack_destroy( istack* s ); void istack_push( istack* s, int v ); int istack_pop( istack* s ); Modified: trunk/lib/nn/nn.h =================================================================== --- trunk/lib/nn/nn.h 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/nn/nn.h 2011-10-14 07:07:52 UTC (rev 11965) @@ -316,7 +316,7 @@ // Contains version string for the nn package. // -extern char* nn_version; +extern const char* nn_version; // Limits verbose information to a particular vertex (used mainly for // debugging purposes). Modified: trunk/lib/nn/nnai.c =================================================================== --- trunk/lib/nn/nnai.c 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/nn/nnai.c 2011-10-14 07:07:52 UTC (rev 11965) @@ -46,7 +46,7 @@ nn_weights* weights; }; -void nn_quit( char* format, ... ); +void nn_quit( const char* format, ... ); void nnpi_calculate_weights( nnpi* nn ); int nnpi_get_nvertices( nnpi* nn ); int* nnpi_get_vertices( nnpi* nn ); @@ -64,7 +64,7 @@ nnai* nnai_build( delaunay* d, int n, double* x, double* y ) { nnai * nn = malloc( sizeof ( nnai ) ); - nnpi * nnpi = nnpi_create( d ); + nnpi * nnp = nnpi_create( d ); int * vertices; double* weights; int i; @@ -88,22 +88,22 @@ p.x = x[i]; p.y = y[i]; - nnpi_reset( nnpi ); - nnpi_set_point( nnpi, &p ); - nnpi_calculate_weights( nnpi ); - nnpi_normalize_weights( nnpi ); + nnpi_reset( nnp ); + nnpi_set_point( nnp, &p ); + nnpi_calculate_weights( nnp ); + nnpi_normalize_weights( nnp ); - vertices = nnpi_get_vertices( nnpi ); - weights = nnpi_get_weights( nnpi ); + vertices = nnpi_get_vertices( nnp ); + weights = nnpi_get_weights( nnp ); - w->nvertices = nnpi_get_nvertices( nnpi ); + w->nvertices = nnpi_get_nvertices( nnp ); w->vertices = malloc( w->nvertices * sizeof ( int ) ); memcpy( w->vertices, vertices, w->nvertices * sizeof ( int ) ); w->weights = malloc( w->nvertices * sizeof ( double ) ); memcpy( w->weights, weights, w->nvertices * sizeof ( double ) ); } - nnpi_destroy( nnpi ); + nnpi_destroy( nnp ); return nn; } Modified: trunk/lib/nn/nncommon.c =================================================================== --- trunk/lib/nn/nncommon.c 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/nn/nncommon.c 2011-10-14 07:07:52 UTC (rev 11965) @@ -46,7 +46,11 @@ #include "version.h" -void nn_quit( char* format, ... ) +void nn_quit( const char* format, ... ); +int circle_build( circle* c, point* p1, point* p2, point* p3 ); +int circle_contains( circle* c, point* p ); + +void nn_quit( const char* format, ... ) { va_list args; Modified: trunk/lib/nn/nnpi.c =================================================================== --- trunk/lib/nn/nnpi.c 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/nn/nnpi.c 2011-10-14 07:07:52 UTC (rev 11965) @@ -69,7 +69,14 @@ int circle_contains( circle* c, point* p ); void delaunay_circles_find( delaunay* d, point* p, int* n, int** out ); int delaunay_xytoi( delaunay* d, point* p, int seed ); -void nn_quit( char* format, ... ); +void nn_quit( const char* format, ... ); +void nnpi_reset( nnpi* nn ); +void nnpi_calculate_weights( nnpi* nn ); +void nnpi_normalize_weights( nnpi* nn ); +void nnpi_set_point( nnpi* nn, point* p ); +int nnpi_get_nvertices( nnpi* nn ); +int* nnpi_get_vertices( nnpi* nn ); +double* nnpi_get_weights( nnpi* nn ); #define NSTART 10 #define NINC 10 @@ -505,14 +512,14 @@ // Finds Natural Neighbours-interpolated value in a point. // -// @param nnhpi NN point hashing interpolator +// @param nnhp NN point hashing interpolator // @param p Point to be interpolated (p->x, p->y -- input; p->z -- output) // -void nnhpi_interpolate( nnhpi* nnhpi, point* p ) +void nnhpi_interpolate( nnhpi* nnhp, point* p ) { - nnpi * nnpi = nnhpi->nnpi; - delaunay * d = nnpi->d; - hashtable * ht_weights = nnhpi->ht_weights; + nnpi * nnp = nnhp->nnpi; + delaunay * d = nnp->d; + hashtable * ht_weights = nnhp->ht_weights; nn_weights* weights; int i; @@ -524,21 +531,21 @@ } else { - nnpi_reset( nnpi ); - nnpi->p = p; - nnpi_calculate_weights( nnpi ); - nnpi_normalize_weights( nnpi ); + nnpi_reset( nnp ); + nnp->p = p; + nnpi_calculate_weights( nnp ); + nnpi_normalize_weights( nnp ); weights = malloc( sizeof ( nn_weights ) ); - weights->vertices = malloc( sizeof ( int ) * nnpi->nvertices ); - weights->weights = malloc( sizeof ( double ) * nnpi->nvertices ); + weights->vertices = malloc( sizeof ( int ) * nnp->nvertices ); + weights->weights = malloc( sizeof ( double ) * nnp->nvertices ); - weights->nvertices = nnpi->nvertices; + weights->nvertices = nnp->nvertices; - for ( i = 0; i < nnpi->nvertices; ++i ) + for ( i = 0; i < nnp->nvertices; ++i ) { - weights->vertices[i] = nnpi->vertices[i]; - weights->weights[i] = nnpi->weights[i]; + weights->vertices[i] = nnp->vertices[i]; + weights->weights[i] = nnp->weights[i]; } ht_insert( ht_weights, p, weights ); @@ -547,15 +554,15 @@ { if ( nn_test_vertice == -1 ) { - if ( nnpi->n == 0 ) + if ( nnp->n == 0 ) fprintf( stderr, "weights:\n" ); - fprintf( stderr, " %d: {", nnpi->n ); + fprintf( stderr, " %d: {", nnp->n ); - for ( i = 0; i < nnpi->nvertices; ++i ) + for ( i = 0; i < nnp->nvertices; ++i ) { - fprintf( stderr, "(%d,%.5g)", nnpi->vertices[i], nnpi->weights[i] ); + fprintf( stderr, "(%d,%.5g)", nnp->vertices[i], nnp->weights[i] ); - if ( i < nnpi->nvertices - 1 ) + if ( i < nnp->nvertices - 1 ) fprintf( stderr, ", " ); } fprintf( stderr, "}\n" ); @@ -564,13 +571,13 @@ { double w = 0.0; - if ( nnpi->n == 0 ) + if ( nnp->n == 0 ) fprintf( stderr, "weights for vertex %d:\n", nn_test_vertice ); - for ( i = 0; i < nnpi->nvertices; ++i ) + for ( i = 0; i < nnp->nvertices; ++i ) { - if ( nnpi->vertices[i] == nn_test_vertice ) + if ( nnp->vertices[i] == nn_test_vertice ) { - w = nnpi->weights[i]; + w = nnp->weights[i]; break; } @@ -579,10 +586,10 @@ } } - nnpi->n++; + nnp->n++; } - nnhpi->n++; + nnhp->n++; if ( weights->nvertices == 0 ) { @@ -593,7 +600,7 @@ p->z = 0.0; for ( i = 0; i < weights->nvertices; ++i ) { - if ( weights->weights[i] < nnpi->wmin ) + if ( weights->weights[i] < nnp->wmin ) { p->z = NaN; return; @@ -607,12 +614,12 @@ // pd->x = p->x and pd->y = p->y, and copies p->z to pd->z. Exits with error // if the point is not found. // -// @param nnhpi Natural Neighbours hashing point interpolator +// @param nnhp Natural Neighbours hashing point interpolator // @param p New data // -void nnhpi_modify_data( nnhpi* nnhpi, point* p ) +void nnhpi_modify_data( nnhpi* nnhp, point* p ) { - point* orig = ht_find( nnhpi->ht_data, p ); + point* orig = ht_find( nnhp->ht_data, p ); assert( orig != NULL ); orig->z = p->z; Modified: trunk/lib/nn/version.h =================================================================== --- trunk/lib/nn/version.h 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/nn/version.h 2011-10-14 07:07:52 UTC (rev 11965) @@ -14,6 +14,6 @@ #if !defined ( _VERSION_H ) #define _VERSION_H -char* nn_version = "1.38"; +const char* nn_version = "1.38"; #endif Modified: trunk/lib/qsastime/deltaT-gen.c =================================================================== --- trunk/lib/qsastime/deltaT-gen.c 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/qsastime/deltaT-gen.c 2011-10-14 07:07:52 UTC (rev 11965) @@ -78,13 +78,13 @@ int i = 0; int number_of_lines = 0; - if ( ( fr = fopen( argv[1], "r" ) ) == NULL ) + if ( (argc < 2) || ( fr = fopen( argv[1], "r" ) ) == NULL ) { fprintf( stderr, "Cannot open first file as readable\n" ); exit( 1 ); } - if ( ( fw = fopen( argv[2], "w" ) ) == NULL ) + if ( (argc < 3) || ( fw = fopen( argv[2], "w" ) ) == NULL ) { fprintf( stderr, "Cannot open second file as writable\n" ); exit( 1 ); Modified: trunk/lib/qsastime/qsastime.c =================================================================== --- trunk/lib/qsastime/qsastime.c 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/qsastime/qsastime.c 2011-10-14 07:07:52 UTC (rev 11965) @@ -333,7 +333,7 @@ const char * getDayOfWeek( const MJDtime *MJD ) { - static char *dow = { "Wed\0Thu\0Fri\0Sat\0Sun\0Mon\0Tue" }; + static const char *dow = { "Wed\0Thu\0Fri\0Sat\0Sun\0Mon\0Tue" }; int d = MJD->base_day % 7; if ( d < 0 ) d += 7; @@ -342,7 +342,7 @@ const char * getLongDayOfWeek( const MJDtime *MJD ) { - static char *dow = { "Wednesday\0Thursday\0\0Friday\0\0\0\0Saturday\0\0Sunday\0\0\0\0Monday\0\0\0\0Tuesday" }; + static const char *dow = { "Wednesday\0Thursday\0\0Friday\0\0\0\0Saturday\0\0Sunday\0\0\0\0Monday\0\0\0\0Tuesday" }; int d = MJD->base_day % 7; if ( d < 0 ) d += 7; @@ -351,13 +351,13 @@ const char * getMonth( int m ) { - static char *months = { "Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec" }; + static const char *months = { "Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec" }; return &( months[( m ) * 4] ); } const char * getLongMonth( int m ) { - static char *months = { "January\0\0\0February\0\0March\0\0\0\0\0April\0\0\0\0\0May\0\0\0\0\0\0\0June\0\0\0\0\0\0July\0\0\0\0\0\0August\0\0\0\0September\0October\0\0\0November\0\0December" }; + static const char *months = { "January\0\0\0February\0\0March\0\0\0\0\0April\0\0\0\0\0May\0\0\0\0\0\0\0June\0\0\0\0\0\0July\0\0\0\0\0\0August\0\0\0\0September\0October\0\0\0November\0\0December" }; return &( months[( m ) * 10] ); } @@ -540,7 +540,7 @@ else if ( next == 'D' ) { // month/day/year - int y = year % 100; + y = year % 100; if ( ysign == 0 ) sprintf( DateTime, "%02d/%02d/%02d", month + 1, day, y ); else @@ -839,7 +839,6 @@ } else if ( next == 'V' ) { - int days_in_wk1; // week of year as a number, (01 - 53) start of week is Monday and first week has at least 3 days in year getYAD( &y1, &ifleapyear, &doy, nMJD, forceJulian ); days_in_wk1 = ( nMJD->base_day - doy - 3 ) % 7; @@ -1328,18 +1327,18 @@ else { // binary hunt phase where we are assured 0 <= *low < n - indexbase = (void *) ( ( (const char *) base ) + ( size * ( *low ) ) ); + indexbase = (const void *) ( ( (const char *) base ) + ( size * ( *low ) ) ); if ( ( *ge )( key, indexbase ) ) { high = ( *low ) + hunt_inc; - indexbase = (void *) ( ( (const char *) base ) + ( size * high ) ); + indexbase = (const void *) ( ( (const char *) base ) + ( size * high ) ); // indexbase is valid if high < n. while ( ( high < n ) && ( ( *ge )( key, indexbase ) ) ) { *low = high; hunt_inc += hunt_inc; high = high + hunt_inc; - indexbase = (void *) ( ( (const char *) base ) + ( size * high ) ); + indexbase = (const void *) ( ( (const char *) base ) + ( size * high ) ); } if ( high >= n ) high = n; @@ -1350,14 +1349,14 @@ { high = *low; *low = high - hunt_inc; - indexbase = (void *) ( ( (const char *) base ) + ( size * ( *low ) ) ); + indexbase = (const void *) ( ( (const char *) base ) + ( size * ( *low ) ) ); // indexbase is valid if(*low) >= 0 while ( ( ( *low ) >= 0 ) && !( ( *ge )( key, indexbase ) ) ) { high = *low; hunt_inc += hunt_inc; *low = ( *low ) - hunt_inc; - indexbase = (void *) ( ( (const char *) base ) + ( size * ( *low ) ) ); + indexbase = (const void *) ( ( (const char *) base ) + ( size * ( *low ) ) ); } if ( ( *low ) < 0 ) *low = -1; @@ -1371,7 +1370,7 @@ while ( high - *low > 1 ) { mid = *low + ( high - *low ) / 2; - indexbase = (void *) ( ( (const char *) base ) + ( size * mid ) ); + indexbase = (const void *) ( ( (const char *) base ) + ( size * mid ) ); if ( ( *ge )( key, indexbase ) ) *low = mid; else Modified: trunk/lib/qsastime/tai-utc-gen.c =================================================================== --- trunk/lib/qsastime/tai-utc-gen.c 2011-10-14 05:04:02 UTC (rev 11964) +++ trunk/lib/qsastime/tai-utc-gen.c 2011-10-14 07:07:52 UTC (rev 11965) @@ -87,13 +87,13 @@ int i = 0; int number_of_lines = 0; - if ( ( fr = fopen( argv[1], "r" ) ) == NULL ) + if ( ( argc < 2 ) || ( fr = fopen( argv[1], "r" ) ) == NULL ) { fprintf( stderr, "Cannot open first file as readable\n" ); exit( 1 ); } - if ( ( fw = fopen( argv[2], "w" ) ) == NULL ) + if ( ( argc < 3 ) || ( fw = fopen( argv[2], "w" ) ) == NULL ) { fprintf( stderr, "Cannot open second file as writable\n" ); exit( 1 ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |