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
ccd5bad4
Kaydet (Commit)
ccd5bad4
authored
Şub 23, 1993
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Extensive changes to regex module (group(), casefold, etc.)
üst
337b20e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
12 deletions
+46
-12
regexmodule.c
Modules/regexmodule.c
+46
-12
No files found.
Modules/regexmodule.c
Dosyayı görüntüle @
ccd5bad4
...
...
@@ -168,7 +168,7 @@ reg_search(re, args)
}
static
object
*
reg_
substring
(
re
,
args
)
reg_
group
(
re
,
args
)
regexobject
*
re
;
object
*
args
;
{
...
...
@@ -179,7 +179,7 @@ reg_substring(re, args)
if
(
res
==
NULL
)
return
NULL
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
object
*
v
=
reg_
substring
(
re
,
gettupleitem
(
args
,
i
));
object
*
v
=
reg_
group
(
re
,
gettupleitem
(
args
,
i
));
if
(
v
==
NULL
)
{
DECREF
(
res
);
return
NULL
;
...
...
@@ -191,12 +191,12 @@ reg_substring(re, args)
if
(
!
getargs
(
args
,
"i"
,
&
i
))
return
NULL
;
if
(
i
<
0
||
i
>=
RE_NREGS
)
{
err_setstr
(
RegexError
,
"
substring
() index out of range"
);
err_setstr
(
RegexError
,
"
group
() index out of range"
);
return
NULL
;
}
if
(
re
->
re_lastok
==
NULL
)
{
err_setstr
(
RegexError
,
"
substring
() only valid after successful match/search"
);
"
group
() only valid after successful match/search"
);
return
NULL
;
}
a
=
re
->
re_regs
.
start
[
i
];
...
...
@@ -211,7 +211,7 @@ reg_substring(re, args)
static
struct
methodlist
reg_methods
[]
=
{
{
"match"
,
reg_match
},
{
"search"
,
reg_search
},
{
"
substring"
,
reg_substring
},
{
"
group"
,
reg_group
},
{
NULL
,
NULL
}
/* sentinel */
};
...
...
@@ -222,21 +222,40 @@ reg_getattr(re, name)
{
if
(
strcmp
(
name
,
"regs"
)
==
0
)
{
if
(
re
->
re_lastok
==
NULL
)
{
err_setstr
(
RegexError
,
"regs only valid after successful match/search"
);
return
NULL
;
INCREF
(
None
);
return
None
;
}
return
makeresult
(
&
re
->
re_regs
);
}
if
(
strcmp
(
name
,
"last"
)
==
0
)
{
if
(
re
->
re_lastok
==
NULL
)
{
err_setstr
(
RegexError
,
"last only valid after successful match/search"
);
return
NULL
;
INCREF
(
None
);
return
None
;
}
INCREF
(
re
->
re_lastok
);
return
re
->
re_lastok
;
}
if
(
strcmp
(
name
,
"translate"
)
==
0
)
{
if
(
re
->
re_translate
==
NULL
)
{
INCREF
(
None
);
return
None
;
}
INCREF
(
re
->
re_translate
);
return
re
->
re_translate
;
}
if
(
strcmp
(
name
,
"__members__"
)
==
0
)
{
object
*
list
=
newlistobject
(
3
);
if
(
list
)
{
setlistitem
(
list
,
0
,
newstringobject
(
"last"
));
setlistitem
(
list
,
1
,
newstringobject
(
"regs"
));
setlistitem
(
list
,
2
,
newstringobject
(
"translate"
));
if
(
err_occurred
())
{
DECREF
(
list
);
list
=
NULL
;
}
}
return
list
;
}
return
findmethod
(
reg_methods
,
(
object
*
)
re
,
name
);
}
...
...
@@ -373,7 +392,7 @@ static struct methodlist regex_global_methods[] = {
initregex
()
{
object
*
m
,
*
d
;
object
*
m
,
*
d
,
*
v
;
m
=
initmodule
(
"regex"
,
regex_global_methods
);
d
=
getmoduledict
(
m
);
...
...
@@ -382,4 +401,19 @@ initregex()
RegexError
=
newstringobject
(
"regex.error"
);
if
(
RegexError
==
NULL
||
dictinsert
(
d
,
"error"
,
RegexError
)
!=
0
)
fatal
(
"can't define regex.error"
);
/* Initialize regex.casefold constant */
v
=
newsizedstringobject
((
char
*
)
NULL
,
256
);
if
(
v
!=
NULL
)
{
int
i
;
char
*
s
=
getstringvalue
(
v
);
for
(
i
=
0
;
i
<
256
;
i
++
)
{
if
(
isupper
(
i
))
s
[
i
]
=
tolower
(
i
);
else
s
[
i
]
=
i
;
}
dictinsert
(
d
,
"casefold"
,
v
);
DECREF
(
v
);
}
}
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