Windows fixes
parent
18082274ca
commit
18525922fd
|
@ -486,12 +486,15 @@ mut args := ''
|
||||||
// Find clang executable
|
// Find clang executable
|
||||||
fast_clang := '/usr/local/Cellar/llvm/8.0.0/bin/clang'
|
fast_clang := '/usr/local/Cellar/llvm/8.0.0/bin/clang'
|
||||||
args := a.join(' ')
|
args := a.join(' ')
|
||||||
cmd := if os.file_exists(fast_clang) {
|
mut cmd := if os.file_exists(fast_clang) {
|
||||||
'$fast_clang -I. $args'
|
'$fast_clang $args'
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
'cc -I. $args'
|
'cc $args'
|
||||||
}
|
}
|
||||||
|
$if windows {
|
||||||
|
cmd = 'gcc $args'
|
||||||
|
}
|
||||||
// Print the C command
|
// Print the C command
|
||||||
if c.show_c_cmd || c.is_verbose {
|
if c.show_c_cmd || c.is_verbose {
|
||||||
println('\n==========\n$cmd\n=========\n')
|
println('\n==========\n$cmd\n=========\n')
|
||||||
|
|
|
@ -179,13 +179,11 @@ fn (s mut Scanner) scan() ScanRes {
|
||||||
return scan_res(STRING, s.ident_string())
|
return scan_res(STRING, s.ident_string())
|
||||||
}
|
}
|
||||||
s.skip_whitespace()
|
s.skip_whitespace()
|
||||||
// println('ws skipped')
|
|
||||||
// end of file
|
// end of file
|
||||||
if s.pos >= s.text.len {
|
if s.pos >= s.text.len {
|
||||||
// println('scan(): returning EOF (pos >= len)')
|
// println('scan(): returning EOF (pos >= len)')
|
||||||
return scan_res(EOF, '')
|
return scan_res(EOF, '')
|
||||||
}
|
}
|
||||||
// println('!!!!! HANDLE CHAR pos=$s.pos')
|
|
||||||
// handle each char
|
// handle each char
|
||||||
c := s.text[s.pos]
|
c := s.text[s.pos]
|
||||||
mut nextc := `\0`
|
mut nextc := `\0`
|
||||||
|
@ -481,6 +479,11 @@ fn (s mut Scanner) scan() ScanRes {
|
||||||
}
|
}
|
||||||
return scan_res(DIV, '')
|
return scan_res(DIV, '')
|
||||||
}
|
}
|
||||||
|
$if windows {
|
||||||
|
if c == `\0` {
|
||||||
|
return scan_res(EOF, '')
|
||||||
|
}
|
||||||
|
}
|
||||||
println('(char code=$c) pos=$s.pos len=$s.text.len')
|
println('(char code=$c) pos=$s.pos len=$s.text.len')
|
||||||
s.error('invalid character `${c.str()}`')
|
s.error('invalid character `${c.str()}`')
|
||||||
return scan_res(EOF, '')
|
return scan_res(EOF, '')
|
||||||
|
|
|
@ -77,8 +77,14 @@ fn parse_windows_cmd_line(cmd byteptr) []string {
|
||||||
// read_file reads the file in `path` and returns the contents.
|
// read_file reads the file in `path` and returns the contents.
|
||||||
pub fn read_file(path string) ?string {
|
pub fn read_file(path string) ?string {
|
||||||
mut res := ''
|
mut res := ''
|
||||||
|
mut mode := 'r'
|
||||||
|
777 // TODO
|
||||||
|
// Need 'rb' on windows to avoid the \r\n mess.
|
||||||
|
$if windows {
|
||||||
|
mode = 'rb'
|
||||||
|
}
|
||||||
cpath := path.cstr()
|
cpath := path.cstr()
|
||||||
fp := C.fopen(cpath, 'r')
|
fp := C.fopen(cpath, mode.cstr())
|
||||||
if isnil(fp) {
|
if isnil(fp) {
|
||||||
return error('failed to open file "$path"')
|
return error('failed to open file "$path"')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue