summaryrefslogtreecommitdiffstats
path: root/generic/tkGet.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkGet.c')
-rw-r--r--generic/tkGet.c504
1 files changed, 246 insertions, 258 deletions
diff --git a/generic/tkGet.c b/generic/tkGet.c
index 4d62c27..b58ae03 100644
--- a/generic/tkGet.c
+++ b/generic/tkGet.c
@@ -1,29 +1,28 @@
-/*
+/*
* tkGet.c --
*
- * This file contains a number of "Tk_GetXXX" procedures, which
- * parse text strings into useful forms for Tk. This file has
- * the simpler procedures, like Tk_GetDirection and Tk_GetUid.
- * The more complex procedures like Tk_GetColor are in separate
- * files.
+ * This file contains a number of "Tk_GetXXX" procedures, which parse
+ * text strings into useful forms for Tk. This file has the simpler
+ * functions, like Tk_GetDirection and Tk_GetUid. The more complex
+ * functions like Tk_GetColor are in separate files.
*
* Copyright (c) 1991-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkGet.c,v 1.10 2002/08/05 04:30:38 dgp Exp $
+ * RCS: @(#) $Id: tkGet.c,v 1.11 2005/11/07 15:58:21 dkf Exp $
*/
#include "tkInt.h"
#include "tkPort.h"
/*
- * One of these structures is created per thread to store
- * thread-specific data. In this case, it is used to house the
- * Tk_Uid structs used by each thread. The "dataKey" below is
- * used to locate the ThreadSpecificData for the current thread.
+ * One of these structures is created per thread to store thread-specific
+ * data. In this case, it is used to house the Tk_Uid structs used by each
+ * thread. The "dataKey" below is used to locate the ThreadSpecificData for
+ * the current thread.
*/
typedef struct ThreadSpecificData {
@@ -32,7 +31,7 @@ typedef struct ThreadSpecificData {
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
-static void FreeUidThreadExitProc _ANSI_ARGS_((ClientData clientData));
+static void FreeUidThreadExitProc(ClientData clientData);
/*
* The following tables defines the string values for reliefs, which are
@@ -40,12 +39,11 @@ static void FreeUidThreadExitProc _ANSI_ARGS_((ClientData clientData));
*/
static CONST char *anchorStrings[] = {
- "n", "ne", "e", "se", "s", "sw", "w", "nw", "center", (char *) NULL
+ "n", "ne", "e", "se", "s", "sw", "w", "nw", "center", NULL
};
static CONST char *justifyStrings[] = {
- "left", "right", "center", (char *) NULL
+ "left", "right", "center", NULL
};
-
/*
*----------------------------------------------------------------------
@@ -66,17 +64,17 @@ static CONST char *justifyStrings[] = {
*/
int
-Tk_GetAnchorFromObj(interp, objPtr, anchorPtr)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tcl_Obj *objPtr; /* The object we are trying to get the
- * value from. */
- Tk_Anchor *anchorPtr; /* Where to place the Tk_Anchor that
+Tk_GetAnchorFromObj(
+ Tcl_Interp *interp, /* Used for error reporting. */
+ Tcl_Obj *objPtr, /* The object we are trying to get the value
+ * from. */
+ Tk_Anchor *anchorPtr) /* Where to place the Tk_Anchor that
* corresponds to the string value of
* objPtr. */
{
int index, code;
- code = Tcl_GetIndexFromObj(interp, objPtr, anchorStrings, "anchor", 0,
+ code = Tcl_GetIndexFromObj(interp, objPtr, anchorStrings, "anchor", 0,
&index);
if (code == TCL_OK) {
*anchorPtr = (Tk_Anchor) index;
@@ -92,11 +90,10 @@ Tk_GetAnchorFromObj(interp, objPtr, anchorPtr)
* Given a string, return the corresponding Tk_Anchor.
*
* Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * position is stored at *anchorPtr; otherwise TCL_ERROR
- * is returned and an error message is left in
- * the interp's result.
+ * The return value is a standard Tcl return result. If TCL_OK is
+ * returned, then everything went well and the position is stored at
+ * *anchorPtr; otherwise TCL_ERROR is returned and an error message is
+ * left in the interp's result.
*
* Side effects:
* None.
@@ -105,62 +102,61 @@ Tk_GetAnchorFromObj(interp, objPtr, anchorPtr)
*/
int
-Tk_GetAnchor(interp, string, anchorPtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- CONST char *string; /* String describing a direction. */
- Tk_Anchor *anchorPtr; /* Where to store Tk_Anchor corresponding
- * to string. */
+Tk_GetAnchor(
+ Tcl_Interp *interp, /* Use this for error reporting. */
+ CONST char *string, /* String describing a direction. */
+ Tk_Anchor *anchorPtr) /* Where to store Tk_Anchor corresponding to
+ * string. */
{
switch (string[0]) {
- case 'n':
- if (string[1] == 0) {
- *anchorPtr = TK_ANCHOR_N;
- return TCL_OK;
- } else if ((string[1] == 'e') && (string[2] == 0)) {
- *anchorPtr = TK_ANCHOR_NE;
- return TCL_OK;
- } else if ((string[1] == 'w') && (string[2] == 0)) {
- *anchorPtr = TK_ANCHOR_NW;
- return TCL_OK;
- }
- goto error;
- case 's':
- if (string[1] == 0) {
- *anchorPtr = TK_ANCHOR_S;
- return TCL_OK;
- } else if ((string[1] == 'e') && (string[2] == 0)) {
- *anchorPtr = TK_ANCHOR_SE;
- return TCL_OK;
- } else if ((string[1] == 'w') && (string[2] == 0)) {
- *anchorPtr = TK_ANCHOR_SW;
- return TCL_OK;
- } else {
- goto error;
- }
- case 'e':
- if (string[1] == 0) {
- *anchorPtr = TK_ANCHOR_E;
- return TCL_OK;
- }
- goto error;
- case 'w':
- if (string[1] == 0) {
- *anchorPtr = TK_ANCHOR_W;
- return TCL_OK;
- }
- goto error;
- case 'c':
- if (strncmp(string, "center", strlen(string)) == 0) {
- *anchorPtr = TK_ANCHOR_CENTER;
- return TCL_OK;
- }
+ case 'n':
+ if (string[1] == 0) {
+ *anchorPtr = TK_ANCHOR_N;
+ return TCL_OK;
+ } else if ((string[1] == 'e') && (string[2] == 0)) {
+ *anchorPtr = TK_ANCHOR_NE;
+ return TCL_OK;
+ } else if ((string[1] == 'w') && (string[2] == 0)) {
+ *anchorPtr = TK_ANCHOR_NW;
+ return TCL_OK;
+ }
+ goto error;
+ case 's':
+ if (string[1] == 0) {
+ *anchorPtr = TK_ANCHOR_S;
+ return TCL_OK;
+ } else if ((string[1] == 'e') && (string[2] == 0)) {
+ *anchorPtr = TK_ANCHOR_SE;
+ return TCL_OK;
+ } else if ((string[1] == 'w') && (string[2] == 0)) {
+ *anchorPtr = TK_ANCHOR_SW;
+ return TCL_OK;
+ } else {
goto error;
+ }
+ case 'e':
+ if (string[1] == 0) {
+ *anchorPtr = TK_ANCHOR_E;
+ return TCL_OK;
+ }
+ goto error;
+ case 'w':
+ if (string[1] == 0) {
+ *anchorPtr = TK_ANCHOR_W;
+ return TCL_OK;
+ }
+ goto error;
+ case 'c':
+ if (strncmp(string, "center", strlen(string)) == 0) {
+ *anchorPtr = TK_ANCHOR_CENTER;
+ return TCL_OK;
+ }
+ goto error;
}
- error:
+ error:
Tcl_AppendResult(interp, "bad anchor position \"", string,
- "\": must be n, ne, e, se, s, sw, w, nw, or center",
- (char *) NULL);
+ "\": must be n, ne, e, se, s, sw, w, nw, or center", NULL);
return TCL_ERROR;
}
@@ -169,8 +165,7 @@ Tk_GetAnchor(interp, string, anchorPtr)
*
* Tk_NameOfAnchor --
*
- * Given a Tk_Anchor, return the string that corresponds
- * to it.
+ * Given a Tk_Anchor, return the string that corresponds to it.
*
* Results:
* None.
@@ -182,20 +177,20 @@ Tk_GetAnchor(interp, string, anchorPtr)
*/
CONST char *
-Tk_NameOfAnchor(anchor)
- Tk_Anchor anchor; /* Anchor for which identifying string
- * is desired. */
+Tk_NameOfAnchor(
+ Tk_Anchor anchor) /* Anchor for which identifying string is
+ * desired. */
{
switch (anchor) {
- case TK_ANCHOR_N: return "n";
- case TK_ANCHOR_NE: return "ne";
- case TK_ANCHOR_E: return "e";
- case TK_ANCHOR_SE: return "se";
- case TK_ANCHOR_S: return "s";
- case TK_ANCHOR_SW: return "sw";
- case TK_ANCHOR_W: return "w";
- case TK_ANCHOR_NW: return "nw";
- case TK_ANCHOR_CENTER: return "center";
+ case TK_ANCHOR_N: return "n";
+ case TK_ANCHOR_NE: return "ne";
+ case TK_ANCHOR_E: return "e";
+ case TK_ANCHOR_SE: return "se";
+ case TK_ANCHOR_S: return "s";
+ case TK_ANCHOR_SW: return "sw";
+ case TK_ANCHOR_W: return "w";
+ case TK_ANCHOR_NW: return "nw";
+ case TK_ANCHOR_CENTER: return "center";
}
return "unknown anchor position";
}
@@ -208,11 +203,10 @@ Tk_NameOfAnchor(anchor)
* Given a string, return the corresponding Tk JoinStyle.
*
* Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * justification is stored at *joinPtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * the interp's result.
+ * The return value is a standard Tcl return result. If TCL_OK is
+ * returned, then everything went well and the justification is stored at
+ * *joinPtr; otherwise TCL_ERROR is returned and an error message is left
+ * in the interp's result.
*
* Side effects:
* None.
@@ -221,11 +215,11 @@ Tk_NameOfAnchor(anchor)
*/
int
-Tk_GetJoinStyle(interp, string, joinPtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- CONST char *string; /* String describing a justification style. */
- int *joinPtr; /* Where to store join style corresponding
- * to string. */
+Tk_GetJoinStyle(
+ Tcl_Interp *interp, /* Use this for error reporting. */
+ CONST char *string, /* String describing a justification style. */
+ int *joinPtr) /* Where to store join style corresponding to
+ * string. */
{
int c;
size_t length;
@@ -247,8 +241,7 @@ Tk_GetJoinStyle(interp, string, joinPtr)
}
Tcl_AppendResult(interp, "bad join style \"", string,
- "\": must be bevel, miter, or round",
- (char *) NULL);
+ "\": must be bevel, miter, or round", NULL);
return TCL_ERROR;
}
@@ -257,8 +250,7 @@ Tk_GetJoinStyle(interp, string, joinPtr)
*
* Tk_NameOfJoinStyle --
*
- * Given a Tk JoinStyle, return the string that corresponds
- * to it.
+ * Given a Tk JoinStyle, return the string that corresponds to it.
*
* Results:
* None.
@@ -270,14 +262,14 @@ Tk_GetJoinStyle(interp, string, joinPtr)
*/
CONST char *
-Tk_NameOfJoinStyle(join)
- int join; /* Join style for which identifying string
- * is desired. */
+Tk_NameOfJoinStyle(
+ int join) /* Join style for which identifying string is
+ * desired. */
{
switch (join) {
- case JoinBevel: return "bevel";
- case JoinMiter: return "miter";
- case JoinRound: return "round";
+ case JoinBevel: return "bevel";
+ case JoinMiter: return "miter";
+ case JoinRound: return "round";
}
return "unknown join style";
}
@@ -290,11 +282,10 @@ Tk_NameOfJoinStyle(join)
* Given a string, return the corresponding Tk CapStyle.
*
* Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * justification is stored at *capPtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * the interp's result.
+ * The return value is a standard Tcl return result. If TCL_OK is
+ * returned, then everything went well and the justification is stored at
+ * *capPtr; otherwise TCL_ERROR is returned and an error message is left
+ * in the interp's result.
*
* Side effects:
* None.
@@ -303,11 +294,11 @@ Tk_NameOfJoinStyle(join)
*/
int
-Tk_GetCapStyle(interp, string, capPtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- CONST char *string; /* String describing a justification style. */
- int *capPtr; /* Where to store cap style corresponding
- * to string. */
+Tk_GetCapStyle(
+ Tcl_Interp *interp, /* Use this for error reporting. */
+ CONST char *string, /* String describing a justification style. */
+ int *capPtr) /* Where to store cap style corresponding to
+ * string. */
{
int c;
size_t length;
@@ -329,8 +320,7 @@ Tk_GetCapStyle(interp, string, capPtr)
}
Tcl_AppendResult(interp, "bad cap style \"", string,
- "\": must be butt, projecting, or round",
- (char *) NULL);
+ "\": must be butt, projecting, or round", NULL);
return TCL_ERROR;
}
@@ -339,8 +329,7 @@ Tk_GetCapStyle(interp, string, capPtr)
*
* Tk_NameOfCapStyle --
*
- * Given a Tk CapStyle, return the string that corresponds
- * to it.
+ * Given a Tk CapStyle, return the string that corresponds to it.
*
* Results:
* None.
@@ -352,14 +341,14 @@ Tk_GetCapStyle(interp, string, capPtr)
*/
CONST char *
-Tk_NameOfCapStyle(cap)
- int cap; /* Cap style for which identifying string
- * is desired. */
+Tk_NameOfCapStyle(
+ int cap) /* Cap style for which identifying string is
+ * desired. */
{
switch (cap) {
- case CapButt: return "butt";
- case CapProjecting: return "projecting";
- case CapRound: return "round";
+ case CapButt: return "butt";
+ case CapProjecting: return "projecting";
+ case CapRound: return "round";
}
return "unknown cap style";
}
@@ -383,11 +372,11 @@ Tk_NameOfCapStyle(cap)
*/
int
-Tk_GetJustifyFromObj(interp, objPtr, justifyPtr)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tcl_Obj *objPtr; /* The object we are trying to get the
- * value from. */
- Tk_Justify *justifyPtr; /* Where to place the Tk_Justify that
+Tk_GetJustifyFromObj(
+ Tcl_Interp *interp, /* Used for error reporting. */
+ Tcl_Obj *objPtr, /* The object we are trying to get the value
+ * from. */
+ Tk_Justify *justifyPtr) /* Where to place the Tk_Justify that
* corresponds to the string value of
* objPtr. */
{
@@ -409,11 +398,10 @@ Tk_GetJustifyFromObj(interp, objPtr, justifyPtr)
* Given a string, return the corresponding Tk_Justify.
*
* Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * justification is stored at *justifyPtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * the interp's result.
+ * The return value is a standard Tcl return result. If TCL_OK is
+ * returned, then everything went well and the justification is stored at
+ * *justifyPtr; otherwise TCL_ERROR is returned and an error message is
+ * left in the interp's result.
*
* Side effects:
* None.
@@ -422,11 +410,11 @@ Tk_GetJustifyFromObj(interp, objPtr, justifyPtr)
*/
int
-Tk_GetJustify(interp, string, justifyPtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- CONST char *string; /* String describing a justification style. */
- Tk_Justify *justifyPtr; /* Where to store Tk_Justify corresponding
- * to string. */
+Tk_GetJustify(
+ Tcl_Interp *interp, /* Use this for error reporting. */
+ CONST char *string, /* String describing a justification style. */
+ Tk_Justify *justifyPtr) /* Where to store Tk_Justify corresponding to
+ * string. */
{
int c;
size_t length;
@@ -448,8 +436,7 @@ Tk_GetJustify(interp, string, justifyPtr)
}
Tcl_AppendResult(interp, "bad justification \"", string,
- "\": must be left, right, or center",
- (char *) NULL);
+ "\": must be left, right, or center", NULL);
return TCL_ERROR;
}
@@ -471,14 +458,14 @@ Tk_GetJustify(interp, string, justifyPtr)
*/
CONST char *
-Tk_NameOfJustify(justify)
- Tk_Justify justify; /* Justification style for which
- * identifying string is desired. */
+Tk_NameOfJustify(
+ Tk_Justify justify) /* Justification style for which identifying
+ * string is desired. */
{
switch (justify) {
- case TK_JUSTIFY_LEFT: return "left";
- case TK_JUSTIFY_RIGHT: return "right";
- case TK_JUSTIFY_CENTER: return "center";
+ case TK_JUSTIFY_LEFT: return "left";
+ case TK_JUSTIFY_RIGHT: return "right";
+ case TK_JUSTIFY_CENTER: return "center";
}
return "unknown justification style";
}
@@ -500,10 +487,10 @@ Tk_NameOfJustify(justify)
*/
static void
-FreeUidThreadExitProc(clientData)
- ClientData clientData; /* Not used. */
+FreeUidThreadExitProc(
+ ClientData clientData) /* Not used. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_DeleteHashTable(&tsdPtr->uidTable);
tsdPtr->initialized = 0;
@@ -514,17 +501,16 @@ FreeUidThreadExitProc(clientData)
*
* Tk_GetUid --
*
- * Given a string, this procedure returns a unique identifier
- * for the string.
+ * Given a string, this function returns a unique identifier for the
+ * string.
*
* Results:
- * This procedure returns a Tk_Uid corresponding to the "string"
- * argument. The Tk_Uid has a string value identical to string
- * (strcmp will return 0), but it's guaranteed that any other
- * calls to this procedure with a string equal to "string" will
- * return exactly the same result (i.e. can compare Tk_Uid
- * *values* directly, without having to call strcmp on what they
- * point to).
+ * This function returns a Tk_Uid corresponding to the "string" argument.
+ * The Tk_Uid has a string value identical to string (strcmp will return
+ * 0), but it's guaranteed that any other calls to this function with a
+ * string equal to "string" will return exactly the same result (i.e. can
+ * compare Tk_Uid *values* directly, without having to call strcmp on
+ * what they point to).
*
* Side effects:
* New information may be entered into the identifier table.
@@ -533,11 +519,11 @@ FreeUidThreadExitProc(clientData)
*/
Tk_Uid
-Tk_GetUid(string)
- CONST char *string; /* String to convert. */
+Tk_GetUid(
+ CONST char *string) /* String to convert. */
{
int dummy;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashTable *tablePtr = &tsdPtr->uidTable;
@@ -555,15 +541,14 @@ Tk_GetUid(string)
*
* Tk_GetScreenMM --
*
- * Given a string, returns the number of screen millimeters
- * corresponding to that string.
+ * Given a string, returns the number of screen millimeters corresponding
+ * to that string.
*
* Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * screen distance is stored at *doublePtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * the interp's result.
+ * The return value is a standard Tcl return result. If TCL_OK is
+ * returned, then everything went well and the screen distance is stored
+ * at *doublePtr; otherwise TCL_ERROR is returned and an error message is
+ * left in the interp's result.
*
* Side effects:
* None.
@@ -572,13 +557,13 @@ Tk_GetUid(string)
*/
int
-Tk_GetScreenMM(interp, tkwin, string, doublePtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- Tk_Window tkwin; /* Window whose screen determines conversion
+Tk_GetScreenMM(
+ Tcl_Interp *interp, /* Use this for error reporting. */
+ Tk_Window tkwin, /* Window whose screen determines conversion
* from centimeters and other absolute
* units. */
- CONST char *string; /* String describing a screen distance. */
- double *doublePtr; /* Place to store converted result. */
+ CONST char *string, /* String describing a screen distance. */
+ double *doublePtr) /* Place to store converted result. */
{
char *end;
double d;
@@ -586,35 +571,34 @@ Tk_GetScreenMM(interp, tkwin, string, doublePtr)
d = strtod(string, &end);
if (end == string) {
error:
- Tcl_AppendResult(interp, "bad screen distance \"", string,
- "\"", (char *) NULL);
+ Tcl_AppendResult(interp, "bad screen distance \"", string, "\"", NULL);
return TCL_ERROR;
}
while ((*end != '\0') && isspace(UCHAR(*end))) {
end++;
}
switch (*end) {
- case 0:
- d /= WidthOfScreen(Tk_Screen(tkwin));
- d *= WidthMMOfScreen(Tk_Screen(tkwin));
- break;
- case 'c':
- d *= 10;
- end++;
- break;
- case 'i':
- d *= 25.4;
- end++;
- break;
- case 'm':
- end++;
- break;
- case 'p':
- d *= 25.4/72.0;
- end++;
- break;
- default:
- goto error;
+ case 0:
+ d /= WidthOfScreen(Tk_Screen(tkwin));
+ d *= WidthMMOfScreen(Tk_Screen(tkwin));
+ break;
+ case 'c':
+ d *= 10;
+ end++;
+ break;
+ case 'i':
+ d *= 25.4;
+ end++;
+ break;
+ case 'm':
+ end++;
+ break;
+ case 'p':
+ d *= 25.4/72.0;
+ end++;
+ break;
+ default:
+ goto error;
}
while ((*end != '\0') && isspace(UCHAR(*end))) {
end++;
@@ -631,15 +615,14 @@ Tk_GetScreenMM(interp, tkwin, string, doublePtr)
*
* Tk_GetPixels --
*
- * Given a string, returns the number of pixels corresponding
- * to that string.
+ * Given a string, returns the number of pixels corresponding to that
+ * string.
*
* Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * rounded pixel distance is stored at *intPtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * the interp's result.
+ * The return value is a standard Tcl return result. If TCL_OK is
+ * returned, then everything went well and the rounded pixel distance is
+ * stored at *intPtr; otherwise TCL_ERROR is returned and an error
+ * message is left in the interp's result.
*
* Side effects:
* None.
@@ -648,13 +631,13 @@ Tk_GetScreenMM(interp, tkwin, string, doublePtr)
*/
int
-Tk_GetPixels(interp, tkwin, string, intPtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- Tk_Window tkwin; /* Window whose screen determines conversion
+Tk_GetPixels(
+ Tcl_Interp *interp, /* Use this for error reporting. */
+ Tk_Window tkwin, /* Window whose screen determines conversion
* from centimeters and other absolute
* units. */
- CONST char *string; /* String describing a number of pixels. */
- int *intPtr; /* Place to store converted result. */
+ CONST char *string, /* String describing a number of pixels. */
+ int *intPtr) /* Place to store converted result. */
{
double d;
@@ -674,15 +657,15 @@ Tk_GetPixels(interp, tkwin, string, intPtr)
*
* TkGetDoublePixels --
*
- * Given a string, returns the number of pixels corresponding
- * to that string.
+ * Given a string, returns the number of pixels corresponding to that
+ * string.
*
* Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * pixel distance is stored at *doublePtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * interp->result.
+
+ * The return value is a standard Tcl return result. If TCL_OK is
+ * returned, then everything went well and the pixel distance is stored
+ * at *doublePtr; otherwise TCL_ERROR is returned and an error message is
+ * left in interp->result.
*
* Side effects:
* None.
@@ -691,52 +674,51 @@ Tk_GetPixels(interp, tkwin, string, intPtr)
*/
int
-TkGetDoublePixels(interp, tkwin, string, doublePtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- Tk_Window tkwin; /* Window whose screen determines conversion
+TkGetDoublePixels(
+ Tcl_Interp *interp, /* Use this for error reporting. */
+ Tk_Window tkwin, /* Window whose screen determines conversion
* from centimeters and other absolute
* units. */
- CONST char *string; /* String describing a number of pixels. */
- double *doublePtr; /* Place to store converted result. */
+ CONST char *string, /* String describing a number of pixels. */
+ double *doublePtr) /* Place to store converted result. */
{
char *end;
double d;
d = strtod((char *) string, &end);
if (end == string) {
- error:
- Tcl_AppendResult(interp, "bad screen distance \"", string,
- "\"", (char *) NULL);
+ error:
+ Tcl_AppendResult(interp, "bad screen distance \"", string, "\"", NULL);
return TCL_ERROR;
}
while ((*end != '\0') && isspace(UCHAR(*end))) {
end++;
}
switch (*end) {
- case 0:
- break;
- case 'c':
- d *= 10*WidthOfScreen(Tk_Screen(tkwin));
- d /= WidthMMOfScreen(Tk_Screen(tkwin));
- end++;
- break;
- case 'i':
- d *= 25.4*WidthOfScreen(Tk_Screen(tkwin));
- d /= WidthMMOfScreen(Tk_Screen(tkwin));
- end++;
- break;
- case 'm':
- d *= WidthOfScreen(Tk_Screen(tkwin));
- d /= WidthMMOfScreen(Tk_Screen(tkwin));
- end++;
- break;
- case 'p':
- d *= (25.4/72.0)*WidthOfScreen(Tk_Screen(tkwin));
- d /= WidthMMOfScreen(Tk_Screen(tkwin));
- end++;
- break;
- default:
- goto error;
+ case 0:
+ break;
+ case 'c':
+ d *= 10*WidthOfScreen(Tk_Screen(tkwin));
+ d /= WidthMMOfScreen(Tk_Screen(tkwin));
+ end++;
+ break;
+ case 'i':
+ d *= 25.4*WidthOfScreen(Tk_Screen(tkwin));
+ d /= WidthMMOfScreen(Tk_Screen(tkwin));
+ end++;
+ break;
+ case 'm':
+ d *= WidthOfScreen(Tk_Screen(tkwin));
+ d /= WidthMMOfScreen(Tk_Screen(tkwin));
+ end++;
+ break;
+ case 'p':
+ d *= (25.4/72.0)*WidthOfScreen(Tk_Screen(tkwin));
+ d /= WidthMMOfScreen(Tk_Screen(tkwin));
+ end++;
+ break;
+ default:
+ goto error;
}
while ((*end != '\0') && isspace(UCHAR(*end))) {
end++;
@@ -747,5 +729,11 @@ TkGetDoublePixels(interp, tkwin, string, doublePtr)
*doublePtr = d;
return TCL_OK;
}
-
-
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */