summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/tk/tcltklib.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c
index 721f497ef4..1e425d7654 100644
--- a/ext/tk/tcltklib.c
+++ b/ext/tk/tcltklib.c
@@ -6215,14 +6215,16 @@ ip_init(argc, argv, self)
case 1:
/* argv0 */
if (!NIL_P(argv0)) {
- if (strncmp(StringValueCStr(argv0), "-e", 3) == 0
- || strncmp(StringValueCStr(argv0), "-", 2) == 0) {
- Tcl_SetVar(ptr->ip, "argv0", "ruby", TCL_GLOBAL_ONLY);
+ const char *name = StringValueCStr(argv0);
+ long len = RSTRING_LEN(argv0);
+ int flag = TCL_GLOBAL_ONLY;
+ if ((len == 2 && memcmp(name, "-e", 2) == 0)
+ || (len == 1 && memcmp(name, "-", 1) == 0)) {
+ name = "ruby";
} else {
- /* Tcl_SetVar(ptr->ip, "argv0", StringValueCStr(argv0), 0); */
- Tcl_SetVar(ptr->ip, "argv0", StringValueCStr(argv0),
- TCL_GLOBAL_ONLY);
+ /* flag = 0; */
}
+ Tcl_SetVar(ptr->ip, "argv0", name, flag);
}
case 0:
/* no args */