Skip to content

Commit 8102c00

Browse files
committed
Get rid of most silly #include and #ifdefs near the top; these are all
obsolete now it includes Python.h. Make all functions K&R compatible (Sue Williams).
1 parent 6459627 commit 8102c00

1 file changed

Lines changed: 59 additions & 55 deletions

File tree

‎Modules/regexpr.c‎

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,9 @@
2828
*
2929
* $Id$ */
3030

31-
#include "config.h" /* For Win* specific redefinition of printf c.s. */
32-
33-
#include "myproto.h" /* For PROTO macro --Guido */
34-
35-
#include <stdio.h>
3631
#include "Python.h"
37-
38-
#ifndef NDEBUG
39-
#define NDEBUG 1
40-
#endif
41-
42-
#include <assert.h>
4332
#include "regexpr.h"
44-
45-
#ifdef THINK_C
46-
/* Think C on the Mac really needs these headers... --Guido */
47-
#include <stdlib.h>
48-
#include <string.h>
49-
#else
50-
#if defined(__STDC__) || defined(_MSC_VER)
51-
/* Don't mess around, use the standard headers */
52-
#include <stdlib.h>
53-
#include <string.h>
54-
#else
55-
char *malloc();
56-
void free();
57-
char *realloc();
58-
#endif /* __STDC__ */
59-
#endif /* THINK_C */
33+
#include <assert.h>
6034

6135
/* The original code blithely assumed that sizeof(short) == 2. Not
6236
* always true. Original instances of "(short)x" were replaced by
@@ -472,7 +446,7 @@ static int regexp_ansi_sequences;
472446

473447
unsigned char re_syntax_table[256];
474448

475-
void re_compile_initialize(void)
449+
void re_compile_initialize()
476450
{
477451
int a;
478452

@@ -572,7 +546,8 @@ void re_compile_initialize(void)
572546
regexp_ansi_sequences = (regexp_syntax & RE_ANSI_HEX) != 0;
573547
}
574548

575-
int re_set_syntax(int syntax)
549+
int re_set_syntax(syntax)
550+
int syntax;
576551
{
577552
int ret;
578553

@@ -583,7 +558,8 @@ int re_set_syntax(int syntax)
583558
return ret;
584559
}
585560

586-
static int hex_char_to_decimal(int ch)
561+
static int hex_char_to_decimal(ch)
562+
int ch;
587563
{
588564
if (ch >= '0' && ch <= '9')
589565
return ch - '0';
@@ -594,11 +570,16 @@ static int hex_char_to_decimal(int ch)
594570
return 16;
595571
}
596572

597-
static void re_compile_fastmap_aux(unsigned char *code,
598-
int pos,
599-
unsigned char *visited,
600-
unsigned char *can_be_null,
601-
unsigned char *fastmap)
573+
static void re_compile_fastmap_aux(code,
574+
pos,
575+
visited,
576+
can_be_null,
577+
fastmap)
578+
unsigned char *code;
579+
int pos;
580+
unsigned char *visited;
581+
unsigned char *can_be_null;
582+
unsigned char *fastmap;
602583
{
603584
int a;
604585
int b;
@@ -725,11 +706,16 @@ static void re_compile_fastmap_aux(unsigned char *code,
725706
}
726707
}
727708

728-
static int re_do_compile_fastmap(unsigned char *buffer,
729-
int used,
730-
int pos,
731-
unsigned char *can_be_null,
732-
unsigned char *fastmap)
709+
static int re_do_compile_fastmap(buffer,
710+
used,
711+
pos,
712+
can_be_null,
713+
fastmap)
714+
unsigned char *buffer;
715+
int used;
716+
int pos;
717+
unsigned char *can_be_null;
718+
unsigned char *fastmap;
733719
{
734720
unsigned char small_visited[512], *visited;
735721

@@ -750,7 +736,8 @@ static int re_do_compile_fastmap(unsigned char *buffer,
750736
return 1;
751737
}
752738

753-
void re_compile_fastmap(regexp_t bufp)
739+
void re_compile_fastmap(bufp)
740+
regexp_t bufp;
754741
{
755742
if (!bufp->fastmap || bufp->fastmap_accurate)
756743
return;
@@ -795,7 +782,9 @@ void re_compile_fastmap(regexp_t bufp)
795782
*
796783
*/
797784

798-
static int re_optimize_star_jump(regexp_t bufp, unsigned char *code)
785+
static int re_optimize_star_jump(bufp, code)
786+
regexp_t bufp;
787+
unsigned char *code;
799788
{
800789
unsigned char map[256];
801790
unsigned char can_be_null;
@@ -956,7 +945,8 @@ static int re_optimize_star_jump(regexp_t bufp, unsigned char *code)
956945
return 1;
957946
}
958947

959-
static int re_optimize(regexp_t bufp)
948+
static int re_optimize(bufp)
949+
regexp_t bufp;
960950
{
961951
unsigned char *code;
962952

@@ -1157,7 +1147,10 @@ else \
11571147
} \
11581148
}
11591149

1160-
char *re_compile_pattern(unsigned char *regex, int size, regexp_t bufp)
1150+
char *re_compile_pattern(regex, size, bufp)
1151+
unsigned char *regex;
1152+
int size;
1153+
regexp_t bufp;
11611154
{
11621155
int a;
11631156
int pos;
@@ -1589,11 +1582,16 @@ var = (unsigned char)*text++; \
15891582
if (translate) \
15901583
var = translate[var]
15911584

1592-
int re_match(regexp_t bufp,
1593-
unsigned char *string,
1594-
int size,
1595-
int pos,
1596-
regexp_registers_t old_regs)
1585+
int re_match(bufp,
1586+
string,
1587+
size,
1588+
pos,
1589+
old_regs)
1590+
regexp_t bufp;
1591+
unsigned char *string;
1592+
int size;
1593+
int pos;
1594+
regexp_registers_t old_regs;
15971595
{
15981596
unsigned char *code;
15991597
unsigned char *translate;
@@ -2019,12 +2017,18 @@ int re_match(regexp_t bufp,
20192017
#undef PREFETCH
20202018
#undef NEXTCHAR
20212019

2022-
int re_search(regexp_t bufp,
2023-
unsigned char *string,
2024-
int size,
2025-
int pos,
2026-
int range,
2027-
regexp_registers_t regs)
2020+
int re_search(bufp,
2021+
string,
2022+
size,
2023+
pos,
2024+
range,
2025+
regs)
2026+
regexp_t bufp;
2027+
unsigned char *string;
2028+
int size;
2029+
int pos;
2030+
int range;
2031+
regexp_registers_t regs;
20282032
{
20292033
unsigned char *fastmap;
20302034
unsigned char *translate;

0 commit comments

Comments
 (0)