From 8b8b730d3ba98d6c9e4e6274844641043b5fefbb Mon Sep 17 00:00:00 2001
From: Sébastien Dailly <sebastien@dailly.me>
Date: Mon, 17 Mar 2025 09:11:25 +0100
Subject: Moved the syntax module in its own library

---
 lib/csv/csv.ml       | 30 -----------------------------
 lib/csv/dataType.ml  | 23 -----------------------
 lib/csv/dataType.mli |  9 ---------
 lib/csv/dune         |  7 -------
 lib/csv/format.c     | 53 ----------------------------------------------------
 5 files changed, 122 deletions(-)
 delete mode 100644 lib/csv/csv.ml
 delete mode 100644 lib/csv/dataType.ml
 delete mode 100644 lib/csv/dataType.mli
 delete mode 100755 lib/csv/dune
 delete mode 100644 lib/csv/format.c

(limited to 'lib/csv')

diff --git a/lib/csv/csv.ml b/lib/csv/csv.ml
deleted file mode 100644
index db7329d..0000000
--- a/lib/csv/csv.ml
+++ /dev/null
@@ -1,30 +0,0 @@
-open StdLabels
-
-type t = int
-
-let column_of_char = function
-  | 'A' .. 'Z' as c -> Char.code c - (Char.code 'A' - 1)
-  | 'a' .. 'z' as c -> Char.code c - (Char.code 'a' - 1)
-  | c -> raise (Invalid_argument ("column: " ^ Char.escaped c))
-
-let column_of_string : string -> int =
- fun s ->
-  String.fold_left s ~init:0 ~f:(fun value c -> (value * 26) + column_of_char c)
-
-(** Accumulate the remaining for the successives divisions in a list. *)
-let rec _to_char ~b i =
-  if i > 0 then
-    let res = i mod 26 in
-    let res = if res = 0 then 26 else res in
-
-    let c = char_of_int @@ (res + 64) in
-    (* The modulo is accumulated in the list head, which is the expected
-       sequence *)
-    let b = c :: b in
-
-    _to_char ~b @@ ((i - res) / 26)
-  else b
-
-let column_to_string i =
-  let res = _to_char ~b:[] i in
-  List.to_seq res |> String.of_seq
diff --git a/lib/csv/dataType.ml b/lib/csv/dataType.ml
deleted file mode 100644
index 6bf85ae..0000000
--- a/lib/csv/dataType.ml
+++ /dev/null
@@ -1,23 +0,0 @@
-external show_float : string -> float -> string = "show_float"
-
-let match_date = Re.Str.regexp {|[0-9]+/[0-9]+/[0-9]+|}
-
-type t =
-  | Null
-  | Error of string
-  | Content of string
-  | Integer of int
-  | Float of float
-
-let to_string locale = function
-  | Null -> ""
-  | Error s -> s
-  | Integer i -> string_of_int i
-  | Float f -> show_float locale f
-  | Content c -> (
-      match String.starts_with ~prefix:"0" c with
-      | false -> c
-      | true ->
-          (* If the string is a date, do not escape it *)
-          if Re.Str.string_match match_date c 0 then c
-          else String.concat "" [ "=\""; c; "\"" ])
diff --git a/lib/csv/dataType.mli b/lib/csv/dataType.mli
deleted file mode 100644
index df5edf1..0000000
--- a/lib/csv/dataType.mli
+++ /dev/null
@@ -1,9 +0,0 @@
-type t =
-  | Null
-  | Error of string
-  | Content of string
-  | Integer of int
-  | Float of float
-
-val to_string : string -> t -> string
-(** [to_string locale value] Format the text using the given locale *)
diff --git a/lib/csv/dune b/lib/csv/dune
deleted file mode 100755
index 2cdc868..0000000
--- a/lib/csv/dune
+++ /dev/null
@@ -1,7 +0,0 @@
-(library
- (name importCSV)
- (libraries 
-   re
- )
- (foreign_stubs (language c) (names format))
-)
diff --git a/lib/csv/format.c b/lib/csv/format.c
deleted file mode 100644
index 1394dc7..0000000
--- a/lib/csv/format.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <stdio.h>
-#include <locale.h>
-#include <caml/memory.h>
-#include <caml/alloc.h>
-
-#ifndef _vscprintf
-/* For some reason, MSVC fails to honour this #ifndef. */
-/* Hence function renamed to _vscprintf_so(). */
-int _vscprintf_so(const char * format, va_list pargs) {
-    int retval;
-    va_list argcopy;
-    va_copy(argcopy, pargs);
-    retval = vsnprintf(NULL, 0, format, argcopy);
-    va_end(argcopy);
-    return retval;}
-#endif // _vscprintf
-
-#ifndef vasprintf
-int vasprintf(char **strp, const char *fmt, va_list ap) {
-    int len = _vscprintf_so(fmt, ap);
-    if (len == -1) return -1;
-    char *str = malloc((size_t) len + 1);
-    if (!str) return -1;
-    int r = vsnprintf(str, len + 1, fmt, ap); /* "secure" version of vsprintf */
-    if (r == -1) return free(str), -1;
-    *strp = str;
-    return r;}
-#endif // vasprintf
-
-#ifndef asprintf
-int asprintf(char *strp[], const char *fmt, ...) {
-    va_list ap;
-    va_start(ap, fmt);
-    int r = vasprintf(strp, fmt, ap);
-    va_end(ap);
-    return r;}
-#endif // asprintf
-
-CAMLprim value show_float(value locale_param, value float_param )
-{
-    CAMLparam2(locale_param, float_param );
-    CAMLlocal1( ml_data );
-    double f = Double_val(float_param);
-    char* raw_data;
-    const char *s;
-    s = String_val(locale_param);
-    const char *saved_locale = setlocale(LC_NUMERIC, s);
-    int data_len = asprintf(&raw_data, "%f", f);
-    setlocale(LC_NUMERIC, saved_locale);
-    ml_data = caml_copy_string( raw_data );
-    free(raw_data);
-    CAMLreturn( ml_data );
-}
-- 
cgit v1.2.3