@@ -91,6 +91,8 @@ static void UpdateStringOfMM(Tcl_Obj *objPtr);
9191static int SetMMFromAny (Tcl_Interp * interp , Tcl_Obj * objPtr );
9292static int SetPixelFromAny (Tcl_Interp * interp , Tcl_Obj * objPtr );
9393static int SetWindowFromAny (Tcl_Interp * interp , Tcl_Obj * objPtr );
94+ static Tcl_Size LengthOneOrTwo (Tcl_Obj * objPtr );
95+
9496
9597/*
9698 * The following structure defines the implementation of the "pixel" Tcl
@@ -104,7 +106,7 @@ static const TkObjType pixelObjType = {
104106 DupPixelInternalRep , /* dupIntRepProc */
105107 NULL , /* updateStringProc */
106108 NULL , /* setFromAnyProc */
107- TCL_OBJTYPE_V1 (TkLengthOne )},
109+ TCL_OBJTYPE_V1 (LengthOneOrTwo )},
108110 0
109111};
110112
@@ -127,7 +129,7 @@ static const TkObjType mmObjType = {
127129 DupMMInternalRep , /* dupIntRepProc */
128130 UpdateStringOfMM , /* updateStringProc */
129131 NULL , /* setFromAnyProc */
130- TCL_OBJTYPE_V1 (TkLengthOne )},
132+ TCL_OBJTYPE_V1 (LengthOneOrTwo )},
131133 0
132134};
133135
@@ -146,6 +148,35 @@ static const TkObjType windowObjType = {
146148 0
147149};
148150
151+ /*
152+ *----------------------------------------------------------------------
153+ *
154+ * LengthOneOrTwo --
155+ *
156+ * Determine the length of a "pixel" or "mm". It returns 2 if there is any
157+ * space between the float and the 'c', 'i', 'm' or 'p', 1 otherwise.
158+ *
159+ *----------------------------------------------------------------------
160+ */
161+ Tcl_Size
162+ LengthOneOrTwo (
163+ Tcl_Obj * objPtr )
164+ {
165+ if (objPtr -> bytes ) {
166+ const char * p = objPtr -> bytes + strlen (objPtr -> bytes );
167+ while (strchr (" \f\n\r\t\v" , * -- p )) {
168+ // skip spacing at end;
169+ }
170+ if (strchr ("cimp" , * p )) {
171+ // Check whether character is preceded by space
172+ if (strchr (" \f\n\r\t\v" , * -- p )) {
173+ return 2 ;
174+ }
175+ }
176+ }
177+ return 1 ;
178+ }
179+
149180/*
150181 *----------------------------------------------------------------------
151182 *
0 commit comments