From: <and...@us...> - 2011-10-17 21:16:48
|
Revision: 11973 http://plplot.svn.sourceforge.net/plplot/?rev=11973&view=rev Author: andrewross Date: 2011-10-17 21:16:39 +0000 (Mon, 17 Oct 2011) Log Message: ----------- Another big round of changes to fix gcc warnings / ensure standards conformance. Changes include - explicit casting between types - removing or commenting out unused variables / functions - correct using of "const" modifier - replacing use of finite with isfinite where available (this is in C99, but not supported by MSVC so still need complicated set of macros to check) - rename local variables which shadow other global or local variables / symbols Modified Paths: -------------- trunk/cmake/modules/plplot.cmake trunk/config.h.cmake trunk/drivers/ps.c trunk/drivers/psttf.cc trunk/drivers/svg.c trunk/drivers/xfig.c trunk/include/pdf.h trunk/include/plcore.h trunk/include/plfci-type1.h trunk/include/plfreetype.h trunk/include/plplotP.h trunk/include/plstrm.h trunk/src/mt19937ar.c trunk/src/pdfutils.c trunk/src/plarc.c trunk/src/plargs.c trunk/src/plbox.c trunk/src/plbuf.c trunk/src/plcont.c trunk/src/plcore.c trunk/src/plctrl.c trunk/src/plcvt.c trunk/src/pldeprecated.c trunk/src/plf2ops.c trunk/src/plfill.c trunk/src/plfreetype.c trunk/src/plgradient.c trunk/src/plgridd.c trunk/src/plimage.c trunk/src/pllegend.c trunk/src/plline.c trunk/src/plmap.c trunk/src/plot3d.c trunk/src/plpage.c trunk/src/plsdef.c trunk/src/plshade.c trunk/src/plstdio.c trunk/src/plstripc.c trunk/src/plsym.c trunk/src/plvect.c trunk/src/plvpor.c Modified: trunk/cmake/modules/plplot.cmake =================================================================== --- trunk/cmake/modules/plplot.cmake 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/cmake/modules/plplot.cmake 2011-10-17 21:16:39 UTC (rev 11973) @@ -226,27 +226,35 @@ # Check for FP functions, including underscored version which # are sometimes all that is available on windows +check_symbol_exists(isfinite "math.h" HAVE_ISFINITE_SYMBOL) check_symbol_exists(finite "math.h" HAVE_FINITE_SYMBOL) -if(HAVE_FINITE_SYMBOL) - set(PL_HAVE_FINITE ON) -else(HAVE_FINITE_SYMBOL) - check_function_exists(finite HAVE_FINITE_FUNCTION) - if(HAVE_FINITE_FUNCTION) +if(HAVE_ISFINITE_SYMBOL) + set(PL_HAVE_ISFINITE ON) +else(HAVE_ISFINITE_SYMBOL) + if(HAVE_FINITE_SYMBOL) set(PL_HAVE_FINITE ON) - else(HAVE_FINITE_FUNCTION) - check_symbol_exists(_finite "math.h" HAVE__FINITE_SYMBOL) - if(HAVE__FINITE_SYMBOL) - set(PL__HAVE_FINITE ON) - else(HAVE__FINITE_SYMBOL) - check_function_exists(_finite HAVE__FINITE_FUNCTION) - if(HAVE__FINITE_FUNCTION) + else(HAVE_FINITE_SYMBOL) + check_function_exists(finite HAVE_FINITE_FUNCTION) + if(HAVE_FINITE_FUNCTION) + set(PL_HAVE_FINITE ON) + else(HAVE_FINITE_FUNCTION) + check_symbol_exists(_finite "math.h" HAVE__FINITE_SYMBOL) + if(HAVE__FINITE_SYMBOL) set(PL__HAVE_FINITE ON) - endif(HAVE__FINITE_FUNCTION) - endif(HAVE__FINITE_SYMBOL) - endif(HAVE_FINITE_FUNCTION) -endif(HAVE_FINITE_SYMBOL) + else(HAVE__FINITE_SYMBOL) + check_function_exists(_finite HAVE__FINITE_FUNCTION) + if(HAVE__FINITE_FUNCTION) + set(PL__HAVE_FINITE ON) + endif(HAVE__FINITE_FUNCTION) + endif(HAVE__FINITE_SYMBOL) + endif(HAVE_FINITE_FUNCTION) + endif(HAVE_FINITE_SYMBOL) +endif(HAVE_ISFINITE_SYMBOL) +if(PL_HAVE_FINITE) + set(PL_HAVE_ISFINITE ON) +endif(PL_HAVE_FINITE) if(PL__HAVE_FINITE) - set(PL_HAVE_FINITE ON) + set(PL_HAVE_ISFINITE ON) endif(PL__HAVE_FINITE) check_symbol_exists(isnan "math.h" HAVE_ISNAN_SYMBOL) Modified: trunk/config.h.cmake =================================================================== --- trunk/config.h.cmake 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/config.h.cmake 2011-10-17 21:16:39 UTC (rev 11973) @@ -51,6 +51,9 @@ // Define to 1 if you have the <dlfcn.h> header file. #cmakedefine HAVE_DLFCN_H 1 +// Define if isfinite is available +#cmakedefine PL_HAVE_ISFINITE + // Define if finite is available #cmakedefine PL_HAVE_FINITE Modified: trunk/drivers/ps.c =================================================================== --- trunk/drivers/ps.c 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/drivers/ps.c 2011-10-17 21:16:39 UTC (rev 11973) @@ -81,7 +81,7 @@ const Unicode_to_Type1_table lookup[], const int number_of_entries ); -static char * +static const char * get_font( PSDev* dev, PLUNICODE fci ); // text > 0 uses some postscript tricks, namely a transformation matrix @@ -450,7 +450,7 @@ dev->ury = MAX( dev->ury, y2 ); fprintf( OF, "%s", outbuf ); - pls->bytecnt += 1 + strlen( outbuf ); + pls->bytecnt += 1 + (PLINT) strlen( outbuf ); dev->xold = x2; dev->yold = y2; } @@ -688,7 +688,7 @@ dev->urx = MAX( dev->urx, x ); dev->ury = MAX( dev->ury, y ); fprintf( OF, "%s", outbuf ); - pls->bytecnt += strlen( outbuf ); + pls->bytecnt += (PLINT) strlen( outbuf ); continue; } @@ -709,7 +709,7 @@ dev->ury = MAX( dev->ury, y ); fprintf( OF, "%s", outbuf ); - pls->bytecnt += strlen( outbuf ); + pls->bytecnt += (PLINT) strlen( outbuf ); pls->linepos += 21; } dev->xold = PL_UNDEFINED; @@ -732,7 +732,7 @@ t = time( (time_t *) 0 ); p = ctime( &t ); - len = strlen( p ); + len = (int) strlen( p ); *( p + len - 1 ) = '\0'; // zap the newline character return p; } @@ -757,12 +757,13 @@ void proc_str( PLStream *pls, EscText *args ) { - PLFLT *t = args->xform, tt[4]; // Transform matrices - PLFLT theta, shear, stride; // Rotation angle and shear from the matrix - PLFLT ft_ht, offset; // Font height and offset - PLFLT cs, sn, l1, l2; - PSDev *dev = (PSDev *) pls->dev; - char *font, esc; + PLFLT *t = args->xform, tt[4]; // Transform matrices + PLFLT theta, shear, stride; // Rotation angle and shear from the matrix + PLFLT ft_ht, offset; // Font height and offset + PLFLT cs, sn, l1, l2; + PSDev *dev = (PSDev *) pls->dev; + const char *font; + char esc; // Be generous. Used to store lots of font changes which take // 3 characters per change. #define PROC_STR_STRING_LENGTH 1000 @@ -779,12 +780,12 @@ // unicode only! so test for it. if ( args->unicode_array_len > 0 ) { - int j, s, f; - char *fonts[PROC_STR_STRING_LENGTH]; + int j, s, f; + const char *fonts[PROC_STR_STRING_LENGTH]; const PLUNICODE *cur_text; - PLUNICODE fci, fci_save; - PLFLT old_sscale, sscale, old_soffset, soffset, dup; - PLINT level = 0; + PLUNICODE fci, fci_save; + PLFLT old_sscale, sscale, old_soffset, soffset, ddup; + PLINT level = 0; // translate from unicode into type 1 font index. // // Choose the font family, style, variant, and weight using @@ -808,7 +809,7 @@ { fci_save = cur_text[j]; fonts[f++] = get_font( dev, fci_save ); - cur_str[s++] = esc; + cur_str[s++] = (unsigned char) esc; cur_str[s++] = 'f'; cur_str[s++] = 'f'; } @@ -842,7 +843,7 @@ // font instead which will return a blank if // that fails as well. fonts[f++] = get_font( dev, 0 ); - cur_str[s++] = esc; + cur_str[s++] = (unsigned char) esc; cur_str[s++] = 'f'; cur_str[s++] = 'f'; cur_str[s++] = plunicode2type1( cur_text[j], dev->lookup, dev->nlookup ); @@ -853,7 +854,7 @@ // font instead which will return a blank if // that fails as well. fonts[f++] = get_font( dev, fci_save ); - cur_str[s++] = esc; + cur_str[s++] = (unsigned char) esc; cur_str[s++] = 'f'; cur_str[s++] = 'f'; cur_str[s++] = plunicode2type1( cur_text[j], dev->lookup, dev->nlookup ); @@ -1014,8 +1015,8 @@ // between the baseline and middle coordinate systems // for subscripts should be // -0.5*(base font size - superscript/subscript font size). - dup = -0.5 * ( 1.0 - sscale ); - up = -font_factor * ENLARGE * ft_ht * ( RISE_FACTOR * soffset + dup ); + ddup = -0.5 * ( 1.0 - sscale ); + up = -font_factor * ENLARGE * ft_ht * ( RISE_FACTOR * soffset + ddup ); break; case 'u': //superscript @@ -1027,8 +1028,8 @@ // between the baseline and middle coordinate systems // for superscripts should be // 0.5*(base font size - superscript/subscript font size). - dup = 0.5 * ( 1.0 - sscale ); - up = font_factor * ENLARGE * ft_ht * ( RISE_FACTOR * soffset + dup ); + ddup = 0.5 * ( 1.0 - sscale ); + up = font_factor * ENLARGE * ft_ht * ( RISE_FACTOR * soffset + ddup ); break; // ignore the next sequences @@ -1190,10 +1191,10 @@ // // Sets the Type1 font. //-------------------------------------------------------------------------- -static char * +static const char * get_font( PSDev* dev, PLUNICODE fci ) { - char *font; + const char *font; // fci = 0 is a special value indicating the Type 1 Symbol font // is desired. This value cannot be confused with a normal FCI value // because it doesn't have the PL_FCI_MARK. Modified: trunk/drivers/psttf.cc =================================================================== --- trunk/drivers/psttf.cc 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/drivers/psttf.cc 2011-10-17 21:16:39 UTC (rev 11973) @@ -31,11 +31,9 @@ #include "plDevs.h" -#define DEBUG - #if defined ( PLD_psttf ) -#define NEED_PLDEBUG +//#define NEED_PLDEBUG #include "plplotP.h" #include "drivers.h" #include "ps.h" @@ -70,7 +68,7 @@ static void ps_init( PLStream * ); static void fill_polygon( PLStream *pls ); static void proc_str( PLStream *, EscText * ); -static void esc_purge( char *, char * ); +//static void esc_purge( char *, char * ); #define OUTBUF_LEN 128 static char outbuf[OUTBUF_LEN]; @@ -450,7 +448,7 @@ doc->osHeader() << "PSDict begin\n"; doc->osHeader() << "@start\n"; - doc->osHeader() << "%d @copies\n", COPIES; + doc->osHeader() << "%d @copies\n" << COPIES; doc->osHeader() << "@line\n"; doc->osHeader() << YSIZE << " @hsize\n"; doc->osHeader() << XSIZE << " @vsize\n"; @@ -1274,44 +1272,44 @@ } } -static void -esc_purge( char *dstr, char *sstr ) -{ - char esc; +//static void +//esc_purge( char *dstr, char *sstr ) +//{ +// char esc; +// +// plgesc( &esc ); +// +// while ( *sstr ) +// { +// if ( *sstr != esc ) +// { +// *dstr++ = *sstr++; +// continue; +// } +// +// sstr++; +// if ( *sstr == esc ) +// { +// *dstr++ = *sstr++; +// continue; +// } +// +// else +// { +// switch ( *sstr++ ) +// { +// case 'f': +// sstr++; +// break; // two chars sequence +// +// default: +// break; // single char escape +// } +// } +// } +// *dstr = '\0'; +//} - plgesc( &esc ); - - while ( *sstr ) - { - if ( *sstr != esc ) - { - *dstr++ = *sstr++; - continue; - } - - sstr++; - if ( *sstr == esc ) - { - *dstr++ = *sstr++; - continue; - } - - else - { - switch ( *sstr++ ) - { - case 'f': - sstr++; - break; // two chars sequence - - default: - break; // single char escape - } - } - } - *dstr = '\0'; -} - #else int pldummy_psttf() Modified: trunk/drivers/svg.c =================================================================== --- trunk/drivers/svg.c 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/drivers/svg.c 2011-10-17 21:16:39 UTC (rev 11973) @@ -219,7 +219,7 @@ { aStream->textClipping = 1; } - aStream->textClipping = text_clipping; + aStream->textClipping = (short) text_clipping; aStream->svgIndent = 0; aStream->gradient_index = 0; @@ -567,7 +567,7 @@ static short which_clip = 0; short i; short totalTags = 1; - short ucs4Len = args->unicode_array_len; + short ucs4Len = (short) args->unicode_array_len; double ftHt, scaled_offset, scaled_ftHt; PLUNICODE fci; PLINT rcx[4], rcy[4]; @@ -578,7 +578,7 @@ // PLFLT *t = args->xform; PLUNICODE *ucs4 = args->unicode_array; SVG *aStream; - PLFLT old_sscale, sscale, old_soffset, soffset, old_dup, dup; + PLFLT old_sscale, sscale, old_soffset, soffset, old_dup, ddup; PLINT level; // check that we got unicode @@ -750,7 +750,7 @@ i = 0; scaled_ftHt = ftHt; level = 0; - dup = 0.; + ddup = 0.; while ( i < ucs4Len ) { if ( ucs4[i] < PL_FCI_MARK ) // not a font change @@ -795,15 +795,15 @@ // between the baseline and middle coordinate systems // for superscripts should be // 0.5*(base font size - superscript/subscript font size). - old_dup = dup; - dup = 0.5 * ( 1.0 - sscale ); + old_dup = ddup; + ddup = 0.5 * ( 1.0 - sscale ); if ( level <= 0 ) { - scaled_offset = FONT_SHIFT_RATIO * ftHt * ( 0.80 * ( soffset - old_soffset ) - ( dup - old_dup ) ); + scaled_offset = FONT_SHIFT_RATIO * ftHt * ( 0.80 * ( soffset - old_soffset ) - ( ddup - old_dup ) ); } else { - scaled_offset = -FONT_SHIFT_RATIO * ftHt * ( 0.80 * ( soffset - old_soffset ) + ( dup - old_dup ) ); + scaled_offset = -FONT_SHIFT_RATIO * ftHt * ( 0.80 * ( soffset - old_soffset ) + ( ddup - old_dup ) ); } scaled_ftHt = sscale * ftHt; if ( if_write ) @@ -824,15 +824,15 @@ // between the baseline and middle coordinate systems // for superscripts should be // 0.5*(base font size - superscript/subscript font size). - old_dup = dup; - dup = 0.5 * ( 1.0 - sscale ); + old_dup = ddup; + ddup = 0.5 * ( 1.0 - sscale ); if ( level < 0 ) { - scaled_offset = FONT_SHIFT_RATIO * ftHt * ( 0.80 * ( soffset - old_soffset ) - ( dup - old_dup ) ); + scaled_offset = FONT_SHIFT_RATIO * ftHt * ( 0.80 * ( soffset - old_soffset ) - ( ddup - old_dup ) ); } else { - scaled_offset = -FONT_SHIFT_RATIO * ftHt * ( 0.80 * ( soffset - old_soffset ) + ( dup - old_dup ) ); + scaled_offset = -FONT_SHIFT_RATIO * ftHt * ( 0.80 * ( soffset - old_soffset ) + ( ddup - old_dup ) ); } scaled_ftHt = sscale * ftHt; if ( if_write ) Modified: trunk/drivers/xfig.c =================================================================== --- trunk/drivers/xfig.c 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/drivers/xfig.c 2011-10-17 21:16:39 UTC (rev 11973) @@ -166,7 +166,7 @@ stcmap1( pls ); dev->bufflen = 2 * BSIZE; - dev->buffptr = (int *) malloc( sizeof ( int ) * dev->bufflen ); + dev->buffptr = (int *) malloc( sizeof ( int ) * (size_t) ( dev->bufflen ) ); if ( dev->buffptr == NULL ) plexit( "plD_init_xfig: Out of memory!" ); } @@ -265,7 +265,7 @@ { dev->bufflen += 2 * BSIZE; tempptr = (int *) - realloc( (void *) dev->buffptr, dev->bufflen * sizeof ( int ) ); + realloc( (void *) dev->buffptr, (size_t) ( dev->bufflen ) * sizeof ( int ) ); if ( tempptr == NULL ) { free( (void *) dev->buffptr ); Modified: trunk/include/pdf.h =================================================================== --- trunk/include/pdf.h 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/include/pdf.h 2011-10-17 21:16:39 UTC (rev 11973) @@ -55,7 +55,7 @@ #ifdef PLPLOT_USE_TCL_CHANNELS Tcl_Channel tclChan; // Tcl channel #endif - long bp, bufmax; // Buffer pointer and max size + size_t bp, bufmax; // Buffer pointer and max size } PDFstrm; // Info for the i/o device. Only used by Tcl/TK/dp drivers for now @@ -86,7 +86,7 @@ void pdf_set PLARGS( ( char *option, int value ) ); PLDLLIMPEXP PDFstrm *pdf_fopen PLARGS( ( const char *fileName, const char *mode ) ); -PLDLLIMPEXP PDFstrm *pdf_bopen PLARGS( ( U_CHAR * buffer, long bufmax ) ); +PLDLLIMPEXP PDFstrm *pdf_bopen PLARGS( ( U_CHAR * buffer, size_t bufmax ) ); PLDLLIMPEXP PDFstrm *pdf_finit PLARGS( ( FILE * file ) ); PDFstrm *plLibOpenPdfstrm PLARGS( (const char * fn) ); PLDLLIMPEXP int pdf_close PLARGS( ( PDFstrm * pdfs ) ); Modified: trunk/include/plcore.h =================================================================== --- trunk/include/plcore.h 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/include/plcore.h 2011-10-17 21:16:39 UTC (rev 11973) @@ -50,7 +50,7 @@ // Static function prototypes -static char *utf8_to_ucs4( const char *ptr, PLUNICODE *unichar ); +static const char *utf8_to_ucs4( const char *ptr, PLUNICODE *unichar ); static void grline( short *, short *, PLINT ); static void grpolyline( short *, short *, PLINT ); static void grfill( short *, short *, PLINT ); Modified: trunk/include/plfci-type1.h =================================================================== --- trunk/include/plfci-type1.h 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/include/plfci-type1.h 2011-10-17 21:16:39 UTC (rev 11973) @@ -40,34 +40,34 @@ #define N_Type1Lookup 30 static const FCI_to_FontName_Table Type1Lookup[N_Type1Lookup] = { - { PL_FCI_MARK | 0x000, (unsigned char *) "Helvetica" }, - { PL_FCI_MARK | 0x001, (unsigned char *) "Times-Roman" }, - { PL_FCI_MARK | 0x002, (unsigned char *) "Courier" }, - { PL_FCI_MARK | 0x003, (unsigned char *) "Helvetica" }, - { PL_FCI_MARK | 0x004, (unsigned char *) "Helvetica" }, - { PL_FCI_MARK | 0x010, (unsigned char *) "Helvetica-Oblique" }, - { PL_FCI_MARK | 0x011, (unsigned char *) "Times-Italic" }, - { PL_FCI_MARK | 0x012, (unsigned char *) "Courier-Oblique" }, - { PL_FCI_MARK | 0x013, (unsigned char *) "Helvetica-Oblique" }, - { PL_FCI_MARK | 0x014, (unsigned char *) "Helvetica-Oblique" }, - { PL_FCI_MARK | 0x020, (unsigned char *) "Helvetica-Oblique" }, - { PL_FCI_MARK | 0x021, (unsigned char *) "Times-Italic" }, - { PL_FCI_MARK | 0x022, (unsigned char *) "Courier-Oblique" }, - { PL_FCI_MARK | 0x023, (unsigned char *) "Helvetica-Oblique" }, - { PL_FCI_MARK | 0x024, (unsigned char *) "Helvetica-Oblique" }, - { PL_FCI_MARK | 0x100, (unsigned char *) "Helvetica-Bold" }, - { PL_FCI_MARK | 0x101, (unsigned char *) "Times-Bold" }, - { PL_FCI_MARK | 0x102, (unsigned char *) "Courier-Bold" }, - { PL_FCI_MARK | 0x103, (unsigned char *) "Helvetica-Bold" }, - { PL_FCI_MARK | 0x104, (unsigned char *) "Helvetica-Bold" }, - { PL_FCI_MARK | 0x110, (unsigned char *) "Helvetica-BoldOblique" }, - { PL_FCI_MARK | 0x111, (unsigned char *) "Times-BoldItalic" }, - { PL_FCI_MARK | 0x112, (unsigned char *) "Courier-BoldOblique" }, - { PL_FCI_MARK | 0x113, (unsigned char *) "Helvetica-BoldOblique" }, - { PL_FCI_MARK | 0x114, (unsigned char *) "Helvetica-BoldOblique" }, - { PL_FCI_MARK | 0x120, (unsigned char *) "Helvetica-BoldOblique" }, - { PL_FCI_MARK | 0x121, (unsigned char *) "Times-BoldItalic" }, - { PL_FCI_MARK | 0x122, (unsigned char *) "Courier-BoldOblique" }, - { PL_FCI_MARK | 0x123, (unsigned char *) "Helvetica-BoldOblique" }, - { PL_FCI_MARK | 0x124, (unsigned char *) "Helvetica-BoldOblique" }, + { PL_FCI_MARK | 0x000, (const unsigned char *) "Helvetica" }, + { PL_FCI_MARK | 0x001, (const unsigned char *) "Times-Roman" }, + { PL_FCI_MARK | 0x002, (const unsigned char *) "Courier" }, + { PL_FCI_MARK | 0x003, (const unsigned char *) "Helvetica" }, + { PL_FCI_MARK | 0x004, (const unsigned char *) "Helvetica" }, + { PL_FCI_MARK | 0x010, (const unsigned char *) "Helvetica-Oblique" }, + { PL_FCI_MARK | 0x011, (const unsigned char *) "Times-Italic" }, + { PL_FCI_MARK | 0x012, (const unsigned char *) "Courier-Oblique" }, + { PL_FCI_MARK | 0x013, (const unsigned char *) "Helvetica-Oblique" }, + { PL_FCI_MARK | 0x014, (const unsigned char *) "Helvetica-Oblique" }, + { PL_FCI_MARK | 0x020, (const unsigned char *) "Helvetica-Oblique" }, + { PL_FCI_MARK | 0x021, (const unsigned char *) "Times-Italic" }, + { PL_FCI_MARK | 0x022, (const unsigned char *) "Courier-Oblique" }, + { PL_FCI_MARK | 0x023, (const unsigned char *) "Helvetica-Oblique" }, + { PL_FCI_MARK | 0x024, (const unsigned char *) "Helvetica-Oblique" }, + { PL_FCI_MARK | 0x100, (const unsigned char *) "Helvetica-Bold" }, + { PL_FCI_MARK | 0x101, (const unsigned char *) "Times-Bold" }, + { PL_FCI_MARK | 0x102, (const unsigned char *) "Courier-Bold" }, + { PL_FCI_MARK | 0x103, (const unsigned char *) "Helvetica-Bold" }, + { PL_FCI_MARK | 0x104, (const unsigned char *) "Helvetica-Bold" }, + { PL_FCI_MARK | 0x110, (const unsigned char *) "Helvetica-BoldOblique" }, + { PL_FCI_MARK | 0x111, (const unsigned char *) "Times-BoldItalic" }, + { PL_FCI_MARK | 0x112, (const unsigned char *) "Courier-BoldOblique" }, + { PL_FCI_MARK | 0x113, (const unsigned char *) "Helvetica-BoldOblique" }, + { PL_FCI_MARK | 0x114, (const unsigned char *) "Helvetica-BoldOblique" }, + { PL_FCI_MARK | 0x120, (const unsigned char *) "Helvetica-BoldOblique" }, + { PL_FCI_MARK | 0x121, (const unsigned char *) "Times-BoldItalic" }, + { PL_FCI_MARK | 0x122, (const unsigned char *) "Courier-BoldOblique" }, + { PL_FCI_MARK | 0x123, (const unsigned char *) "Helvetica-BoldOblique" }, + { PL_FCI_MARK | 0x124, (const unsigned char *) "Helvetica-BoldOblique" }, }; Modified: trunk/include/plfreetype.h =================================================================== --- trunk/include/plfreetype.h 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/include/plfreetype.h 2011-10-17 21:16:39 UTC (rev 11973) @@ -34,6 +34,7 @@ #include FT_FREETYPE_H #include FT_GLYPH_H #include FT_OUTLINE_H +#include FT_MODULE_H #define FT_Data _FT_Data_ Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/include/plplotP.h 2011-10-17 21:16:39 UTC (rev 11973) @@ -252,22 +252,25 @@ # endif #endif #if defined ( PL__HAVE_ISINF ) -# define isinf _isinf +# define isinf _isinf #endif +#if defined ( PL_HAVE_FINITE ) +# define isfinite finite +#endif #if defined ( PL__HAVE_FINITE ) -# define finite _finite +# define isfinite _finite #endif // Note these replacements follow the old BSD convention and not // C99. In particular isinf does not distinguish +/- inf. #if !defined ( PL_HAVE_ISNAN ) -# define isnan( x ) ( ( x ) != ( x ) ) +# define isnan( x ) ( ( x ) != ( x ) ) #endif #if !defined ( PL_HAVE_ISINF ) -# define isinf( x ) ( !isnan( x ) && isnan( x - x ) ) +# define isinf( x ) ( !isnan( x ) && isnan( x - x ) ) #endif -#if !defined ( PL_HAVE_FINITE ) -# define finite( x ) ( !isnan( x - x ) ) +#if !defined ( PL_HAVE_ISFINITE ) +# define isfinite( x ) ( !isnan( x - x ) ) #endif // Check if C99 HUGE_VAL macro is available - if not then @@ -1158,7 +1161,7 @@ } FCI_to_FontName_Table; // Internal function to obtain a pointer to a valid font name. -PLDLLIMPEXP char * +PLDLLIMPEXP const char * plP_FCI2FontName( PLUNICODE fci, const FCI_to_FontName_Table lookup[], const int nlookup ); @@ -1190,10 +1193,18 @@ void plio_fgets( char *, int, FILE * ); +// Draws a tick parallel to x, using world coordinates +void +plwxtik( PLFLT x, PLFLT y, PLBOOL minor, PLBOOL invert ); + +// Draws a tick parallel to y, using world coordinates +void +plwytik( PLFLT x, PLFLT y, PLBOOL minor, PLBOOL invert ); + // get drivers directory #ifdef ENABLE_DYNDRIVERS -PLDLLIMPEXP char* +PLDLLIMPEXP const char* plGetDrvDir( void ); #endif Modified: trunk/include/plstrm.h =================================================================== --- trunk/include/plstrm.h 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/include/plstrm.h 2011-10-17 21:16:39 UTC (rev 11973) @@ -774,31 +774,31 @@ // transformation between broken-down and continuous time used in // the qsastime library. - QSASConfig *qsasconfig; + QSASConfig *qsasconfig; // Gradient section. - PLINT dev_gradient; - PLINT ngradient; - PLINT *xgradient, *ygradient; + PLINT dev_gradient; + PLINT ngradient; + PLINT *xgradient, *ygradient; // The next three variables define the polygon boundary used // in the software fallback for the gradient. - PLINT n_polygon; - PLFLT *x_polygon, *y_polygon; + PLINT n_polygon; + const PLFLT *x_polygon, *y_polygon; //CONSTANT SOVERSION FIX - PLBOOL stream_closed; - PLINT line_style; - PLINT dev_mem_alpha; - PLINT has_string_length; - PLFLT string_length; - PLINT get_string_length; - PLINT dev_eofill; + PLBOOL stream_closed; + PLINT line_style; + PLINT dev_mem_alpha; + PLINT has_string_length; + PLFLT string_length; + PLINT get_string_length; + PLINT dev_eofill; // Drawing mode section - PLINT dev_modeset; + PLINT dev_modeset; // Calculate bounding-box limits rather than plot box? - PLBOOL if_boxbb; + PLBOOL if_boxbb; // Bounding box limits in mm for box including decorations // (inverted tick marks and numerical tick labels if either is // present). Modified: trunk/src/mt19937ar.c =================================================================== --- trunk/src/mt19937ar.c 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/src/mt19937ar.c 2011-10-17 21:16:39 UTC (rev 11973) @@ -63,7 +63,7 @@ for ( mti = 1; mti < N; mti++ ) { mt[mti] = - ( 1812433253UL * ( mt[mti - 1] ^ ( mt[mti - 1] >> 30 ) ) + mti ); + ( 1812433253UL * ( mt[mti - 1] ^ ( mt[mti - 1] >> 30 ) ) + (unsigned long) mti ); // See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. // In the previous versions, MSBs of the seed affect // only MSBs of the array mt[]. @@ -86,8 +86,8 @@ for (; k; k-- ) { mt[i] = ( mt[i] ^ ( ( mt[i - 1] ^ ( mt[i - 1] >> 30 ) ) * 1664525UL ) ) - + init_key[j] + j; // non linear - mt[i] &= 0xffffffffUL; // for WORDSIZE > 32 machines + + init_key[j] + (unsigned long) j; // non linear + mt[i] &= 0xffffffffUL; // for WORDSIZE > 32 machines i++; j++; if ( i >= N ) { @@ -99,8 +99,8 @@ for ( k = N - 1; k; k-- ) { mt[i] = ( mt[i] ^ ( ( mt[i - 1] ^ ( mt[i - 1] >> 30 ) ) * 1566083941UL ) ) - - i; // non linear - mt[i] &= 0xffffffffUL; // for WORDSIZE > 32 machines + - (unsigned long) i; // non linear + mt[i] &= 0xffffffffUL; // for WORDSIZE > 32 machines i++; if ( i >= N ) { @@ -161,14 +161,14 @@ // generates a random number on [0,1]-real-interval double genrand_real1( void ) { - return genrand_int32() * ( 1.0 / 4294967295.0 ); + return (double) genrand_int32() * ( 1.0 / 4294967295.0 ); // divided by 2^32-1 } // generates a random number on [0,1)-real-interval double genrand_real2( void ) { - return genrand_int32() * ( 1.0 / 4294967296.0 ); + return (double) genrand_int32() * ( 1.0 / 4294967296.0 ); // divided by 2^32 } @@ -183,6 +183,6 @@ double genrand_res53( void ) { unsigned long a = genrand_int32() >> 5, b = genrand_int32() >> 6; - return ( a * 67108864.0 + b ) * ( 1.0 / 9007199254740992.0 ); + return ( (double) a * 67108864.0 + (double) b ) * ( 1.0 / 9007199254740992.0 ); } // These real versions are due to Isaku Wada, 2002/01/09 added Modified: trunk/src/pdfutils.c =================================================================== --- trunk/src/pdfutils.c 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/src/pdfutils.c 2011-10-17 21:16:39 UTC (rev 11973) @@ -1,4 +1,4 @@ -// $Id$ +// xId: pdfutils.c 11966 2011-10-14 07:10:05Z andrewross $ // // pdf_utils.c // @@ -133,7 +133,7 @@ //-------------------------------------------------------------------------- PDFstrm * -pdf_bopen( U_CHAR *buffer, long bufmax ) +pdf_bopen( U_CHAR *buffer, size_t bufmax ) { PDFstrm *pdfs; @@ -270,7 +270,7 @@ plexit( "pdf_putc: Insufficient memory" ); } } - pdfs->buffer[pdfs->bp++] = c; + pdfs->buffer[pdfs->bp++] = (unsigned char) c; result = c; } else @@ -342,7 +342,7 @@ { if ( pdfs->bp > 0 ) { - pdfs->buffer[--pdfs->bp] = c; + pdfs->buffer[--pdfs->bp] = (unsigned char) c; result = c; } } @@ -365,8 +365,8 @@ if ( pdfs->file != NULL ) { - result = fwrite( x, 1, nitems, pdfs->file ); - pdfs->bp += nitems; + result = (int) fwrite( x, 1, (size_t) nitems, pdfs->file ); + pdfs->bp += (size_t) nitems; #ifdef PLPLOT_USE_TCL_CHANNELS } else if ( pdfs->tclChan != NULL ) @@ -411,8 +411,8 @@ if ( pdfs->file != NULL ) { - result = fread( x, 1, nitems, pdfs->file ); - pdfs->bp += nitems; + result = (int) fread( x, 1, (size_t) nitems, pdfs->file ); + pdfs->bp += (size_t) nitems; #ifdef PLPLOT_USE_TCL_CHANNELS } else if ( pdfs->tclChan != NULL ) @@ -482,7 +482,7 @@ if ( ( c = pdf_getc( pdfs ) ) == EOF ) return PDF_RDERR; - header[i] = c; + header[i] = (char) c; if ( header[i] == '\n' ) break; } @@ -531,7 +531,7 @@ if ( ( c = pdf_getc( pdfs ) ) == EOF ) return PDF_RDERR; - string[i] = c; + string[i] = (char) c; if ( c == '\0' ) break; } @@ -610,8 +610,8 @@ return PDF_RDERR; *ps = 0; - *ps |= (U_LONG) x[0]; - *ps |= (U_LONG) x[1] << 8; + *ps |= (U_SHORT) x[0]; + *ps |= (U_SHORT) x[1] << 8; return 0; } @@ -772,10 +772,11 @@ int pdf_wr_ieeef( PDFstrm *pdfs, float f ) { - double fdbl, fmant, f_new; - float fsgl, f_tmp; - int istat, ex, e_new, e_off, bias = 127; - U_LONG value, s_ieee, e_ieee, f_ieee; + double fdbl, fmant, f_new; + float fsgl, f_tmp; + int istat, ex, e_new, e_off; + const int bias = 127; + U_LONG value, s_ieee, e_ieee, f_ieee; if ( f == 0.0 ) { @@ -803,7 +804,7 @@ } else { - e_ieee = e_new + bias; + e_ieee = (U_LONG) ( e_new + bias ); f_tmp = (float) ( f_new - 1 ); } f_ieee = (U_LONG) ( f_tmp * 8388608 ); // multiply by 2^23 @@ -946,12 +947,12 @@ { PLINT i; - if ( ( *f = (PLFLT **) calloc( nx, sizeof ( PLFLT * ) ) ) == NULL ) + if ( ( *f = (PLFLT **) calloc( (size_t) nx, sizeof ( PLFLT * ) ) ) == NULL ) plexit( "Memory allocation error in \"plAlloc2dGrid\"" ); for ( i = 0; i < nx; i++ ) { - if ( ( ( *f )[i] = (PLFLT *) calloc( ny, sizeof ( PLFLT ) ) ) == NULL ) + if ( ( ( *f )[i] = (PLFLT *) calloc( (size_t) ny, sizeof ( PLFLT ) ) ) == NULL ) plexit( "Memory allocation error in \"plAlloc2dGrid\"" ); } } @@ -986,7 +987,7 @@ int i, j; PLFLT m, M; - if ( !finite( f[0][0] ) ) + if ( !isfinite( f[0][0] ) ) { M = -HUGE_VAL; m = HUGE_VAL; @@ -998,7 +999,7 @@ { for ( j = 0; j < ny; j++ ) { - if ( !finite( f[i][j] ) ) + if ( !isfinite( f[i][j] ) ) continue; if ( f[i][j] > M ) M = f[i][j]; Modified: trunk/src/plarc.c =================================================================== --- trunk/src/plarc.c 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/src/plarc.c 2011-10-17 21:16:39 UTC (rev 11973) @@ -51,7 +51,7 @@ sphi = sin( DEG_TO_RAD( rotate ) ); // The number of line segments used to approximate the arc - segments = fabs( d_angle ) / ( 2.0 * M_PI ) * CIRCLE_SEGMENTS; + segments = (PLINT) ( fabs( d_angle ) / ( 2.0 * M_PI ) * CIRCLE_SEGMENTS ); // Always use at least 2 arc points, otherwise fills will break. if ( segments < 2 ) segments = 2; Modified: trunk/src/plargs.c =================================================================== --- trunk/src/plargs.c 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/src/plargs.c 2011-10-17 21:16:39 UTC (rev 11973) @@ -1116,7 +1116,7 @@ // Set var (can be NULL initially) to point to optarg string - *(char **) tab->var = (const char *) optarg; + *(const char **) tab->var = optarg; break; default: @@ -1247,7 +1247,7 @@ if ( tab->syntax == NULL ) continue; - len = 3 + strlen( tab->syntax ); // space [ string ] + len = 3 + (int) strlen( tab->syntax ); // space [ string ] if ( col + len > 79 ) { fprintf( stderr, "\n " ); // 3 spaces @@ -1728,7 +1728,8 @@ { const char *rgb; char *color_field, *alpha_field; - long bgcolor, r, g, b; + long bgcolor; + PLINT r, g, b; PLFLT a; // Strip off leading "#" (TK-ism) if present. @@ -1761,9 +1762,9 @@ switch ( strlen( color_field ) ) { case 3: - r = ( bgcolor & 0xF00 ) >> 8; - g = ( bgcolor & 0x0F0 ) >> 4; - b = ( bgcolor & 0x00F ); + r = (PLINT) ( ( bgcolor & 0xF00 ) >> 8 ); + g = (PLINT) ( ( bgcolor & 0x0F0 ) >> 4 ); + b = (PLINT) ( bgcolor & 0x00F ); r = r | ( r << 4 ); g = g | ( g << 4 ); // doubling @@ -1771,9 +1772,9 @@ break; case 6: - r = ( bgcolor & 0xFF0000 ) >> 16; - g = ( bgcolor & 0x00FF00 ) >> 8; - b = ( bgcolor & 0x0000FF ); + r = (PLINT) ( ( bgcolor & 0xFF0000 ) >> 16 ); + g = (PLINT) ( ( bgcolor & 0x00FF00 ) >> 8 ); + b = (PLINT) ( bgcolor & 0x0000FF ); break; default: @@ -1975,11 +1976,11 @@ static int opt_fsiz( const char *opt, const char *optarg, void *client_data ) { - PLINT bytemax; - int len = strlen( optarg ); - char lastchar = optarg[len - 1]; - PLFLT multiplier = 1.0e6; - char *spec = (char *) malloc( len + 1 ); + PLINT bytemax; + size_t len = strlen( optarg ); + char lastchar = optarg[len - 1]; + PLFLT multiplier = 1.0e6; + char *spec = (char *) malloc( len + 1 ); if ( spec == NULL ) plexit( "opt_fsiz: Insufficient memory" ); Modified: trunk/src/plbox.c =================================================================== --- trunk/src/plbox.c 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/src/plbox.c 2011-10-17 21:16:39 UTC (rev 11973) @@ -65,6 +65,15 @@ static void label_box( const char *xopt, PLFLT xtick1, const char *yopt, PLFLT ytick1 ); +static void +plP_default_label_log( PLINT axis, PLFLT value, char *string, PLINT len, void *data ); + +static void +plP_default_label_log_fixed( PLINT axis, PLFLT value, char *string, PLINT len, void *data ); + +static void +plP_default_label( PLINT axis, PLFLT value, char *string, PLINT len, void *data ); + //-------------------------------------------------------------------------- // void plbox() // @@ -127,7 +136,7 @@ const char *yopt, PLFLT ytick, PLINT nysub ) { PLBOOL lax, lbx, lcx, ldx, lgx, lix, llx, lsx, ltx, lux, lwx, lxx; - PLBOOL lay, lBy, lby, lCy, lcy, ldy, lgy, liy, lly, lsy, lty, luy, lwy, lxy; + PLBOOL lay, lby, lcy, ldy, lgy, liy, lly, lsy, lty, luy, lwy, lxy; PLINT xmajor, xminor, ymajor, yminor; PLINT i, i1x, i2x, i3x, i4x, i1y, i2y, i3y, i4y; PLINT nxsub1, nysub1; @@ -1148,7 +1157,7 @@ if ( lm && right ) plztx( "v", dx, dy, wx, wy1, wy2, -0.5, pos, 0.0, string ); - lstring = strlen( string ); + lstring = (PLINT) strlen( string ); *digits = MAX( *digits, lstring ); } if ( !ll && !lo && mode ) @@ -1826,7 +1835,6 @@ PLFLT vpwxmi, vpwxma, vpwymi, vpwyma; PLFLT vpwxmin, vpwxmax, vpwymin, vpwymax; PLFLT pos, tn, offset, height, just; - PLFLT factor, tstart; const char *timefmt; PLINT i; PLINT xdigmax, xdigits, xdigmax_old, xdigits_old; @@ -1834,7 +1842,7 @@ PLINT lxmin, lxmax, lymin, lymax; PLINT pxmin, pxmax, pymin, pymax; PLFLT default_mm, char_height_mm, height_mm; - PLFLT string_length_mm, pos_mm; + PLFLT string_length_mm = 0.0, pos_mm = 0.0; plgchr( &default_mm, &char_height_mm ); @@ -2364,7 +2372,7 @@ void plP_default_label_log( PLINT axis, PLFLT value, char *string, PLINT len, void *data ) { // Exponential, i.e. 10^-1, 10^0, 10^1, etc - snprintf( string, len, "10#u%d", (int) ROUND( value ) ); + snprintf( string, (size_t) len, "10#u%d", (int) ROUND( value ) ); } void plP_default_label_log_fixed( PLINT axis, PLFLT value, char *string, PLINT len, void *data ) @@ -2378,11 +2386,11 @@ { char form[FORMAT_LEN]; snprintf( form, FORMAT_LEN, "%%.%df", ABS( exponent ) ); - snprintf( string, len, form, value ); + snprintf( string, (size_t) len, form, value ); } else { - snprintf( string, len, "%d", (int) value ); + snprintf( string, (size_t) len, "%d", (int) value ); } } @@ -2411,7 +2419,7 @@ snprintf( form, FORMAT_LEN, "%%.%df", (int) prec ); snprintf( temp, TEMP_LEN, form, value ); - strncpy( string, temp, len - 1 ); + strncpy( string, temp, (size_t) ( len - 1 ) ); string[len - 1] = '\0'; } Modified: trunk/src/plbuf.c =================================================================== --- trunk/src/plbuf.c 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/src/plbuf.c 2011-10-17 21:16:39 UTC (rev 11973) @@ -115,8 +115,8 @@ wr_data( pls, &npts, sizeof ( PLINT ) ); - wr_data( pls, xa, sizeof ( short ) * npts ); - wr_data( pls, ya, sizeof ( short ) * npts ); + wr_data( pls, xa, sizeof ( short ) * (size_t) npts ); + wr_data( pls, ya, sizeof ( short ) * (size_t) npts ); } //-------------------------------------------------------------------------- @@ -265,9 +265,9 @@ wr_data( pls, &pls->dev_zmin, sizeof ( short ) ); wr_data( pls, &pls->dev_zmax, sizeof ( short ) ); - wr_data( pls, pls->dev_ix, sizeof ( short ) * npts ); - wr_data( pls, pls->dev_iy, sizeof ( short ) * npts ); - wr_data( pls, pls->dev_z, sizeof ( unsigned short ) * ( pls->dev_nptsX - 1 ) * ( pls->dev_nptsY - 1 ) ); + wr_data( pls, pls->dev_ix, sizeof ( short ) * (size_t) npts ); + wr_data( pls, pls->dev_iy, sizeof ( short ) * (size_t) npts ); + wr_data( pls, pls->dev_z, sizeof ( unsigned short ) * (size_t) ( ( pls->dev_nptsX - 1 ) * ( pls->dev_nptsY - 1 ) ) ); } //-------------------------------------------------------------------------- @@ -421,8 +421,8 @@ dbug_enter( "plbuf_fill" ); wr_data( pls, &pls->dev_npts, sizeof ( PLINT ) ); - wr_data( pls, pls->dev_x, sizeof ( short ) * pls->dev_npts ); - wr_data( pls, pls->dev_y, sizeof ( short ) * pls->dev_npts ); + wr_data( pls, pls->dev_x, sizeof ( short ) * (size_t) pls->dev_npts ); + wr_data( pls, pls->dev_y, sizeof ( short ) * (size_t) pls->dev_npts ); } //-------------------------------------------------------------------------- @@ -475,8 +475,8 @@ dbug_enter( "rdbuf_line" ); - rd_data( pls, xpl, sizeof ( short ) * npts ); - rd_data( pls, ypl, sizeof ( short ) * npts ); + rd_data( pls, xpl, sizeof ( short ) * (size_t) npts ); + rd_data( pls, ypl, sizeof ( short ) * (size_t) npts ); plP_line( xpl, ypl ); } @@ -500,8 +500,8 @@ if ( npts > PL_MAXPOLY ) { - xpl = (short *) malloc( ( npts + 1 ) * sizeof ( PLINT ) ); - ypl = (short *) malloc( ( npts + 1 ) * sizeof ( PLINT ) ); + xpl = (short *) malloc( (size_t) ( npts + 1 ) * sizeof ( short ) ); + ypl = (short *) malloc( (size_t) ( npts + 1 ) * sizeof ( short ) ); if ( ( xpl == NULL ) || ( ypl == NULL ) ) { @@ -515,8 +515,8 @@ } - rd_data( pls, xpl, sizeof ( short ) * npts ); - rd_data( pls, ypl, sizeof ( short ) * npts ); + rd_data( pls, xpl, sizeof ( short ) * (size_t) npts ); + rd_data( pls, ypl, sizeof ( short ) * (size_t) npts ); plP_polyline( xpl, ypl, npts ); @@ -736,8 +736,8 @@ if ( npts > PL_MAXPOLY ) { - xpl = (short *) malloc( ( npts + 1 ) * sizeof ( PLINT ) ); - ypl = (short *) malloc( ( npts + 1 ) * sizeof ( PLINT ) ); + xpl = (short *) malloc( (size_t) ( npts + 1 ) * sizeof ( short ) ); + ypl = (short *) malloc( (size_t) ( npts + 1 ) * sizeof ( short ) ); if ( ( xpl == NULL ) || ( ypl == NULL ) ) { @@ -750,8 +750,8 @@ ypl = _ypl; } - rd_data( pls, xpl, sizeof ( short ) * npts ); - rd_data( pls, ypl, sizeof ( short ) * npts ); + rd_data( pls, xpl, sizeof ( short ) * (size_t) npts ); + rd_data( pls, ypl, sizeof ( short ) * (size_t) npts ); plP_fill( xpl, ypl, npts ); @@ -794,14 +794,14 @@ // we still allocate and copy the data because I think that method works // better in a multithreaded environment. I could be wrong. // - if ( ( ( dev_ix = (short *) malloc( npts * sizeof ( short ) ) ) == NULL ) || - ( ( dev_iy = (short *) malloc( npts * sizeof ( short ) ) ) == NULL ) || - ( ( dev_z = (unsigned short *) malloc( ( nptsX - 1 ) * ( nptsY - 1 ) * sizeof ( unsigned short ) ) ) == NULL ) ) + if ( ( ( dev_ix = (short *) malloc( (size_t) npts * sizeof ( short ) ) ) == NULL ) || + ( ( dev_iy = (short *) malloc( (size_t) npts * sizeof ( short ) ) ) == NULL ) || + ( ( dev_z = (unsigned short *) malloc( (size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) * sizeof ( unsigned short ) ) ) == NULL ) ) plexit( "rdbuf_image: Insufficient memory" ); - rd_data( pls, dev_ix, sizeof ( short ) * npts ); - rd_data( pls, dev_iy, sizeof ( short ) * npts ); - rd_data( pls, dev_z, sizeof ( unsigned short ) * ( nptsX - 1 ) * ( nptsY - 1 ) ); + rd_data( pls, dev_ix, sizeof ( short ) * (size_t) npts ); + rd_data( pls, dev_iy, sizeof ( short ) * (size_t) npts ); + rd_data( pls, dev_z, sizeof ( unsigned short ) * (size_t) ( ( nptsX - 1 ) * ( nptsY - 1 ) ) ); // // COMMENTED OUT by Hezekiah Carty @@ -1217,8 +1217,8 @@ // save_size = sizeof ( struct _state ) + 2 * sizeof ( struct _color_map ) - + pls->ncol0 * sizeof ( PLColor ) - + pls->ncol1 * sizeof ( PLColor ); + + (size_t) ( pls->ncol0 ) * sizeof ( PLColor ) + + (size_t) ( pls->ncol1 ) * sizeof ( PLColor ); #ifndef BUFFERED_FILE // Only copy as much of the plot buffer that is being used @@ -1340,9 +1340,9 @@ // Then we need to make space for the colormaps themselves plot_state->color_map[0].cmap = (PLColor *) buf; - buf += sizeof ( PLColor ) * pls->ncol0; + buf += sizeof ( PLColor ) * (size_t) ( pls->ncol0 ); plot_state->color_map[1].cmap = (PLColor *) buf; - buf += sizeof ( PLColor ) * pls->ncol1; + buf += sizeof ( PLColor ) * (size_t) ( pls->ncol1 ); // Save cmap 0 plot_state->color_map[0].icol = pls->icol0; Modified: trunk/src/plcont.c =================================================================== --- trunk/src/plcont.c 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/src/plcont.c 2011-10-17 21:16:39 UTC (rev 11973) @@ -148,9 +148,9 @@ realloc_line( CONT_LINE *line ) { if ( ( ( line->x = (PLFLT *) realloc( line->x, - ( line->npts + LINE_ITEMS ) * sizeof ( PLFLT ) ) ) == NULL ) || + (size_t) ( line->npts + LINE_ITEMS ) * sizeof ( PLFLT ) ) ) == NULL ) || ( ( line->y = (PLFLT *) realloc( line->y, - ( line->npts + LINE_ITEMS ) * sizeof ( PLFLT ) ) ) == NULL ) ) + (size_t) ( line->npts + LINE_ITEMS ) * sizeof ( PLFLT ) ) ) == NULL ) ) plexit( "realloc_line: Insufficient memory" ); } @@ -368,9 +368,9 @@ mant = (int) ( mant * pow( 10.0, prec - 1 ) + 0.5 * mant / fabs( mant ) ) / pow( 10.0, prec - 1 ); snprintf( form, FORM_LEN, "%%.%df", prec - 1 ); - snprintf( string, len, form, mant ); + snprintf( string, (size_t) len, form, mant ); snprintf( tmpstring, TMPSTRING_LEN, "#(229)10#u%d", exponent ); - strncat( string, tmpstring, len - strlen( string ) - 1 ); + strncat( string, tmpstring, (size_t) len - strlen( string ) - 1 ); if ( abs( exponent ) < limexp || value == 0.0 ) { @@ -385,7 +385,7 @@ prec = 0; snprintf( form, FORM_LEN, "%%.%df", (int) prec ); - snprintf( string, len, form, value ); + snprintf( string, (size_t) len, form, value ); } } @@ -567,14 +567,14 @@ return; } - if ( ( ipts = (PLINT **) malloc( nx * sizeof ( PLINT * ) ) ) == NULL ) + if ( ( ipts = (PLINT **) malloc( (size_t) nx * sizeof ( PLINT * ) ) ) == NULL ) { plexit( "plfcont: Insufficient memory" ); } for ( i = 0; i < nx; i++ ) { - if ( ( ipts[i] = (PLINT *) malloc( ny * sizeof ( PLINT * ) ) ) == NULL ) + if ( ( ipts[i] = (PLINT *) malloc( (size_t) ny * sizeof ( PLINT * ) ) ) == NULL ) { plexit( "plfcont: Insufficient memory" ); } Modified: trunk/src/plcore.c =================================================================== --- trunk/src/plcore.c 2011-10-17 20:22:53 UTC (rev 11972) +++ trunk/src/plcore.c 2011-10-17 21:16:39 UTC (rev 11973) @@ -89,6 +89,12 @@ #include <errno.h> +int +text2num( const char *text, char end, PLUNICODE *num ); + +int +text2fci( const char *text, unsigned char *hexdigit, unsigned char *hexpower ); + //-------------------------------------------------------------------------- // Driver Interface // @@ -539,7 +545,7 @@ char *endptr; char msgbuf[BUFFER_SIZE]; - *num = strtoul( text, &endptr, 0 ); + *num = (PLUNICODE) strtoul( text, &endptr, 0 ); if ( end != endptr[0] ) { @@ -572,7 +578,7 @@ { typedef struct { - char *ptext; + const char *ptext; unsigned char hexdigit; unsigned char hexpower; } @@ -596,8 +602,8 @@ int i, length; for ( i = 0; i < N_TextLookupTable; i++ ) { - length = strlen( lookup[i].ptext ); - if ( !strncmp( text, lookup[i].ptext, length ) ) + length = (int) strlen( lookup[i].ptext ); + if ( !strncmp( text, lookup[i].ptext, (size_t) length ) ) { *hexdigit = lookup[i].hexdigit; *hexpower = lookup[i].hexpower; @@ -617,13 +623,13 @@ { if ( plsc->dev_text ) // Does the device render it's own text ? { - EscText args; - short len = 0; - char skip; - unsigned short i, j; - PLUNICODE code; - char esc; - int idx; + EscText args; + short len = 0; + char skip; + int i, j; + PLUNICODE code; + char esc; + int idx = -1; args.base = base; args.just = just; @@ -648,9 +654,9 @@ // { - len = strlen( string ); // this length is only used in the loop - // counter, we will work out the length of - // the unicode string as we go + len = (short) strlen( string ); // this length is only used in the loop + // counter, we will work out the length of + // the unicode string as we go plgesc( &esc ); // At this stage we will do some translations into unicode, like @@ -677,8 +683,8 @@ switch ( string[i + 1] ) { case '(': // hershey code - i += 2 + text2num( &string[i + 2], ')', &code ); - idx = plhershey2unicode( code ); + i += ( 2 + text2num( &string[i + 2], ')', &code ) ); + idx = plhershey2unicode( (int) code ); unicode_buffer[j++] = \ (PLUNICODE) hershey_to_unicode_lookup_table[idx].Unicode; @@ -690,14 +696,14 @@ // escape characters that are interpreted by the device // driver. // - if ( unicode_buffer[j - 1] == esc ) - unicode_buffer[j++] = esc; + if ( unicode_buffer[j - 1] == (PLUNICODE) esc ) + unicode_buffer[j++] = (PLUNICODE) esc; j--; skip = 1; break; case '[': // unicode - i += 2 + text2num( &string[i + 2], ']', &code ); + i += ( 2 + text2num( &string[i + 2], ']', &code ) ); unicode_buffer[j++] = code; @@ -708,8 +714,8 @@ // escape characters that are interpreted by the device // driver. // - if ( unicode_buffer[j - 1] == esc ) - unicode_buffer[j++] = esc; + if ( unicode_buffer[j - 1] == (PLUNICODE) esc ) + unicode_buffer[j++] = (PLUNICODE) esc; j--; skip = 1; break; @@ -817,7 +823,7 @@ ig = 685; else if ( ig == 647 ) ig = 686; - idx = plhershey2unicode( ig ); + idx = (int) plhershey2unicode( ig ); unicode_buffer[j++] = \ (PLUNICODE) hershey_to_unicode_lookup_table[idx].Unicode; i += 2; @@ -840,11 +846,11 @@ if ( skip == 0 ) { - PLUNICODE unichar = 0; + PLUNICODE unichar = 0; #ifdef HAVE_LIBUNICODE - char * ptr = unicode_get_utf8( string + i, &unichar ); + const char * ptr = unicode_get_utf8( string + i, &unichar ); #else - char * ptr = utf8_to_ucs4( string + i, &unichar ); + const char * ptr = utf8_to_ucs4( string + i, &unichar ); #endif if ( ptr == NULL ) { @@ -858,27 +864,27 @@ return; } unicode_buffer [j] = unichar; - i += ptr - ( string + i ) - 1; + i += (int) ( ptr - ( string + i ) - 1 ); // Search for escesc (an unescaped escape) in the input // string and adjust unicode_buffer accordingly). // - if ( unicode_buffer[j] == esc && string[i + 1] == esc ) + if ( unicode_buffer[j] == (PLUNICODE) esc && string[i + 1] == esc ) { i++; - unicode_buffer[++j] = esc; + unicode_buffer[++j] = (PLUNICODE) esc; } } j++; } if ( j > 0 ) { - args.unicode_array_len = j; // Much easier to set the length than + args.unicode_array_len = (short unsigned int) j; // Much easier to set the length than // work it out later :-) - args.unicode_array = &unicode_buffer[0]; // Get address of the - // unicode buffer (even - // though it is - // currently static) + args.unicode_array = &unicode_buffer[0]; // Get address of the + // unicode buffer (even + // though it is + // currently static) } @@ -899,7 +905,7 @@ { case '(': // hershey code i += 2 + text2num( &string[i + 2], ')', &code ); - idx = plhershey2unicode( code ); + idx = plhershey2unicode( (int) code ); args.n_char = \ (PLUNICODE) hershey_to_unicode_lookup_table[idx].Unicode; plP_esc( PLESC_TEXT_CHAR, &args ); @@ -1069,11 +1075,11 @@ if ( skip == 0 ) { - PLUNICODE unichar = 0; + PLUNICODE unichar = 0; #ifdef HAVE_LIBUNICODE - char * ptr = unicode_get_utf8( string + i, &unichar ); + const char * ptr = unicode_get_utf8( string + i, &unichar ); #else - char * ptr = utf8_to_ucs4( string + i, &unichar ); + const char * ptr = utf8_to_ucs4( string + i, &unichar ); #endif if ( ptr == NULL ) { @@ -1086,7 +1092,7 @@ plabort( buf ); return; } - i += ptr - ( string + i ) - 1; + i += (int) ( ptr - ( string + i ) - 1 ); // Search for escesc (an unescaped escape) in the input // string and adjust unicode_buffer accordingly). @@ -1094,7 +1100,7 @@ if ( string[i] == esc && string[i + 1] == esc ) { i++; - args.n_char = esc; + args.n_char = (PLUNICODE) esc; } else { @@ -1134,7 +1140,7 @@ } // convert utf8 string to ucs4 unichar -static char * +static const char * utf8_to_ucs4( const char *ptr, PLUNICODE *unichar ) { char tmp; @@ -1199,7 +1205,7 @@ } } } while ( cnt > 0 ); - return (char *) ptr; + return ptr; } // convert ucs4 unichar to utf8 string @@ -1219,31 +1225,31 @@ } else if ( ( unichar & 0xfff800 ) == 0 ) // two bytes { - *tmp = (unsigned char) 0xc0 | ( unichar >> 6 ); + *tmp = (unsigned char) 0xc0 | (unsigned char) ( unichar >> 6 ); tmp++; - *tmp = (unsigned char) 0x80 | ( unichar & 0x3f ); + *tmp = (unsigned char) 0x80 | (unsigned char) ( unichar & 0x3f ); tmp++; len = 2; } else if ( ( unichar & 0xff0000 ) == 0 ) // three bytes { - *tmp = (unsigned char) 0xe0 | ( unichar >> 12 ); + *tmp = (unsigned char) 0xe0 | (unsigned char) ( unichar >> 12 ); tmp++; - *tmp = (unsigned char) 0x80 | ( ( unichar >> 6 ) & 0x3f ); + *tmp = (unsigned char) 0x80 | (unsigned char) ( ( unichar >> 6 ) & 0x3f ); tmp++; - *tmp = (unsigned char) 0x80 | ( unichar & 0x3f ); + *tmp = (unsigned char) 0x80 | ( (unsigned char) unichar & 0x3f ); tmp++; len = 3; } else if ( ( unichar & 0xe0000 ) == 0 ) // four bytes { - *tmp = (unsigned char) 0xf0 | ( unichar >> 18 ); + *tmp = (unsigned char) 0xf0 | (unsigned char) ( unichar >> 18 ); tmp++; - *tmp = (unsigned char) 0x80 | ( ( unichar >> 12 ) & 0x3f ); + *tmp = (unsigned char) 0x80 | (unsigned char) ( ( unichar >> 12 ) & 0x3f ); tmp++; - *tmp = (unsigned char) 0x80 | ( ( unichar >> 6 ) & 0x3f ); + *tmp = (unsigned char) 0x80 | (unsigned char) ( ( unichar >> 6 ) & 0x3f ); tmp++; - *tmp = (unsigned char) 0x80 | ( unichar & 0x3f ); + *tmp = (unsigned char) 0x80 | (unsigned char) ( unichar & 0x3f ); tmp++; len = 4; } @@ -1335,7 +1341,7 @@ //-------------------------------------------------------------------------- void -difilt( PLINT *xscl, PLINT *yscl, PLINT npts, +difilt( PLINT *xsc, PLINT *ysc, PLINT npts, PLINT *clpxmi, PLINT *clpxma, PLINT *clpymi, PLINT *clpyma ) { PLINT i, x, y; @@ -1346,8 +1352,8 @@ { for ( i = 0; i < npts; i++ ) { - xscl[i] = (PLINT) ( plsc->dimxax * xscl[i] + plsc->dimxb ); - yscl[i]... [truncated message content] |