File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -29,17 +29,19 @@ when defined(unix): # XXX: suitable?
29
29
# #
30
30
# replace "~username" with `pwd.getpwnam(username).pw_dir`
31
31
# translated from CPython's pwd.getpwnam, a.k.a. pwd_getpwnam_impl in Modules/pwdmodule.c
32
- var bufsize = sysconf(SC_GETPW_R_SIZE_MAX)
33
- if bufsize == - 1 :
34
- bufsize = DEFAULT_BUFFER_SIZE
35
-
36
32
let name_chars = cstring username
37
33
38
34
var
39
35
nomem = false
40
36
p: ptr Passwd = nil
41
37
buf: cstring = nil
42
- when declared(getpwnam_r) and declared(reallocShared):
38
+
39
+ when declared(getpwnam_r) and declared(SC_GETPW_R_SIZE_MAX) and
40
+ declared(reallocShared):
41
+ var bufsize = sysconf(SC_GETPW_R_SIZE_MAX)
42
+ if bufsize == - 1 :
43
+ bufsize = DEFAULT_BUFFER_SIZE
44
+
43
45
var pwd: Passwd
44
46
while true :
45
47
let buf2 = cast [cstring ](reallocShared(buf, bufsize))
You can’t perform that action at this time.
0 commit comments