better error handling in the pascal wrapper
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
14fbbd1f31
commit
1a7d86a293
6
go/cb.go
6
go/cb.go
@ -144,10 +144,10 @@ func hcl_go_cci_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.in
|
||||
|
||||
ioarg.is_bytes = 0
|
||||
if unsafe.Sizeof(buf[0]) == unsafe.Sizeof(dummy) {
|
||||
C.memcpy (
|
||||
C.memcpy(
|
||||
unsafe.Pointer(&ioarg.buf[0]),
|
||||
unsafe.Pointer(&buf[0]),
|
||||
C.size_t(unsafe.Sizeof(buf[0]) * uintptr(n)))
|
||||
C.size_t(unsafe.Sizeof(buf[0])*uintptr(n)))
|
||||
} else {
|
||||
var dst uintptr
|
||||
// work around cgo's union issue. not able to access individual union
|
||||
@ -155,7 +155,7 @@ func hcl_go_cci_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.in
|
||||
dst = uintptr(unsafe.Pointer(&ioarg.buf[0]))
|
||||
for i = 0; i < n; i++ {
|
||||
//ioarg.buf.c[i] = C.hcl_uch_t(buf[i])
|
||||
*(*C.hcl_uch_t)(unsafe.Pointer(dst)) = C.hcl_uch_t(buf[i]);
|
||||
*(*C.hcl_uch_t)(unsafe.Pointer(dst)) = C.hcl_uch_t(buf[i])
|
||||
dst += unsafe.Sizeof(dummy)
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ label
|
||||
begin
|
||||
f := SysUtils.FileOpen(filename, SysUtils.fmOpenRead);
|
||||
if f = System.THandle(-1) then begin
|
||||
errmsg := 'failed to open file - ' + filename;
|
||||
errmsg := 'failed to open ' + filename + ' - ' + SysUtils.SysErrorMessage(SysUtils.GetLastOSError());
|
||||
goto oops;
|
||||
end;
|
||||
|
||||
@ -367,7 +367,7 @@ begin
|
||||
while true do begin
|
||||
len := SysUtils.FileRead(f, buf, System.SizeOf(buf));
|
||||
if len <= -1 then begin
|
||||
errmsg := 'failed to read file - ' + filename;
|
||||
errmsg := 'failed to read ' + filename + ' - ' + SysUtils.SysErrorMessage(SysUtils.GetLastOSError());
|
||||
goto oops;
|
||||
end;
|
||||
if len = 0 then break;
|
||||
@ -395,7 +395,7 @@ oops:
|
||||
if feed_ongoing then hcl_endfeed(self.handle);
|
||||
if attached then hcl_detachccio(self.handle);
|
||||
self.basefile := '';
|
||||
if f >= -1 then SysUtils.FileClose(f);
|
||||
if f <> System.THandle(-1) then SysUtils.FileClose(f);
|
||||
raise Exception.Create(errmsg);
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user