summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2003-07-17 09:58:13 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2003-07-17 09:58:13 (GMT)
commite4f1f83a7bade235b9bf9b51ef349ce33ccf2b5c (patch)
treee2103ff5ad7fa5c1d4d87c45e33f6b534eabe6de
parent1e153f3dbf586557f291abfb9068871b58c67382 (diff)
downloadtk-e4f1f83a7bade235b9bf9b51ef349ce33ccf2b5c.zip
tk-e4f1f83a7bade235b9bf9b51ef349ce33ccf2b5c.tar.gz
tk-e4f1f83a7bade235b9bf9b51ef349ce33ccf2b5c.tar.bz2
I prefer direct return from switch processing; simpler to understand.
Also resolves [Bug 771988] since the breaks are "wrong" in that style.
-rw-r--r--ChangeLog7
-rw-r--r--generic/tkImgPhoto.c35
2 files changed, 23 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 33b9848..4baff2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-07-17 Donal K. Fellows <fellowsd@cs.man.ac.uk>
+
+ * generic/tkImgPhoto.c (ImgPhotoCmd): Rewrote subcommand processing
+ to never jump to the end of the switch. I find that confusing as
+ I can't see whether there's processing still to be done from a
+ quick glance at the code, unlike with a direct return. [Bug 771988]
+
2003-07-16 Don Porter <dgp@users.sourceforge.net>
* generic/tkPack.c (ConfigureSlaves): silence compiler warning
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 8379f1d..4153648 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -16,7 +16,7 @@
* Department of Computer Science,
* Australian National University.
*
- * RCS: @(#) $Id: tkImgPhoto.c,v 1.36 2002/10/18 00:48:22 hobbs Exp $
+ * RCS: @(#) $Id: tkImgPhoto.c,v 1.36.2.1 2003/07/17 09:58:14 dkf Exp $
*/
#include "tkInt.h"
@@ -686,11 +686,11 @@ ImgPhotoCmd(clientData, interp, objc, objv)
if (objc == 2) {
Tk_PhotoBlank(masterPtr);
+ return TCL_OK;
} else {
Tcl_WrongNumArgs(interp, 2, objv, (char *) NULL);
return TCL_ERROR;
}
- break;
case PHOTO_CGET: {
char *arg;
@@ -704,17 +704,15 @@ ImgPhotoCmd(clientData, interp, objc, objv)
if (masterPtr->dataString) {
Tcl_SetObjResult(interp, masterPtr->dataString);
}
- return TCL_OK;
- }
- if (strncmp(arg,"-format", length) == 0) {
+ } else if (strncmp(arg,"-format", length) == 0) {
if (masterPtr->format) {
Tcl_SetObjResult(interp, masterPtr->format);
}
- return TCL_OK;
+ } else {
+ Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs,
+ (char *) masterPtr, Tcl_GetString(objv[2]), 0);
}
- Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs,
- (char *) masterPtr, Tcl_GetString(objv[2]), 0);
- break;
+ return TCL_OK;
}
case PHOTO_CONFIGURE:
@@ -882,8 +880,7 @@ ImgPhotoCmd(clientData, interp, objc, objv)
options.toY2 - options.toY, options.zoomX, options.zoomY,
options.subsampleX, options.subsampleY,
options.compositingRule);
-
- break;
+ return TCL_OK;
case PHOTO_DATA: {
char *data;
@@ -968,7 +965,6 @@ ImgPhotoCmd(clientData, interp, objc, objv)
ckfree(data);
}
return result;
- break;
}
case PHOTO_GET: {
@@ -1001,7 +997,7 @@ ImgPhotoCmd(clientData, interp, objc, objv)
sprintf(string, "%d %d %d", pixelPtr[0], pixelPtr[1],
pixelPtr[2]);
Tcl_AppendResult(interp, string, (char *) NULL);
- break;
+ return TCL_OK;
}
case PHOTO_PUT:
@@ -1129,7 +1125,7 @@ ImgPhotoCmd(clientData, interp, objc, objv)
options.toX, options.toY, options.toX2 - options.toX,
options.toY2 - options.toY, TK_PHOTO_COMPOSITE_SET);
ckfree((char *) block.pixelPtr);
- break;
+ return TCL_OK;
case PHOTO_READ: {
Tcl_Obj *format;
@@ -1240,7 +1236,6 @@ ImgPhotoCmd(clientData, interp, objc, objv)
Tcl_Close(NULL, chan);
}
return result;
- break;
}
case PHOTO_REDITHER:
@@ -1276,7 +1271,7 @@ ImgPhotoCmd(clientData, interp, objc, objv)
(masterPtr->width - x), (masterPtr->height - y),
masterPtr->width, masterPtr->height);
}
- break;
+ return TCL_OK;
case PHOTO_TRANS: {
static CONST char *photoTransOptions[] = {
@@ -1391,10 +1386,11 @@ ImgPhotoCmd(clientData, interp, objc, objv)
Tk_ImageChanged(masterPtr->tkMaster, x, y, 1, 1,
masterPtr->width, masterPtr->height);
masterPtr->flags &= ~IMAGE_CHANGED;
+ return TCL_OK;
}
-
}
- return TCL_OK;
+
+ panic("unexpected fallthrough");
}
case PHOTO_WRITE: {
@@ -1516,7 +1512,8 @@ ImgPhotoCmd(clientData, interp, objc, objv)
}
}
- return TCL_OK;
+ panic("unexpected fallthrough");
+ return TCL_ERROR; /* NOT REACHED */
}
/*