--- tclClock.c-orig	2006-07-28 17:23:18.687500000 +0100
+++ tclClock.c	2006-07-28 17:49:59.125000000 +0100
@@ -183,6 +183,35 @@
 static void		TzsetIfNecessary(void);
 static void		ClockDeleteCmdProc(ClientData);
 
+/*
+ * Structure containing information needed to create the clock commands.
+ */
+
+typedef struct ClockCommand {
+    char *tail;			/* The tail of the command name. The full
+				 * name is "::tcl::clock::<tail>" */
+    Tcl_ObjCmdProc *objCmdProc;	/* Function that evaluates the function */
+    int usesClockClientData;	/* Boolean - does the objCmdProc use the
+				 * ClockClientData client data */
+	
+} ClockCommand;
+
+static ClockCommand clockCommands[] = {
+    { "clicks",			ClockClicksObjCmd,		0 },
+    { "getenv",			ClockGetenvObjCmd,		0 },
+    { "microseconds",		ClockMicrosecondsObjCmd, 	0 },
+    { "milliseconds",		ClockMillisecondsObjCmd,	0 },
+    { "seconds",		ClockSecondsObjCmd,		0 },
+    { "Oldscan",		TclClockOldscanObjCmd,		0 },
+    { "ConvertLocalToUTC",	ClockConvertlocaltoutcObjCmd,	1 },
+    { "GetDateFields",		ClockGetdatefieldsObjCmd,	1 },
+    { "GetJulianDayFromEraYearMonthDay",
+		ClockGetjuliandayfromerayearmonthdayObjCmd,	1 },
+    { "GetJulianDayFromEraYearWeekDay",
+    		ClockGetjuliandayfromerayearweekdayObjCmd,	1 },
+    { NULL, NULL, 0 }
+};
+
 
 /*
  *----------------------------------------------------------------------
@@ -206,6 +235,10 @@
 TclClockInit(
     Tcl_Interp* interp		/* Tcl interpreter */
 ) {
+    ClockCommand *clockCmd;
+    char cmdName[50];  /* big enough for
+			* "::tcl::clock::GetJulianDayFromEraYearMonthDay" */
+    char *cmdNameTail;
     int i;
 
     /*
@@ -230,36 +263,19 @@
      * Install the commands.
      */
 
-    Tcl_CreateObjCommand(interp,	"::tcl::clock::clicks",
-	    ClockClicksObjCmd,	(ClientData) NULL, NULL);
-    Tcl_CreateObjCommand(interp,	"::tcl::clock::getenv",
-	    ClockGetenvObjCmd,	(ClientData) NULL, NULL);
-    Tcl_CreateObjCommand(interp,	"::tcl::clock::microseconds",
-	    ClockMicrosecondsObjCmd,	(ClientData) NULL, NULL);
-    Tcl_CreateObjCommand(interp,	"::tcl::clock::milliseconds",
-	    ClockMillisecondsObjCmd,	(ClientData) NULL, NULL);
-    Tcl_CreateObjCommand(interp,	"::tcl::clock::seconds",
-	    ClockSecondsObjCmd,	(ClientData) NULL, NULL);
-    Tcl_CreateObjCommand(interp,	"::tcl::clock::Oldscan",
-	    TclClockOldscanObjCmd,	(ClientData) NULL, NULL);
-    Tcl_CreateObjCommand(interp,	"::tcl::clock::ConvertLocalToUTC",
-	    ClockConvertlocaltoutcObjCmd, (ClientData) data,
-	    ClockDeleteCmdProc);
-    ++data->refCount;
-    Tcl_CreateObjCommand(interp,	"::tcl::clock::GetDateFields",
-	    ClockGetdatefieldsObjCmd,(ClientData) data,
-	    ClockDeleteCmdProc);
-    ++data->refCount;
-    Tcl_CreateObjCommand(interp,
-	    "::tcl::clock::GetJulianDayFromEraYearMonthDay",
-	    ClockGetjuliandayfromerayearmonthdayObjCmd,(ClientData) data,
-	    ClockDeleteCmdProc);
-    ++data->refCount;
-    Tcl_CreateObjCommand(interp,
-	    "::tcl::clock::GetJulianDayFromEraYearWeekDay",
-	    ClockGetjuliandayfromerayearweekdayObjCmd,(ClientData) data,
-	    ClockDeleteCmdProc);
-    ++data->refCount;
+    strcpy(cmdName, "::tcl::clock::");
+    cmdNameTail = cmdName + (sizeof("::tcl::clock::") - 1);
+    for (clockCmd = clockCommands; clockCmd->tail != NULL; ++clockCmd) {
+	strcpy(cmdNameTail, clockCmd->tail);
+	if (clockCmd->usesClockClientData) {
+	    Tcl_CreateObjCommand(interp, cmdName, clockCmd->objCmdProc,
+		    (ClientData) data, ClockDeleteCmdProc);
+	    ++data->refCount;
+	} else {
+	    Tcl_CreateObjCommand(interp, cmdName, clockCmd->objCmdProc,
+		    NULL, NULL);
+	}
+    }
 }
 
 /*
