--- a/LargeInteger.st Tue Apr 26 21:57:25 2016 +0100
+++ b/LargeInteger.st Wed Apr 27 07:53:49 2016 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1994 by Claus Gittinger
All Rights Reserved
@@ -238,7 +240,7 @@
digitBytes:aByteArrayOfDigits
"create and return a new LargeInteger with digits (lsb-first)
from the argument, aByteArray.
- Experimental interface - May change/be removed without notice."
+ The byteArray argument provides the unsigned magnitude in lsb-first order."
^ self basicNew setDigits:aByteArrayOfDigits
@@ -252,7 +254,8 @@
digitBytes:aByteArrayOfDigits MSB:msb
"create and return a new LargeInteger with digits (which may be in either msb/lsb order)
- from the argument, aByteArray."
+ from the argument, aByteArray.
+ The byteArray argument provides the unsigned magnitude in the specified byte order."
|digits|
@@ -270,9 +273,9 @@
!
digitBytes:aByteArrayOfDigits sign:sign
- "create and return a new LargeInteger with digits (lsb-first)
+ "create and return a new sign-magnitude LargeInteger with digits (lsb-first)
from the argument, aByteArray.
- Experimental interface - May change/be removed without notice."
+ The byteArray argument provides the unsigned magnitude in lsb-first order."
^ self basicNew setDigits:aByteArrayOfDigits sign:sign
@@ -3324,7 +3327,7 @@
((aSmallInteger < (SmallInteger minVal + 255))
or:[aSmallInteger > (SmallInteger maxVal - 255)]) ifTrue:[
- ^ self absMinus:(self class value:aSmallInteger) sign:newSign.
+ ^ self absMinus:(self class value:aSmallInteger) sign:newSign.
].
len := digitByteArray size.
@@ -3338,123 +3341,133 @@
%{
if (__isByteArray(__INST(digitByteArray))
&& __isByteArray(resultDigitByteArray)) {
- unsigned INT __borrow = __intVal(borrow);
- INT __diff;
- int __index = 1;
- int __len = __intVal(len);
- unsigned char *__digitP = __ByteArrayInstPtr(__INST(digitByteArray))->ba_element;
- unsigned char *__resultP = __ByteArrayInstPtr(resultDigitByteArray)->ba_element;
- int __len3;
+ unsigned INT __borrow = __intVal(borrow);
+ INT __diff;
+ int __index = 1;
+ int __len = __intVal(len);
+ unsigned char *__digitP = __ByteArrayInstPtr(__INST(digitByteArray))->ba_element;
+ unsigned char *__resultP = __ByteArrayInstPtr(resultDigitByteArray)->ba_element;
+ int __len3;
#if defined(__LSBFIRST__)
# if (__POINTER_SIZE__ == 8)
- /*
- * subtract int-wise
- */
- __len3 = __len - 3;
- while (__index < __len3) {
- /* do not make this into one expression - ask cg why */
- __diff = ((unsigned int *)(__digitP + __index-1))[0];
- __diff -= (__borrow & 0xFFFFFFFFL);
- __borrow >>= 32;
- if (__diff < 0) {
- /* __diff += 0x100000000; */
- __borrow++;
- }
- ((unsigned int *)(__resultP+__index-1))[0] = __diff;
- __index += 4;
- }
+ /*
+ * subtract int-wise
+ */
+ __len3 = __len - 3;
+ while (__index < __len3) {
+ /* do not make this into one expression - ask cg why */
+ __diff = ((unsigned int *)(__digitP + __index-1))[0];
+ __diff -= (__borrow & 0xFFFFFFFFL);
+ __borrow >>= 32;
+ ((unsigned int *)(__resultP+__index-1))[0] = __diff;
+ __index += 4;
+ if (__diff < 0) {
+ /* __diff += 0x100000000; */
+ __borrow++;
+ } else {
+ if (__borrow == 0) {
+ /* nothing more to subtract .. */
+ while (__index < __len3) {
+ ((unsigned int *)(__resultP+__index-1))[0] = ((unsigned int *)(__digitP+__index-1))[0];
+ __index += 4;
+ }
+ if (__index < __len) {
+ ((unsigned short *)(__resultP+__index-1))[0] = ((unsigned short *)(__digitP+__index-1))[0];
+ __index += 2;
+ }
+ if (__index <= __len) {
+ __resultP[__index-1] = __digitP[__index-1];
+ }
+ break;
+ }
+ }
+ }
# endif
- /*
- * subtract short-wise
- */
- while (__index < __len) {
- /* do not make this into one expression - ask cg why */
- __diff = ((unsigned short *)(__digitP+__index-1))[0];
- __diff -= (__borrow & 0xFFFF);
- __borrow >>= 16;
- if (__diff < 0) {
- /* __diff += 0x10000; */
- __borrow++;
- } else {
- if (__borrow == 0) {
- ((unsigned short *)(__resultP+__index-1))[0] = __diff;
- __index += 2;
-
- /* nothing more to subtract .. */
- while (__index < __len) {
- ((unsigned short *)(__resultP+__index-1))[0] = ((unsigned short *)(__digitP+__index-1))[0];
- __index += 2;
- }
- if (__index <= __len) {
- __resultP[__index-1] = __digitP[__index-1];
- }
- break;
- }
- }
- ((unsigned short *)(__resultP+__index-1))[0] = __diff;
- __index += 2;
- }
+ /*
+ * subtract short-wise
+ */
+ while (__index < __len) {
+ /* do not make this into one expression - ask cg why */
+ __diff = ((unsigned short *)(__digitP+__index-1))[0];
+ __diff -= (__borrow & 0xFFFF);
+ __borrow >>= 16;
+ ((unsigned short *)(__resultP+__index-1))[0] = __diff;
+ __index += 2;
+ if (__diff < 0) {
+ /* __diff += 0x10000; */
+ __borrow++;
+ } else {
+ if (__borrow == 0) {
+ /* nothing more to subtract .. */
+ while (__index < __len) {
+ ((unsigned short *)(__resultP+__index-1))[0] = ((unsigned short *)(__digitP+__index-1))[0];
+ __index += 2;
+ }
+ if (__index <= __len) {
+ __resultP[__index-1] = __digitP[__index-1];
+ }
+ break;
+ }
+ }
+ }
#endif
- /*
- * subtract byte-wise
- */
- while (__index <= __len) {
- __diff = __digitP[__index-1];
- __diff -= (__borrow & 0xFF);
- __borrow >>= 8;
- if (__diff < 0) {
- /* __diff += 0x100; */
- __borrow++;
- } else {
- if (__borrow == 0) {
- __resultP[__index-1] = __diff;
- __index++;
-
- /* nothing more to subtract .. */
- while (__index <= __len) {
- __resultP[__index-1] = __digitP[__index-1];
- __index++;
- }
- break;
- }
- }
- __resultP[__index-1] = __diff;
- __index++;
- }
- lastDigit = __mkSmallInteger( __resultP[__index-1-1] );
- ok = true;
+ /*
+ * subtract byte-wise
+ */
+ while (__index <= __len) {
+ __diff = __digitP[__index-1];
+ __diff -= (__borrow & 0xFF);
+ __borrow >>= 8;
+ __resultP[__index-1] = __diff;
+ __index++;
+ if (__diff < 0) {
+ /* __diff += 0x100; */
+ __borrow++;
+ } else {
+ if (__borrow == 0) {
+ /* nothing more to subtract .. */
+ while (__index <= __len) {
+ __resultP[__index-1] = __digitP[__index-1];
+ __index++;
+ }
+ break;
+ }
+ }
+ }
+ lastDigit = __mkSmallInteger( __resultP[__index-1-1] );
+ ok = true;
}
%}.
ok == true ifFalse:[ "/ cannot happen
- index := 1.
- [borrow ~~ 0] whileTrue:[
- (index <= len) ifTrue:[
- diff := (digitByteArray basicAt:index) - (borrow bitAnd:16rFF).
- borrow := borrow bitShift:-8.
- diff < 0 ifTrue:[
- diff := diff + 256.
- borrow := borrow + 1.
- ]
- ] ifFalse:[
- diff := borrow bitAnd:255.
- borrow := borrow bitShift:-8.
- ].
- resultDigitByteArray basicAt:index put:(lastDigit := diff).
- index := index + 1
- ].
- [index <= len] whileTrue:[
- resultDigitByteArray basicAt:index put:(lastDigit := digitByteArray basicAt:index).
- index := index + 1
- ].
- (index <= rsltLen) ifTrue:[
- lastDigit := 0.
- ]
+ index := 1.
+ [borrow ~~ 0] whileTrue:[
+ (index <= len) ifTrue:[
+ diff := (digitByteArray basicAt:index) - (borrow bitAnd:16rFF).
+ borrow := borrow bitShift:-8.
+ diff < 0 ifTrue:[
+ diff := diff + 256.
+ borrow := borrow + 1.
+ ]
+ ] ifFalse:[
+ diff := borrow bitAnd:255.
+ borrow := borrow bitShift:-8.
+ ].
+ resultDigitByteArray basicAt:index put:(lastDigit := diff).
+ index := index + 1
+ ].
+ [index <= len] whileTrue:[
+ resultDigitByteArray basicAt:index put:(lastDigit := digitByteArray basicAt:index).
+ index := index + 1
+ ].
+ (index <= rsltLen) ifTrue:[
+ lastDigit := 0.
+ ]
].
(lastDigit == 0 or:[rsltLen <= SmallInteger maxBytes]) ifTrue:[
- ^ result compressed.
+ ^ result compressed.
].
^ result
@@ -3489,7 +3502,7 @@
((aSmallInteger < (SmallInteger minVal + 255))
or:[aSmallInteger > (SmallInteger maxVal - 255)]) ifTrue:[
- ^ self absPlus:(self class value:aSmallInteger) sign:newSign.
+ ^ self absPlus:(self class value:aSmallInteger) sign:newSign.
].
len := rsltLen := digitByteArray size.
@@ -3498,18 +3511,18 @@
"/ if it is 255 (since the other number is definitely smaller)
"/
(digitByteArray at:len) == 16rFF ifTrue:[
- rsltLen := len + 1.
+ rsltLen := len + 1.
] ifFalse:[
- "/ or the argument has something in the high byte ..
+ "/ or the argument has something in the high byte ..
%{
#if __POINTER_SIZE__ == 8
- if (__intVal(aSmallInteger) & 0xFF00000000000000L) {
- rsltLen = __mkSmallInteger(__intVal(len) + 1);
- }
+ if (__intVal(aSmallInteger) & 0xFF00000000000000L) {
+ rsltLen = __mkSmallInteger(__intVal(len) + 1);
+ }
#else
- if (__intVal(aSmallInteger) & 0xFF000000) {
- rsltLen = __mkSmallInteger(__intVal(len) + 1);
- }
+ if (__intVal(aSmallInteger) & 0xFF000000) {
+ rsltLen = __mkSmallInteger(__intVal(len) + 1);
+ }
#endif
%}
].
@@ -3521,307 +3534,309 @@
if (__isByteArray(__INST(digitByteArray))
&& __isByteArray(resultDigitByteArray)
&& __isSmallInteger(aSmallInteger)) {
- /* carry is NOT unsigned (see negation below) */
- INT __carry = __intVal(aSmallInteger);
- int __index = 1;
- int __len = __intVal(len);
- unsigned char *__src = (unsigned char *)(__ByteArrayInstPtr(__INST(digitByteArray))->ba_element);
- unsigned char *__dst = (unsigned char *)(__ByteArrayInstPtr(resultDigitByteArray)->ba_element);
- INT __ptrDelta = __dst - __src;
- unsigned char *__srcLast = __src + __len - 1;
- int __rsltLen = __intVal(rsltLen);
-
- if (__carry < 0) {
- __carry = -__carry;
- }
+ /* carry is NOT unsigned (see negation below) */
+ INT __carry = __intVal(aSmallInteger);
+ int __index = 1;
+ int __len = __intVal(len);
+ unsigned char *__src = (unsigned char *)(__ByteArrayInstPtr(__INST(digitByteArray))->ba_element);
+ unsigned char *__dst = (unsigned char *)(__ByteArrayInstPtr(resultDigitByteArray)->ba_element);
+ INT __ptrDelta = __dst - __src;
+ unsigned char *__srcLast = __src + __len - 1;
+ int __rsltLen = __intVal(rsltLen);
+
+ if (__carry < 0) {
+ __carry = -__carry;
+ }
#if defined(__LSBFIRST__)
# if defined(__i386__) && defined(__GNUC__) && (__POINTER_SIZE__ == 4)
# if 0 /* NOTICE - the code below is 20% slower ... - why */
- /*
- * add long-wise
- */
- asm(" jecxz nothingToDo \n\
- movl %%eax, %%esi /* __src input */ \n\
- movl %%ebx, %%edi /* __dst input */ \n\
- \n\
- /* the first 4-byte int */ \n\
- lodsl /* fetch */ \n\
- addl %%edx, %%eax /* add */ \n\
- stosl /* store */ \n\
- leal -1(%%ecx),%%ecx /* do not clobber carry */ \n\
- jecxz doneLoop /* any more ? */ \n\
- /* remaining 4-byte ints */ \n\
- jmp addLoop \n\
- \n\
- .align 8 \n\
- addLoop: \n\
- movl 0(%%esi), %%ebx /* fetch */ \n\
- jnc copyLoop2 \n\
- movl $0, %%eax \n\
- leal 4(%%esi), %%esi \n\
- adcl %%ebx, %%eax /* & add carry from prev int */\n\
- leal 8(%%edi), %%edi \n\
- movl %%eax, -8(%%edi) /* store */ \n\
- leal -1(%%ecx),%%ecx /* do not clobber carry */ \n\
- jecxz doneLoop /* any more ? */ \n\
- \n\
- movl 0(%%esi), %%ebx /* fetch */ \n\
- movl $0, %%eax \n\
- leal 4(%%esi), %%esi \
- adcl %%ebx, %%eax /* & add carry from prev int */\n\
- movl %%eax, -4(%%edi) /* store */ \n\
- \n\
- loop addLoop \n\
- jmp doneLoop \n\
- \n\
- .align 8 \n\
- copyLoop: \n\
- movl 0(%%esi), %%ebx \n\
- copyLoop2: \n\
- add $4, %%esi \n\
- add $4, %%edi \n\
- movl %%ebx, -4(%%edi) \n\
- loop copyLoop \n\
- \n\
- doneLoop: \n\
- movl $0, %%edx /* do not clobber carry (xorl clears it) */ \n\
- adcl $0, %%edx \n\
- movl %%esi, %%eax /* __src output */ \n\
- nothingToDo: \n\
- " : "=d" ((unsigned long)(__carry)),
- "=a" (__src)
- : "1" (__src),
- "b" (__dst),
- "c" (__len / 4),
- "0" (__carry)
- : "esi", "edi");
+ /*
+ * add long-wise
+ */
+ asm(" jecxz nothingToDo \n\
+ movl %%eax, %%esi /* __src input */ \n\
+ movl %%ebx, %%edi /* __dst input */ \n\
+ \n\
+ /* the first 4-byte int */ \n\
+ lodsl /* fetch */ \n\
+ addl %%edx, %%eax /* add */ \n\
+ stosl /* store */ \n\
+ leal -1(%%ecx),%%ecx /* do not clobber carry */ \n\
+ jecxz doneLoop /* any more ? */ \n\
+ /* remaining 4-byte ints */ \n\
+ jmp addLoop \n\
+ \n\
+ .align 8 \n\
+ addLoop: \n\
+ movl 0(%%esi), %%ebx /* fetch */ \n\
+ jnc copyLoop2 \n\
+ movl $0, %%eax \n\
+ leal 4(%%esi), %%esi \n\
+ adcl %%ebx, %%eax /* & add carry from prev int */\n\
+ leal 8(%%edi), %%edi \n\
+ movl %%eax, -8(%%edi) /* store */ \n\
+ leal -1(%%ecx),%%ecx /* do not clobber carry */ \n\
+ jecxz doneLoop /* any more ? */ \n\
+ \n\
+ movl 0(%%esi), %%ebx /* fetch */ \n\
+ movl $0, %%eax \n\
+ leal 4(%%esi), %%esi \
+ adcl %%ebx, %%eax /* & add carry from prev int */\n\
+ movl %%eax, -4(%%edi) /* store */ \n\
+ \n\
+ loop addLoop \n\
+ jmp doneLoop \n\
+ \n\
+ .align 8 \n\
+ copyLoop: \n\
+ movl 0(%%esi), %%ebx \n\
+ copyLoop2: \n\
+ add $4, %%esi \n\
+ add $4, %%edi \n\
+ movl %%ebx, -4(%%edi) \n\
+ loop copyLoop \n\
+ \n\
+ doneLoop: \n\
+ movl $0, %%edx /* do not clobber carry (xorl clears it) */ \n\
+ adcl $0, %%edx \n\
+ movl %%esi, %%eax /* __src output */ \n\
+ nothingToDo: \n\
+ " : "=d" ((unsigned long)(__carry)),
+ "=a" (__src)
+ : "1" (__src),
+ "b" (__dst),
+ "c" (__len / 4),
+ "0" (__carry)
+ : "esi", "edi");
# else
- {
- unsigned char *__srcLastX;
-
- __srcLastX = __srcLast - 3 - 4;
- while (__src <= __srcLastX) {
- unsigned int __sum, __sum2;
- unsigned __digit1, __digit2;
-
- __digit1 = ((unsigned *)__src)[0];
- __digit2 = ((unsigned *)__src)[1];
- asm ("addl %%edx,%%ecx \n\
- adcl $0, %%eax \n\
- movl $0, %%edx \n\
- adcl $0, %%edx"
- : "=d" ((unsigned long)(__carry)),
- "=c" ((unsigned long)(__sum)),
- "=a" ((unsigned long)(__sum2))
- : "0" ((unsigned long)(__carry)),
- "1" (__digit1),
- "2" (__digit2));
-
- ((unsigned int *)(__src + __ptrDelta))[0] = __sum;
- ((unsigned int *)(__src + __ptrDelta))[1] = __sum2;
-
- __src += 8;
-
- if (__carry == 0) {
- while (__src <= __srcLastX) {
- /* copy over words */
- ((unsigned int *)(__src + __ptrDelta))[0] = ((unsigned int *)__src)[0];
- ((unsigned int *)(__src + __ptrDelta))[1] = ((unsigned int *)__src)[1];
- __src += 8;
- }
- while (__src <= __srcLast) {
- /* copy over bytes */
- __src[__ptrDelta] = __src[0];
- __src ++;
- }
- goto doneSource;
- }
- }
-
- __srcLastX = __srcLastX + 4;
- if (__src <= __srcLastX) {
- unsigned int __sum, __digit;
-
- __digit = ((unsigned *)__src)[0];
-
- asm ("addl %%eax,%%edx \n\
- movl $0,%%eax \n\
- adcl $0,%%eax"
- : "=a" ((unsigned long)(__carry)),
- "=d" ((unsigned long)(__sum))
- : "0" ((unsigned long)(__carry)),
- "1" (__digit) );
-
- ((unsigned int *)(__src + __ptrDelta))[0] = __sum;
- __src += 4;
-
- if (__carry == 0) {
- while (__src <= __srcLast) {
- /* copy over bytes */
- __src[__ptrDelta] = __src[0];
- __src ++;
- }
- goto doneSource;
- }
- }
- }
+ {
+ unsigned char *__srcLastX;
+
+ __srcLastX = __srcLast - 3 - 4;
+ while (__src <= __srcLastX) {
+ unsigned int __sum, __sum2;
+ unsigned __digit1, __digit2;
+
+ __digit1 = ((unsigned *)__src)[0];
+ __digit2 = ((unsigned *)__src)[1];
+ asm ("addl %%edx,%%ecx \n\
+ adcl $0, %%eax \n\
+ movl $0, %%edx \n\
+ adcl $0, %%edx"
+ : "=d" ((unsigned long)(__carry)),
+ "=c" ((unsigned long)(__sum)),
+ "=a" ((unsigned long)(__sum2))
+ : "0" ((unsigned long)(__carry)),
+ "1" (__digit1),
+ "2" (__digit2));
+
+ ((unsigned int *)(__src + __ptrDelta))[0] = __sum;
+ ((unsigned int *)(__src + __ptrDelta))[1] = __sum2;
+
+ __src += 8;
+
+ if (__carry == 0) {
+ while (__src <= __srcLastX) {
+ /* copy over words */
+ ((unsigned int *)(__src + __ptrDelta))[0] = ((unsigned int *)__src)[0];
+ ((unsigned int *)(__src + __ptrDelta))[1] = ((unsigned int *)__src)[1];
+ __src += 8;
+ }
+ while (__src <= __srcLast) {
+ /* copy over bytes */
+ __src[__ptrDelta] = __src[0];
+ __src ++;
+ }
+ goto doneSource;
+ }
+ }
+
+ __srcLastX = __srcLastX + 4;
+ if (__src <= __srcLastX) {
+ unsigned int __sum, __digit;
+
+ __digit = ((unsigned *)__src)[0];
+
+ asm ("addl %%eax,%%edx \n\
+ movl $0,%%eax \n\
+ adcl $0,%%eax"
+ : "=a" ((unsigned long)(__carry)),
+ "=d" ((unsigned long)(__sum))
+ : "0" ((unsigned long)(__carry)),
+ "1" (__digit) );
+
+ ((unsigned int *)(__src + __ptrDelta))[0] = __sum;
+ __src += 4;
+
+ if (__carry == 0) {
+ while (__src <= __srcLast) {
+ /* copy over bytes */
+ __src[__ptrDelta] = __src[0];
+ __src ++;
+ }
+ goto doneSource;
+ }
+ }
+ }
# endif
# else /* not i386-GNUC */
# if defined(WIN32) && defined(__BORLANDC__) && defined(__i386__) && (__POINTER_SIZE__ == 4)
- {
- unsigned char *__srcLast4;
-
- /*
- * add long-wise
- */
- __srcLast4 = __srcLast - 3;
- while (__src <= __srcLast4) {
- unsigned int __sum;
-
- __sum = ((unsigned int *)__src)[0];
- asm {
- mov eax, __sum
- add eax, __carry
- mov edx, 0
- adc edx, 0
- mov __sum, eax
- mov __carry, edx
- }
-
- ((unsigned int *)(__src + __ptrDelta))[0] = __sum;
- __src += 4;
- if (__carry == 0) {
- while (__src <= __srcLast4) {
- /* copy over words */
- ((unsigned int *)(__src + __ptrDelta))[0] = ((unsigned int *)__src)[0];
- __src += 4;
- }
- while (__src <= __srcLast) {
- /* copy over bytes */
- __src[__ptrDelta] = __src[0];
- __src ++;
- }
- goto doneSource;
- }
- }
- }
+ {
+ unsigned char *__srcLast4;
+
+ /*
+ * add long-wise
+ */
+ __srcLast4 = __srcLast - 3;
+ while (__src <= __srcLast4) {
+ unsigned int __sum;
+
+ __sum = ((unsigned int *)__src)[0];
+ asm {
+ mov eax, __sum
+ add eax, __carry
+ mov edx, 0
+ adc edx, 0
+ mov __sum, eax
+ mov __carry, edx
+ }
+
+ ((unsigned int *)(__src + __ptrDelta))[0] = __sum;
+ __src += 4;
+ if (__carry == 0) {
+ while (__src <= __srcLast4) {
+ /* copy over words */
+ ((unsigned int *)(__src + __ptrDelta))[0] = ((unsigned int *)__src)[0];
+ __src += 4;
+ }
+ while (__src <= __srcLast) {
+ /* copy over bytes */
+ __src[__ptrDelta] = __src[0];
+ __src ++;
+ }
+ goto doneSource;
+ }
+ }
+ }
# else /* not i386-WIN32 */
# if defined(__LSBFIRST__) && (__POINTER_SIZE__ == 8)
- {
- unsigned char *__srcLast4;
-
- /*
- * add long-wise
- */
- __srcLast4 = __srcLast - 3;
- while (__src <= __srcLast4) {
- unsigned INT __sum;
-
- __sum = ((unsigned int *)__src)[0] + __carry;
- ((unsigned int *)(__src + __ptrDelta))[0] = __sum /* & 0xFFFF */;
- __src += 4;
- __carry = __sum >> 32;
- if (__carry == 0) {
- while (__src <= __srcLast4) {
- /* copy over words */
- ((unsigned int *)(__src + __ptrDelta))[0] = ((unsigned int *)__src)[0];
- __src += 4;
- }
- while (__src <= __srcLast) {
- /* copy over bytes */
- __src[__ptrDelta] = __src[0];
- __src ++;
- }
- goto doneSource;
- }
- }
- }
+ {
+ unsigned char *__srcLast4;
+
+ /*
+ * add long-wise
+ */
+ __srcLast4 = __srcLast - 3;
+ while (__src <= __srcLast4) {
+ unsigned INT __sum;
+
+ __sum = (INT)(((unsigned int *)__src)[0]);
+ __sum += __carry;
+ ((unsigned int *)(__src + __ptrDelta))[0] = __sum /* & 0xFFFF */;
+ __src += 4;
+ __carry = __sum >> 32;
+ if (__carry == 0) {
+ while (__src <= __srcLast4) {
+ /* copy over words */
+ ((unsigned int *)(__src + __ptrDelta))[0] = ((unsigned int *)__src)[0];
+ __src += 4;
+ }
+ while (__src <= __srcLast) {
+ /* copy over bytes */
+ __src[__ptrDelta] = __src[0];
+ __src ++;
+ }
+ goto doneSource;
+ }
+ }
+ }
# endif /* LSB+64bit */
# endif /* __i386__ & WIN32 */
# endif /* __i386__ & GNUC */
- /*
- * add short-wise
- */
- while (__src < __srcLast) {
- __carry += ((unsigned short *)__src)[0];
- ((unsigned short *)(__src + __ptrDelta))[0] = __carry /* & 0xFFFF */;
- __carry >>= 16;
- __src += 2;
- }
- /*
- * last (odd) byte
- */
- if (__src <= __srcLast) {
- __carry += __src[0];
- __src[__ptrDelta] = __carry /* & 0xFF */;
- __carry >>= 8;
- __src++;
- }
+ /*
+ * add short-wise
+ */
+ while (__src < __srcLast) {
+ __carry += ((unsigned short *)__src)[0];
+ ((unsigned short *)(__src + __ptrDelta))[0] = __carry /* & 0xFFFF */;
+ __carry >>= 16;
+ __src += 2;
+ }
+ /*
+ * last (odd) byte
+ */
+ if (__src <= __srcLast) {
+ __carry += __src[0];
+ __src[__ptrDelta] = __carry /* & 0xFF */;
+ __carry >>= 8;
+ __src++;
+ }
#else /* not __LSBFIRST__ */
- /*
- * add byte-wise
- */
- while (__src <= __srcLast) {
- __carry += __src[0];
- __src[__ptrDelta] = __carry /* & 0xFF */;
- __src++;
- __carry >>= 8;
-
- if (__carry == 0) {
- while (__src <= __srcLast) {
- /* copy over rest */
- __src[__ptrDelta] = __src[0];
- __src++;
- }
- goto doneSource;
- }
- }
+ /*
+ * add byte-wise
+ */
+ while (__src <= __srcLast) {
+ __carry += __src[0];
+ __src[__ptrDelta] = __carry /* & 0xFF */;
+ __src++;
+ __carry >>= 8;
+
+ if (__carry == 0) {
+ while (__src <= __srcLast) {
+ /* copy over rest */
+ __src[__ptrDelta] = __src[0];
+ __src++;
+ }
+ goto doneSource;
+ }
+ }
#endif /* __LSBFIRST__ */
doneSource: ;
- /*
- * now, at most one other byte is to be stored ...
- */
- if (__len < __rsltLen) {
- __src[__ptrDelta] = __carry /* & 0xFF */;
- __src++;
- }
-
- if (__src[__ptrDelta-1]) { /* lastDigit */
- RETURN (result);
- }
- ok = true;
+ /*
+ * now, at most one other byte is to be stored ...
+ */
+ if (__len < __rsltLen) {
+ __src[__ptrDelta] = __carry /* & 0xFF */;
+ __src++;
+ }
+
+ if (__src[__ptrDelta-1] != 0) { /* lastDigit */
+ RETURN (result);
+ }
+ // must compress
+ ok = true;
}
%}.
ok ~~ true ifTrue:[
- index := 1.
- carry := aSmallInteger abs.
-
- [carry ~~ 0] whileTrue:[
- (index <= len) ifTrue:[
- carry := (digitByteArray basicAt:index) + carry.
- ].
- resultDigitByteArray basicAt:index put:(lastDigit := carry bitAnd:16rFF).
- carry := carry bitShift:-8.
- index := index + 1
- ].
-
- (index <= rsltLen) ifTrue:[
- [index <= len] whileTrue:[
- resultDigitByteArray basicAt:index put:(digitByteArray basicAt:index).
- index := index + 1
- ].
- lastDigit := 0.
- ].
-
- (lastDigit ~~ 0 and:[rsltLen > SmallInteger maxBytes]) ifTrue:[
- ^ result
- ].
+ index := 1.
+ carry := aSmallInteger abs.
+
+ [carry ~~ 0] whileTrue:[
+ (index <= len) ifTrue:[
+ carry := (digitByteArray basicAt:index) + carry.
+ ].
+ resultDigitByteArray basicAt:index put:(lastDigit := carry bitAnd:16rFF).
+ carry := carry bitShift:-8.
+ index := index + 1
+ ].
+
+ (index <= rsltLen) ifTrue:[
+ [index <= len] whileTrue:[
+ resultDigitByteArray basicAt:index put:(digitByteArray basicAt:index).
+ index := index + 1
+ ].
+ lastDigit := 0.
+ ].
+
+ (lastDigit ~~ 0 and:[rsltLen > SmallInteger maxBytes]) ifTrue:[
+ ^ result
+ ].
].
^ result compressed
@@ -5499,23 +5514,29 @@
!
numberOfDigits:nDigits
-"/ digitByteArray := ByteArray uninitializedNew:nDigits.
+ "allocate space for nDigits bytes of magnitude"
+
digitByteArray := ByteArray new:nDigits.
sign := 1.
!
numberOfDigits:nDigits sign:newSign
-"/ digitByteArray := ByteArray uninitializedNew:nDigits.
+ "allocate space for nDigits bytes of magnitude"
+
digitByteArray := ByteArray new:nDigits.
sign := newSign.
!
setDigits:digits
+ "set the digits from the lsb-ordered digit-bytes"
+
digitByteArray := digits.
sign := 1.
!
setDigits:digits sign:newSign
+ "set the digits from the lsb-ordered digit-bytes"
+
digitByteArray := digits.
sign := newSign.
!
--- a/Win32OperatingSystem.st Tue Apr 26 21:57:25 2016 +0100
+++ b/Win32OperatingSystem.st Wed Apr 27 07:53:49 2016 +0100
@@ -675,15 +675,46 @@
return __get_functionAddress(&libHandle, "ole32.DLL", functionName);
}
+#if 0
+// original: biased for 1.1.1601
+// obsolete...
OBJ
FileTimeToOsTime(LPFILETIME pft)
{
LONGLONG lTime = ((LONGLONG)pft->dwHighDateTime << 32) + pft->dwLowDateTime;
lTime = (lTime / 10000); // convert multiple of 100ns to milliseconds
-
+#if __POINTER_SIZE__ == 8
+ return(__MKUINT(lTime));
+#else
return(__MKLARGEINT64(1, (unsigned INT)(lTime & 0xFFFFFFFF), (unsigned INT)(lTime >> 32)));
+#endif
}
-
+#endif
+
+// biased for 1.1.1970
+// (renamed to catch references from other classes)
+OBJ
+FileTimeToOsTime1970(LPFILETIME pft)
+{
+ LONGLONG lTime = ((LONGLONG)pft->dwHighDateTime << 32) + pft->dwLowDateTime;
+ lTime = (lTime / 10000); // convert multiple of 100ns to milliseconds
+
+#if __POINTER_SIZE__ == 8
+ lTime -= 11644473600000LL; // the number of millis from 1.1.1601 to 1.1.1970
+ return(__MKINT(lTime));
+#else
+ if (lTime >= 11644473600000LL) {
+ lTime -= 11644473600000LL; // the number of millis from 1.1.1601 to 1.1.1970
+ return(__MKLARGEINT64(1, (unsigned INT)(lTime & 0xFFFFFFFF), (unsigned INT)(lTime >> 32)));
+ } else {
+ lTime = 11644473600000LL - lTime;
+ return(__MKLARGEINT64(-1, (unsigned INT)(lTime & 0xFFFFFFFF), (unsigned INT)(lTime >> 32)));
+ }
+#endif
+}
+
+#if 0
+// obsolete; biased for 1.1.1601
int
OsTimeToFileTime(OBJ tLow, OBJ tHigh, LPFILETIME pft) {
LONGLONG lTime;
@@ -700,6 +731,27 @@
pft->dwLowDateTime = (UINT)(lTime & 0xFFFFFFFF);
return(1);
}
+#endif
+
+// biased for 1.1.1970
+// renamed to catch any references from other classes.
+int
+OsTime1970ToFileTime(OBJ tLow, OBJ tHigh, LPFILETIME pft) {
+ LONGLONG lTime;
+ UINT low = __unsignedLongIntVal(tLow);
+ UINT hi = __unsignedLongIntVal(tHigh);
+
+ if (hi == 0 && !__isSmallInteger(tHigh))
+ return(0); // conversion error
+
+ lTime = ((LONGLONG)hi << 32) + (LONGLONG)low;
+ lTime += 11644473600000LL; // rebias to 1.1.1601
+ lTime = lTime * 10000; // convert to multiple of 100ns
+
+ pft->dwHighDateTime = (UINT)(lTime >> 32);
+ pft->dwLowDateTime = (UINT)(lTime & 0xFFFFFFFF);
+ return(1);
+}
%}
! !
@@ -1665,15 +1717,15 @@
%}.
osCrtTime isNil
ifTrue: [crtTime := Timestamp now]
- ifFalse:[crtTime := Timestamp new fromOSTime:(osCrtTime - OperatingSystem osTimeOf19700101)].
+ ifFalse:[crtTime := Timestamp new fromOSTime:(osCrtTime "- OperatingSystem osTimeOf19700101 -- already done")].
osAccTime isNil
ifTrue: [accTime := Timestamp now]
- ifFalse:[accTime := Timestamp new fromOSTime:(osAccTime - OperatingSystem osTimeOf19700101)].
+ ifFalse:[accTime := Timestamp new fromOSTime:(osAccTime "- OperatingSystem osTimeOf19700101 -- already done")].
osModTime isNil
ifTrue: [modTime := accTime]
- ifFalse:[modTime := Timestamp new fromOSTime:(osModTime - OperatingSystem osTimeOf19700101)].
+ ifFalse:[modTime := Timestamp new fromOSTime:(osModTime "- OperatingSystem osTimeOf19700101 -- already done")].
^ FileStatusInfo
type:type
@@ -1715,9 +1767,9 @@
osPathname = __mkStringOrU16String_maxlen( data.cFileName, MAXPATHLEN );
osFileAttributes = __mkSmallInteger( data.dwFileAttributes );
- osCrtTime = FileTimeToOsTime(&data.ftCreationTime);
- osAccTime = FileTimeToOsTime(&data.ftLastAccessTime);
- osModTime = FileTimeToOsTime(&data.ftLastWriteTime);
+ osCrtTime = FileTimeToOsTime1970(&data.ftCreationTime);
+ osAccTime = FileTimeToOsTime1970(&data.ftLastAccessTime);
+ osModTime = FileTimeToOsTime1970(&data.ftLastWriteTime);
} else {
error = __mkSmallInteger( __threadErrno );
@@ -3764,26 +3816,26 @@
primExec:commandPath commandLine:commandLine fileDescriptors:fdArray fork:doFork newPgrp:newPgrp inPath:dirName createFlags:flagsOrNil inheritHandles:inheritHandles
"Internal lowLevel entry for combined fork & exec for WIN32"
- |handle
+ |handle
commandPathUni16 commandLineUni16 dirNameUni16|
handle := Win32ProcessHandle new.
-
+
commandPathUni16 := commandPath.
commandLineUni16 := commandLine.
dirNameUni16 := dirName.
commandPathUni16 notNil ifTrue:[
- commandPathUni16 := commandPathUni16 asUnicode16String.
+ commandPathUni16 := commandPathUni16 asUnicode16String.
].
commandLineUni16 notNil ifTrue:[
- commandLineUni16 := commandLineUni16 asUnicode16String.
+ commandLineUni16 := commandLineUni16 asUnicode16String.
].
dirNameUni16 notNil ifTrue:[
- dirNameUni16 := dirNameUni16 asUnicode16String.
- ].
-
-
+ dirNameUni16 := dirNameUni16 asUnicode16String.
+ ].
+
+
%{
/*
@@ -3793,23 +3845,23 @@
*/
int i, l; // i -> for iteration, l -> for length
- /*
- * CreateProcess supports 32767 characters/bytes including all variables and values
+ /*
+ * CreateProcess supports 32767 characters/bytes including all variables and values
* so take a good average for its arguments 4096
* ATTENTION this value is also used hardcoded in the following code to check the length
*/
wchar_t cmdPathW[4096];
wchar_t cmdLineW[4096];
- wchar_t dirNameW[4096];
-
- /*
- * pass pointers to CreateProcess
+ wchar_t dirNameW[4096];
+
+ /*
+ * pass pointers to CreateProcess
* NULL pointers used to indicate no value
* so only set the pointer if the value is valid
- */
- wchar_t *cmdPathWP = NULL;
- wchar_t *cmdLineWP = NULL;
- wchar_t *dirNameWP = NULL;
+ */
+ wchar_t *cmdPathWP = NULL;
+ wchar_t *cmdLineWP = NULL;
+ wchar_t *dirNameWP = NULL;
DWORD fdwCreate = 0;
STARTUPINFOW lpsiStartInfo;
@@ -3818,277 +3870,277 @@
SECURITY_DESCRIPTOR securityDescriptor;
if ((__isUnicode16String(commandPathUni16) || (commandPathUni16 == nil)) && __isUnicode16String(commandLineUni16)) {
- HANDLE stdinHandle = NULL;
- HANDLE stdoutHandle = NULL;
- HANDLE stderrHandle = NULL;
- int mustClose_stdinHandle = 0;
- int mustClose_stdoutHandle = 0;
- int mustClose_stderrHandle = 0;
-
- /*
- * terminate the multi byte strings
- */
- // #commandPathUni16
- if (commandPathUni16 != nil) {
- l = __unicode16StringSize(commandPathUni16);
- if (l >= 4096) { // >= need 1 space for terminator
- #ifdef PROCESSDEBUGWIN32
- console_fprintf(stderr, "argument #commandPathUni16 is to long\n");
- #endif
- RETURN(nil);
- }
- for (i = 0; i < l; i++) {
- cmdPathW[i] = __unicode16StringVal(commandPathUni16)[i];
- }
- cmdPathW[i] = 0; // set terminator
- cmdPathWP = &cmdPathW[0];
- }
-
- // commandLineUni16
- l = __unicode16StringSize(commandLineUni16);
- if (l >= 4096) { // >= need 1 space for terminator
- #ifdef PROCESSDEBUGWIN32
- console_fprintf(stderr, "argument #commandLineUni16 is to long\n");
- #endif
- RETURN(nil);
- }
- for (i = 0; i < l; i++) {
- cmdLineW[i] = __unicode16StringVal(commandLineUni16)[i];
- }
- cmdLineW[i] = 0; // set terminator
- cmdLineWP = &cmdLineW[0];
-
- // #dirNameUni16
- if (__isUnicode16String(dirNameUni16)) {
- l = __unicode16StringSize(dirNameUni16);
- if (l >= 4096) { // >= need 1 space for terminator
- #ifdef PROCESSDEBUGWIN32
- console_fprintf(stderr, "argument #dirNameUni16 is to long\n");
- #endif
- RETURN(nil);
- }
- for (i = 0; i < l; i++) {
- dirNameW[i] = __unicode16StringVal(dirNameUni16)[i];
- }
- dirNameW[i] = 0; // set terminator
- dirNameWP = &dirNameW[0];
- }
-
- /*
- * create descriptors as req'd
- */
- memset(&securityAttributes, 0, sizeof(securityAttributes));
- securityAttributes.nLength = sizeof(securityAttributes);
- securityAttributes.bInheritHandle = (inheritHandles == true) ? TRUE : FALSE;
-
- InitializeSecurityDescriptor(&securityDescriptor, SECURITY_DESCRIPTOR_REVISION);
- SetSecurityDescriptorDacl(&securityDescriptor, -1, 0, 0);
-
- securityAttributes.lpSecurityDescriptor = &securityDescriptor;
- memset(&lppiProcInfo, 0, sizeof (lppiProcInfo));
-
- memset(&lpsiStartInfo, 0, sizeof(lpsiStartInfo));
- lpsiStartInfo.cb = sizeof(lpsiStartInfo);
- lpsiStartInfo.lpReserved = NULL;
- lpsiStartInfo.lpDesktop = NULL;
- lpsiStartInfo.lpTitle = NULL;
- lpsiStartInfo.dwX = 0;
- lpsiStartInfo.dwY = 0;
- lpsiStartInfo.dwXSize = 100;
- lpsiStartInfo.dwYSize = 100;
- lpsiStartInfo.dwXCountChars = 0;
- lpsiStartInfo.dwYCountChars = 0;
- lpsiStartInfo.dwFillAttribute = 0;
- lpsiStartInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES /*| STARTF_USEPOSITION*/;
- lpsiStartInfo.wShowWindow = SW_HIDE /*SW_SHOWDEFAULT*/;
- lpsiStartInfo.cbReserved2 = 0;
- lpsiStartInfo.lpReserved2 = NULL;
- lpsiStartInfo.hStdInput = NULL;
- lpsiStartInfo.hStdOutput = NULL;
- lpsiStartInfo.hStdError = NULL;
-
- /*
- * set create process flags
- * if the flags arg is nil, use common defaults;
- * if non-nil, it must be a positive integer containing the fdwCreate bits.
- */
- if (flagsOrNil != nil) {
- fdwCreate = __longIntVal(flagsOrNil);
- } else {
- fdwCreate = CREATE_NEW_CONSOLE; //|IDLE_PRIORITY_CLASS; // DETACHED_PROCESS; // NORMAL_PRIORITY_CLASS ;
- if (newPgrp == true) {
- fdwCreate |= CREATE_NEW_PROCESS_GROUP;
- }
- fdwCreate |= CREATE_DEFAULT_ERROR_MODE;
- }
-
- if (fdArray == nil) {
- stdinHandle = (HANDLE) _get_osfhandle (0);
- stdoutHandle = (HANDLE) _get_osfhandle (1);
- stderrHandle = (HANDLE) _get_osfhandle (2);
- } else if (__isArrayLike(fdArray) && (__arraySize(fdArray) >= 3)) {
- if (__ArrayInstPtr(fdArray)->a_element[0] != nil) {
- if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[0])) {
- stdinHandle = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[0]);
- } else {
- stdinHandle = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[0]));
- }
- }
- if (__ArrayInstPtr(fdArray)->a_element[1] != nil) {
- if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[1])) {
- stdoutHandle = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[1]);
- } else {
- stdoutHandle = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[1]));
- }
- }
- if (__ArrayInstPtr(fdArray)->a_element[2] != nil) {
- if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[2])) {
- stderrHandle = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[2]);
- } else {
- stderrHandle = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[2]));
- }
- }
- } else {
- console_fprintf(stderr, "Win32OS [warning]: bad fd arg in createProcess\n");
- }
+ HANDLE stdinHandle = NULL;
+ HANDLE stdoutHandle = NULL;
+ HANDLE stderrHandle = NULL;
+ int mustClose_stdinHandle = 0;
+ int mustClose_stdoutHandle = 0;
+ int mustClose_stderrHandle = 0;
+
+ /*
+ * terminate the multi byte strings
+ */
+ // #commandPathUni16
+ if (commandPathUni16 != nil) {
+ l = __unicode16StringSize(commandPathUni16);
+ if (l >= 4096) { // >= need 1 space for terminator
+ #ifdef PROCESSDEBUGWIN32
+ console_fprintf(stderr, "argument #commandPathUni16 is to long\n");
+ #endif
+ RETURN(nil);
+ }
+ for (i = 0; i < l; i++) {
+ cmdPathW[i] = __unicode16StringVal(commandPathUni16)[i];
+ }
+ cmdPathW[i] = 0; // set terminator
+ cmdPathWP = &cmdPathW[0];
+ }
+
+ // commandLineUni16
+ l = __unicode16StringSize(commandLineUni16);
+ if (l >= 4096) { // >= need 1 space for terminator
+ #ifdef PROCESSDEBUGWIN32
+ console_fprintf(stderr, "argument #commandLineUni16 is to long\n");
+ #endif
+ RETURN(nil);
+ }
+ for (i = 0; i < l; i++) {
+ cmdLineW[i] = __unicode16StringVal(commandLineUni16)[i];
+ }
+ cmdLineW[i] = 0; // set terminator
+ cmdLineWP = &cmdLineW[0];
+
+ // #dirNameUni16
+ if (__isUnicode16String(dirNameUni16)) {
+ l = __unicode16StringSize(dirNameUni16);
+ if (l >= 4096) { // >= need 1 space for terminator
+ #ifdef PROCESSDEBUGWIN32
+ console_fprintf(stderr, "argument #dirNameUni16 is to long\n");
+ #endif
+ RETURN(nil);
+ }
+ for (i = 0; i < l; i++) {
+ dirNameW[i] = __unicode16StringVal(dirNameUni16)[i];
+ }
+ dirNameW[i] = 0; // set terminator
+ dirNameWP = &dirNameW[0];
+ }
+
+ /*
+ * create descriptors as req'd
+ */
+ memset(&securityAttributes, 0, sizeof(securityAttributes));
+ securityAttributes.nLength = sizeof(securityAttributes);
+ securityAttributes.bInheritHandle = (inheritHandles == true) ? TRUE : FALSE;
+
+ InitializeSecurityDescriptor(&securityDescriptor, SECURITY_DESCRIPTOR_REVISION);
+ SetSecurityDescriptorDacl(&securityDescriptor, -1, 0, 0);
+
+ securityAttributes.lpSecurityDescriptor = &securityDescriptor;
+ memset(&lppiProcInfo, 0, sizeof (lppiProcInfo));
+
+ memset(&lpsiStartInfo, 0, sizeof(lpsiStartInfo));
+ lpsiStartInfo.cb = sizeof(lpsiStartInfo);
+ lpsiStartInfo.lpReserved = NULL;
+ lpsiStartInfo.lpDesktop = NULL;
+ lpsiStartInfo.lpTitle = NULL;
+ lpsiStartInfo.dwX = 0;
+ lpsiStartInfo.dwY = 0;
+ lpsiStartInfo.dwXSize = 100;
+ lpsiStartInfo.dwYSize = 100;
+ lpsiStartInfo.dwXCountChars = 0;
+ lpsiStartInfo.dwYCountChars = 0;
+ lpsiStartInfo.dwFillAttribute = 0;
+ lpsiStartInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES /*| STARTF_USEPOSITION*/;
+ lpsiStartInfo.wShowWindow = SW_HIDE /*SW_SHOWDEFAULT*/;
+ lpsiStartInfo.cbReserved2 = 0;
+ lpsiStartInfo.lpReserved2 = NULL;
+ lpsiStartInfo.hStdInput = NULL;
+ lpsiStartInfo.hStdOutput = NULL;
+ lpsiStartInfo.hStdError = NULL;
+
+ /*
+ * set create process flags
+ * if the flags arg is nil, use common defaults;
+ * if non-nil, it must be a positive integer containing the fdwCreate bits.
+ */
+ if (flagsOrNil != nil) {
+ fdwCreate = __longIntVal(flagsOrNil);
+ } else {
+ fdwCreate = CREATE_NEW_CONSOLE; //|IDLE_PRIORITY_CLASS; // DETACHED_PROCESS; // NORMAL_PRIORITY_CLASS ;
+ if (newPgrp == true) {
+ fdwCreate |= CREATE_NEW_PROCESS_GROUP;
+ }
+ fdwCreate |= CREATE_DEFAULT_ERROR_MODE;
+ }
+
+ if (fdArray == nil) {
+ stdinHandle = (HANDLE) _get_osfhandle (0);
+ stdoutHandle = (HANDLE) _get_osfhandle (1);
+ stderrHandle = (HANDLE) _get_osfhandle (2);
+ } else if (__isArrayLike(fdArray) && (__arraySize(fdArray) >= 3)) {
+ if (__ArrayInstPtr(fdArray)->a_element[0] != nil) {
+ if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[0])) {
+ stdinHandle = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[0]);
+ } else {
+ stdinHandle = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[0]));
+ }
+ }
+ if (__ArrayInstPtr(fdArray)->a_element[1] != nil) {
+ if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[1])) {
+ stdoutHandle = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[1]);
+ } else {
+ stdoutHandle = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[1]));
+ }
+ }
+ if (__ArrayInstPtr(fdArray)->a_element[2] != nil) {
+ if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[2])) {
+ stderrHandle = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[2]);
+ } else {
+ stderrHandle = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[2]));
+ }
+ }
+ } else {
+ console_fprintf(stderr, "Win32OS [warning]: bad fd arg in createProcess\n");
+ }
#if defined(PROCESSDEBUGWIN32)
- console_fprintf(stderr, "stdin %x\n", stdinHandle);
- console_fprintf(stderr, "stdout %x\n", stdoutHandle);
- console_fprintf(stderr, "stderr %x\n", stderrHandle);
-#endif
-
- {
- HANDLE childHandle;
- int sameHandle = (stdoutHandle == stderrHandle);
-
- // these MUST be inheritable!
- if (stdinHandle) {
+ console_fprintf(stderr, "stdin %x\n", stdinHandle);
+ console_fprintf(stderr, "stdout %x\n", stdoutHandle);
+ console_fprintf(stderr, "stderr %x\n", stderrHandle);
+#endif
+
+ {
+ HANDLE childHandle;
+ int sameHandle = (stdoutHandle == stderrHandle);
+
+ // these MUST be inheritable!
+ if (stdinHandle) {
#if 0
- if (SetHandleInformation(stdinHandle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) {
- // good
- } else {
- console_fprintf(stderr, "Win32OS [warning]: SetHandleInformation failed in createProcess\n");
- }
-#else
- if (DuplicateHandle(GetCurrentProcess(), stdinHandle, GetCurrentProcess(),
- &childHandle, 0, TRUE, DUPLICATE_SAME_ACCESS)) {
- stdinHandle = childHandle;
- mustClose_stdinHandle = 1;
- } else {
- console_fprintf(stderr, "Win32OS [warning]: duplicateHandle failed in createProcess\n");
- }
-#endif
- }
- if (stdoutHandle) {
+ if (SetHandleInformation(stdinHandle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) {
+ // good
+ } else {
+ console_fprintf(stderr, "Win32OS [warning]: SetHandleInformation failed in createProcess\n");
+ }
+#else
+ if (DuplicateHandle(GetCurrentProcess(), stdinHandle, GetCurrentProcess(),
+ &childHandle, 0, TRUE, DUPLICATE_SAME_ACCESS)) {
+ stdinHandle = childHandle;
+ mustClose_stdinHandle = 1;
+ } else {
+ console_fprintf(stderr, "Win32OS [warning]: duplicateHandle failed in createProcess\n");
+ }
+#endif
+ }
+ if (stdoutHandle) {
#if 0
- if (SetHandleInformation(stdoutHandle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) {
- // good
- } else {
- console_fprintf(stderr, "Win32OS [warning]: SetHandleInformation failed in createProcess\n");
- }
-#else
- if (DuplicateHandle(GetCurrentProcess(), stdoutHandle, GetCurrentProcess(),
- &childHandle, 0, TRUE, DUPLICATE_SAME_ACCESS)) {
- stdoutHandle = childHandle;
- mustClose_stdoutHandle = 1;
- } else {
- console_fprintf(stderr, "Win32OS [warning]: duplicateHandle failed in createProcess\n");
- }
-#endif
- }
- if (stderrHandle) {
- if (sameHandle) {
- stderrHandle = stdoutHandle;
- } else {
+ if (SetHandleInformation(stdoutHandle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) {
+ // good
+ } else {
+ console_fprintf(stderr, "Win32OS [warning]: SetHandleInformation failed in createProcess\n");
+ }
+#else
+ if (DuplicateHandle(GetCurrentProcess(), stdoutHandle, GetCurrentProcess(),
+ &childHandle, 0, TRUE, DUPLICATE_SAME_ACCESS)) {
+ stdoutHandle = childHandle;
+ mustClose_stdoutHandle = 1;
+ } else {
+ console_fprintf(stderr, "Win32OS [warning]: duplicateHandle failed in createProcess\n");
+ }
+#endif
+ }
+ if (stderrHandle) {
+ if (sameHandle) {
+ stderrHandle = stdoutHandle;
+ } else {
#if 0
- if (SetHandleInformation(stderrHandle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) {
- // good
- } else {
- console_fprintf(stderr, "Win32OS [warning]: SetHandleInformation failed in createProcess\n");
- }
-#else
- if (DuplicateHandle(GetCurrentProcess(), stderrHandle, GetCurrentProcess(),
- &childHandle, 0, TRUE, DUPLICATE_SAME_ACCESS)) {
- stderrHandle = childHandle;
- mustClose_stderrHandle = 1;
- } else {
- console_fprintf(stderr, "Win32OS [warning]: duplicateHandle failed in createProcess\n");
- }
-#endif
- }
- }
- }
- lpsiStartInfo.hStdInput = stdinHandle;
- lpsiStartInfo.hStdOutput = stdoutHandle;
- lpsiStartInfo.hStdError = stderrHandle;
-
- if (doFork == true) {
+ if (SetHandleInformation(stderrHandle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) {
+ // good
+ } else {
+ console_fprintf(stderr, "Win32OS [warning]: SetHandleInformation failed in createProcess\n");
+ }
+#else
+ if (DuplicateHandle(GetCurrentProcess(), stderrHandle, GetCurrentProcess(),
+ &childHandle, 0, TRUE, DUPLICATE_SAME_ACCESS)) {
+ stderrHandle = childHandle;
+ mustClose_stderrHandle = 1;
+ } else {
+ console_fprintf(stderr, "Win32OS [warning]: duplicateHandle failed in createProcess\n");
+ }
+#endif
+ }
+ }
+ }
+ lpsiStartInfo.hStdInput = stdinHandle;
+ lpsiStartInfo.hStdOutput = stdoutHandle;
+ lpsiStartInfo.hStdError = stderrHandle;
+
+ if (doFork == true) {
#ifdef PROCESSDEBUGWIN32
- console_fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir);
-#endif
- if (CreateProcessW( cmdPathWP,
- cmdLineWP,
- &securityAttributes, NULL /* &securityAttributes */,
- securityAttributes.bInheritHandle, /* inherit handles */
- fdwCreate | CREATE_SUSPENDED, /* resume after setting affinity */
- NULL, /* env */
- dirNameWP,
- &lpsiStartInfo,
- &lppiProcInfo ))
- {
- DWORD_PTR processAffinityMask, systemAffinityMask;
-
- /*
- * Process was created suspended, now set the affinity mask
- * to any processor, and resume the processes main thread.
- * (librun/process.s limited the affinity to a single processor).
- */
- GetProcessAffinityMask(lppiProcInfo.hProcess, &processAffinityMask, &systemAffinityMask);
- SetProcessAffinityMask(lppiProcInfo.hProcess, systemAffinityMask);
- if ((fdwCreate & CREATE_SUSPENDED) == 0) {
- ResumeThread(lppiProcInfo.hThread);
- }
- CloseHandle(lppiProcInfo.hThread);
+ console_fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir);
+#endif
+ if (CreateProcessW( cmdPathWP,
+ cmdLineWP,
+ &securityAttributes, NULL /* &securityAttributes */,
+ securityAttributes.bInheritHandle, /* inherit handles */
+ fdwCreate | CREATE_SUSPENDED, /* resume after setting affinity */
+ NULL, /* env */
+ dirNameWP,
+ &lpsiStartInfo,
+ &lppiProcInfo ))
+ {
+ DWORD_PTR processAffinityMask, systemAffinityMask;
+
+ /*
+ * Process was created suspended, now set the affinity mask
+ * to any processor, and resume the processes main thread.
+ * (librun/process.s limited the affinity to a single processor).
+ */
+ GetProcessAffinityMask(lppiProcInfo.hProcess, &processAffinityMask, &systemAffinityMask);
+ SetProcessAffinityMask(lppiProcInfo.hProcess, systemAffinityMask);
+ if ((fdwCreate & CREATE_SUSPENDED) == 0) {
+ ResumeThread(lppiProcInfo.hThread);
+ }
+ CloseHandle(lppiProcInfo.hThread);
#if 0
- // only works with real console handles
- {
- // change the child's stdIn (console) mode
- DWORD mode = 0;
-
- if (! GetConsoleMode(stdinHandle, &mode)) {
- console_fprintf(stderr, "Win32OS [warning]: GetConsoleMode failed in createProcess\n");
- }
- if (! SetConsoleMode(stdinHandle, mode & (~ENABLE_ECHO_INPUT))){
- console_fprintf(stderr, "Win32OS [warning]: SetConsoleMode failed in createProcess\n");
- }
- }
-#endif
- if (mustClose_stdinHandle) {
- CloseHandle(stdinHandle);
- }
- if (mustClose_stdoutHandle) {
- CloseHandle(stdoutHandle);
- }
- if (mustClose_stderrHandle) {
- CloseHandle(stderrHandle);
- }
+ // only works with real console handles
+ {
+ // change the child's stdIn (console) mode
+ DWORD mode = 0;
+
+ if (! GetConsoleMode(stdinHandle, &mode)) {
+ console_fprintf(stderr, "Win32OS [warning]: GetConsoleMode failed in createProcess\n");
+ }
+ if (! SetConsoleMode(stdinHandle, mode & (~ENABLE_ECHO_INPUT))){
+ console_fprintf(stderr, "Win32OS [warning]: SetConsoleMode failed in createProcess\n");
+ }
+ }
+#endif
+ if (mustClose_stdinHandle) {
+ CloseHandle(stdinHandle);
+ }
+ if (mustClose_stdoutHandle) {
+ CloseHandle(stdoutHandle);
+ }
+ if (mustClose_stderrHandle) {
+ CloseHandle(stderrHandle);
+ }
#ifdef PROCESSDEBUGWIN32
- console_fprintf(stderr, "created process hProcess=%x\n", lppiProcInfo.hProcess);
-#endif
-
- __externalAddressVal(handle) = lppiProcInfo.hProcess;
- ((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(handle))->pid = __mkSmallInteger(lppiProcInfo.dwProcessId);
- RETURN (handle);
- }
+ console_fprintf(stderr, "created process hProcess=%x\n", lppiProcInfo.hProcess);
+#endif
+
+ __externalAddressVal(handle) = lppiProcInfo.hProcess;
+ ((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(handle))->pid = __mkSmallInteger(lppiProcInfo.dwProcessId);
+ RETURN (handle);
+ }
#ifdef PROCESSDEBUGWIN32
- console_fprintf(stderr, "created process error %d\n", GetLastError());
-#endif
- RETURN (nil);
- } else {
- ; /* should never be called that way */
- }
+ console_fprintf(stderr, "created process error %d\n", GetLastError());
+#endif
+ RETURN (nil);
+ } else {
+ ; /* should never be called that way */
+ }
}
%}.
"
@@ -5120,7 +5172,7 @@
!
getOpenFilename: openFilenameStructureExternalAddress
- "Opens a windows native file dialog without blocking stx
+ "Opens a windows native file dialog without blocking stx
for an OpenFilenameStructure stored in an externalStructure"
| rslt |
@@ -5132,14 +5184,14 @@
if (__isExternalAddressLike(openFilenameStructureExternalAddress)
|| __isExternalBytesLike(openFilenameStructureExternalAddress)){
- __address = __externalAddressVal(openFilenameStructureExternalAddress);
- __rslt = __STX_API_CALL1( "GetOpenFileNameA", (void *)GetOpenFileNameA, __address);
-
- if (__rslt == TRUE) {
- rslt = true;
- } else {
- rslt = false;
- }
+ __address = __externalAddressVal(openFilenameStructureExternalAddress);
+ __rslt = __STX_API_CALL1( "GetOpenFileNameA", (void *)GetOpenFileNameA, __address);
+
+ if (__rslt == TRUE) {
+ rslt = true;
+ } else {
+ rslt = false;
+ }
}
%}.
rslt isNil ifTrue:[ self primitiveFailed ].
@@ -5150,7 +5202,7 @@
getSaveFilename: openFilenameStructureExternalAddress
- "Opens a windows native file dialog without blocking stx
+ "Opens a windows native file dialog without blocking stx
for an OpenFilenameStructure stored in an externalStructure."
| rslt |
@@ -5162,14 +5214,14 @@
if (__isExternalAddressLike(openFilenameStructureExternalAddress)
|| __isExternalBytesLike(openFilenameStructureExternalAddress)){
- __address = __externalAddressVal(openFilenameStructureExternalAddress);
- __rslt = __STX_API_CALL1( "GetSaveFileName", (void *)GetSaveFileName, __address);
-
- if (__rslt == TRUE) {
- rslt = true;
- } else {
- rslt = false;
- }
+ __address = __externalAddressVal(openFilenameStructureExternalAddress);
+ __rslt = __STX_API_CALL1( "GetSaveFileName", (void *)GetSaveFileName, __address);
+
+ if (__rslt == TRUE) {
+ rslt = true;
+ } else {
+ rslt = false;
+ }
}
%}.
rslt isNil ifTrue:[ self primitiveFailed ].
@@ -6086,9 +6138,9 @@
mode = __mkSmallInteger(modeBits);
- cOsTime = FileTimeToOsTime(&fileAttributeData.ftCreationTime);
- aOsTime = FileTimeToOsTime(&fileAttributeData.ftLastAccessTime);
- mOsTime = FileTimeToOsTime(&fileAttributeData.ftLastWriteTime);
+ cOsTime = FileTimeToOsTime1970(&fileAttributeData.ftCreationTime);
+ aOsTime = FileTimeToOsTime1970(&fileAttributeData.ftLastAccessTime);
+ mOsTime = FileTimeToOsTime1970(&fileAttributeData.ftLastWriteTime);
}
badArgument: ;
@@ -6115,17 +6167,17 @@
mode notNil ifTrue:[
atime isNil ifTrue:[
"/ rebias to 1970 by subtracting the number of millis from 1.1.1601 to 1.1.1970
- aOsTime := aOsTime - self osTimeOf19700101.
+ "/ aOsTime := aOsTime - self osTimeOf19700101. -- already done
atime := Timestamp new fromOSTime:aOsTime.
].
mtime isNil ifTrue:[
"/ rebias to 1970 by subtracting the number of millis from 1.1.1601 to 1.1.1970
- mOsTime := mOsTime - self osTimeOf19700101.
+ "/ mOsTime := mOsTime - self osTimeOf19700101. -- already done
mtime := Timestamp new fromOSTime:mOsTime.
].
ctime isNil ifTrue:[
"/ rebias to 1970 by subtracting the number of millis from 1.1.1601 to 1.1.1970
- cOsTime := cOsTime - self osTimeOf19700101.
+ "/ cOsTime := cOsTime - self osTimeOf19700101. -- already done
ctime := Timestamp new fromOSTime:cOsTime.
].
@@ -7931,39 +7983,39 @@
%{
if (__isString(aDirectoryPathName)
&& __isSmallInteger(changeFlags)) {
- char *__dirName = __stringVal(aDirectoryPathName);
- INT __flags = __intVal(changeFlags);
- HANDLE __changeHandle;
-
- __changeHandle = FindFirstChangeNotification(__dirName, FALSE, __flags);
- if (__changeHandle == INVALID_HANDLE_VALUE) {
- console_printf("failed to create handle\n");
- } else {
- __externalAddressVal(handle) = __changeHandle;
- RETURN (handle);
- }
+ char *__dirName = __stringVal(aDirectoryPathName);
+ INT __flags = __intVal(changeFlags);
+ HANDLE __changeHandle;
+
+ __changeHandle = FindFirstChangeNotification(__dirName, FALSE, __flags);
+ if (__changeHandle == INVALID_HANDLE_VALUE) {
+ console_printf("failed to create handle\n");
+ } else {
+ __externalAddressVal(handle) = __changeHandle;
+ RETURN (handle);
+ }
}
%}.
self primitiveFailed
"
- |h|
-
- [
- h := OperatingSystem createChangeNotificationHandleFor:'.'
- flags:(FILE_NOTIFY_CHANGE_FILE_NAME |
- FILE_NOTIFY_CHANGE_DIR_NAME |
- FILE_NOTIFY_CHANGE_ATTRIBUTES |
- FILE_NOTIFY_CHANGE_SIZE |
- FILE_NOTIFY_CHANGE_LAST_WRITE).
- Transcript showCR:'waiting...'.
- OperatingSystem waitForSingleObject:h withTimeout:1000.
- Transcript showCR:'got a change...'.
- h close.
- ] fork.
- Delay waitForSeconds:0.25.
- Transcript showCR:'changing...'.
- './bla' asFilename contents:'hello'.
+ |h|
+
+ [
+ h := OperatingSystem createChangeNotificationHandleFor:'.'
+ flags:(FILE_NOTIFY_CHANGE_FILE_NAME |
+ FILE_NOTIFY_CHANGE_DIR_NAME |
+ FILE_NOTIFY_CHANGE_ATTRIBUTES |
+ FILE_NOTIFY_CHANGE_SIZE |
+ FILE_NOTIFY_CHANGE_LAST_WRITE).
+ Transcript showCR:'waiting...'.
+ OperatingSystem waitForSingleObject:h withTimeout:1000.
+ Transcript showCR:'got a change...'.
+ h close.
+ ] fork.
+ Delay waitForSeconds:0.25.
+ Transcript showCR:'changing...'.
+ './bla' asFilename contents:'hello'.
"
! !
@@ -10626,14 +10678,15 @@
if (! SystemTimeToFileTime(&sysTime, &fileTime))
goto error;
- osTime = FileTimeToOsTime(&fileTime);
+ osTime = FileTimeToOsTime1970(&fileTime);
}
outOfRange: ;
error: ;
%}.
osTime notNil ifTrue:[
"/ rebias to 1970 by subtracting the number of millis from 1.1.1601 to 1.1.1970
- ^ osTime - self osTimeOf19700101.
+ "/ ^ osTime - self osTimeOf19700101. -- already done
+ ^ osTime
].
"Error, some invalid date ot time"
@@ -10750,10 +10803,11 @@
FILETIME fileTime;
GetSystemTimeAsFileTime(&fileTime);
- osTime = FileTimeToOsTime(&fileTime);
+ osTime = FileTimeToOsTime1970(&fileTime);
%}.
"/ rebias to 1970 by subtracting the number of millis from 1.1.1601 to 1.1.1970
- ^ osTime - self osTimeOf19700101.
+ "/ ^ osTime - self osTimeOf19700101 -- already done.
+ ^ osTime
"
OperatingSystem getOSTime.
@@ -10941,7 +10995,7 @@
|year month day hour minute second millis utcOffset isDst
dst yDay weekDay info reason tLow tHigh t error |
- t := (osSeconds * 1000) + osMilliSeconds + self osTimeOf19700101.
+ t := (osSeconds * 1000) + osMilliSeconds "+ self osTimeOf19700101 -- done in C".
tLow := (t bitAnd:16rFFFFFFFF).
tHigh := t bitShift:-32.
@@ -10969,7 +11023,7 @@
}
}
- if (!OsTimeToFileTime(tLow, tHigh, &fileTime))
+ if (!OsTime1970ToFileTime(tLow, tHigh, &fileTime))
goto out;
if (!FileTimeToSystemTime(&fileTime, &sysTime))
goto out;
@@ -15700,9 +15754,9 @@
If no such key exists and createIfAbsent is true, the key is created.
Otherwise, nil is returned.
flags may be one of:
- #KEY_WOW64_64KEY to force access to the 64Bit Windows key,
- #KEY_WOW64_32KEY to force access to the 32Bit Windows key,
- or nil, to access the key (32/64) for the current application"
+ #KEY_WOW64_64KEY to force access to the 64Bit Windows key,
+ #KEY_WOW64_32KEY to force access to the 32Bit Windows key,
+ or nil, to access the key (32/64) for the current application"
|subKeyStringZ newEntry subHandle errorNumber disposition|
@@ -15721,60 +15775,60 @@
int _disposition = 0;
if (flags != nil) {
- if (flags == @symbol(KEY_WOW64_64KEY)) {
- _flags = KEY_WOW64_64KEY;
- } else if (flags == @symbol(KEY_WOW64_32KEY)) {
- _flags = KEY_WOW64_32KEY;
- } else {
- errorNumber = @symbol(badArgument2);
- goto out;
- }
+ if (flags == @symbol(KEY_WOW64_64KEY)) {
+ _flags = KEY_WOW64_64KEY;
+ } else if (flags == @symbol(KEY_WOW64_32KEY)) {
+ _flags = KEY_WOW64_32KEY;
+ } else {
+ errorNumber = @symbol(badArgument2);
+ goto out;
+ }
}
if (__isExternalAddressLike(__INST(handle))
- && __isUnicode16String(subKeyStringZ)) {
- myKey = (HKEY)__externalAddressVal(__INST(handle));
- if (createIfAbsent == true) {
- _retVal = RegCreateKeyExW(myKey,
- __unicode16StringVal(subKeyStringZ),
- 0, // reserved
- NULL, // class
- 0, // options
- KEY_ALL_ACCESS|_flags, // rights
- NULL, // securityAttributes - handle cannot be inherited
- &subKey,
- &_disposition); // disposition (created vs. opened)
- disposition = _disposition == REG_CREATED_NEW_KEY ? true : false;
- } else {
- _retVal = RegOpenKeyExW(myKey,
- __unicode16StringVal(subKeyStringZ),
- 0,
- KEY_ALL_ACCESS|_flags,
- &subKey);
- disposition = false;
- }
- if (_retVal == ERROR_SUCCESS) {
- subHandle = __MKEXTERNALADDRESS(subKey);
- } else {
- if ((_retVal != ERROR_PATH_NOT_FOUND)
- && (_retVal != ERROR_FILE_NOT_FOUND)) {
- errorNumber = __MKSMALLINT(_retVal);
- }
- }
+ && __isUnicode16String(subKeyStringZ)) {
+ myKey = (HKEY)__externalAddressVal(__INST(handle));
+ if (createIfAbsent == true) {
+ _retVal = RegCreateKeyExW(myKey,
+ __unicode16StringVal(subKeyStringZ),
+ 0, // reserved
+ NULL, // class
+ 0, // options
+ KEY_ALL_ACCESS|_flags, // rights
+ NULL, // securityAttributes - handle cannot be inherited
+ &subKey,
+ &_disposition); // disposition (created vs. opened)
+ disposition = _disposition == REG_CREATED_NEW_KEY ? true : false;
+ } else {
+ _retVal = RegOpenKeyExW(myKey,
+ __unicode16StringVal(subKeyStringZ),
+ 0,
+ KEY_ALL_ACCESS|_flags,
+ &subKey);
+ disposition = false;
+ }
+ if (_retVal == ERROR_SUCCESS) {
+ subHandle = __MKEXTERNALADDRESS(subKey);
+ } else {
+ if ((_retVal != ERROR_PATH_NOT_FOUND)
+ && (_retVal != ERROR_FILE_NOT_FOUND)) {
+ errorNumber = __MKSMALLINT(_retVal);
+ }
+ }
}
out:;
%}.
subHandle notNil ifTrue:[
- newEntry := self class basicNew
- setHandle:subHandle
- path:((path ? '?') , self class separator asString , subKeyString)
- isNew:disposition.
-
- newEntry registerForFinalization.
- ^ newEntry.
+ newEntry := self class basicNew
+ setHandle:subHandle
+ path:((path ? '?') , self class separator asString , subKeyString)
+ isNew:disposition.
+
+ newEntry registerForFinalization.
+ ^ newEntry.
].
errorNumber notNil ifTrue:[
- (OperatingSystem errorHolderForNumber:errorNumber) reportProceedableError.
+ (OperatingSystem errorHolderForNumber:errorNumber) reportProceedableError.
].
^ nil
@@ -16301,13 +16355,13 @@
idx := 0.
[true] whileTrue:[
- subEntry := self subKeyAtIndex:idx.
- subEntry isNil ifTrue:[
- ^self
- ].
- aBlock value:subEntry.
- subEntry close.
- idx := idx + 1.
+ subEntry := self subKeyAtIndex:idx.
+ subEntry isNil ifTrue:[
+ ^self
+ ].
+ aBlock value:subEntry.
+ subEntry close.
+ idx := idx + 1.
]
"
@@ -16315,7 +16369,7 @@
top := self key:'HKEY_LOCAL_MACHINE'.
top subKeysDo:[:subEntry |
- Transcript showCR:subEntry path
+ Transcript showCR:subEntry path
]
"
"
@@ -16323,11 +16377,11 @@
top := self key:'HKEY_LOCAL_MACHINE'.
OSErrorHolder noPermissionsSignal handle:[:ex |
- ex proceed
+ ex proceed
] do:[
- top subKeysDo:[:subEntry |
- Transcript showCR:subEntry path
- ]
+ top subKeysDo:[:subEntry |
+ Transcript showCR:subEntry path
+ ]
]
"
!