Skip to content

Commit bbbabb0

Browse files
committed
FIX: simplified request-password native code and fixed Win32 version
1 parent 8082761 commit bbbabb0

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

src/core/n-io.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -1155,14 +1155,11 @@ static REBSER *Read_All_File(char *fname)
11551155

11561156
OS_REQUEST_PASSWORD(&req);
11571157

1158-
if (req.file.path == NULL) return R_NONE;
1158+
if (req.data == NULL) return R_NONE;
11591159

1160-
#ifdef TO_WINDOWS
1161-
str = Decode_UTF_String(req.file.path, req.file.size, 16, 0, 0);
1162-
#else
1163-
str = Decode_UTF_String(req.file.path, req.file.size, 8, 0, 0);
1164-
#endif
1165-
FREE_MEM(req.file.path);
1160+
str = Copy_OS_Str(req.data, req.actual);
1161+
1162+
FREE_MEM(req.data);
11661163
SET_STRING(D_RET, str);
11671164
return R_RET;
11681165
}

src/os/posix/host-lib.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ static int Try_Browser(char *browser, REBCHR *url)
13821382
REBYTE *str = malloc(size);
13831383
REBYTE c;
13841384

1385-
req->file.path = NULL;
1385+
req->data = NULL;
13861386

13871387
while (read(STDIN_FILENO, &c, 1) && c != '\r') {
13881388
if (c == 27) { // ESC
@@ -1400,8 +1400,8 @@ static int Try_Browser(char *browser, REBCHR *url)
14001400
str = realloc(str, size);
14011401
}
14021402
}
1403-
req->file.path = str;
1404-
req->file.size = pos;
1403+
req->data = str;
1404+
req->actual = pos;
14051405
str[pos++] = 0; // null terminate the tail.. just in case
14061406
}
14071407

src/os/win32/host-lib.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -1445,28 +1445,28 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPAR
14451445
{
14461446
REBCNT size = 64;
14471447
REBCNT pos = 0;
1448-
REBUNI *str = (REBUNI*)malloc(size * sizeof(REBUNI));
1449-
REBUNI c;
1448+
REBCHR *str = (REBUNI*)malloc(size * sizeof(REBCHR));
1449+
REBCHR c;
14501450

1451-
req->file.path = NULL;
1451+
req->data = NULL;
14521452

14531453
while ((c = _getwch()) != '\r') {
14541454
if (c == 27) { // ESC
14551455
free(str);
14561456
return;
14571457
}
1458-
if (c == 127) { // backspace
1458+
if (c == '\b') { // backspace
14591459
if (pos > 0) pos--;
14601460
continue;
14611461
}
14621462
str[pos++] = c;
14631463
if (pos+1 == size) {
14641464
size += 64;
1465-
str = (REBUNI*)realloc(str, size * sizeof(REBUNI));
1465+
str = (REBCHR *)realloc(str, size * sizeof(REBCHR));
14661466
}
14671467
}
1468-
req->file.path = (REBYTE*)str;
1469-
req->file.size = pos * sizeof(REBUNI);
1468+
req->data = (REBYTE*)str;
1469+
req->actual = pos;
14701470
str[pos++] = 0;
14711471
}
14721472

0 commit comments

Comments
 (0)