SHA1Stream.st
changeset 13895 cacfa6e615f9
parent 13878 02134ed737a0
child 13916 6c993e4f9852
--- a/SHA1Stream.st	Sun Jan 08 01:55:19 2012 +0100
+++ b/SHA1Stream.st	Sun Jan 08 01:57:43 2012 +0100
@@ -555,64 +555,69 @@
        __qClass(__INST(hashContext)) == @global(ByteArray) &&
        __byteArraySize(__INST(hashContext)) == sizeof(SHA1_CTX)
    ) {
-	SHA1_CTX *ctx =
-	    (SHA1_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element;
+        SHA1_CTX *ctx =
+            (SHA1_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element;
 
-	if (__isNonNilObject(anObject)) {
-	    OBJ cls =__qClass(anObject);
-	    INT mask = (INT)(__ClassInstPtr(cls)->c_flags) & __MASKSMALLINT(ARRAYMASK);
+        if (__isNonNilObject(anObject)) {
+            OBJ cls =__qClass(anObject);
+            INT mask = (INT)(__ClassInstPtr(cls)->c_flags) & __MASKSMALLINT(ARRAYMASK);
 
-	    if (cls == @global(String) || cls == @global(Symbol)) {
-		/* String: omit leading '\0' */
+            if (cls == @global(String) || cls == @global(Symbol)) {
+                /* String: omit leading '\0' */
 
-		SHA1Update(ctx, __StringInstPtr(anObject)->s_element, __stringSize(anObject));
-	    } else if (mask != __MASKSMALLINT(POINTERARRAY) &&
-		mask != __MASKSMALLINT(WKPOINTERARRAY) &&
-		mask != __MASKSMALLINT(0)
-	    ) {
-		/* Byte|Integer|.... Array */
+                SHA1Update(ctx, __StringInstPtr(anObject)->s_element, __stringSize(anObject));
+            } else if (mask != __MASKSMALLINT(POINTERARRAY) &&
+                mask != __MASKSMALLINT(WKPOINTERARRAY) &&
+                mask != __MASKSMALLINT(0)
+            ) {
+                /* Byte|Integer|.... Array */
 
-		register int n;
-		char *pFirst;
+                register int n;
+                char *pFirst;
 
-		n /* nInstVars */  = __intVal(__ClassInstPtr(cls)->c_ninstvars);
-		n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* nInstVars */);
-		pFirst = (char *)(__InstPtr(anObject)) + n /* nInstBytes */;
-		n /* nbytes */     = __qSize(anObject) - n /* nInstBytes */;
-		SHA1Update(ctx, pFirst, n);
-	    } else if (cls == @global(Character)) {
-		/* Character */
+                n /* nInstVars */  = __intVal(__ClassInstPtr(cls)->c_ninstvars);
+                n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* nInstVars */);
+                pFirst = (char *)(__InstPtr(anObject)) + n /* nInstBytes */;
+                n /* nbytes */     = __qSize(anObject) - n /* nInstBytes */;
+                SHA1Update(ctx, pFirst, n);
+            } else if (cls == @global(Character)) {
+                /* Character */
 
-		INT val = __intVal(_characterVal(anObject));
-		if (val > 255) {
-		    /* Two byte character */
-		    short s = val;
-		    SHA1Update(ctx, (char *)&s, 2);
-		} else {
-		    char c = val;
-		    SHA1Update(ctx, &c, 1);
-		}
-	    } else {
-		ret = false;
-	    }
-	} else {
-	    if (anObject == nil) {
-		ret = false;
-	    } else {
-		/* SmallInteger */
-
-		INT i = __intVal(anObject);
-		SHA1Update(ctx, (char *)&i, sizeof(INT));
-	    }
-	}
+                INT val = __intVal(_characterVal(anObject));
+                if (val > 255) {
+                    /* Two byte character */
+                    short s = val;
+                    SHA1Update(ctx, (char *)&s, 2);
+                } else {
+                    char c = val;
+                    SHA1Update(ctx, &c, 1);
+                }
+            } else {
+                ret = false;
+            }
+        } else {
+            if (anObject == nil) {
+                ret = false;
+            } else {
+                /* SmallInteger */
+                // cg: I hope, noone used that interface; it depended on the machines byteorder !
+#if 0
+                INT i = __intVal(anObject);
+                SHA1Update(ctx, (char *)&i, sizeof(INT));
+#else
+                ret = false;
+#endif
+            }
+        }
     }
 %}.
 
     ret notNil ifTrue:[
-	^ self primitiveFailed
+        ^ self primitiveFailed
     ].
 
-    "Created: / 17.3.1999 / 16:14:13 / stefan"
+    "Created: / 17-03-1999 / 16:14:13 / stefan"
+    "Modified: / 08-01-2012 / 01:48:44 / cg"
 !
 
 nextPutBytes:count from:anObject startingAt:start
@@ -684,11 +689,11 @@
 !SHA1Stream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/SHA1Stream.st,v 1.20 2011-12-26 09:56:58 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SHA1Stream.st,v 1.21 2012-01-08 00:57:43 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/SHA1Stream.st,v 1.20 2011-12-26 09:56:58 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SHA1Stream.st,v 1.21 2012-01-08 00:57:43 cg Exp $'
 ! !
 
 SHA1Stream initialize!