summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2002-10-18 00:48:41 (GMT)
committerhobbs <hobbs>2002-10-18 00:48:41 (GMT)
commit0b7d9e3fb472279afc615ecac40b8ee29a10f3b1 (patch)
tree830c348452f9386274fa7d8c1496d22a4a190e92
parent5da334a4c226388852e03e090587fe7444904083 (diff)
downloadtk-0b7d9e3fb472279afc615ecac40b8ee29a10f3b1.zip
tk-0b7d9e3fb472279afc615ecac40b8ee29a10f3b1.tar.gz
tk-0b7d9e3fb472279afc615ecac40b8ee29a10f3b1.tar.bz2
* tests/imgPhoto.test:
* generic/tkImgPhoto.c (ImgPhotoConfigureMaster): fix arg handling for missing -format or -data options. [Bug #624974]
-rw-r--r--ChangeLog4
-rw-r--r--generic/tkImgPhoto.c22
-rw-r--r--tests/imgPhoto.test11
3 files changed, 29 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index f09f7f1..9cd91d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2002-10-17 Jeff Hobbs <jeffh@ActiveState.com>
+ * tests/imgPhoto.test:
+ * generic/tkImgPhoto.c (ImgPhotoConfigureMaster): fix arg handling
+ for missing -format or -data options. [Bug #624974]
+
* tests/text.test: properly return the number of
* unix/tkUnixFont.c (ControlUtfProc): bytes consumed. [Bug #624732]
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 11c6314..bde05e3 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -15,7 +15,7 @@
* Department of Computer Science,
* Australian National University.
*
- * RCS: @(#) $Id: tkImgPhoto.c,v 1.18.2.2 2001/09/14 20:39:23 andreas_kupries Exp $
+ * RCS: @(#) $Id: tkImgPhoto.c,v 1.18.2.3 2002/10/18 00:48:41 hobbs Exp $
*/
#include "tkInt.h"
@@ -1606,16 +1606,24 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags)
args[j] = Tcl_GetStringFromObj(objv[i], &length);
if ((length > 1) && (args[j][0] == '-')) {
if ((args[j][1] == 'd') &&
- !strncmp(args[j],"-data", (size_t) length)) {
- if (i < objc) {
- data = objv[++i];
+ !strncmp(args[j], "-data", (size_t) length)) {
+ if (++i < objc) {
+ data = objv[i];
j--;
+ } else {
+ Tcl_AppendResult(interp,
+ "value for \"-data\" missing", (char *) NULL);
+ return TCL_ERROR;
}
} else if ((args[j][1] == 'f') &&
- !strncmp(args[j],"-format", (size_t) length)) {
- if (i < objc) {
- format = objv[++i];
+ !strncmp(args[j], "-format", (size_t) length)) {
+ if (++i < objc) {
+ format = objv[i];
j--;
+ } else {
+ Tcl_AppendResult(interp,
+ "value for \"-format\" missing", (char *) NULL);
+ return TCL_ERROR;
}
}
}
diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test
index 28704da..6bc77ec 100644
--- a/tests/imgPhoto.test
+++ b/tests/imgPhoto.test
@@ -9,7 +9,7 @@
#
# Author: Paul Mackerras (paulus@cs.anu.edu.au)
#
-# RCS: @(#) $Id: imgPhoto.test,v 1.7.2.1 2001/04/04 07:57:17 hobbs Exp $
+# RCS: @(#) $Id: imgPhoto.test,v 1.7.2.2 2002/10/18 00:48:41 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
@@ -85,6 +85,15 @@ test imgPhoto-1.7 {options for photo images} {
test imgPhoto-1.8 {options for photo images} {
list [catch {image create photo -blah blah} err] $err
} {1 {unknown option "-blah"}}
+test imgPhoto-1.9 {options for photo images - error case} {
+ list [catch {image create photo -format} err] $err
+} {1 {value for "-format" missing}}
+test imgPhoto-1.10 {options for photo images - error case} {
+ list [catch {image create photo -data} err] $err
+} {1 {value for "-data" missing}}
+test imgPhoto-1.11 {options for photo images - error case} {
+ list [catch {image create photo p1 -format} err] $err
+} {1 {value for "-format" missing}}
test imgPhoto-2.1 {ImgPhotoCreate procedure} {
eval image delete [image names]