[前][次][番号順一覧][スレッド一覧]

ruby-changes:43158

From: nobu <ko1@a...>
Date: Wed, 1 Jun 2016 01:49:36 +0900 (JST)
Subject: [ruby-changes:43158] nobu:r55232 (trunk): crypt.c: protoize

nobu	2016-06-01 01:49:32 +0900 (Wed, 01 Jun 2016)

  New Revision: 55232

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55232

  Log:
    crypt.c: protoize
    
    * missing/crypt.c: protoize function definitions and make
      always-zero functions void.

  Modified files:
    trunk/missing/crypt.c
Index: missing/crypt.c
===================================================================
--- missing/crypt.c	(revision 55231)
+++ missing/crypt.c	(revision 55232)
@@ -108,16 +108,13 @@ static char sccsid[] = "@(#)crypt.c	8.1 https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L108
 #define	LARGEDATA
 #endif
 
-int des_setkey(), des_cipher();
+void des_setkey(const char *key);
+void des_cipher(const char *in, char *out, long salt, int num_iter);
 
 /* compile with "-DSTATIC=int" when profiling */
 #ifndef STATIC
 #define	STATIC	static
 #endif
-STATIC void init_des(), init_perm(), permute();
-#ifdef DEBUG
-STATIC void prtab();
-#endif
 
 /* ==================================== */
 
@@ -303,11 +300,7 @@ typedef union { https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L300
 	{ C_block tblk; permute((cpp),&tblk,(p),4); LOAD ((d),(d0),(d1),tblk); }
 
 STATIC void
-permute(cp, out, p, chars_in)
-	unsigned char *cp;
-	C_block *out;
-	register C_block *p;
-	int chars_in;
+permute(unsigned char *cp, C_block *out, register C_block *p, int chars_in)
 {
 	register DCL_BLOCK(D,D0,D1);
 	register C_block *tp;
@@ -323,6 +316,12 @@ permute(cp, out, p, chars_in) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L316
 }
 #endif /* LARGEDATA */
 
+STATIC void init_des(void);
+STATIC void init_perm(C_block perm[64/CHUNKBITS][1<<CHUNKBITS], unsigned char p[64], int chars_in, int chars_out);
+
+#ifdef DEBUG
+STATIC void prtab(const char *s, const unsigned char *t, int num_rows);
+#endif
 
 /* =====  (mostly) Standard DES Tables ==================== */
 
@@ -497,9 +496,7 @@ static char	cryptresult[1+4+4+11+1];	/* https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L496
  * followed by an encryption produced by the "key" and "setting".
  */
 char *
-crypt(key, setting)
-	register const char *key;
-	register const char *setting;
+crypt(const char *key, const char *setting)
 {
 	register char *encp;
 	register long i;
@@ -513,8 +510,7 @@ crypt(key, setting) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L510
 			key++;
 		keyblock.b[i] = t;
 	}
-	if (des_setkey((char *)keyblock.b))	/* also initializes "a64toi" */
-		return (NULL);
+	des_setkey((char *)keyblock.b);	/* also initializes "a64toi" */
 
 	encp = &cryptresult[0];
 	switch (*setting) {
@@ -523,16 +519,14 @@ crypt(key, setting) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L519
 		 * Involve the rest of the password 8 characters at a time.
 		 */
 		while (*key) {
-			if (des_cipher((char *)&keyblock,
-			    (char *)&keyblock, 0L, 1))
-				return (NULL);
+			des_cipher((char *)&keyblock,
+				   (char *)&keyblock, 0L, 1);
 			for (i = 0; i < 8; i++) {
 				if ((t = 2*(unsigned char)(*key)) != 0)
 					key++;
 				keyblock.b[i] ^= t;
 			}
-			if (des_setkey((char *)keyblock.b))
-				return (NULL);
+			des_setkey((char *)keyblock.b);
 		}
 
 		*encp++ = *setting++;
@@ -562,9 +556,8 @@ crypt(key, setting) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L556
 		salt = (salt<<6) | a64toi[t];
 	}
 	encp += salt_size;
-	if (des_cipher((char *)&constdatablock, (char *)&rsltblock,
-	    salt, num_iter))
-		return (NULL);
+	des_cipher((char *)&constdatablock, (char *)&rsltblock,
+		   salt, num_iter);
 
 	/*
 	 * Encode the 64 cipher bits as 11 ascii characters.
@@ -599,9 +592,8 @@ static C_block	KS[KS_SIZE]; https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L592
 /*
  * Set up the key schedule from the key.
  */
-int
-des_setkey(key)
-	register const char *key;
+void
+des_setkey(const char *key)
 {
 	register DCL_BLOCK(K, K0, K1);
 	register C_block *ptabp;
@@ -623,7 +615,6 @@ des_setkey(key) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L615
 		PERM6464(K,K0,K1,(unsigned char *)key,ptabp);
 		STORE(K&~0x03030303L, K0&~0x03030303L, K1, *(C_block *)key);
 	}
-	return (0);
 }
 
 /*
@@ -634,12 +625,8 @@ des_setkey(key) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L625
  * NOTE: the performance of this routine is critically dependent on your
  * compiler and machine architecture.
  */
