summaryrefslogtreecommitdiffstats
path: root/generic/tkArgv.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkArgv.c')
-rw-r--r--generic/tkArgv.c51
1 files changed, 20 insertions, 31 deletions
diff --git a/generic/tkArgv.c b/generic/tkArgv.c
index 6bfcedc..134b081 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) {
@@ -143,7 +142,7 @@ Tk_ParseArgv(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"ambiguous option \"%s\"", curArg));
Tcl_SetErrorCode(interp, "TK", "ARG", "AMBIGUOUS", curArg,
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
matchPtr = infoPtr;
@@ -159,7 +158,7 @@ Tk_ParseArgv(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unrecognized argument \"%s\"", curArg));
Tcl_SetErrorCode(interp, "TK", "ARG", "UNRECOGNIZED", curArg,
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
argv[dstIndex] = curArg;
@@ -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;
@@ -250,17 +239,17 @@ Tk_ParseArgv(
}
case TK_ARGV_HELP:
PrintUsage(interp, argTable, flags);
- Tcl_SetErrorCode(interp, "TK", "ARG", "HELP", NULL);
+ Tcl_SetErrorCode(interp, "TK", "ARG", "HELP", (char *)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--;
@@ -271,7 +260,7 @@ Tk_ParseArgv(
"\"%s\" option requires two following arguments",
curArg));
Tcl_SetErrorCode(interp, "TK", "ARG", "NAME_VALUE", curArg,
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
Tk_AddOption(tkwin, argv[srcIndex], argv[srcIndex+1],
@@ -282,7 +271,7 @@ Tk_ParseArgv(
default:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad argument type %d in Tk_ArgvInfo", infoPtr->type));
- Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "API_ABUSE", (char *)NULL);
return TCL_ERROR;
}
}
@@ -306,7 +295,7 @@ Tk_ParseArgv(
missingArg:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"\"%s\" option requires an additional argument", curArg));
- Tcl_SetErrorCode(interp, "TK", "ARG", "MISSING", curArg, NULL);
+ Tcl_SetErrorCode(interp, "TK", "ARG", "MISSING", curArg, (char *)NULL);
return TCL_ERROR;
}
@@ -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);
}