summaryrefslogtreecommitdiff
path: root/xc
diff options
context:
space:
mode:
authorconverse <empty>1995-06-22 22:31:11 +0000
committerconverse <empty>1995-06-22 22:31:11 +0000
commitc7ae9d3c9e4ad5a7d96d69bcc0e2a60f740bc4be (patch)
treebf6e478e6e0419812ccccbb7c5558784f19e2442 /xc
parentfc7a02505a9101112031078520e7bfa991ea308d (diff)
Change how the ApplicationShell treats argv. It is copied, and its
contents are copied, and it is not assumed to be ended by a NULL element. An ending NULL element is present in the copy. Allow -1 as argc to indicate ignorning argv. Assume caller treats argc and argv as a resource pair that do not contain conflicting values. #7157
Diffstat (limited to 'xc')
-rw-r--r--xc/lib/Xt/Shell.c56
1 files changed, 46 insertions, 10 deletions
diff --git a/xc/lib/Xt/Shell.c b/xc/lib/Xt/Shell.c
index b88dbbab2..100e8791b 100644
--- a/xc/lib/Xt/Shell.c
+++ b/xc/lib/Xt/Shell.c
@@ -1,4 +1,4 @@
-/* $XConsortium: Shell.c,v 1.167 94/09/02 16:16:48 kaleb Exp converse $ */
+/* $XConsortium: Shell.c,v 1.168 95/01/06 21:14:23 converse Exp converse $ */
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
@@ -1045,6 +1045,7 @@ static void TopLevelInitialize(req, new, args, num_args)
w->wm.wm_hints.initial_state = IconicState;
}
+static String *NewArgv();
static String *NewStringArray();
static void FreeStringArray();
@@ -1056,8 +1057,9 @@ static void ApplicationInitialize(req, new, args, num_args)
{
ApplicationShellWidget w = (ApplicationShellWidget)new;
- if (w->application.argv) w->application.argv =
- NewStringArray(w->application.argv);
+ if (w->application.argc > 0)
+ w->application.argv = NewArgv(w->application.argc,
+ w->application.argv);
}
#define XtSaveInactive 0
@@ -1664,7 +1666,8 @@ static void ApplicationDestroy(wid)
Widget wid;
{
ApplicationShellWidget w = (ApplicationShellWidget) wid;
- FreeStringArray(w->application.argv);
+ if (w->application.argc > 0)
+ FreeStringArray(w->application.argv);
}
static void SessionDestroy(wid)
@@ -2364,6 +2367,37 @@ static Boolean TopLevelSetValues(oldW, refW, newW, args, num_args)
return False;
}
+static String * NewArgv(count, str)
+ int count;
+ String *str; /* do not assume it's terminated by a NULL element */
+{
+ Cardinal nbytes = 0;
+ Cardinal num = 0;
+ String *newarray, *new;
+ String *strarray = str;
+ String sptr;
+
+ if (count <= 0 || !str) return NULL;
+
+ for (num = count; num--; str++) {
+ nbytes += strlen(*str);
+ nbytes++;
+ }
+ num = (count+1) * sizeof(String);
+ new = newarray = (String *) XtMalloc(num + nbytes);
+ sptr = ((char *) new) + num;
+
+ for (str = strarray; count--; str++) {
+ *new = sptr;
+ strcpy(*new, *str);
+ new++;
+ sptr = strchr(sptr, '\0');
+ sptr++;
+ }
+ *new = NULL;
+ return newarray;
+}
+
/*ARGSUSED*/
static Boolean ApplicationSetValues(current, request, new, args, num_args)
@@ -2374,13 +2408,15 @@ static Boolean ApplicationSetValues(current, request, new, args, num_args)
ApplicationShellWidget nw = (ApplicationShellWidget) new;
ApplicationShellWidget cw = (ApplicationShellWidget) current;
- if (cw->application.argv != nw->application.argv) {
- nw->application.argv = NewStringArray(nw->application.argv);
- FreeStringArray(cw->application.argv);
- }
+ if (cw->application.argc != nw->application.argc ||
+ cw->application.argv != nw->application.argv) {
+
+ if (nw->application.argc > 0)
+ nw->application.argv = NewArgv(nw->application.argc,
+ nw->application.argv);
+ if (cw->application.argc > 0)
+ FreeStringArray(cw->application.argv);
- if (cw->application.argv != nw->application.argv ||
- cw->application.argc != nw->application.argc) {
if (XtIsRealized(new) && !nw->shell.override_redirect) {
if (nw->application.argc >= 0 && nw->application.argv)
XSetCommand(XtDisplay(new), XtWindow(new),