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
58132c67
Kaydet (Commit)
58132c67
authored
Ara 17, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
AMK's latest; plus three null bytes that I added for purify
üst
e4eb2231
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
21 deletions
+36
-21
pcre-int.h
Modules/pcre-int.h
+3
-4
pcre.h
Modules/pcre.h
+4
-4
pcremodule.c
Modules/pcremodule.c
+29
-13
pypcre.c
Modules/pypcre.c
+0
-0
No files found.
Modules/pcre-int
ernal
.h
→
Modules/pcre-int.h
Dosyayı görüntüle @
58132c67
...
...
@@ -3,7 +3,7 @@
*************************************************/
#define PCRE_VERSION "1.0
1 19-Nov
-1997"
#define PCRE_VERSION "1.0
2 12-Dec
-1997"
/* This is a library of functions to support regular expressions whose syntax
...
...
@@ -114,7 +114,7 @@ enum { ESC_A = 1, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W, ESC_w,
/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
OP_EO
L
must correspond in order to the list of escapes immediately above. */
OP_EO
D
must correspond in order to the list of escapes immediately above. */
enum
{
OP_END
,
/* End of pattern */
...
...
@@ -131,8 +131,7 @@ enum {
OP_NOT_WORDCHAR
,
/* \W */
OP_WORDCHAR
,
/* \w */
OP_CUT
,
/* The analogue of Prolog's "cut" operation (extension) */
OP_EOD
,
/* End of data: or \Z. This must always be the last
of the backslashed meta values. */
OP_EOD
,
/* End of data: \Z. */
OP_NOT_WORD_BOUNDARY_L
,
/* localized \B */
OP_WORD_BOUNDARY_L
,
/* localized \b */
...
...
Modules/pcre.h
Dosyayı görüntüle @
58132c67
...
...
@@ -55,14 +55,14 @@ extern void (*pcre_free)(void *);
/* Functions */
#ifdef FOR_PYTHON
extern
pcre
*
pcre_compile
(
const
char
*
,
int
,
char
**
,
int
*
,
PyObject
*
);
extern
pcre
*
pcre_compile
(
const
char
*
,
int
,
c
onst
c
har
**
,
int
*
,
PyObject
*
);
#else
extern
pcre
*
pcre_compile
(
const
char
*
,
int
,
char
**
,
int
*
);
extern
pcre
*
pcre_compile
(
const
char
*
,
int
,
c
onst
c
har
**
,
int
*
);
#endif
extern
int
pcre_exec
(
const
pcre
*
,
const
pcre_extra
*
,
const
char
*
,
int
,
int
,
int
*
,
int
);
extern
int
pcre_info
(
const
pcre
*
,
int
*
,
int
*
);
extern
pcre_extra
*
pcre_study
(
const
pcre
*
,
int
,
char
**
);
extern
char
*
pcre_version
(
void
);
extern
pcre_extra
*
pcre_study
(
const
pcre
*
,
int
,
c
onst
c
har
**
);
extern
c
onst
c
har
*
pcre_version
(
void
);
#endif
/* End of pcre.h */
Modules/pcremodule.c
Dosyayı görüntüle @
58132c67
/***********************************************************
Copyright 199
1-1995
by Stichting Mathematisch Centrum, Amsterdam,
Copyright 199
7
by Stichting Mathematisch Centrum, Amsterdam,
The Netherlands.
All Rights Reserved
...
...
@@ -33,6 +33,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Python.h"
#include <assert.h>
#ifndef Py_eval_input
/* For Python 1.4, graminit.h has to be explicitly included */
#include "graminit.h"
...
...
@@ -44,7 +45,7 @@ PERFORMANCE OF THIS SOFTWARE.
#endif
#include "pcre.h"
#include "pcre-int
ernal
.h"
#include "pcre-int.h"
static
PyObject
*
ErrorObject
;
...
...
@@ -127,7 +128,9 @@ PyPcre_exec(self, args)
if
(
count
==
PCRE_ERROR_NOMATCH
)
{
Py_INCREF
(
Py_None
);
return
Py_None
;}
if
(
count
<
0
)
{
PyErr_SetObject
(
ErrorObject
,
Py_BuildValue
(
"si"
,
"Regex error"
,
count
));
PyObject
*
errval
=
Py_BuildValue
(
"si"
,
"Regex execution error"
,
count
);
PyErr_SetObject
(
ErrorObject
,
errval
);
Py_XDECREF
(
errval
);
return
NULL
;
}
...
...
@@ -191,7 +194,7 @@ PyPcre_compile(self, args)
PcreObject
*
rv
;
PyObject
*
dictionary
;
char
*
pattern
,
*
newpattern
;
char
*
error
;
c
onst
c
har
*
error
;
int
num_zeros
,
i
,
j
;
int
patternlen
,
options
,
erroroffset
;
...
...
@@ -203,12 +206,13 @@ PyPcre_compile(self, args)
return
NULL
;
/* PCRE doesn't like having null bytes in its pattern, so we have to replace
any zeros in the string with the characters '\0'. */
num_zeros
=
1
;
any zeros in the string with the characters '\000'. This increases the size
of the string by 3*num_zeros, plus 1 byte for the terminating \0. */
num_zeros
=
1
;
/* Start at 1; this will give 3 extra bytes of leeway */
for
(
i
=
0
;
i
<
patternlen
;
i
++
)
{
if
(
pattern
[
i
]
==
0
)
num_zeros
++
;
}
newpattern
=
malloc
(
patternlen
+
num_zeros
);
newpattern
=
malloc
(
patternlen
+
num_zeros
*
3
+
4
);
if
(
newpattern
==
NULL
)
{
PyErr_SetString
(
PyExc_MemoryError
,
"can't allocate memory for new pattern"
);
return
NULL
;
...
...
@@ -217,10 +221,16 @@ PyPcre_compile(self, args)
{
if
(
pattern
[
i
]
!=
0
)
newpattern
[
j
]
=
pattern
[
i
];
else
{
newpattern
[
j
++
]
=
'\\'
;
newpattern
[
j
]
=
'0'
;
newpattern
[
j
++
]
=
'\\'
;
newpattern
[
j
++
]
=
'0'
;
newpattern
[
j
++
]
=
'0'
;
newpattern
[
j
]
=
'0'
;
}
}
/* Keep purify happy; for pcre, one null byte is enough! */
newpattern
[
j
++
]
=
'\0'
;
newpattern
[
j
++
]
=
'\0'
;
newpattern
[
j
++
]
=
'\0'
;
newpattern
[
j
]
=
'\0'
;
rv
->
regex
=
pcre_compile
((
char
*
)
newpattern
,
options
,
...
...
@@ -231,21 +241,27 @@ PyPcre_compile(self, args)
PyMem_DEL
(
rv
);
if
(
!
PyErr_Occurred
())
{
PyErr_SetObject
(
ErrorObject
,
Py_BuildValue
(
"si"
,
error
,
erroroffset
));
PyObject
*
errval
=
Py_BuildValue
(
"si"
,
error
,
erroroffset
);
PyErr_SetObject
(
ErrorObject
,
errval
);
Py_XDECREF
(
errval
);
}
return
NULL
;
}
rv
->
regex_extra
=
pcre_study
(
rv
->
regex
,
0
,
&
error
);
if
(
rv
->
regex_extra
==
NULL
&&
error
!=
NULL
)
{
PyObject
*
errval
=
Py_BuildValue
(
"si"
,
error
,
0
);
PyMem_DEL
(
rv
);
PyErr_SetObject
(
ErrorObject
,
Py_BuildValue
(
"si"
,
error
,
0
));
PyErr_SetObject
(
ErrorObject
,
errval
);
Py_XDECREF
(
errval
);
return
NULL
;
}
rv
->
num_groups
=
pcre_info
(
rv
->
regex
,
NULL
,
NULL
);
if
(
rv
->
num_groups
<
0
)
{
PyErr_SetObject
(
ErrorObject
,
Py_BuildValue
(
"si"
,
"Regex error"
,
rv
->
num_groups
));
PyObject
*
errval
=
Py_BuildValue
(
"si"
,
error
,
rv
->
num_groups
);
PyErr_SetObject
(
ErrorObject
,
errval
);
Py_XDECREF
(
errval
);
PyMem_DEL
(
rv
);
return
NULL
;
}
...
...
@@ -526,7 +542,7 @@ PyPcre_expand(self, args)
Py_DECREF
(
r
);
Py_DECREF
(
tuple
);
if
(
result
==
NULL
)
{
/* The group() method trigged an exception of some sort */
/* The group() method trigge
re
d an exception of some sort */
Py_DECREF
(
results
);
Py_DECREF
(
value
);
return
NULL
;
...
...
Modules/pypcre.c
Dosyayı görüntüle @
58132c67
This diff is collapsed.
Click to expand it.
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