From e9c0596dfe6f71e774308c10577dddded9388976 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 10 Feb 2020 09:17:45 -0500 Subject: [PATCH] One additional change to allow a single value to the "format" command to apply to both column widths. --- tcltk/tclnetgen.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tcltk/tclnetgen.c b/tcltk/tclnetgen.c index 6aea747..0062d07 100644 --- a/tcltk/tclnetgen.c +++ b/tcltk/tclnetgen.c @@ -1978,7 +1978,7 @@ _netgen_printmem(ClientData clientData, /*------------------------------------------------------*/ /* Function name: _netcmp_format */ /* Syntax: */ -/* netgen::format [col1_width col2_width] */ +/* netgen::format [col1_width [col2_width]] */ /* Formerly: (none) */ /* Results: */ /* Side Effects: */ @@ -1990,11 +1990,16 @@ _netcmp_format(ClientData clientData, { int col1_width = 41, col2_width = 41; - if (objc == 3) { + if (objc > 1) { if (Tcl_GetIntFromObj(interp, objv[1], &col1_width) != TCL_OK) return TCL_ERROR; - if (Tcl_GetIntFromObj(interp, objv[2], &col2_width) != TCL_OK) - return TCL_ERROR; + if (objc > 2) { + if (Tcl_GetIntFromObj(interp, objv[2], &col2_width) != TCL_OK) + return TCL_ERROR; + } else { + /* If only one argument is given, then apply it to both columns */ + col2_width = col1_width; + } if (col1_width <= 0 || col2_width <= 0) { Tcl_SetResult(interp, "Column width cannot be zero or less\n", NULL); @@ -2020,7 +2025,7 @@ _netcmp_format(ClientData clientData, return TCL_OK; } else { - Tcl_WrongNumArgs(interp, 1, objv, "col1_width col2_width"); + Tcl_WrongNumArgs(interp, 1, objv, "[col1_width [col2_width]]"); return TCL_ERROR; } }