Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
99549766
Commit
99549766
authored
Apr 01, 1993
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for frozen scripts; added -i option.
parent
e837529c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
150 additions
and
5 deletions
+150
-5
Include/marshal.h
Include/marshal.h
+1
-0
Modules/config.c.in
Modules/config.c.in
+19
-1
Python/frozenmain.c
Python/frozenmain.c
+57
-0
Python/import.c
Python/import.c
+40
-2
Python/marshal.c
Python/marshal.c
+15
-1
Python/pythonmain.c
Python/pythonmain.c
+18
-1
No files found.
Include/marshal.h
View file @
99549766
...
...
@@ -31,3 +31,4 @@ void wr_object PROTO((object *, FILE *));
long
rd_long
PROTO
((
FILE
*
));
int
rd_short
PROTO
((
FILE
*
));
object
*
rd_object
PROTO
((
FILE
*
));
object
*
rds_object
PROTO
((
char
*
,
int
));
Modules/config.c.in
View file @
99549766
...
...
@@ -82,6 +82,8 @@ char version[80];
char *argv0; /* For dynamic loading in import.c */
extern char verbose;
/*ARGSUSED*/
void
initargs(p_argc, p_argv)
...
...
@@ -98,7 +100,11 @@ initargs(p_argc, p_argv)
#endif
wargs(p_argc, p_argv);
#endif /* USE_STDWIN */
if (*p_argc < 2 && isatty(0) && isatty(1))
#ifdef USE_FROZEN
if (verbose)
#else
if (verbose || *p_argc < 2 && isatty(0) && isatty(1))
#endif
{
printf("Python %s.\n", version);
printf(
...
...
@@ -448,3 +454,15 @@ struct {
{0, 0} /* Sentinel */
};
#ifdef USE_FROZEN
#include "frozen.c"
#else
struct frozen {
char *name;
char *code;
int size;
} frozen_modules[] = {
{0, 0, 0}
};
#endif
Python/frozenmain.c
0 → 100644
View file @
99549766
/***********************************************************
Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission.
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* Python interpreter main program for frozen scripts */
#include "allobjects.h"
extern
char
*
getenv
();
extern
int
debugging
;
extern
int
verbose
;
main
(
argc
,
argv
)
int
argc
;
char
**
argv
;
{
char
*
p
;
int
n
;
if
((
p
=
getenv
(
"PYTHONDEBUG"
))
&&
*
p
!=
'\0'
)
debugging
=
1
;
if
((
p
=
getenv
(
"PYTHONVERBOSE"
))
&&
*
p
!=
'\0'
)
verbose
=
1
;
initargs
(
&
argc
,
&
argv
);
/* Defined in config*.c */
initall
();
setpythonargv
(
argc
,
argv
);
n
=
init_frozen
(
"__main__"
);
if
(
n
==
0
)
fatal
(
"__main__ not frozen"
);
if
(
n
<
0
)
{
print_error
();
goaway
(
1
);
}
else
goaway
(
0
);
/*NOTREACHED*/
}
Python/import.c
View file @
99549766
...
...
@@ -52,7 +52,7 @@ extern int verbose; /* Defined in pythonmain.c */
extern
char
*
argv0
;
#endif
/* Magic word to reject
pre-0.9.9 .pyc file
s */
/* Magic word to reject
.pyc files generated by other Python version
s */
#define MAGIC 0x99BE3AL
...
...
@@ -325,8 +325,11 @@ import_module(name)
char
*
name
;
{
object
*
m
;
int
n
;
if
((
m
=
dictlookup
(
modules
,
name
))
==
NULL
)
{
if
(
init_builtin
(
name
))
{
if
((
n
=
init_builtin
(
name
))
||
(
n
=
init_frozen
(
name
)))
{
if
(
n
<
0
)
return
NULL
;
if
((
m
=
dictlookup
(
modules
,
name
))
==
NULL
)
err_setstr
(
SystemError
,
"builtin module missing"
);
...
...
@@ -411,3 +414,38 @@ init_builtin(name)
}
return
0
;
}
extern
struct
frozen
{
char
*
name
;
char
*
code
;
int
size
;
}
frozen_modules
[];
int
init_frozen
(
name
)
char
*
name
;
{
struct
frozen
*
p
;
codeobject
*
co
;
object
*
m
,
*
d
,
*
v
;
for
(
p
=
frozen_modules
;
;
p
++
)
{
if
(
p
->
name
==
NULL
)
return
0
;
if
(
strcmp
(
p
->
name
,
name
)
==
0
)
break
;
}
if
(
verbose
)
fprintf
(
stderr
,
"import %s # frozen
\n
"
,
name
);
co
=
(
codeobject
*
)
rds_object
(
p
->
code
,
p
->
size
);
if
(
co
==
NULL
)
return
-
1
;
if
((
m
=
add_module
(
name
))
==
NULL
||
(
d
=
getmoduledict
(
m
))
==
NULL
||
(
v
=
eval_code
(
co
,
d
,
d
,
(
object
*
)
NULL
))
==
NULL
)
{
DECREF
(
co
);
return
-
1
;
}
DECREF
(
co
);
DECREF
(
v
);
return
1
;
}
Python/marshal.c
View file @
99549766
...
...
@@ -225,7 +225,8 @@ wr_object(x, fp)
typedef
WFILE
RFILE
;
/* Same struct with different invariants */
#define r_byte(p) ((p)->fp ? getc((p)->fp) \
: ((p)->ptr != (p)->end) ? *(p)->ptr++ : EOF)
: ((p)->ptr != (p)->end) ? \
(unsigned char)*(p)->ptr++ : EOF)
static
int
r_string
(
s
,
n
,
p
)
...
...
@@ -425,6 +426,19 @@ rd_object(fp)
return
r_object
(
&
rf
);
}
object
*
rds_object
(
str
,
len
)
char
*
str
;
int
len
;
{
RFILE
rf
;
rf
.
fp
=
NULL
;
rf
.
str
=
NULL
;
rf
.
ptr
=
str
;
rf
.
end
=
str
+
len
;
return
r_object
(
&
rf
);
}
/* And an interface for Python programs... */
static
object
*
...
...
Python/pythonmain.c
View file @
99549766
...
...
@@ -34,6 +34,8 @@ extern int optind;
extern
char
*
optarg
;
extern
int
getopt
PROTO
((
int
,
char
**
,
char
*
));
extern
char
*
getenv
();
main
(
argc
,
argv
)
int
argc
;
char
**
argv
;
...
...
@@ -43,10 +45,17 @@ main(argc, argv)
char
*
command
=
NULL
;
char
*
filename
=
NULL
;
FILE
*
fp
=
stdin
;
char
*
p
;
int
inspect
=
0
;
if
((
p
=
getenv
(
"PYTHONDEBUG"
))
&&
*
p
!=
'\0'
)
debugging
=
1
;
if
((
p
=
getenv
(
"PYTHONVERBOSE"
))
&&
*
p
!=
'\0'
)
verbose
=
1
;
initargs
(
&
argc
,
&
argv
);
/* Defined in config*.c */
while
((
c
=
getopt
(
argc
,
argv
,
"c:dv"
))
!=
EOF
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"c:d
i
v"
))
!=
EOF
)
{
if
(
c
==
'c'
)
{
/* -c is the last option; following arguments
that look like options are left for the
...
...
@@ -64,6 +73,10 @@ main(argc, argv)
debugging
++
;
break
;
case
'i'
:
inspect
++
;
break
;
case
'v'
:
verbose
++
;
break
;
...
...
@@ -118,6 +131,10 @@ main(argc, argv)
sts
=
run
(
fp
,
filename
==
NULL
?
"<stdin>"
:
filename
)
!=
0
;
}
if
(
inspect
&&
isatty
((
int
)
fileno
(
stdin
))
&&
(
filename
!=
NULL
||
command
!=
NULL
))
sts
=
run
(
stdin
,
"<stdin>"
)
!=
0
;
goaway
(
sts
);
/*NOTREACHED*/
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment