Skip to content

Commit

Permalink
Merge branch 'master' of github.com:red/red
Browse files Browse the repository at this point in the history
  • Loading branch information
dockimbel committed Feb 5, 2016
2 parents 587aa76 + d556993 commit b6d220d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions environment/console/terminal.reds
Expand Up @@ -999,6 +999,7 @@ terminal: context [
str/head: 0
emit-string vt str no no
str/head: head
vt/edit-pos: out/last
]
]
num
Expand Down
1 change: 1 addition & 0 deletions environment/console/windows.reds
Expand Up @@ -346,6 +346,7 @@ ConsoleWndProc: func [
mbmp: CreateCompatibleBitmap hdc max-win-width vt/char-h
SelectObject mdc mbmp
SelectObject mdc vt/font
set-normal-color vt
paint vt
EndPaint hWnd ps
DeleteDC mdc
Expand Down
6 changes: 1 addition & 5 deletions runtime/datatypes/integer.reds
Expand Up @@ -484,18 +484,14 @@ integer: context [
return: [integer!]
/local
res [integer!]
neg? [logic!]
][
res: 1
neg?: false

if exp < 0 [neg?: true exp: 0 - exp]
while [exp <> 0][
if as logic! exp and 1 [res: res * base]
exp: exp >> 1
base: base * base
]
either neg? [1 / res][res]
res
]

power: func [
Expand Down
15 changes: 7 additions & 8 deletions runtime/datatypes/string.reds
Expand Up @@ -1403,7 +1403,7 @@ string: context [

s: GET_BUFFER(str)
unit: GET_UNIT(s)
buffer: (as byte-ptr! s/offset) + (str/head << (log-b unit))
buffer: (as byte-ptr! s/offset) + (str/head << (unit >> 1))
end: as byte-ptr! s/tail

if any [ ;-- early exit if string is empty or at tail
Expand Down Expand Up @@ -1432,7 +1432,7 @@ string: context [
result/header: TYPE_NONE
return result
]
(as byte-ptr! s/offset) + (int/value - 1 << (log-b unit)) ;-- int argument is 1-based
buffer + (int/value - 1 << (unit >> 1)) ;-- int argument is 1-based
][
str2: as red-string! part
unless all [
Expand All @@ -1441,7 +1441,7 @@ string: context [
][
ERR_INVALID_REFINEMENT_ARG(refinements/_part part)
]
(as byte-ptr! s/offset) + (str2/head << (log-b unit))
buffer + (str2/head << (unit >> 1))
]
part?: yes
]
Expand All @@ -1453,22 +1453,21 @@ string: context [
]
reverse? [
step: 0 - step
buffer: either part? [limit][(as byte-ptr! s/offset) + (str/head - 1 << (log-b unit))]
buffer: either part? [limit][(as byte-ptr! s/offset) + (str/head - 1 << (unit >> 1))]
end: as byte-ptr! s/offset
if buffer < end [ ;-- early exit if str/head = 0
result/header: TYPE_NONE
return result
]
]
true [
buffer: (as byte-ptr! s/offset) + (str/head << (log-b unit))
end: either part? [limit + unit][as byte-ptr! s/tail] ;-- + unit => compensate for the '>= test
]
]

case?: either TYPE_OF(str) = TYPE_STRING [not case?][no] ;-- inverted case? meaning
reverse?: any [reverse? last?] ;-- reduce both flags to one
step: step << (log-b unit)
step: step << (unit >> 1)
pattern: null

;-- Value argument processing --
Expand All @@ -1495,7 +1494,7 @@ string: context [
]
s2: GET_BUFFER(str2)
unit2: GET_UNIT(s2)
pattern: (as byte-ptr! s2/offset) + (head2 << (log-b unit2))
pattern: (as byte-ptr! s2/offset) + (head2 << (unit2 >> 1))
end2: (as byte-ptr! s2/tail)
]
default [
Expand Down Expand Up @@ -1608,7 +1607,7 @@ string: context [

either found? [
str: as red-string! result
str/head: (as-integer buffer - s/offset) >> (log-b unit) ;-- just change the head position on stack
str/head: (as-integer buffer - s/offset) >> (unit >> 1) ;-- just change the head position on stack
][
result/header: TYPE_NONE ;-- change the stack 1st argument to none.
]
Expand Down
5 changes: 2 additions & 3 deletions system/runtime/common.reds
Expand Up @@ -118,10 +118,9 @@ re-throw: func [/local id [integer!]][


#if type = 'exe [
#switch target [
#switch target [ ;-- do not raise exceptions as we use some C functions may cause exception
IA-32 [
system/fpu/control-word: 0272h ;-- default control word: division by zero, invalid op,
;-- and overflow raise exceptions.
system/fpu/control-word: 027Fh
system/fpu/update
]
ARM [
Expand Down

0 comments on commit b6d220d

Please sign in to comment.