summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkImgPhoto.c44
-rw-r--r--tests/imgPhoto.test2
2 files changed, 22 insertions, 24 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 3e03f3d..cd3df4a 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -813,18 +813,18 @@ ImgPhotoCmd(
case PHOTO_PUT:
/*
- * photo put command - first parse the options and colors specified.
+ * photo put command - first get the image data, then parse the options and colors specified.
*/
- index = 2;
+ index = 3;
memset(&options, 0, sizeof(options));
- options.name = NULL;
- if (ParseSubcommandOptions(&options, interp, OPT_TO|OPT_FORMAT,
- &index, objc, objv) != TCL_OK) {
+ if (objc<3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "data ?-option value ...?");
return TCL_ERROR;
}
- if ((options.name == NULL) || (index < objc)) {
- Tcl_WrongNumArgs(interp, 2, objv, "data ?-option value ...?");
+ options.name = objv[2];
+ if (ParseSubcommandOptions(&options, interp, OPT_TO|OPT_FORMAT,
+ &index, objc, objv) != TCL_OK) {
return TCL_ERROR;
}
@@ -1000,22 +1000,21 @@ ImgPhotoCmd(
Tcl_Obj *format;
/*
- * photo read command - first parse the options specified.
+ * photo read command - first get the filename, then parse the options specified.
*/
- index = 2;
+ index = 3;
memset(&options, 0, sizeof(options));
- options.name = NULL;
- options.format = NULL;
+ if (objc < 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
+ return TCL_ERROR;
+ }
+ options.name = objv[2];
if (ParseSubcommandOptions(&options, interp,
OPT_FORMAT | OPT_FROM | OPT_TO | OPT_SHRINK,
&index, objc, objv) != TCL_OK) {
return TCL_ERROR;
}
- if ((options.name == NULL) || (index < objc)) {
- Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
- return TCL_ERROR;
- }
/*
* Prevent file system access in safe interpreters.
@@ -1292,22 +1291,21 @@ ImgPhotoCmd(
}
/*
- * photo write command - first parse and check any options given.
+ * photo write command - first get the filename, then parse and check any options given.
*/
- index = 2;
+ index = 3;
memset(&options, 0, sizeof(options));
- options.name = NULL;
- options.format = NULL;
+ if (objc<3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
+ return TCL_ERROR;
+ }
+ options.name = objv[2];
if (ParseSubcommandOptions(&options, interp,
OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND,
&index, objc, objv) != TCL_OK) {
return TCL_ERROR;
}
- if ((options.name == NULL) || (index < objc)) {
- Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
- return TCL_ERROR;
- }
if ((options.fromX > masterPtr->width)
|| (options.fromY > masterPtr->height)
|| (options.fromX2 > masterPtr->width)
diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test
index e85f512..062c00c 100644
--- a/tests/imgPhoto.test
+++ b/tests/imgPhoto.test
@@ -422,7 +422,7 @@ test imgPhoto-4.28 {ImgPhotoCmd procedure: put option} -setup {
test imgPhoto-4.29 {ImgPhotoCmd procedure: put option} -setup {
image create photo photo1
} -body {
- photo1 put -to 10 10 20 20 {{white}}
+ photo1 put {{white}} -to 10 10 20 20
photo1 get 19 19
} -cleanup {
image delete photo1