فهرست منبع

fixed __cpp__ for different newline endings

Nicolas Cannasse 10 سال پیش
والد
کامیت
24d5894ac7
1فایلهای تغییر یافته به همراه6 افزوده شده و 3 حذف شده
  1. 6 3
      gencpp.ml

+ 6 - 3
gencpp.ml

@@ -396,6 +396,9 @@ match field_access with
    | _ -> ""
 ;;
 
+let format_code code =
+	String.concat "\n" (ExtString.String.nsplit code "\r\n")
+
 let get_code meta key =
    let code = get_meta_string meta key in
    let magic_var = "${GENCPP_SOURCE_DIRECTORY}"  in
@@ -406,7 +409,7 @@ let get_code meta key =
       end else
          code
       in
-   if (code<>"") then String.concat "\n" (ExtString.String.nsplit code "\r\n") ^ "\n" else code
+   if (code<>"") then format_code code ^ "\n" else code
 ;;
 
 let has_meta_key meta key =
@@ -1964,9 +1967,9 @@ and gen_expression ctx retval expression =
          | TLocal { v_name = "__cpp__" } -> true
          | _ -> false) ->
       ( match arg_list with
-      | [{ eexpr = TConst (TString code) }] -> output code;
+      | [{ eexpr = TConst (TString code) }] -> output (format_code code);
       | ({ eexpr = TConst (TString code) } as ecode) :: tl ->
-         Codegen.interpolate_code ctx.ctx_common code tl output (gen_expression ctx true) ecode.epos
+         Codegen.interpolate_code ctx.ctx_common (format_code code) tl output (gen_expression ctx true) ecode.epos
       | _ -> error "__cpp__'s first argument must be a string" func.epos;
       )
    | TCall (func, arg_list) when tcall_expand_args->