Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6cd2fe04
Kaydet (Commit)
6cd2fe04
authored
Agu 29, 1994
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Correct problems found by THINK C 6.0
üst
f4b1a64a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
44 deletions
+67
-44
listobject.c
Objects/listobject.c
+67
-44
No files found.
Objects/listobject.c
Dosyayı görüntüle @
6cd2fe04
/***********************************************************
/***********************************************************
Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
Copyright 1991, 1992, 1993
, 1994
by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
Amsterdam, The Netherlands.
All Rights Reserved
All Rights Reserved
...
@@ -27,6 +27,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
...
@@ -27,6 +27,11 @@ 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"
#ifdef STDC_HEADERS
#include <stddef.h>
#else
#include <sys/types.h>
/* For size_t */
#endif
object
*
object
*
newlistobject
(
size
)
newlistobject
(
size
)
...
@@ -34,7 +39,7 @@ newlistobject(size)
...
@@ -34,7 +39,7 @@ newlistobject(size)
{
{
int
i
;
int
i
;
listobject
*
op
;
listobject
*
op
;
MALLARG
nbytes
;
size_t
nbytes
;
if
(
size
<
0
)
{
if
(
size
<
0
)
{
err_badcall
();
err_badcall
();
return
NULL
;
return
NULL
;
...
@@ -211,21 +216,17 @@ static object *
...
@@ -211,21 +216,17 @@ static object *
list_repr
(
v
)
list_repr
(
v
)
listobject
*
v
;
listobject
*
v
;
{
{
object
*
s
,
*
t
,
*
comma
;
object
*
s
,
*
comma
;
int
i
;
int
i
;
s
=
newstringobject
(
"["
);
s
=
newstringobject
(
"["
);
comma
=
newstringobject
(
", "
);
comma
=
newstringobject
(
", "
);
for
(
i
=
0
;
i
<
v
->
ob_size
&&
s
!=
NULL
;
i
++
)
{
for
(
i
=
0
;
i
<
v
->
ob_size
&&
s
!=
NULL
;
i
++
)
{
if
(
i
>
0
)
if
(
i
>
0
)
joinstring
(
&
s
,
comma
);
joinstring
(
&
s
,
comma
);
t
=
reprobject
(
v
->
ob_item
[
i
]);
joinstring_decref
(
&
s
,
reprobject
(
v
->
ob_item
[
i
]));
joinstring
(
&
s
,
t
);
DECREF
(
t
);
}
}
DECREF
(
comma
);
XDECREF
(
comma
);
t
=
newstringobject
(
"]"
);
joinstring_decref
(
&
s
,
newstringobject
(
"]"
));
joinstring
(
&
s
,
t
);
DECREF
(
t
);
return
s
;
return
s
;
}
}
...
@@ -500,15 +501,11 @@ listappend(self, args)
...
@@ -500,15 +501,11 @@ listappend(self, args)
return
ins
(
self
,
(
int
)
self
->
ob_size
,
v
);
return
ins
(
self
,
(
int
)
self
->
ob_size
,
v
);
}
}
static
object
*
c
mp
func
;
static
object
*
c
ompare
func
;
static
int
static
int
cmp
(
v
,
w
)
cmp
(
v
,
w
)
#ifdef __STDC__
const
ANY
*
v
,
*
w
;
void
*
v
,
*
w
;
#else
char
*
v
,
*
w
;
#endif
{
{
object
*
t
,
*
res
;
object
*
t
,
*
res
;
long
i
;
long
i
;
...
@@ -516,14 +513,14 @@ cmp(v, w)
...
@@ -516,14 +513,14 @@ cmp(v, w)
if
(
err_occurred
())
if
(
err_occurred
())
return
0
;
return
0
;
if
(
c
mp
func
==
NULL
)
if
(
c
ompare
func
==
NULL
)
return
cmpobject
(
*
(
object
**
)
v
,
*
(
object
**
)
w
);
return
cmpobject
(
*
(
object
**
)
v
,
*
(
object
**
)
w
);
/* Call the user-supplied comparison function */
/* Call the user-supplied comparison function */
t
=
mkvalue
(
"OO"
,
*
(
object
**
)
v
,
*
(
object
**
)
w
);
t
=
mkvalue
(
"OO"
,
*
(
object
**
)
v
,
*
(
object
**
)
w
);
if
(
t
==
NULL
)
if
(
t
==
NULL
)
return
0
;
return
0
;
res
=
call_object
(
c
mp
func
,
t
);
res
=
call_object
(
c
ompare
func
,
t
);
DECREF
(
t
);
DECREF
(
t
);
if
(
res
==
NULL
)
if
(
res
==
NULL
)
return
0
;
return
0
;
...
@@ -547,24 +544,24 @@ listsort(self, args)
...
@@ -547,24 +544,24 @@ listsort(self, args)
listobject
*
self
;
listobject
*
self
;
object
*
args
;
object
*
args
;
{
{
object
*
save_c
mp
func
;
object
*
save_c
ompare
func
;
if
(
self
->
ob_size
<=
1
)
{
if
(
self
->
ob_size
<=
1
)
{
INCREF
(
None
);
INCREF
(
None
);
return
None
;
return
None
;
}
}
save_c
mpfunc
=
cmp
func
;
save_c
omparefunc
=
compare
func
;
c
mp
func
=
args
;
c
ompare
func
=
args
;
if
(
c
mp
func
!=
NULL
)
{
if
(
c
ompare
func
!=
NULL
)
{
/* Test the comparison function for obvious errors */
/* Test the comparison function for obvious errors */
(
void
)
cmp
(
&
self
->
ob_item
[
0
],
&
self
->
ob_item
[
1
]);
(
void
)
cmp
(
(
ANY
*
)
&
self
->
ob_item
[
0
],
(
ANY
*
)
&
self
->
ob_item
[
1
]);
if
(
err_occurred
())
{
if
(
err_occurred
())
{
c
mpfunc
=
save_cmp
func
;
c
omparefunc
=
save_compare
func
;
return
NULL
;
return
NULL
;
}
}
}
}
qsort
((
char
*
)
self
->
ob_item
,
qsort
((
char
*
)
self
->
ob_item
,
(
int
)
self
->
ob_size
,
sizeof
(
object
*
),
cmp
);
(
int
)
self
->
ob_size
,
sizeof
(
object
*
),
cmp
);
c
mpfunc
=
save_cmp
func
;
c
omparefunc
=
save_compare
func
;
if
(
err_occurred
())
if
(
err_occurred
())
return
NULL
;
return
NULL
;
INCREF
(
None
);
INCREF
(
None
);
...
@@ -612,6 +609,32 @@ sortlist(v)
...
@@ -612,6 +609,32 @@ sortlist(v)
return
0
;
return
0
;
}
}
object
*
listtuple
(
v
)
object
*
v
;
{
object
*
w
;
object
**
p
;
int
n
;
if
(
v
==
NULL
||
!
is_listobject
(
v
))
{
err_badcall
();
return
NULL
;
}
n
=
((
listobject
*
)
v
)
->
ob_size
;
w
=
newtupleobject
(
n
);
if
(
w
==
NULL
)
return
NULL
;
p
=
((
tupleobject
*
)
w
)
->
ob_item
;
memcpy
((
ANY
*
)
p
,
(
ANY
*
)((
listobject
*
)
v
)
->
ob_item
,
n
*
sizeof
(
object
*
));
while
(
--
n
>=
0
)
{
INCREF
(
*
p
);
p
++
;
}
return
w
;
}
static
object
*
static
object
*
listindex
(
self
,
args
)
listindex
(
self
,
args
)
listobject
*
self
;
listobject
*
self
;
...
@@ -675,13 +698,13 @@ listremove(self, args)
...
@@ -675,13 +698,13 @@ listremove(self, args)
}
}
static
struct
methodlist
list_methods
[]
=
{
static
struct
methodlist
list_methods
[]
=
{
{
"append"
,
listappend
},
{
"append"
,
(
method
)
listappend
},
{
"count"
,
listcount
},
{
"count"
,
(
method
)
listcount
},
{
"index"
,
listindex
},
{
"index"
,
(
method
)
listindex
},
{
"insert"
,
listinsert
},
{
"insert"
,
(
method
)
listinsert
},
{
"sort"
,
listsort
},
{
"sort"
,
(
method
)
listsort
},
{
"remove"
,
listremove
},
{
"remove"
,
(
method
)
listremove
},
{
"reverse"
,
listreverse
},
{
"reverse"
,
(
method
)
listreverse
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
@@ -694,13 +717,13 @@ list_getattr(f, name)
...
@@ -694,13 +717,13 @@ list_getattr(f, name)
}
}
static
sequence_methods
list_as_sequence
=
{
static
sequence_methods
list_as_sequence
=
{
list_length
,
/*sq_length*/
(
inquiry
)
list_length
,
/*sq_length*/
list_concat
,
/*sq_concat*/
(
binaryfunc
)
list_concat
,
/*sq_concat*/
list_repeat
,
/*sq_repeat*/
(
intargfunc
)
list_repeat
,
/*sq_repeat*/
list_item
,
/*sq_item*/
(
intargfunc
)
list_item
,
/*sq_item*/
list_slice
,
/*sq_slice*/
(
intintargfunc
)
list_slice
,
/*sq_slice*/
list_ass_item
,
/*sq_ass_item*/
(
intobjargproc
)
list_ass_item
,
/*sq_ass_item*/
list_ass_slice
,
/*sq_ass_slice*/
(
intintobjargproc
)
list_ass_slice
,
/*sq_ass_slice*/
};
};
typeobject
Listtype
=
{
typeobject
Listtype
=
{
...
@@ -709,12 +732,12 @@ typeobject Listtype = {
...
@@ -709,12 +732,12 @@ typeobject Listtype = {
"list"
,
"list"
,
sizeof
(
listobject
),
sizeof
(
listobject
),
0
,
0
,
list_dealloc
,
/*tp_dealloc*/
(
destructor
)
list_dealloc
,
/*tp_dealloc*/
list_print
,
/*tp_print*/
(
printfunc
)
list_print
,
/*tp_print*/
list_getattr
,
/*tp_getattr*/
(
getattrfunc
)
list_getattr
,
/*tp_getattr*/
0
,
/*tp_setattr*/
0
,
/*tp_setattr*/
list_compare
,
/*tp_compare*/
(
cmpfunc
)
list_compare
,
/*tp_compare*/
list_repr
,
/*tp_repr*/
(
reprfunc
)
list_repr
,
/*tp_repr*/
0
,
/*tp_as_number*/
0
,
/*tp_as_number*/
&
list_as_sequence
,
/*tp_as_sequence*/
&
list_as_sequence
,
/*tp_as_sequence*/
0
,
/*tp_as_mapping*/
0
,
/*tp_as_mapping*/
...
...
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