From db010468005eb279d242a698ed5b89b05bc0d817 Mon Sep 17 00:00:00 2001 From: David Mathog <> Date: Thu, 27 Sep 2012 08:40:44 +0200 Subject: fix compiler warnings with old GCC on Mac OS X and Solaris (bzr r11668.1.16) --- src/extension/internal/emf-inout.cpp | 42 ++++++++++++++++----------- src/extension/internal/emf-print.cpp | 30 +++++++++----------- src/extension/internal/uemf.c | 6 ++-- src/extension/internal/uemf_endian.c | 55 +++++++++++++++++++++++------------- 4 files changed, 78 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 9fef38333..44f7d0465 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -138,7 +138,7 @@ my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) p->size += length; } -void toPNG(PMEMPNG accum, int width, int height, char *px, uint32_t cbPx){ +void toPNG(PMEMPNG accum, int width, int height, char *px){ bitmap_t bmstore; bitmap_t *bitmap=&bmstore; accum->buffer=NULL; // PNG constructed in memory will end up here, caller must free(). @@ -650,8 +650,7 @@ uint32_t add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint32_t toPNG( // Get the image from the RGBA px into mempng &mempng, width, height, - rgba_px, - 4 * width * height); + rgba_px); free(rgba_px); } } @@ -1462,7 +1461,8 @@ std::cout << "BEFORE DRAW" tmp_outdef << "xDPI = 2540; @@ -2557,8 +2557,7 @@ std::cout << "BEFORE DRAW" toPNG( // Get the image from the RGBA px into mempng &mempng, width, height, - rgba_px, - 4 * width * height); + rgba_px); free(rgba_px); } } @@ -2710,18 +2709,20 @@ std::cout << "BEFORE DRAW" // EMF textalignment is a bit strange: 0x6 is center, 0x2 is right, 0x0 is left, the value 0x4 is also drawn left int lcr = ((d->dc[d->level].textAlign & U_TA_CENTER) == U_TA_CENTER) ? 2 : ((d->dc[d->level].textAlign & U_TA_CENTER) == U_TA_LEFT) ? 0 : 1; - ts << " id++) << "\"\n"; - ts << " xml:space=\"preserve\"\n"; - ts << " x=\"" << x << "\"\n"; - ts << " y=\"" << y << "\"\n"; + ts << "dc[d->level].style.baseline_shift.value) { - ts << " transform=\"" + ts << " transform=\"" << "rotate(-" << d->dc[d->level].style.baseline_shift.value << " " << x << " " << y << ")" << "\"\n"; } - ts << " style=\"" + ts << ">dc[d->level].style.font_size.computed) << "px;" << tmp << "font-style:" << (i ? "italic" : "normal") << ";" @@ -2732,6 +2733,7 @@ std::cout << "BEFORE DRAW" << "\"\n"; ts << " >"; ts << escaped_text; + ts << " "; ts << "\n"; *(d->outsvg) += ts.str().c_str(); @@ -2989,7 +2991,7 @@ std::cout << "BEFORE DRAW" } //end of while // When testing, uncomment the following to show the final SVG derived from the EMF -// std::cout << *(d->outsvg) << std::endl; +std::cout << *(d->outsvg) << std::endl; return 1; } @@ -3019,6 +3021,12 @@ typedef struct } APMHEADER, *PAPMHEADER; #pragma pack( pop ) +void free_emf_strings(EMF_STRINGS name){ + if(name.count){ + for(int i=0; i< name.count; i++){ free(name.strings[i]); } + free(name.strings); + } +} SPDocument * Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) @@ -3080,9 +3088,9 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) delete d.path; delete d.outdef; delete d.defs; - if(d.hatches.count){ free(d.hatches.strings); } - if(d.images.count){ free(d.images.strings); } - + free_emf_strings(d.hatches); + free_emf_strings(d.images); + if (d.emf_obj) { int i; for (i=0; iFace(style->text->font_family.value, font_style_to_pos(*style)); - if (tf) { - LOGFONT *lf = pango_win32_font_logfont(tf->pFont); - tf->Unref(); - hfont = CreateFontIndirect(lf); - g_free(lf); - } -*/ -#endif + double ky; // the dx array is smuggled in like: textw1 w2 w3 ...wn, where the widths are floats 7 characters wide, including the space int ndx; uint32_t *adx; - smuggle_adx_out(text, &adx, &ndx, PX2WORLD * std::min(tf.expansionX(),tf.expansionY())); // side effect: free() adx + smuggle_adxky_out(text, &adx, &ky, &ndx, PX2WORLD * std::min(tf.expansionX(),tf.expansionY())); // side effect: free() adx char *text2 = strdup(text); // because U_Utf8ToUtf16le calls iconv which does not like a const char * uint16_t *unicode_text = U_Utf8ToUtf16le( text2, 0, NULL ); @@ -2045,8 +2039,12 @@ unsigned int PrintEmf::text(Inkscape::Extension::Print * /*mod*/, char const *te Geom::Point p2 = p * tf; //Handle super/subscripts. Negative sign because of geometry of MM_TEXT. +/* p2[Geom::X] -= style->baseline_shift.computed * std::sin( rotb ); p2[Geom::Y] -= style->baseline_shift.computed * std::cos( rotb ); +*/ + p2[Geom::X] += ky * std::sin( rotb ); + p2[Geom::Y] += ky * std::cos( rotb ); //Conditionally handle compensation for PPT EMF import bug (affects PPT 2003-2010, at least) if(FixPPTCharPos){ diff --git a/src/extension/internal/uemf.c b/src/extension/internal/uemf.c index 9cbac159e..517f1f99f 100644 --- a/src/extension/internal/uemf.c +++ b/src/extension/internal/uemf.c @@ -14,8 +14,8 @@ /* File: uemf.c -Version: 0.0.8 -Date: 14-SEP-2012 +Version: 0.0.89 +Date: 25-SEP-2012 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu Copyright: 2012 David Mathog and California Institute of Technology (Caltech) @@ -59,7 +59,7 @@ definitions are not needed in end user code, so they are here rather than in uem D = UP4(C); /* pixel array might not be a multiples of 4 bytes*/ \ E = sizeof(U_BITMAPINFOHEADER) + 4 * B->bmiHeader.biClrUsed; /* bmiheader + colortable*/ \ }\ - else { D = 0; E=0; } + else { C = 0; D = 0; E=0; } // variable "off" must be declared in the function diff --git a/src/extension/internal/uemf_endian.c b/src/extension/internal/uemf_endian.c index 703714bbb..9c9f7f578 100644 --- a/src/extension/internal/uemf_endian.c +++ b/src/extension/internal/uemf_endian.c @@ -10,12 +10,15 @@ on the native byte order. The only function here which should be called directly is U_emf_endian(), and then,except for testing purposes, only on a BE machine. + + Many variables are initialized to zero even though they will always be set because + some versions of gcc give spurious "may be used uninitialized" warnings otherwise. */ /* File: uemf_endian.h -Version: 0.0.8 -Date: 17-SEP-2012 +Version: 0.0.9 +Date: 26-SEP-2012 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu Copyright: 2012 David Mathog and California Institute of Technology (Caltech) @@ -286,7 +289,7 @@ void extlogpen_swap( PU_EXTLOGPEN elp, int torev ){ - int count; + int count=0; U_swap4(elp,3); // elpPenStyle elpWidth elpBrushStyle // ordered bytes: elpColor if(torev){ @@ -382,9 +385,9 @@ void emrtext_swap( int torev ){ int off; - uint32_t count; - uint32_t offDx; - uint32_t fOptions; + uint32_t count=0; + uint32_t offDx=0; + uint32_t fOptions=0; pointl_swap(&(pemt->ptlReference),1); // ptlReference if(torev){ count = pemt->nChars; @@ -438,7 +441,7 @@ void core5_swap(char *record, int torev){ // Functions with the same form starting with U_EMRPOLYBEZIER_swap void core1_swap(char *record, int torev){ - int count; + int count=0; PU_EMRPOLYLINETO pEmr = (PU_EMRPOLYLINETO) (record); if(torev){ count = pEmr->cptl; @@ -454,7 +457,8 @@ void core1_swap(char *record, int torev){ // Functions with the same form starting with U_EMRPOLYPOLYLINE_swap void core2_swap(char *record, int torev){ - int count, nPolys; + int count=0; + int nPolys=0; PU_EMRPOLYPOLYLINE pEmr = (PU_EMRPOLYPOLYLINE) (record); if(torev){ count = pEmr->cptl; @@ -488,7 +492,7 @@ void core4_swap(char *record, int torev){ // Functions with the same form starting with U_EMRPOLYBEZIER16_swap void core6_swap(char *record, int torev){ - int count; + int count=0; PU_EMRPOLYBEZIER16 pEmr = (PU_EMRPOLYBEZIER16) (record); if(torev){ count = pEmr->cpts; @@ -530,7 +534,8 @@ void core9_swap(char *record, int torev){ // Functions with the same form starting with U_EMRPOLYPOLYLINE16_swap void core10_swap(char *record, int torev){ - int count, nPolys; + int count=0; + int nPolys=0; PU_EMRPOLYPOLYLINE16 pEmr = (PU_EMRPOLYPOLYLINE16) (record); if(torev){ count = pEmr->cpts; @@ -549,7 +554,9 @@ void core10_swap(char *record, int torev){ // Functions with the same form starting with U_EMRINVERTRGN_swap and U_EMRPAINTRGN_swap, void core11_swap(char *record, int torev){ - int roff,nextroff, limit; + int roff=0; + int nextroff=0; + int limit=0; PU_EMRINVERTRGN pEmr = (PU_EMRINVERTRGN) (record); roff = 0; if(torev){ @@ -718,7 +725,8 @@ void U_EMRSETBRUSHORGEX_swap(char *record, int torev){ // U_EMREOF 14 void U_EMREOF_swap(char *record, int torev){ - int off,cbPalEntries; + int off=0; + int cbPalEntries=0; core5_swap(record, torev); PU_EMREOF pEmr = (PU_EMREOF)(record); if(torev){ @@ -989,7 +997,7 @@ void U_EMRARCTO_swap(char *record, int torev){ // U_EMRPOLYDRAW 56 void U_EMRPOLYDRAW_swap(char *record, int torev){ - int count; + int count=0; core5_swap(record, torev); PU_EMRPOLYDRAW pEmr = (PU_EMRPOLYDRAW)(record); @@ -1079,7 +1087,9 @@ void U_EMRCOMMENT_swap(char *record, int torev){ // U_EMRFILLRGN 71 void U_EMRFILLRGN_swap(char *record, int torev){ - int roff, nextroff, limit; + int roff=0; + int nextroff=0; + int limit=0; roff=0; PU_EMRFILLRGN pEmr = (PU_EMRFILLRGN)(record); if(torev){ @@ -1109,7 +1119,9 @@ void U_EMRFILLRGN_swap(char *record, int torev){ // U_EMRFRAMERGN 72 void U_EMRFRAMERGN_swap(char *record, int torev){ - int roff, nextroff, limit; + int roff=0; + int nextroff=0; + int limit=0; PU_EMRFRAMERGN pEmr = (PU_EMRFRAMERGN)(record); roff = 0; if(torev){ @@ -1150,7 +1162,9 @@ void U_EMRPAINTRGN_swap(char *record, int torev){ // U_EMREXTSELECTCLIPRGN 75 void U_EMREXTSELECTCLIPRGN_swap(char *record, int torev){ - int roff, nextroff, limit; + int roff=0; + int nextroff=0; + int limit=0; PU_EMREXTSELECTCLIPRGN pEmr = (PU_EMREXTSELECTCLIPRGN) (record); roff = 0; if(torev){ @@ -1383,7 +1397,7 @@ void U_EMRPOLYPOLYGON16_swap(char *record, int torev){ // U_EMRPOLYDRAW16 92 void U_EMRPOLYDRAW16_swap(char *record, int torev){ - int count; + int count=0; core5_swap(record, torev); PU_EMRPOLYDRAW16 pEmr = (PU_EMRPOLYDRAW16)(record); if(torev){ @@ -1472,7 +1486,8 @@ void U_EMRPIXELFORMAT_swap(char *record, int torev){ // U_EMRSMALLTEXTOUT 108 void U_EMRSMALLTEXTOUT_swap(char *record, int torev){ - int roff,fuOptions; + int roff=0; + int fuOptions=0; core5_swap(record, torev); PU_EMRSMALLTEXTOUT pEmr = (PU_EMRSMALLTEXTOUT)(record); if(torev){ @@ -1521,7 +1536,9 @@ void U_EMRTRANSPARENTBLT_swap(char *record, int torev){ #define U_EMRUNDEF117_swap U_EMRNOTIMPLEMENTED_swap // U_EMRGRADIENTFILL 118 void U_EMRGRADIENTFILL_swap(char *record, int torev){ - int nTriVert,nGradObj,ulMode; + int nTriVert=0; + int nGradObj=0; + int ulMode=0; core5_swap(record, torev); PU_EMRGRADIENTFILL pEmr = (PU_EMRGRADIENTFILL)(record); if(torev){ -- cgit v1.2.3