Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | (* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh |
2 | * Jagannathan, and Stephen Weeks. | |
3 | * Copyright (C) 1997-2000 NEC Research Institute. | |
4 | * | |
5 | * MLton is released under a BSD-style license. | |
6 | * See the file MLton-LICENSE for details. | |
7 | *) | |
8 | ||
9 | (* Primitive names are special -- see atoms/prim.fun. *) | |
10 | ||
11 | structure Primitive = struct | |
12 | ||
13 | open Primitive | |
14 | ||
15 | (* NullString is used for strings that must be passed to C and hence must be | |
16 | * null terminated. | |
17 | *) | |
18 | structure NullString8 :> | |
19 | sig | |
20 | type t | |
21 | ||
22 | val empty: t | |
23 | val fromString: String8.string -> t | |
24 | end = | |
25 | struct | |
26 | type t = String8.string | |
27 | ||
28 | fun fromString s = | |
29 | if #"\000" = Vector.subUnsafe (s, SeqIndex.- (Vector.length s, 1)) | |
30 | then s | |
31 | else raise Exn.Fail8 "NullString.fromString" | |
32 | ||
33 | val empty = fromString "\000" | |
34 | end | |
35 | structure NullString8Array = struct type t = NullString8.t array end | |
36 | ||
37 | end |