From c3e5b11af87fda44b0ca570f6e266de2b9e0e172 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 10 May 2019 21:03:44 +0000 Subject: Fix [0d93f2e628]: misleading error message on missed svg option --- generic/tkImgPhoto.c | 9 +++++++-- tests/imgListFormat.test | 3 ++- tests/imgPhoto.test | 15 ++++++++++----- tests/imgSVGnano.test | 3 ++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 40cc98a..bf8e61f 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -2644,8 +2644,13 @@ MatchStringFormat( formatString, NULL); return TCL_ERROR; } else { - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "couldn't recognize image data", -1)); + Tcl_Obj *obj = Tcl_NewStringObj("couldn't recognize image data", -1); + + if (Tcl_GetString(Tcl_GetObjResult(interp))[0] != '\0') { + Tcl_AppendObjToObj(obj, Tcl_NewStringObj("\n", -1)); + Tcl_AppendObjToObj(obj, Tcl_GetObjResult(interp)); + } + Tcl_SetObjResult(interp, obj); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "UNRECOGNIZED_DATA", NULL); return TCL_ERROR; diff --git a/tests/imgListFormat.test b/tests/imgListFormat.test index b2c401c..31f2ebd 100644 --- a/tests/imgListFormat.test +++ b/tests/imgListFormat.test @@ -139,7 +139,8 @@ test imgListFormat-3.4 {StringMatchDef: base64 data is not parsed as valid \ } -format default } -cleanup { imageCleanup -} -returnCodes error -result {couldn't recognize image data} +} -returnCodes error -result {couldn't recognize image data +invalid color name "iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCA"} test imgListFormat-3.5 {StringMatchDef: valid data} -setup { image create photo photo1 } -body { diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index eba3355..bcad919 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -542,14 +542,16 @@ test imgPhoto-4.27 {ImgPhotoCmd procedure: put option} -setup { photo1 put {{white} {white white}} } -returnCodes error -cleanup { image delete photo1 -} -result {couldn't recognize image data} +} -result {couldn't recognize image data +invalid row # 1: all rows must have the same number of elements} test imgPhoto-4.28 {ImgPhotoCmd procedure: put option} -setup { image create photo photo1 } -body { photo1 put {{blahgle}} } -cleanup { image delete photo1 -} -returnCodes error -result {couldn't recognize image data} +} -returnCodes error -result {couldn't recognize image data +invalid color name "blahgle"} test imgPhoto-4.29 {ImgPhotoCmd procedure: put option} -setup { image create photo photo1 } -body { @@ -1149,7 +1151,8 @@ test imgPhoto-4.95 {ImgPhotoCmd put: default fmt, invalid data} -setup { #" } -cleanup { imageCleanup -} -returnCodes error -result {couldn't recognize image data} +} -returnCodes error -result {couldn't recognize image data +unmatched open quote in list} test imgPhoto-4.96 {ImgPhotoCmd put: "default" handler is selected} -setup { image create photo photo1 image create photo photo2 @@ -1932,14 +1935,16 @@ test imgPhoto-19.6 {MatchStringFormat: invalid data for default} -setup { photo1 put bogus } -cleanup { imageCleanup -} -returnCodes error -result {couldn't recognize image data} +} -returnCodes error -result {couldn't recognize image data +invalid color name "bogus"} test imgPhoto-19.7 {MatchStringFormat: invalid data for default} -setup { image create photo photo1 } -body { photo1 put bogus -format dEFault } -cleanup { imageCleanup -} -returnCodes error -result {couldn't recognize image data} +} -returnCodes error -result {couldn't recognize image data +invalid color name "bogus"} test imgPhoto-19.8 {MatchStirngFormat: invalid data for gif} -setup { image create photo photo1 } -body { diff --git a/tests/imgSVGnano.test b/tests/imgSVGnano.test index 74c3318..1cd603c 100644 --- a/tests/imgSVGnano.test +++ b/tests/imgSVGnano.test @@ -78,7 +78,8 @@ test imgSVGnano-2.1 {reading a bad image} -body { } -returnCodes error -result {couldn't recognize image data} test imgSVGnano-2.2 {using bad option} -body { image create photo -data $data(plus) -format {svg -scale 0} -} -returnCodes error -result {couldn't recognize image data} +} -returnCodes error -result {couldn't recognize image data +-scale value must be positive} };# end of namespace svgnano -- cgit v0.12