-int
-des_cipher(in, out, salt, num_iter)
-	const char *in;
-	char *out;
-	long salt;
-	int num_iter;
+void
+des_cipher(const char *in, char *out, long salt, int num_iter)
 {
 	/* variables that we want in registers, most important first */
 #if defined(pdp11)
@@ -747,7 +734,6 @@ des_cipher(in, out, salt, num_iter) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L734
 #else
 	STORE(L,L0,L1,*(C_block *)out);
 #endif
-	return (0);
 }
 
 
@@ -756,7 +742,7 @@ des_cipher(in, out, salt, num_iter) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L742
  * done at compile time, if the compiler were capable of that sort of thing.
  */
 STATIC void
-init_des()
+init_des(void)
 {
 	register int i, j;
 	register long k;
@@ -900,10 +886,8 @@ init_des() https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L886
  * "perm" must be all-zeroes on entry to this routine.
  */
 STATIC void
-init_perm(perm, p, chars_in, chars_out)
-	C_block perm[64/CHUNKBITS][1<<CHUNKBITS];
-	unsigned char p[64];
-	int chars_in, chars_out;
+init_perm(C_block perm[64/CHUNKBITS][1<<CHUNKBITS],
+	  unsigned char p[64], int chars_in, int chars_out)
 {
 	register int i, j, k, l;
 
@@ -923,9 +907,8 @@ init_perm(perm, p, chars_in, chars_out) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L907
 /*
  * "setkey" routine (for backwards compatibility)
  */
-int
-setkey(key)
-	register const char *key;
+void
+setkey(const char *key)
 {
 	register int i, j, k;
 	C_block keyblock;
@@ -938,16 +921,14 @@ setkey(key) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L921
 		}
 		keyblock.b[i] = k;
 	}
-	return (des_setkey((char *)keyblock.b));
+	des_setkey((char *)keyblock.b);
 }
 
 /*
  * "encrypt" routine (for backwards compatibility)
  */
-int
-encrypt(block, flag)
-	register char *block;
-	int flag;
+void
+encrypt(char *block, int flag)
 {
 	register int i, j, k;
 	C_block cblock;
@@ -960,8 +941,7 @@ encrypt(block, flag) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L941
 		}
 		cblock.b[i] = k;
 	}
-	if (des_cipher((char *)&cblock, (char *)&cblock, 0L, (flag ? -1: 1)))
-		return (1);
+	des_cipher((char *)&cblock, (char *)&cblock, 0L, (flag ? -1: 1));
 	for (i = 7; i >= 0; i--) {
 		k = cblock.b[i];
 		for (j = 7; j >= 0; j--) {
@@ -969,15 +949,11 @@ encrypt(block, flag) https://github.com/ruby/ruby/blob/trunk/missing/crypt.c#L949
 			k >>= 1;
 		}
 	}
-	return (0);
 }
 
 #ifdef DEBUG
 STATIC void
-prtab(s, t, num_rows)
-	char *s;
-	unsigned char *t;
-	int num_rows;
+prtab(const char *s, const unsigned char *t, int num_rows)
 {
 	register int i, j;
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]