ANSI-fication
authorPeter Schneider-Kamp <nowonder@nowonder.de>
Mon, 10 Jul 2000 13:05:29 +0000 (13:05 +0000)
committerPeter Schneider-Kamp <nowonder@nowonder.de>
Mon, 10 Jul 2000 13:05:29 +0000 (13:05 +0000)
Modules/regexmodule.c
Modules/regexpr.c
Modules/rotormodule.c

index 2455b0639c22589b5487d22ac2aba5d438fb36a3..b1626db707d598342d538b89657294e5ffa8ca0e 100644 (file)
@@ -40,8 +40,7 @@ typedef struct {
 /* Regex object methods */
 
 static void
-reg_dealloc(re)
-       regexobject *re;
+reg_dealloc(regexobject *re)
 {
        if (re->re_patbuf.buffer)
                PyMem_DEL(re->re_patbuf.buffer);
@@ -54,8 +53,7 @@ reg_dealloc(re)
 }
 
 static PyObject *
-makeresult(regs)
-       struct re_registers *regs;
+makeresult(struct re_registers *regs)
 {
        PyObject *v;
        int i;
@@ -89,9 +87,7 @@ makeresult(regs)
 }
 
 static PyObject *
-regobj_match(re, args)
-       regexobject *re;
-       PyObject *args;
+regobj_match(regexobject *re, PyObject *args)
 {
        PyObject *argstring;
        char *buffer;
@@ -127,9 +123,7 @@ regobj_match(re, args)
 }
 
 static PyObject *
-regobj_search(re, args)
-       regexobject *re;
-       PyObject *args;
+regobj_search(regexobject *re, PyObject *args)
 {
        PyObject *argstring;
        char *buffer;
@@ -174,9 +168,7 @@ regobj_search(re, args)
    an integer index [0 .. 99]
  */
 static PyObject*
-group_from_index(re, index)
-       regexobject *re;
-       PyObject *index;
+group_from_index(regexobject *re, PyObject *index)
 {
        int i, a, b;
        char *v;
@@ -218,9 +210,7 @@ group_from_index(re, index)
 
 
 static PyObject *
-regobj_group(re, args)
-       regexobject *re;
-       PyObject *args;
+regobj_group(regexobject *re, PyObject *args)
 {
        int n = PyTuple_Size(args);
        int i;
@@ -281,9 +271,7 @@ static char* members[] = {
 
 
 static PyObject *
-regobj_getattr(re, name)
-       regexobject *re;
-       char *name;
+regobj_getattr(regexobject *re, char *name)
 {
        if (strcmp(name, "regs") == 0) {
                if (re->re_lastok == NULL) {
@@ -380,11 +368,7 @@ static PyTypeObject Regextype = {
    groupindex: transferred
 */
 static PyObject *
-newregexobject(pattern, translate, givenpat, groupindex)
-       PyObject *pattern;
-       PyObject *translate;
-       PyObject *givenpat;
-       PyObject *groupindex;
+newregexobject(PyObject *pattern, PyObject *translate, PyObject *givenpat, PyObject *groupindex)
 {
        regexobject *re;
        char *pat;
@@ -432,9 +416,7 @@ newregexobject(pattern, translate, givenpat, groupindex)
 }
 
 static PyObject *
-regex_compile(self, args)
-       PyObject *self;
-       PyObject *args;
+regex_compile(PyObject *self, PyObject *args)
 {
        PyObject *pat = NULL;
        PyObject *tran = NULL;
@@ -445,9 +427,7 @@ regex_compile(self, args)
 }
 
 static PyObject *
-symcomp(pattern, gdict)
-       PyObject *pattern;
-       PyObject *gdict;
+symcomp(PyObject *pattern, PyObject *gdict)
 {
        char *opat, *oend, *o, *n, *g, *v;
        int group_count = 0;
@@ -554,9 +534,7 @@ symcomp(pattern, gdict)
 }
 
 static PyObject *
-regex_symcomp(self, args)
-       PyObject *self;
-       PyObject *args;
+regex_symcomp(PyObject *self, PyObject *args)
 {
        PyObject *pattern;
        PyObject *tran = NULL;
@@ -583,8 +561,7 @@ static PyObject *cache_pat;
 static PyObject *cache_prog;
 
 static int
-update_cache(pat)
-       PyObject *pat;
+update_cache(PyObject *pat)
 {
        PyObject *tuple = Py_BuildValue("(O)", pat);
        int status = 0;
@@ -610,9 +587,7 @@ update_cache(pat)
 }
 
 static PyObject *
-regex_match(self, args)
-       PyObject *self;
-       PyObject *args;
+regex_match(PyObject *self, PyObject *args)
 {
        PyObject *pat, *string;
        PyObject *tuple, *v;
@@ -630,9 +605,7 @@ regex_match(self, args)
 }
 
 static PyObject *
-regex_search(self, args)
-       PyObject *self;
-       PyObject *args;
+regex_search(PyObject *self, PyObject *args)
 {
        PyObject *pat, *string;
        PyObject *tuple, *v;
@@ -650,9 +623,7 @@ regex_search(self, args)
 }
 
 static PyObject *
-regex_set_syntax(self, args)
-       PyObject *self;
-       PyObject *args;
+regex_set_syntax(PyObject *self, PyObject *args)
 {
        int syntax;
        if (!PyArg_Parse(args, "i", &syntax))
@@ -667,9 +638,7 @@ regex_set_syntax(self, args)
 }
 
 static PyObject *
-regex_get_syntax(self, args)
-       PyObject *self;
-       PyObject *args;
+regex_get_syntax(PyObject *self, PyObject *args)
 {
        if (!PyArg_Parse(args, ""))
                return NULL;
index cc869772974d50d3f8e87239988e483e0fe21ec4..98fa04ca87e7e72796b1e390d33ecaaddbedca99 100644 (file)
@@ -546,8 +546,7 @@ void re_compile_initialize()
        regexp_ansi_sequences = (regexp_syntax & RE_ANSI_HEX) != 0;
 }
 
-int re_set_syntax(syntax)
-       int syntax;
+int re_set_syntax(int syntax)
 {
        int ret;
        
@@ -558,8 +557,7 @@ int re_set_syntax(syntax)
        return ret;
 }
 
-static int hex_char_to_decimal(ch)
-       int ch;
+static int hex_char_to_decimal(int ch)
 {
        if (ch >= '0' && ch <= '9')
                return ch - '0';
@@ -570,16 +568,10 @@ static int hex_char_to_decimal(ch)
        return 16;
 }
 
-static void re_compile_fastmap_aux(code,
-                                  pos,
-                                  visited,
-                                  can_be_null,
-                                  fastmap)
-       unsigned char *code;
-       int pos;
-       unsigned char *visited;
-       unsigned char *can_be_null;
-       unsigned char *fastmap;
+static void re_compile_fastmap_aux(unsigned char *code, int pos,
+                                   unsigned char *visited,
+                                   unsigned char *can_be_null,
+                                   unsigned char *fastmap)
 {
        int a;
        int b;
@@ -706,16 +698,9 @@ static void re_compile_fastmap_aux(code,
                }
 }
 
-static int re_do_compile_fastmap(buffer,
-                                used,
-                                pos,
-                                can_be_null,
-                                fastmap)
-       unsigned char *buffer;
-       int used;
-       int pos;
-       unsigned char *can_be_null;
-       unsigned char *fastmap;
+static int re_do_compile_fastmap(unsigned char *buffer, int used, int pos,
+                                 unsigned char *can_be_null,
+                                 unsigned char *fastmap)
 {
        unsigned char small_visited[512], *visited;
    
@@ -736,8 +721,7 @@ static int re_do_compile_fastmap(buffer,
        return 1;
 }
 
-void re_compile_fastmap(bufp)
-       regexp_t bufp;
+void re_compile_fastmap(regexp_t bufp)
 {
        if (!bufp->fastmap || bufp->fastmap_accurate)
                return;
@@ -782,9 +766,7 @@ void re_compile_fastmap(bufp)
  *
  */
 
-static int re_optimize_star_jump(bufp, code)
-       regexp_t bufp;
-       unsigned char *code;
+static int re_optimize_star_jump(regexp_t bufp, unsigned char *code)
 {
        unsigned char map[256];
        unsigned char can_be_null;
@@ -945,8 +927,7 @@ static int re_optimize_star_jump(bufp, code)
        return 1;
 }
 
-static int re_optimize(bufp)
-       regexp_t bufp;
+static int re_optimize(regexp_t bufp)
 {
        unsigned char *code;
        
@@ -1147,10 +1128,7 @@ else \
        } \
 }
 
-char *re_compile_pattern(regex, size, bufp)
-       unsigned char *regex;
-       int size;
-       regexp_t bufp;
+char *re_compile_pattern(unsigned char *regex, int size, regexp_t bufp)
 {
        int a;
        int pos;
@@ -1417,8 +1395,8 @@ char *re_compile_pattern(regex, size, bufp)
                        int prev;
                        int offset;
                        int range;
-                       int firstchar;
-           
+                        int firstchar;
+                        
                        SET_LEVEL_START;
                        ALLOC(1+256/8);
                        STORE(Cset);
@@ -1586,16 +1564,8 @@ var = (unsigned char)*text++; \
 if (translate) \
        var = translate[var]
 
-int re_match(bufp,
-            string,
-            size,
-            pos,
-            old_regs)
-       regexp_t bufp;
-       unsigned char *string;
-       int size;
-       int pos;
-       regexp_registers_t old_regs;
+int re_match(regexp_t bufp, unsigned char *string, int size, int pos,
+             regexp_registers_t old_regs)
 {
        unsigned char *code;
        unsigned char *translate;
@@ -2021,18 +1991,8 @@ int re_match(bufp,
 #undef PREFETCH
 #undef NEXTCHAR
 
-int re_search(bufp,
-             string,
-             size,
-             pos,
-             range,
-             regs)
-       regexp_t bufp;
-       unsigned char *string;
-       int size;
-       int pos;
-       int range;
-       regexp_registers_t regs;
+int re_search(regexp_t bufp, unsigned char *string, int size, int pos,
+              int range, regexp_registers_t regs)
 {
        unsigned char *fastmap;
        unsigned char *translate;
index d63ad74c23f1ae430cfbc1212f2ed83ad71a3f25..6960acf1c5c2b69798e3039923ec3c21ff559c49 100644 (file)
@@ -87,8 +87,7 @@ staticforward PyTypeObject Rotor_Type;
 /* This defines the necessary routines to manage rotor objects */
 
 static void
-set_seed(r) 
-       Rotorobj *r;
+set_seed(Rotorobj *r)
 {
        r->seed[0] = r->key[0];
        r->seed[1] = r->key[1];
@@ -98,8 +97,7 @@ set_seed(r)
        
 /* Return the next random number in the range [0.0 .. 1.0) */
 static double
-r_random(r)
-       Rotorobj *r;
+r_random(Rotorobj *r)
 {
        int x, y, z;
        double val, term;
@@ -134,17 +132,13 @@ r_random(r)
 }
 
 static short
-r_rand(r, s)
-       Rotorobj *r;
-       short s;
+r_rand(Rotorobj *r, short s)
 {
        return (short)((short)(r_random(r) * (double)s) % s);
 }
 
 static void
-set_key(r, key)
-       Rotorobj *r;
-       char *key;
+set_key(Rotorobj *r, char *key)
 {
        unsigned long k1=995, k2=576, k3=767, k4=671, k5=463;
        size_t i;
@@ -172,9 +166,7 @@ set_key(r, key)
 \f
 /* These define the interface to a rotor object */
 static Rotorobj *
-rotorobj_new(num_rotors, key)
-       int num_rotors;
-       char *key;
+rotorobj_new(int num_rotors, char *key)
 {
        Rotorobj *xp;
 
@@ -251,9 +243,7 @@ rotorobj_new(num_rotors, key)
 
 /* Set ROTOR to the identity permutation */
 static void
-RTR_make_id_rotor(r, rtr)
-       Rotorobj *r;
-       unsigned char *rtr;
+RTR_make_id_rotor(Rotorobj *r, unsigned char *rtr)
 {
        register int j;
        register int size = r->size;
@@ -265,8 +255,7 @@ RTR_make_id_rotor(r, rtr)
 
 /* The current set of encryption rotors */
 static void
-RTR_e_rotors(r)
-       Rotorobj *r;
+RTR_e_rotors(Rotorobj *r)
 {
        int i;
        for (i = 0; i < r->rotors; i++) {
@@ -276,8 +265,7 @@ RTR_e_rotors(r)
 
 /* The current set of decryption rotors */
 static void
-RTR_d_rotors(r)
-       Rotorobj *r;
+RTR_d_rotors(Rotorobj *r)
 {
        register int i, j;
        for (i = 0; i < r->rotors; i++) {
@@ -289,8 +277,7 @@ RTR_d_rotors(r)
 
 /* The positions of the rotors at this time */
 static void
-RTR_positions(r)
-       Rotorobj *r;
+RTR_positions(Rotorobj *r)
 {
        int i;
        for (i = 0; i < r->rotors; i++) {
@@ -300,8 +287,7 @@ RTR_positions(r)
 
 /* The number of positions to advance the rotors at a time */
 static void
-RTR_advances(r) 
-       Rotorobj *r;
+RTR_advances(Rotorobj *r)
 {
        int i;
        for (i = 0; i < r->rotors; i++) {
@@ -313,10 +299,7 @@ RTR_advances(r)
  * see Knuth for explanation of algorithm.
  */
 static void
-RTR_permute_rotor(r, e, d)
-       Rotorobj *r;
-       unsigned char *e;
-       unsigned char *d;
+RTR_permute_rotor(Rotorobj *r, unsigned char *e, unsigned char *d)
 {
        short i = r->size;
        short q;
@@ -338,8 +321,7 @@ RTR_permute_rotor(r, e, d)
  * Set the advancement, position, and permutation of the rotors
  */
 static void
-RTR_init(r)
-       Rotorobj *r;
+RTR_init(Rotorobj *r)
 {
        int i;
        set_seed(r);
@@ -359,8 +341,7 @@ RTR_init(r)
 
 /* Change the RTR-positions vector, using the RTR-advances vector */
 static void
-RTR_advance(r)
-       Rotorobj *r;
+RTR_advance(Rotorobj *r)
 {
        register int i=0, temp=0;
        if (r->size_mask) {
@@ -386,9 +367,7 @@ RTR_advance(r)
 
 /* Encrypt the character P with the current rotor machine */
 static unsigned char
-RTR_e_char(r, p)
-       Rotorobj *r;
-       unsigned char p;
+RTR_e_char(Rotorobj *r, unsigned char p)
 {
        register int i=0;
        register unsigned char tp=p;
@@ -413,9 +392,7 @@ RTR_e_char(r, p)
 
 /* Decrypt the character C with the current rotor machine */
 static unsigned char
-RTR_d_char(r, c)
-       Rotorobj *r;
-       unsigned char c;
+RTR_d_char(Rotorobj *r, unsigned char c)
 {
        register int i = r->rotors - 1;
        register unsigned char tc = c;
@@ -440,11 +417,7 @@ RTR_d_char(r, c)
 
 /* Perform a rotor encryption of the region from BEG to END by KEY */
 static void
-RTR_e_region(r, beg, len, doinit)
-       Rotorobj *r;
-       unsigned char *beg;
-       int len;
-       int doinit;
+RTR_e_region(Rotorobj *r, unsigned char *beg, int len, int doinit)
 {
        register int i;
        if (doinit || r->isinited == FALSE)
@@ -456,11 +429,7 @@ RTR_e_region(r, beg, len, doinit)
 
 /* Perform a rotor decryption of the region from BEG to END by KEY */
 static void
-RTR_d_region(r, beg, len, doinit)
-       Rotorobj *r;
-       unsigned char *beg;
-       int len;
-       int doinit;
+RTR_d_region(Rotorobj *r, unsigned char *beg, int len, int doinit)
 {
        register int i;
        if (doinit || r->isinited == FALSE)
@@ -474,8 +443,7 @@ RTR_d_region(r, beg, len, doinit)
 \f
 /* Rotor methods */
 static void
-rotor_dealloc(xp)
-       Rotorobj *xp;
+rotor_dealloc(Rotorobj *xp)
 {
        if (xp->e_rotor)
                PyMem_DEL(xp->e_rotor);
@@ -489,9 +457,7 @@ rotor_dealloc(xp)
 }
 
 static PyObject * 
-rotorobj_encrypt(self, args)
-       Rotorobj *self;
-       PyObject * args;
+rotorobj_encrypt(Rotorobj *self, PyObject *args)
 {
        char *string = NULL;
        int len = 0;
@@ -513,9 +479,7 @@ rotorobj_encrypt(self, args)
 }
 
 static PyObject * 
-rotorobj_encrypt_more(self, args)
-       Rotorobj *self;
-       PyObject * args;
+rotorobj_encrypt_more(Rotorobj *self, PyObject *args)
 {
        char *string = NULL;
        int len = 0;
@@ -537,9 +501,7 @@ rotorobj_encrypt_more(self, args)
 }
 
 static PyObject * 
-rotorobj_decrypt(self, args)
-       Rotorobj *self;
-       PyObject * args;
+rotorobj_decrypt(Rotorobj *self, PyObject *args)
 {
        char *string = NULL;
        int len = 0;
@@ -561,9 +523,7 @@ rotorobj_decrypt(self, args)
 }
 
 static PyObject * 
-rotorobj_decrypt_more(self, args)
-       Rotorobj *self;
-       PyObject * args;
+rotorobj_decrypt_more(Rotorobj *self, PyObject *args)
 {
        char *string = NULL;
        int len = 0;
@@ -585,9 +545,7 @@ rotorobj_decrypt_more(self, args)
 }
 
 static PyObject * 
-rotorobj_setkey(self, args)
-       Rotorobj *self;
-       PyObject * args;
+rotorobj_setkey(Rotorobj *self, PyObject *args)
 {
        char *key;
 
@@ -612,9 +570,7 @@ rotorobj_methods[] = {
 
 /* Return a rotor object's named attribute. */
 static PyObject * 
-rotorobj_getattr(s, name)
-       Rotorobj *s;
-       char *name;
+rotorobj_getattr(Rotorobj *s, char *name)
 {
        return Py_FindMethod(rotorobj_methods, (PyObject*)s, name);
 }
@@ -638,9 +594,7 @@ statichere PyTypeObject Rotor_Type = {
 
 
 static PyObject * 
-rotor_rotor(self, args)
-       PyObject * self;
-       PyObject * args;
+rotor_rotor(PyObject *self, PyObject *args)
 {
        Rotorobj *r;
        char *string;