Skip to content

Commit dbc9c68

Browse files
committed
fix: regression windows path slash
1 parent 897a499 commit dbc9c68

13 files changed

+51
-49
lines changed

jscomp/bin/.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
ppx_metaquot
2-
bspack.exe
3-
bsc.exe
4-
!*.d

jscomp/bin/all_ounit_tests.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -6769,7 +6769,7 @@ val replace_backward_slash : string -> string
67696769
(*
67706770
[no_slash s i len]
67716771
*)
6772-
val no_slash : string -> int -> int -> bool
6772+
val no_char : string -> char -> int -> int -> bool
67736773
(** if no conversion happens, reference equality holds *)
67746774
val replace_slash_backward : string -> string
67756775

@@ -6986,13 +6986,13 @@ let find_package_json_dir cwd =
69866986
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
69876987

69886988

6989-
let rec no_slash x i len =
6989+
let rec no_char x ch i len =
69906990
i >= len ||
6991-
(String.unsafe_get x i <> '/' && no_slash x (i + 1) len)
6991+
(String.unsafe_get x i <> ch && no_char x ch (i + 1) len)
69926992

69936993
let replace_backward_slash (x : string)=
69946994
let len = String.length x in
6995-
if no_slash x 0 len then x
6995+
if no_char x '\\' 0 len then x
69966996
else
69976997
String.map (function
69986998
|'\\'-> '/'
@@ -7001,7 +7001,7 @@ let replace_backward_slash (x : string)=
70017001

70027002
let replace_slash_backward (x : string ) =
70037003
let len = String.length x in
7004-
if no_slash x 0 len then x
7004+
if no_char x '/' 0 len then x
70057005
else
70067006
String.map (function
70077007
| '/' -> '\\'

jscomp/bin/bsb.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ val replace_backward_slash : string -> string
10301030
(*
10311031
[no_slash s i len]
10321032
*)
1033-
val no_slash : string -> int -> int -> bool
1033+
val no_char : string -> char -> int -> int -> bool
10341034
(** if no conversion happens, reference equality holds *)
10351035
val replace_slash_backward : string -> string
10361036

@@ -1247,13 +1247,13 @@ let find_package_json_dir cwd =
12471247
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
12481248

12491249

1250-
let rec no_slash x i len =
1250+
let rec no_char x ch i len =
12511251
i >= len ||
1252-
(String.unsafe_get x i <> '/' && no_slash x (i + 1) len)
1252+
(String.unsafe_get x i <> ch && no_char x ch (i + 1) len)
12531253

12541254
let replace_backward_slash (x : string)=
12551255
let len = String.length x in
1256-
if no_slash x 0 len then x
1256+
if no_char x '\\' 0 len then x
12571257
else
12581258
String.map (function
12591259
|'\\'-> '/'
@@ -1262,7 +1262,7 @@ let replace_backward_slash (x : string)=
12621262

12631263
let replace_slash_backward (x : string ) =
12641264
let len = String.length x in
1265-
if no_slash x 0 len then x
1265+
if no_char x '/' 0 len then x
12661266
else
12671267
String.map (function
12681268
| '/' -> '\\'
@@ -6284,7 +6284,7 @@ let (//) = Ext_filename.combine
62846284
*)
62856285
let resolve_bsb_magic_file ~cwd ~desc p =
62866286
let p_len = String.length p in
6287-
let no_slash = Ext_filename.no_slash p 0 p_len in
6287+
let no_slash = Ext_filename.no_char p '/' 0 p_len in
62886288
if no_slash then
62896289
p
62906290
else if Filename.is_relative p &&

jscomp/bin/bsb_helper.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ val replace_backward_slash : string -> string
996996
(*
997997
[no_slash s i len]
998998
*)
999-
val no_slash : string -> int -> int -> bool
999+
val no_char : string -> char -> int -> int -> bool
10001000
(** if no conversion happens, reference equality holds *)
10011001
val replace_slash_backward : string -> string
10021002

@@ -1213,13 +1213,13 @@ let find_package_json_dir cwd =
12131213
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
12141214

12151215

1216-
let rec no_slash x i len =
1216+
let rec no_char x ch i len =
12171217
i >= len ||
1218-
(String.unsafe_get x i <> '/' && no_slash x (i + 1) len)
1218+
(String.unsafe_get x i <> ch && no_char x ch (i + 1) len)
12191219

12201220
let replace_backward_slash (x : string)=
12211221
let len = String.length x in
1222-
if no_slash x 0 len then x
1222+
if no_char x '\\' 0 len then x
12231223
else
12241224
String.map (function
12251225
|'\\'-> '/'
@@ -1228,7 +1228,7 @@ let replace_backward_slash (x : string)=
12281228

12291229
let replace_slash_backward (x : string ) =
12301230
let len = String.length x in
1231-
if no_slash x 0 len then x
1231+
if no_char x '/' 0 len then x
12321232
else
12331233
String.map (function
12341234
| '/' -> '\\'

jscomp/bin/bsdep.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -26064,7 +26064,7 @@ val replace_backward_slash : string -> string
2606426064
(*
2606526065
[no_slash s i len]
2606626066
*)
26067-
val no_slash : string -> int -> int -> bool
26067+
val no_char : string -> char -> int -> int -> bool
2606826068
(** if no conversion happens, reference equality holds *)
2606926069
val replace_slash_backward : string -> string
2607026070

@@ -26281,13 +26281,13 @@ let find_package_json_dir cwd =
2628126281
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
2628226282

2628326283

26284-
let rec no_slash x i len =
26284+
let rec no_char x ch i len =
2628526285
i >= len ||
26286-
(String.unsafe_get x i <> '/' && no_slash x (i + 1) len)
26286+
(String.unsafe_get x i <> ch && no_char x ch (i + 1) len)
2628726287

2628826288
let replace_backward_slash (x : string)=
2628926289
let len = String.length x in
26290-
if no_slash x 0 len then x
26290+
if no_char x '\\' 0 len then x
2629126291
else
2629226292
String.map (function
2629326293
|'\\'-> '/'
@@ -26296,7 +26296,7 @@ let replace_backward_slash (x : string)=
2629626296

2629726297
let replace_slash_backward (x : string ) =
2629826298
let len = String.length x in
26299-
if no_slash x 0 len then x
26299+
if no_char x '/' 0 len then x
2630026300
else
2630126301
String.map (function
2630226302
| '/' -> '\\'

jscomp/bin/bsppx.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -7931,7 +7931,7 @@ val replace_backward_slash : string -> string
79317931
(*
79327932
[no_slash s i len]
79337933
*)
7934-
val no_slash : string -> int -> int -> bool
7934+
val no_char : string -> char -> int -> int -> bool
79357935
(** if no conversion happens, reference equality holds *)
79367936
val replace_slash_backward : string -> string
79377937

@@ -8148,13 +8148,13 @@ let find_package_json_dir cwd =
81488148
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
81498149

81508150

8151-
let rec no_slash x i len =
8151+
let rec no_char x ch i len =
81528152
i >= len ||
8153-
(String.unsafe_get x i <> '/' && no_slash x (i + 1) len)
8153+
(String.unsafe_get x i <> ch && no_char x ch (i + 1) len)
81548154

81558155
let replace_backward_slash (x : string)=
81568156
let len = String.length x in
8157-
if no_slash x 0 len then x
8157+
if no_char x '\\' 0 len then x
81588158
else
81598159
String.map (function
81608160
|'\\'-> '/'
@@ -8163,7 +8163,7 @@ let replace_backward_slash (x : string)=
81638163

81648164
let replace_slash_backward (x : string ) =
81658165
let len = String.length x in
8166-
if no_slash x 0 len then x
8166+
if no_char x '/' 0 len then x
81678167
else
81688168
String.map (function
81698169
| '/' -> '\\'

jscomp/bin/config_whole_compiler.mlp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
(* The main OCaml version string has moved to ../VERSION *)
2424
let version = "4.02.3+BS"
2525

26-
let standard_library_default = "%%LIBDIR%%"
26+
let standard_library_default = %%LIBDIR%%
2727

2828
let standard_library =
2929
try

jscomp/bin/whole_compiler.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -21426,7 +21426,7 @@ val replace_backward_slash : string -> string
2142621426
(*
2142721427
[no_slash s i len]
2142821428
*)
21429-
val no_slash : string -> int -> int -> bool
21429+
val no_char : string -> char -> int -> int -> bool
2143021430
(** if no conversion happens, reference equality holds *)
2143121431
val replace_slash_backward : string -> string
2143221432

@@ -21643,13 +21643,13 @@ let find_package_json_dir cwd =
2164321643
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
2164421644

2164521645

21646-
let rec no_slash x i len =
21646+
let rec no_char x ch i len =
2164721647
i >= len ||
21648-
(String.unsafe_get x i <> '/' && no_slash x (i + 1) len)
21648+
(String.unsafe_get x i <> ch && no_char x ch (i + 1) len)
2164921649

2165021650
let replace_backward_slash (x : string)=
2165121651
let len = String.length x in
21652-
if no_slash x 0 len then x
21652+
if no_char x '\\' 0 len then x
2165321653
else
2165421654
String.map (function
2165521655
|'\\'-> '/'
@@ -21658,7 +21658,7 @@ let replace_backward_slash (x : string)=
2165821658

2165921659
let replace_slash_backward (x : string ) =
2166021660
let len = String.length x in
21661-
if no_slash x 0 len then x
21661+
if no_char x '/' 0 len then x
2166221662
else
2166321663
String.map (function
2166421664
| '/' -> '\\'

jscomp/bsb/bsb_default.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let (//) = Ext_filename.combine
3636
*)
3737
let resolve_bsb_magic_file ~cwd ~desc p =
3838
let p_len = String.length p in
39-
let no_slash = Ext_filename.no_slash p 0 p_len in
39+
let no_slash = Ext_filename.no_char p '/' 0 p_len in
4040
if no_slash then
4141
p
4242
else if Filename.is_relative p &&

jscomp/config.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,14 @@ function patch_config(config_map){
115115
function (_whole, p0) {
116116
if (p0 === "LIBDIR") {
117117
//Escape
118-
var origin_path = path.join(jscomp, '..', 'lib', 'ocaml')
119-
return JSON.stringify(origin_path).slice(1, -1)
118+
if(is_windows){
119+
return 'Filename.concat (Filename.concat (Filename.concat (Filename.dirname Sys.executable_name) "..") "lib") "ocaml"'
120+
}
121+
else{
122+
var origin_path = path.join(jscomp, '..', 'lib', 'ocaml')
123+
return JSON.stringify(origin_path);
124+
// .slice(1, -1)
125+
}
120126
}
121127
else {
122128
return config_map[map[p0]]

jscomp/ext/ext_filename.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ let find_package_json_dir cwd =
209209
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
210210

211211

212-
let rec no_slash x i len =
212+
let rec no_char x ch i len =
213213
i >= len ||
214-
(String.unsafe_get x i <> '/' && no_slash x (i + 1) len)
214+
(String.unsafe_get x i <> ch && no_char x ch (i + 1) len)
215215

216216
let replace_backward_slash (x : string)=
217217
let len = String.length x in
218-
if no_slash x 0 len then x
218+
if no_char x '\\' 0 len then x
219219
else
220220
String.map (function
221221
|'\\'-> '/'
@@ -224,7 +224,7 @@ let replace_backward_slash (x : string)=
224224

225225
let replace_slash_backward (x : string ) =
226226
let len = String.length x in
227-
if no_slash x 0 len then x
227+
if no_char x '/' 0 len then x
228228
else
229229
String.map (function
230230
| '/' -> '\\'

jscomp/ext/ext_filename.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,6 @@ val replace_backward_slash : string -> string
111111
(*
112112
[no_slash s i len]
113113
*)
114-
val no_slash : string -> int -> int -> bool
114+
val no_char : string -> char -> int -> int -> bool
115115
(** if no conversion happens, reference equality holds *)
116116
val replace_slash_backward : string -> string

jscomp/test/ext_filename.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ var package_dir = Block.__(246, [function () {
268268
));
269269
}]);
270270

271-
function no_slash(x, _i, len) {
271+
function no_char(x, ch, _i, len) {
272272
while(true) {
273273
var i = _i;
274274
if (i >= len) {
275275
return /* true */1;
276276
}
277-
else if (x.charCodeAt(i) !== /* "/" */47) {
277+
else if (x.charCodeAt(i) !== ch) {
278278
_i = i + 1 | 0;
279279
continue ;
280280

@@ -287,7 +287,7 @@ function no_slash(x, _i, len) {
287287

288288
function replace_backward_slash(x) {
289289
var len = x.length;
290-
if (no_slash(x, 0, len)) {
290+
if (no_char(x, /* "\\" */92, 0, len)) {
291291
return x;
292292
}
293293
else {
@@ -304,7 +304,7 @@ function replace_backward_slash(x) {
304304

305305
function replace_slash_backward(x) {
306306
var len = x.length;
307-
if (no_slash(x, 0, len)) {
307+
if (no_char(x, /* "/" */47, 0, len)) {
308308
return x;
309309
}
310310
else {
@@ -508,7 +508,7 @@ exports.relative_path = relative_path;
508508
exports.node_relative_path = node_relative_path;
509509
exports.find_package_json_dir = find_package_json_dir;
510510
exports.package_dir = package_dir;
511-
exports.no_slash = no_slash;
511+
exports.no_char = no_char;
512512
exports.replace_backward_slash = replace_backward_slash;
513513
exports.replace_slash_backward = replace_slash_backward;
514514
exports.module_name_of_file = module_name_of_file;

0 commit comments

Comments
 (0)