summaryrefslogtreecommitdiffstats
path: root/generic/tkArgv.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkArgv.c')
-rw-r--r--generic/tkArgv.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/generic/tkArgv.c b/generic/tkArgv.c
index 6bfcedc..33e7d4f 100644
--- a/generic/tkArgv.c
+++ b/generic/tkArgv.c
@@ -4,8 +4,8 @@
* This file contains a function that handles table-based argv-argc
* parsing.
*
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -83,7 +83,6 @@ Tk_ParseArgv(
* than srcIndex). */
int argc; /* # arguments in argv still to process. */
size_t length; /* Number of characters in current argument. */
- char *endPtr; /* Used for identifying junk in arguments. */
int i;
if (flags & TK_ARGV_DONT_SKIP_FIRST_ARG) {
@@ -175,18 +174,13 @@ Tk_ParseArgv(
infoPtr = matchPtr;
switch (infoPtr->type) {
case TK_ARGV_CONSTANT:
- *((int *) infoPtr->dst) = PTR2INT(infoPtr->src);
+ *((int *) infoPtr->dst) = (int)PTR2INT(infoPtr->src);
break;
case TK_ARGV_INT:
if (argc == 0) {
goto missingArg;
}
- *((int *) infoPtr->dst) = strtol(argv[srcIndex], &endPtr, 0);
- if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "expected %s argument for \"%s\" but got \"%s\"",
- "integer", infoPtr->key, argv[srcIndex]));
- Tcl_SetErrorCode(interp, "TK", "ARG", "INTEGER", curArg,NULL);
+ if (Tcl_GetInt(interp, argv[srcIndex], (int *) infoPtr->dst) != TCL_OK) {
return TCL_ERROR;
}
srcIndex++;
@@ -215,12 +209,7 @@ Tk_ParseArgv(
if (argc == 0) {
goto missingArg;
}
- *((double *) infoPtr->dst) = strtod(argv[srcIndex], &endPtr);
- if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "expected %s argument for \"%s\" but got \"%s\"",
- "floating-point", infoPtr->key, argv[srcIndex]));
- Tcl_SetErrorCode(interp, "TK", "ARG", "FLOAT", curArg, NULL);
+ if (Tcl_GetDouble(interp, argv[srcIndex], ((double *) infoPtr->dst)) != TCL_OK) {
return TCL_ERROR;
}
srcIndex++;
@@ -228,9 +217,9 @@ Tk_ParseArgv(
break;
case TK_ARGV_FUNC: {
typedef int (ArgvFunc)(char *, const char *, const char *);
- ArgvFunc *handlerProc = (ArgvFunc *) infoPtr->src;
+ ArgvFunc *handlerProc = (ArgvFunc *)infoPtr->src;
- if (handlerProc(infoPtr->dst, infoPtr->key, argv[srcIndex])) {
+ if (handlerProc((char *)infoPtr->dst, infoPtr->key, argv[srcIndex])) {
srcIndex++;
argc--;
}
@@ -239,9 +228,9 @@ Tk_ParseArgv(
case TK_ARGV_GENFUNC: {
typedef int (ArgvGenFunc)(char *, Tcl_Interp *, const char *, int,
const char **);
- ArgvGenFunc *handlerProc = (ArgvGenFunc *) infoPtr->src;
+ ArgvGenFunc *handlerProc = (ArgvGenFunc *)infoPtr->src;
- argc = handlerProc(infoPtr->dst, interp, infoPtr->key, argc,
+ argc = handlerProc((char *)infoPtr->dst, interp, infoPtr->key, argc,
argv+srcIndex);
if (argc < 0) {
return TCL_ERROR;
@@ -253,14 +242,14 @@ Tk_ParseArgv(
Tcl_SetErrorCode(interp, "TK", "ARG", "HELP", NULL);
return TCL_ERROR;
case TK_ARGV_CONST_OPTION:
- Tk_AddOption(tkwin, infoPtr->dst, infoPtr->src,
+ Tk_AddOption(tkwin, (char *)infoPtr->dst, (char *)infoPtr->src,
TK_INTERACTIVE_PRIO);
break;
case TK_ARGV_OPTION_VALUE:
if (argc < 1) {
goto missingArg;
}
- Tk_AddOption(tkwin, infoPtr->dst, argv[srcIndex],
+ Tk_AddOption(tkwin, (char *)infoPtr->dst, argv[srcIndex],
TK_INTERACTIVE_PRIO);
srcIndex++;
argc--;
@@ -363,7 +352,7 @@ PrintUsage(
}
}
- message = Tcl_NewStringObj("Command-specific options:", -1);
+ message = Tcl_NewStringObj("Command-specific options:", TCL_INDEX_NONE);
for (i = 0; ; i++) {
for (infoPtr = i ? defaultTable : argTable;
infoPtr->type != TK_ARGV_END; infoPtr++) {
@@ -376,7 +365,7 @@ PrintUsage(
while (numSpaces-- > 0) {
Tcl_AppendToObj(message, " ", 1);
}
- Tcl_AppendToObj(message, infoPtr->help, -1);
+ Tcl_AppendToObj(message, infoPtr->help, TCL_INDEX_NONE);
switch (infoPtr->type) {
case TK_ARGV_INT:
Tcl_AppendPrintfToObj(message, "\n\t\tDefault value: %d",
@@ -403,7 +392,7 @@ PrintUsage(
if ((flags & TK_ARGV_NO_DEFAULTS) || (i > 0)) {
break;
}
- Tcl_AppendToObj(message, "\nGeneric options for all commands:", -1);
+ Tcl_AppendToObj(message, "\nGeneric options for all commands:", TCL_INDEX_NONE);
}
Tcl_SetObjResult(interp, message);
}