* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
no longer done by config.c). * stdwinmodule.c (initstdwin), config.c (initall): get command line arguments from sys.argv instead of special-casing stdwin in config.c * import.c (get_module): fix core dump when foomodule.o does not define initfoo(). * ChangeLog: documented changes by Sjoerd.
This commit is contained in:
parent
842d2ccdcd
commit
cacd9579d4
|
@ -70,14 +70,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#define DATE ">= 29 Jul 1993"
|
#define DATE ">= 29 Jul 1993"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_STDWIN
|
|
||||||
#ifdef macintosh
|
|
||||||
#include ":::stdwin:H:stdwin.h"
|
|
||||||
#else /* !macintosh */
|
|
||||||
#include "stdwin.h"
|
|
||||||
#endif /* !macintosh */
|
|
||||||
#endif /* USE_STDWIN */
|
|
||||||
|
|
||||||
char version[80];
|
char version[80];
|
||||||
|
|
||||||
char *argv0; /* For dynamic loading in import.c */
|
char *argv0; /* For dynamic loading in import.c */
|
||||||
|
@ -94,12 +86,6 @@ initargs(p_argc, p_argv)
|
||||||
|
|
||||||
argv0 = **p_argv;
|
argv0 = **p_argv;
|
||||||
|
|
||||||
#ifdef USE_STDWIN
|
|
||||||
#ifdef THINK_C_3_0
|
|
||||||
wsetstdio(1);
|
|
||||||
#endif
|
|
||||||
wargs(p_argc, p_argv);
|
|
||||||
#endif /* USE_STDWIN */
|
|
||||||
#ifdef USE_FROZEN
|
#ifdef USE_FROZEN
|
||||||
if (verbose)
|
if (verbose)
|
||||||
#else
|
#else
|
||||||
|
@ -120,9 +106,6 @@ initcalls()
|
||||||
void
|
void
|
||||||
donecalls()
|
donecalls()
|
||||||
{
|
{
|
||||||
#ifdef USE_STDWIN
|
|
||||||
wdone();
|
|
||||||
#endif
|
|
||||||
#ifdef USE_AUDIO
|
#ifdef USE_AUDIO
|
||||||
asa_done();
|
asa_done();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -66,6 +66,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "allobjects.h"
|
#include "allobjects.h"
|
||||||
#include "modsupport.h"
|
#include "modsupport.h"
|
||||||
#include "ceval.h"
|
#include "ceval.h"
|
||||||
|
#include "sysmodule.h"
|
||||||
|
|
||||||
#ifdef macintosh
|
#ifdef macintosh
|
||||||
#include ":::stdwin:H:stdwin.h"
|
#include ":::stdwin:H:stdwin.h"
|
||||||
|
@ -1942,6 +1943,21 @@ typeobject Windowtype = {
|
||||||
|
|
||||||
/* Stdwin methods */
|
/* Stdwin methods */
|
||||||
|
|
||||||
|
static object *
|
||||||
|
stdwin_done(sw, args)
|
||||||
|
object *sw;
|
||||||
|
object *args;
|
||||||
|
{
|
||||||
|
if (!getnoarg(args))
|
||||||
|
return NULL;
|
||||||
|
wdone();
|
||||||
|
/* XXX There is no protection against continued use of
|
||||||
|
XXX stdwin functions or objects after this call is made.
|
||||||
|
XXX Use at own risk */
|
||||||
|
INCREF(None);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
stdwin_open(sw, args)
|
stdwin_open(sw, args)
|
||||||
object *sw;
|
object *sw;
|
||||||
|
@ -2467,6 +2483,7 @@ static struct methodlist stdwin_methods[] = {
|
||||||
{"askfile", stdwin_askfile},
|
{"askfile", stdwin_askfile},
|
||||||
{"askstr", stdwin_askstr},
|
{"askstr", stdwin_askstr},
|
||||||
{"askync", stdwin_askync},
|
{"askync", stdwin_askync},
|
||||||
|
{"done", stdwin_done},
|
||||||
{"fetchcolor", stdwin_fetchcolor},
|
{"fetchcolor", stdwin_fetchcolor},
|
||||||
#ifdef unix
|
#ifdef unix
|
||||||
{"fileno", stdwin_connectionnumber},
|
{"fileno", stdwin_connectionnumber},
|
||||||
|
@ -2515,6 +2532,67 @@ static struct methodlist stdwin_methods[] = {
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
checkstringlist(args, ps, pn)
|
||||||
|
object *args;
|
||||||
|
char ***ps;
|
||||||
|
int *pn;
|
||||||
|
{
|
||||||
|
int i, n;
|
||||||
|
char **s;
|
||||||
|
if (!is_listobject(args)) {
|
||||||
|
err_setstr(TypeError, "list of strings expected");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
n = getlistsize(args);
|
||||||
|
s = NEW(char *, n+1);
|
||||||
|
if (s == NULL) {
|
||||||
|
err_nomem();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
object *item = getlistitem(args, i);
|
||||||
|
if (!is_stringobject(item)) {
|
||||||
|
err_setstr(TypeError, "list of strings expected");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
s[i] = getstringvalue(item);
|
||||||
|
}
|
||||||
|
s[n] = NULL; /* In case caller wants a NULL-terminated list */
|
||||||
|
*ps = s;
|
||||||
|
*pn = n;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
putbackstringlist(list, s, n)
|
||||||
|
object *list;
|
||||||
|
char **s;
|
||||||
|
int n;
|
||||||
|
{
|
||||||
|
int oldsize = getlistsize(list);
|
||||||
|
object *newlist;
|
||||||
|
int i;
|
||||||
|
if (n == oldsize)
|
||||||
|
return 1;
|
||||||
|
newlist = newlistobject(n);
|
||||||
|
for (i = 0; i < n && newlist != NULL; i++) {
|
||||||
|
object *item = newstringobject(s[i]);
|
||||||
|
if (item == NULL) {
|
||||||
|
DECREF(newlist);
|
||||||
|
newlist = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setlistitem(newlist, i, item);
|
||||||
|
}
|
||||||
|
if (newlist == NULL)
|
||||||
|
return 0;
|
||||||
|
(*list->ob_type->tp_as_sequence->sq_ass_slice)
|
||||||
|
(list, 0, oldsize, newlist);
|
||||||
|
DECREF(newlist);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
initstdwin()
|
initstdwin()
|
||||||
{
|
{
|
||||||
|
@ -2522,7 +2600,18 @@ initstdwin()
|
||||||
static int inited = 0;
|
static int inited = 0;
|
||||||
|
|
||||||
if (!inited) {
|
if (!inited) {
|
||||||
winit();
|
int argc = 0;
|
||||||
|
char **argv = NULL;
|
||||||
|
object *sys_argv = sysget("argv");
|
||||||
|
if (sys_argv != NULL) {
|
||||||
|
if (!checkstringlist(sys_argv, &argv, &argc))
|
||||||
|
err_clear();
|
||||||
|
}
|
||||||
|
winitargs(&argc, &argv);
|
||||||
|
if (argv != NULL) {
|
||||||
|
if (!putbackstringlist(sys_argv, argv, argc))
|
||||||
|
err_clear();
|
||||||
|
}
|
||||||
inited = 1;
|
inited = 1;
|
||||||
}
|
}
|
||||||
m = initmodule("stdwin", stdwin_methods);
|
m = initmodule("stdwin", stdwin_methods);
|
||||||
|
|
|
@ -191,20 +191,22 @@ get_module(m, name, m_ret)
|
||||||
p = (dl_funcptr) dlsym(handle, funcname);
|
p = (dl_funcptr) dlsym(handle, funcname);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr,
|
||||||
|
"import %s # dynamically loaded from \"%s\"\n",
|
||||||
|
name, namebuf);
|
||||||
p = dl_loadmod(argv0, namebuf, funcname);
|
p = dl_loadmod(argv0, namebuf, funcname);
|
||||||
#endif /* SUN_SHLIB */
|
#endif /* SUN_SHLIB */
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
D(fprintf(stderr, "dl_loadmod failed\n"));
|
err_setstr(SystemError,
|
||||||
|
"dynamic module does not define init function");
|
||||||
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
if (verbose)
|
|
||||||
fprintf(stderr,
|
|
||||||
"import %s # dynamically loaded from \"%s\"\n",
|
|
||||||
name, namebuf);
|
|
||||||
(*p)();
|
(*p)();
|
||||||
*m_ret = m = dictlookup(modules, name);
|
*m_ret = m = dictlookup(modules, name);
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
err_setstr(SystemError,
|
err_setstr(SystemError,
|
||||||
"dynamic module missing");
|
"dynamic module not initialized properly");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
D(fprintf(stderr,
|
D(fprintf(stderr,
|
||||||
|
|
Loading…
Reference in New Issue