From a59604a7c466f09bd2756fcc568c044cbba7dd79 Mon Sep 17 00:00:00 2001 From: "nijtmans@users.sourceforge.net" Date: Wed, 11 Jan 2017 10:51:15 +0000 Subject: Alternative proposed solution for [d4fb4e80d220e46e588f310291fd7a4205e8cd67|d4fb4e80d2], with test-case. --- generic/tkImgPhoto.c | 6 +++++- tests/imgPhoto.test | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 4ee9f69..1bd0142 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -1540,7 +1540,11 @@ ParseSubcommandOptions( */ if (!(allowedOptions & bit)) { - goto unknownOrAmbiguousOption; + if (optPtr->name != NULL) { + goto unknownOrAmbiguousOption; + } + optPtr->name = objv[index]; + continue; } /* diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index db23fea..e93dab4 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -804,6 +804,16 @@ test imgPhoto-4.74 {ImgPhotoCmd procedure: put option error handling} -setup { } -cleanup { image delete photo1 } -returnCodes 1 -result {wrong # args: should be "photo1 put data ?-option value ...?"} +test imgPhoto-4.75 { read command: filename starting with '-'} -constraints { + hasTeapotPhoto +} -body { + file copy -force $teapotPhotoFile -teapotPhotoFile + image create photo photo1 + photo1 read -teapotPhotoFile +} -cleanup { + image delete photo1 + file delete ./-teapotPhotoFile +} -result {} test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} -constraints { hasTeapotPhoto -- cgit v0.12