From c0be84b4c9232938ac6a20dc56602a34c01d0d01 Mon Sep 17 00:00:00 2001 From: Nathan Johansen Date: Sun, 15 Jan 2023 17:59:21 +0000 Subject: [PATCH] Update emf-inout.cpp to replace deprecated instances of 'sprintf' with 'snprintf' for compatibility reasons. --- src/extension/internal/emf-inout.cpp | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 71a586977b..919c58f467 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -253,14 +253,14 @@ uint32_t Emf::add_hatch(PEMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hat switch(hatchType){ case U_HS_SOLIDTEXTCLR: case U_HS_DITHEREDTEXTCLR: - sprintf(tmpcolor,"%6.6X",sethexcolor(d->dc[d->level].textColor)); + snprintf(tmpcolor,"%6.6X",sethexcolor(d->dc[d->level].textColor)); break; case U_HS_SOLIDBKCLR: case U_HS_DITHEREDBKCLR: - sprintf(tmpcolor,"%6.6X",sethexcolor(d->dc[d->level].bkColor)); + snprintf(tmpcolor,"%6.6X",sethexcolor(d->dc[d->level].bkColor)); break; default: - sprintf(tmpcolor,"%6.6X",sethexcolor(hatchColor)); + snprintf(tmpcolor,"%6.6X",sethexcolor(hatchColor)); break; } @@ -268,7 +268,7 @@ uint32_t Emf::add_hatch(PEMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hat This will be used late to compose, or recompose the transparent or opaque final hatch.*/ std::string refpath; // used to reference later the path pieces which are about to be created - sprintf(hpathname,"EMFhpath%d_%s",hatchType,tmpcolor); + snprintf(hpathname,"EMFhpath%d_%s",hatchType,tmpcolor); idx = in_hatches(d,hpathname); auto & defs = d->defs; if(!idx){ // add path/color if not already present @@ -392,8 +392,8 @@ uint32_t Emf::add_hatch(PEMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hat } if(d->dc[d->level].bkMode == U_TRANSPARENT || hatchType >= U_HS_SOLIDCLR){ - sprintf(hatchname,"EMFhatch%d_%s",hatchType,tmpcolor); - sprintf(hpathname,"EMFhpath%d_%s",hatchType,tmpcolor); + snprintf(hatchname,"EMFhatch%d_%s",hatchType,tmpcolor); + snprintf(hpathname,"EMFhpath%d_%s",hatchType,tmpcolor); idx = in_hatches(d,hatchname); if(!idx){ // add it if not already present if(d->hatches.count == d->hatches.size){ enlarge_hatches(d); } @@ -409,8 +409,8 @@ uint32_t Emf::add_hatch(PEMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hat } else { // bkMode==U_OPAQUE /* Set up an object in the defs for this background, if there is not one already there */ - sprintf(bkcolor,"%6.6X",sethexcolor(d->dc[d->level].bkColor)); - sprintf(hbkname,"EMFhbkclr_%s",bkcolor); + snprintf(bkcolor,"%6.6X",sethexcolor(d->dc[d->level].bkColor)); + snprintf(hbkname,"EMFhbkclr_%s",bkcolor); idx = in_hatches(d,hbkname); if(!idx){ // add path/color if not already present. Hatchtype is not needed in the name. if(d->hatches.count == d->hatches.size){ enlarge_hatches(d); } @@ -425,7 +425,7 @@ uint32_t Emf::add_hatch(PEMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hat } // this is the pattern, its name will show up in Inkscape's pattern selector - sprintf(hatchname,"EMFhatch%d_%s_%s",hatchType,tmpcolor,bkcolor); + snprintf(hatchname,"EMFhatch%d_%s_%s",hatchType,tmpcolor,bkcolor); idx = in_hatches(d,hatchname); if(!idx){ // add it if not already present if(d->hatches.count == d->hatches.size){ enlarge_hatches(d); } @@ -544,8 +544,8 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint idx = d->images.count; d->images.strings[d->images.count++]=strdup(base64String); - sprintf(imagename,"EMFimage%d",idx++); - sprintf(xywh," x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" ",width,height); // reuse this buffer + snprintf(imagename,"EMFimage%d",idx++); + snprintf(xywh," x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" ",width,height); // reuse this buffer defs += "\n"; defs += " = 0.00001 || current_rotation(d) <= -0.00001){ /* some rotation, allow a little rounding error around 0 degrees */ int tangle = round(current_rotation(d)*1000000.0); - sprintf(imrotname,"EMFrotimage%d_%d",idx-1,tangle); + snprintf(imrotname,"EMFrotimage%d_%d",idx-1,tangle); base64String = g_base64_encode((guchar*) imrotname, strlen(imrotname) ); idx = in_images(d, (char *) base64String); // scan for this "image" if(!idx){ if(d->images.count == d->images.size){ enlarge_images(d); } idx = d->images.count; d->images.strings[d->images.count++]=strdup(base64String); - sprintf(imrotname,"EMFimage%d",idx++); + snprintf(imrotname,"EMFimage%d",idx++); defs += "\n"; defs += "