ocaml405.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. Index: labltk-8.06.2/support/cltkCaml.c
  2. ===================================================================
  3. --- labltk-8.06.2.orig/support/cltkCaml.c
  4. +++ labltk-8.06.2/support/cltkCaml.c
  5. @@ -39,7 +39,7 @@ int CamlCBCmd(ClientData clientdata, Tcl
  6. int id;
  7. if (Tcl_GetInt(interp, argv[1], &id) != TCL_OK)
  8. return TCL_ERROR;
  9. - callback2(*handler_code,Val_int(id),
  10. + caml_callback2(*handler_code,Val_int(id),
  11. copy_string_list(argc - 2,(char **)&argv[2]));
  12. /* Never fails (OCaml would have raised an exception) */
  13. /* but result may have been set by callback */
  14. @@ -65,7 +65,7 @@ CAMLprim value camltk_return (value v)
  15. /* Note: raise_with_string WILL copy the error message */
  16. CAMLprim void tk_error(const char *errmsg)
  17. {
  18. - raise_with_string(*tkerror_exn, errmsg);
  19. + caml_raise_with_string(*tkerror_exn, errmsg);
  20. }
  21. Index: labltk-8.06.2/support/cltkDMain.c
  22. ===================================================================
  23. --- labltk-8.06.2.orig/support/cltkDMain.c
  24. +++ labltk-8.06.2/support/cltkDMain.c
  25. @@ -56,7 +56,7 @@ void invoke_pending_caml_signals (client
  26. /* Rearm timer */
  27. Tk_CreateTimerHandler(SIGNAL_INTERVAL, invoke_pending_caml_signals, NULL);
  28. signal_events = 1;
  29. - leave_blocking_section();
  30. + caml_leave_blocking_section();
  31. }
  32. /* The following is taken from byterun/startup.c */
  33. header_t atom_table[256];
  34. @@ -222,10 +222,10 @@ int Caml_Init(interp)
  35. strcat(f, RCNAME);
  36. if (0 == access(f,R_OK))
  37. if (TCL_OK != Tcl_EvalFile(cltclinterp,f)) {
  38. - stat_free(f);
  39. + caml_stat_free(f);
  40. tk_error(Tcl_GetStringResult(cltclinterp));
  41. };
  42. - stat_free(f);
  43. + caml_stat_free(f);
  44. }
  45. }
  46. Index: labltk-8.06.2/support/cltkEval.c
  47. ===================================================================
  48. --- labltk-8.06.2.orig/support/cltkEval.c
  49. +++ labltk-8.06.2/support/cltkEval.c
  50. @@ -45,7 +45,7 @@ value copy_string_list(int argc, char **
  51. for (i = argc-1; i >= 0; i--) {
  52. oldres = res;
  53. str = tcl_string_to_caml(argv[i]);
  54. - res = alloc(2, 0);
  55. + res = caml_alloc(2, 0);
  56. Field(res, 0) = str;
  57. Field(res, 1) = oldres;
  58. }
  59. @@ -71,7 +71,7 @@ CAMLprim value camltk_tcl_eval(value str
  60. Tcl_ResetResult(cltclinterp);
  61. cmd = caml_string_to_tcl(str);
  62. code = Tcl_Eval(cltclinterp, cmd);
  63. - stat_free(cmd);
  64. + caml_stat_free(cmd);
  65. switch (code) {
  66. case TCL_OK:
  67. @@ -143,8 +143,8 @@ int fill_args (char **argv, int where, v
  68. fill_args(tmpargv,0,Field(v,0));
  69. tmpargv[size] = NULL;
  70. merged = Tcl_Merge(size,(const char *const*)tmpargv);
  71. - for(i = 0; i<size; i++){ stat_free(tmpargv[i]); }
  72. - stat_free((char *)tmpargv);
  73. + for(i = 0; i<size; i++){ caml_stat_free(tmpargv[i]); }
  74. + caml_stat_free((char *)tmpargv);
  75. /* must be freed by stat_free */
  76. argv[where] = (char*)caml_stat_alloc(strlen(merged)+1);
  77. strcpy(argv[where], merged);
  78. @@ -227,10 +227,10 @@ CAMLprim value camltk_tcl_direct_eval(va
  79. /* Free the various things we allocated */
  80. for(i=0; i< size; i ++){
  81. - stat_free((char *) allocated[i]);
  82. + caml_stat_free((char *) allocated[i]);
  83. }
  84. - stat_free((char *)argv);
  85. - stat_free((char *)allocated);
  86. + caml_stat_free((char *)argv);
  87. + caml_stat_free((char *)allocated);
  88. switch (result) {
  89. case TCL_OK:
  90. Index: labltk-8.06.2/support/cltkEvent.c
  91. ===================================================================
  92. --- labltk-8.06.2.orig/support/cltkEvent.c
  93. +++ labltk-8.06.2/support/cltkEvent.c
  94. @@ -49,6 +49,6 @@ CAMLprim value camltk_dooneevent(value f
  95. CheckInit();
  96. - ret = Tk_DoOneEvent(convert_flag_list(flags, event_flag_table));
  97. + ret = Tk_DoOneEvent(caml_convert_flag_list(flags, event_flag_table));
  98. return Val_int(ret);
  99. }
  100. Index: labltk-8.06.2/support/cltkFile.c
  101. ===================================================================
  102. --- labltk-8.06.2.orig/support/cltkFile.c
  103. +++ labltk-8.06.2/support/cltkFile.c
  104. @@ -33,7 +33,7 @@
  105. void FileProc(ClientData clientdata, int mask)
  106. {
  107. - callback2(*handler_code,Val_int(clientdata),Val_int(0));
  108. + caml_callback2(*handler_code,Val_int(clientdata),Val_int(0));
  109. }
  110. /* Map Unix.file_descr values to Tcl file handles */
  111. Index: labltk-8.06.2/support/cltkImg.c
  112. ===================================================================
  113. --- labltk-8.06.2.orig/support/cltkImg.c
  114. +++ labltk-8.06.2/support/cltkImg.c
  115. @@ -47,7 +47,7 @@ CAMLprim value camltk_getimgdata (value
  116. code = Tk_PhotoGetImage(ph,&pib); /* never fails ? */
  117. size = pib.width * pib.height * pib.pixelSize;
  118. - res = alloc_string(size);
  119. + res = caml_alloc_string(size);
  120. /* no holes, default format ? */
  121. if ((pib.pixelSize == 3) &&
  122. Index: labltk-8.06.2/support/cltkMain.c
  123. ===================================================================
  124. --- labltk-8.06.2.orig/support/cltkMain.c
  125. +++ labltk-8.06.2/support/cltkMain.c
  126. @@ -51,11 +51,11 @@ int signal_events = 0; /* do we have a p
  127. void invoke_pending_caml_signals (ClientData clientdata)
  128. {
  129. signal_events = 0;
  130. - enter_blocking_section(); /* triggers signal handling */
  131. + caml_enter_blocking_section(); /* triggers signal handling */
  132. /* Rearm timer */
  133. Tk_CreateTimerHandler(SIGNAL_INTERVAL, invoke_pending_caml_signals, NULL);
  134. signal_events = 1;
  135. - leave_blocking_section();
  136. + caml_leave_blocking_section();
  137. }
  138. /* Now the real Tk stuff */
  139. @@ -77,7 +77,7 @@ CAMLprim value camltk_opentk(value argv)
  140. tmp = Val_unit;
  141. if ( argv == Val_int(0) ){
  142. - failwith("camltk_opentk: argv is empty");
  143. + caml_failwith("camltk_opentk: argv is empty");
  144. }
  145. argv0 = String_val( Field( argv, 0 ) );
  146. @@ -91,7 +91,7 @@ CAMLprim value camltk_opentk(value argv)
  147. /* Register cltclinterp for use in other related extensions */
  148. value *interp = caml_named_value("cltclinterp");
  149. if (interp != NULL)
  150. - Store_field(*interp,0,copy_nativeint((intnat)cltclinterp));
  151. + Store_field(*interp,0,caml_copy_nativeint((intnat)cltclinterp));
  152. }
  153. if (Tcl_Init(cltclinterp) != TCL_OK)
  154. @@ -128,7 +128,7 @@ CAMLprim value camltk_opentk(value argv)
  155. args = Tcl_Merge(argc, (const char *const*)tkargv); /* args must be freed by Tcl_Free */
  156. Tcl_SetVar(cltclinterp, "argv", args, TCL_GLOBAL_ONLY);
  157. Tcl_Free(args);
  158. - stat_free( tkargv );
  159. + caml_stat_free( tkargv );
  160. }
  161. }
  162. if (Tk_Init(cltclinterp) != TCL_OK)
  163. @@ -164,10 +164,10 @@ CAMLprim value camltk_opentk(value argv)
  164. strcat(f, RCNAME);
  165. if (0 == access(f,R_OK))
  166. if (TCL_OK != Tcl_EvalFile(cltclinterp,f)) {
  167. - stat_free(f);
  168. + caml_stat_free(f);
  169. tk_error(Tcl_GetStringResult(cltclinterp));
  170. };
  171. - stat_free(f);
  172. + caml_stat_free(f);
  173. }
  174. }
  175. Index: labltk-8.06.2/support/cltkMisc.c
  176. ===================================================================
  177. --- labltk-8.06.2.orig/support/cltkMisc.c
  178. +++ labltk-8.06.2/support/cltkMisc.c
  179. @@ -41,12 +41,12 @@ CAMLprim value camltk_splitlist (value v
  180. { value res = copy_string_list(argc,argv);
  181. Tcl_Free((char *)argv); /* only one large block was allocated */
  182. /* argv points into utf: utf must be freed after argv are freed */
  183. - stat_free( utf );
  184. + caml_stat_free( utf );
  185. return res;
  186. }
  187. case TCL_ERROR:
  188. default:
  189. - stat_free( utf );
  190. + caml_stat_free( utf );
  191. tk_error(Tcl_GetStringResult(cltclinterp));
  192. }
  193. }
  194. @@ -54,7 +54,7 @@ CAMLprim value camltk_splitlist (value v
  195. /* Copy an OCaml string to the C heap. Should deallocate with stat_free */
  196. char *string_to_c(value s)
  197. {
  198. - int l = string_length(s);
  199. + int l = caml_string_length(s);
  200. char *res = caml_stat_alloc(l + 1);
  201. memmove (res, String_val (s), l);
  202. res[l] = '\0';
  203. Index: labltk-8.06.2/support/cltkTimer.c
  204. ===================================================================
  205. --- labltk-8.06.2.orig/support/cltkTimer.c
  206. +++ labltk-8.06.2/support/cltkTimer.c
  207. @@ -26,7 +26,7 @@
  208. /* Basically the same thing as FileProc */
  209. void TimerProc (ClientData clientdata)
  210. {
  211. - callback2(*handler_code,Val_long(clientdata),Val_int(0));
  212. + caml_callback2(*handler_code,Val_long(clientdata),Val_int(0));
  213. }
  214. CAMLprim value camltk_add_timer(value milli, value cbid)
  215. Index: labltk-8.06.2/support/cltkUtf.c
  216. ===================================================================
  217. --- labltk-8.06.2.orig/support/cltkUtf.c
  218. +++ labltk-8.06.2/support/cltkUtf.c
  219. @@ -76,14 +76,14 @@ value tcl_string_to_caml( const char *s
  220. char *str;
  221. str = utf_to_external( s );
  222. - res = copy_string(str);
  223. - stat_free(str);
  224. + res = caml_copy_string(str);
  225. + caml_stat_free(str);
  226. CAMLreturn(res);
  227. }
  228. #else
  229. char *caml_string_to_tcl(value s){ return string_to_c(s); }
  230. -value tcl_string_to_caml(char *s){ return copy_string(s); }
  231. +value tcl_string_to_caml(char *s){ return caml_copy_string(s); }
  232. #endif
  233. Index: labltk-8.06.2/support/cltkVar.c
  234. ===================================================================
  235. --- labltk-8.06.2.orig/support/cltkVar.c
  236. +++ labltk-8.06.2/support/cltkVar.c
  237. @@ -35,7 +35,7 @@ CAMLprim value camltk_getvar(value var)
  238. stable_var = string_to_c(var);
  239. s = (char *)Tcl_GetVar(cltclinterp,stable_var,
  240. TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG);
  241. - stat_free(stable_var);
  242. + caml_stat_free(stable_var);
  243. if (s == NULL)
  244. tk_error(Tcl_GetStringResult(cltclinterp));
  245. @@ -57,11 +57,11 @@ CAMLprim value camltk_setvar(value var,
  246. utf_contents = caml_string_to_tcl(contents);
  247. s = (char *)Tcl_SetVar(cltclinterp,stable_var, utf_contents,
  248. TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG);
  249. - stat_free(stable_var);
  250. + caml_stat_free(stable_var);
  251. if( s == utf_contents ){
  252. tk_error("camltk_setvar: Tcl_SetVar returned strange result. Call the author of mlTk!");
  253. }
  254. - stat_free(utf_contents);
  255. + caml_stat_free(utf_contents);
  256. if (s == NULL)
  257. tk_error(Tcl_GetStringResult(cltclinterp));
  258. @@ -84,7 +84,7 @@ static char * tracevar(clientdata, inter
  259. Tcl_UntraceVar2(interp, name1, name2,
  260. TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
  261. tracevar, clientdata);
  262. - callback2(*handler_code,Val_int(clientdata),Val_unit);
  263. + caml_callback2(*handler_code,Val_int(clientdata),Val_unit);
  264. return (char *)NULL;
  265. }
  266. @@ -103,10 +103,10 @@ CAMLprim value camltk_trace_var(value va
  267. tracevar,
  268. (ClientData) (Long_val(cbid)))
  269. != TCL_OK) {
  270. - stat_free(cvar);
  271. + caml_stat_free(cvar);
  272. tk_error(Tcl_GetStringResult(cltclinterp));
  273. };
  274. - stat_free(cvar);
  275. + caml_stat_free(cvar);
  276. return Val_unit;
  277. }
  278. @@ -123,6 +123,6 @@ CAMLprim value camltk_untrace_var(value
  279. TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
  280. tracevar,
  281. (ClientData) (Long_val(cbid)));
  282. - stat_free(cvar);
  283. + caml_stat_free(cvar);
  284. return Val_unit;
  285. }
  286. Index: labltk-8.06.2/support/cltkWait.c
  287. ===================================================================
  288. --- labltk-8.06.2.orig/support/cltkWait.c
  289. +++ labltk-8.06.2/support/cltkWait.c
  290. @@ -54,8 +54,8 @@ static void WaitVisibilityProc(clientDat
  291. Tk_DeleteEventHandler(vis->win, VisibilityChangeMask,
  292. WaitVisibilityProc, clientData);
  293. - stat_free((char *)vis);
  294. - callback2(*handler_code,cbid,Val_int(0));
  295. + caml_stat_free((char *)vis);
  296. + caml_callback2(*handler_code,cbid,Val_int(0));
  297. }
  298. /* Sets up a callback upon Visibility of a window */
  299. @@ -65,7 +65,7 @@ CAMLprim value camltk_wait_vis(value win
  300. (struct WinCBData *)caml_stat_alloc(sizeof(struct WinCBData));
  301. vis->win = Tk_NameToWindow(cltclinterp, String_val(win), cltk_mainWindow);
  302. if (vis -> win == NULL) {
  303. - stat_free((char *)vis);
  304. + caml_stat_free((char *)vis);
  305. tk_error(Tcl_GetStringResult(cltclinterp));
  306. };
  307. vis->cbid = Int_val(cbid);
  308. @@ -79,9 +79,9 @@ static void WaitWindowProc(ClientData cl
  309. if (eventPtr->type == DestroyNotify) {
  310. struct WinCBData *vis = clientData;
  311. value cbid = Val_int(vis->cbid);
  312. - stat_free((char *)clientData);
  313. + caml_stat_free((char *)clientData);
  314. /* The handler is destroyed by Tk itself */
  315. - callback2(*handler_code,cbid,Val_int(0));
  316. + caml_callback2(*handler_code,cbid,Val_int(0));
  317. }
  318. }
  319. @@ -92,7 +92,7 @@ CAMLprim value camltk_wait_des(value win
  320. (struct WinCBData *)caml_stat_alloc(sizeof(struct WinCBData));
  321. vis->win = Tk_NameToWindow(cltclinterp, String_val(win), cltk_mainWindow);
  322. if (vis -> win == NULL) {
  323. - stat_free((char *)vis);
  324. + caml_stat_free((char *)vis);
  325. tk_error(Tcl_GetStringResult(cltclinterp));
  326. };
  327. vis->cbid = Int_val(cbid);
  328. Index: labltk-8.06.2/browser/searchpos.ml
  329. ===================================================================
  330. --- labltk-8.06.2.orig/browser/searchpos.ml
  331. +++ labltk-8.06.2/browser/searchpos.ml
  332. @@ -782,7 +782,7 @@ and search_pos_expr ~pos exp =
  333. search_pos_expr exp' ~pos
  334. end;
  335. search_pos_expr exp ~pos
  336. - | Texp_function (_, l, _) ->
  337. + | Texp_function { arg_label = _; param = _ ; cases = l; partial = _; } ->
  338. List.iter l ~f:(search_case ~pos)
  339. | Texp_apply (exp, l) ->
  340. List.iter l ~f:(fun (_, x) -> Misc.may (search_pos_expr ~pos) x);
  341. Index: labltk-8.06.2/jpf/fileselect.ml
  342. ===================================================================
  343. --- labltk-8.06.2.orig/jpf/fileselect.ml
  344. +++ labltk-8.06.2/jpf/fileselect.ml
  345. @@ -55,7 +55,7 @@ let myentry_create p ~variable =
  346. let subshell cmd =
  347. let r,w = pipe () in
  348. match fork () with
  349. - 0 -> close r; dup2 ~src:w ~dst:stdout;
  350. + 0 -> close r; dup2 ~cloexec:false ~src:w ~dst:stdout;
  351. execv ~prog:"/bin/sh" ~args:[| "/bin/sh"; "-c"; cmd |]
  352. | id ->
  353. close w;