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
d8a6d1c2
Commit
d8a6d1c2
authored
Aug 24, 1996
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Afterthough: leave both leading underscores in,
so __spam becomes _ClassName__spam.
parent
fe2236f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
Python/compile.c
Python/compile.c
+5
-5
No files found.
Python/compile.c
View file @
d8a6d1c2
...
@@ -506,12 +506,12 @@ com_mangle(c, name, buffer, maxlen)
...
@@ -506,12 +506,12 @@ com_mangle(c, name, buffer, maxlen)
char
*
buffer
;
char
*
buffer
;
int
maxlen
;
int
maxlen
;
{
{
/* Name mangling: __private becomes _classname_private.
/* Name mangling: __private becomes _classname_
_
private.
This is independent from how the name is used. */
This is independent from how the name is used. */
char
*
p
;
char
*
p
;
int
nlen
,
plen
;
int
nlen
,
plen
;
nlen
=
strlen
(
name
);
nlen
=
strlen
(
name
);
if
(
nlen
+
1
>=
maxlen
)
if
(
nlen
+
2
>=
maxlen
)
return
0
;
/* Don't mangle __extremely_long_names */
return
0
;
/* Don't mangle __extremely_long_names */
if
(
name
[
nlen
-
1
]
==
'_'
&&
name
[
nlen
-
2
]
==
'_'
)
if
(
name
[
nlen
-
1
]
==
'_'
&&
name
[
nlen
-
2
]
==
'_'
)
return
0
;
/* Don't mangle __whatever__ */
return
0
;
/* Don't mangle __whatever__ */
...
@@ -523,11 +523,11 @@ com_mangle(c, name, buffer, maxlen)
...
@@ -523,11 +523,11 @@ com_mangle(c, name, buffer, maxlen)
return
0
;
/* Don't mangle if class is just underscores */
return
0
;
/* Don't mangle if class is just underscores */
plen
=
strlen
(
p
);
plen
=
strlen
(
p
);
if
(
plen
+
nlen
>=
maxlen
)
if
(
plen
+
nlen
>=
maxlen
)
plen
=
maxlen
-
nlen
-
1
;
/* Truncate class name if too long */
plen
=
maxlen
-
nlen
-
2
;
/* Truncate class name if too long */
/* buffer = "_" + p[:plen] + name
[1:] # i.e.
plen+nlen bytes */
/* buffer = "_" + p[:plen] + name
# i.e. 1+
plen+nlen bytes */
buffer
[
0
]
=
'_'
;
buffer
[
0
]
=
'_'
;
strncpy
(
buffer
+
1
,
p
,
plen
);
strncpy
(
buffer
+
1
,
p
,
plen
);
strcpy
(
buffer
+
plen
+
1
,
name
+
1
);
strcpy
(
buffer
+
1
+
plen
,
name
);
/* fprintf(stderr, "mangle %s -> %s\n", name, buffer); */
/* fprintf(stderr, "mangle %s -> %s\n", name, buffer); */
return
1
;
return
1
;
}
}
...
...
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