diff options
author | Araq <rumpf_a@web.de> | 2012-07-08 21:03:47 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-07-08 21:03:47 +0200 |
commit | 4fbba0a65ad310ba9498f1cf9f79eb0826b19f81 (patch) | |
tree | dece3596fbdf153263f5672b4011139f70a4df6a /lib/system | |
parent | 36247e0947699a56d5bc51d48188b6dda1815587 (diff) | |
download | Nim-4fbba0a65ad310ba9498f1cf9f79eb0826b19f81.tar.gz |
changed integer promotion rules; breaks bootstrapping and lots of code
Diffstat (limited to 'lib/system')
-rwxr-xr-x | lib/system/ansi_c.nim | 3 | ||||
-rwxr-xr-x | lib/system/repr.nim | 7 | ||||
-rwxr-xr-x | lib/system/sysio.nim | 8 |
3 files changed, 12 insertions, 6 deletions
diff --git a/lib/system/ansi_c.nim b/lib/system/ansi_c.nim index 3376b9413..7c2c234c2 100755 --- a/lib/system/ansi_c.nim +++ b/lib/system/ansi_c.nim @@ -71,7 +71,8 @@ proc c_fopen(filename, mode: cstring): C_TextFileStar {. importc: "fopen", nodecl.} proc c_fclose(f: C_TextFileStar) {.importc: "fclose", nodecl.} -proc c_sprintf(buf, frmt: CString) {.nodecl, importc: "sprintf", varargs.} +proc c_sprintf(buf, frmt: CString) {.nodecl, importc: "sprintf", varargs, + noSideEffect.} # we use it only in a way that cannot lead to security issues proc c_fread(buf: Pointer, size, n: int, f: C_BinaryFileStar): int {. diff --git a/lib/system/repr.nim b/lib/system/repr.nim index 83fa7aa1d..028887b4c 100755 --- a/lib/system/repr.nim +++ b/lib/system/repr.nim @@ -20,6 +20,11 @@ proc reprPointer(x: pointer): string {.compilerproc.} = c_sprintf(buf, "%p", x) return $buf +proc `$`(x: uint64): string = + var buf: array [0..59, char] + c_sprintf(buf, "%llu", x) + return $buf + proc reprStrAux(result: var string, s: string) = if cast[pointer](s) == nil: add result, "nil" @@ -67,7 +72,7 @@ proc reprEnum(e: int, typ: PNimType): string {.compilerRtl.} = result = $e & " (invalid data!)" type - pbyteArray = ptr array[0.. 0xffff, byte] + pbyteArray = ptr array[0.. 0xffff, int8] proc addSetElem(result: var string, elem: int, typ: PNimType) = case typ.kind diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index ac0880f79..d5234e62f 100755 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -222,17 +222,17 @@ proc fwrite(buf: Pointer, size, n: int, f: TFile): int {. proc readBuffer(f: TFile, buffer: pointer, len: int): int = result = fread(buffer, 1, len, f) -proc ReadBytes(f: TFile, a: var openarray[byte], start, len: int): int = +proc ReadBytes(f: TFile, a: var openarray[int8], start, len: int): int = result = readBuffer(f, addr(a[start]), len) proc ReadChars(f: TFile, a: var openarray[char], start, len: int): int = result = readBuffer(f, addr(a[start]), len) -proc writeBytes(f: TFile, a: openarray[byte], start, len: int): int = - var x = cast[ptr array[0..1000_000_000, byte]](a) +proc writeBytes(f: TFile, a: openarray[int8], start, len: int): int = + var x = cast[ptr array[0..1000_000_000, int8]](a) result = writeBuffer(f, addr(x[start]), len) proc writeChars(f: TFile, a: openarray[char], start, len: int): int = - var x = cast[ptr array[0..1000_000_000, byte]](a) + var x = cast[ptr array[0..1000_000_000, int8]](a) result = writeBuffer(f, addr(x[start]), len) proc writeBuffer(f: TFile, buffer: pointer, len: int): int = result = fwrite(buffer, 1, len, f) |