summaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/.depend16
-rw-r--r--stdlib/Makefile10
-rw-r--r--stdlib/StdlibModules4
-rw-r--r--stdlib/filename.ml16
-rw-r--r--stdlib/filename.mli13
-rw-r--r--stdlib/printf.mli2
-rw-r--r--stdlib/scanf.ml29
-rw-r--r--stdlib/scanf.mli14
-rw-r--r--stdlib/sys.ml2
9 files changed, 67 insertions, 39 deletions
diff --git a/stdlib/.depend b/stdlib/.depend
index 7bdff04569..715d199417 100644
--- a/stdlib/.depend
+++ b/stdlib/.depend
@@ -5,7 +5,7 @@ genlex.cmi: stream.cmi
moreLabels.cmi: set.cmi map.cmi hashtbl.cmi
oo.cmi: camlinternalOO.cmi
parsing.cmi: obj.cmi lexing.cmi
-printf.cmi: buffer.cmi
+printf.cmi: obj.cmi buffer.cmi
random.cmi: nativeint.cmi int64.cmi int32.cmi
rtype.cmi: format.cmi
weak.cmi: hashtbl.cmi
@@ -71,18 +71,28 @@ oo.cmo: camlinternalOO.cmi oo.cmi
oo.cmx: camlinternalOO.cmx oo.cmi
parsing.cmo: obj.cmi lexing.cmi array.cmi parsing.cmi
parsing.cmx: obj.cmx lexing.cmx array.cmx parsing.cmi
+pcre_lex.cmo: string.cmi printf.cmi list.cmi lexing.cmi buffer.cmi array.cmi \
+ pcre_lex.cmi
+pcre_lex.cmx: string.cmx printf.cmx list.cmx lexing.cmx buffer.cmx array.cmx \
+ pcre_lex.cmi
pervasives.cmo: pervasives.cmi
pervasives.cmx: pervasives.cmi
printexc.cmo: printf.cmi obj.cmi printexc.cmi
printexc.cmx: printf.cmx obj.cmx printexc.cmi
-printf.cmo: string.cmi obj.cmi list.cmi char.cmi buffer.cmi printf.cmi
-printf.cmx: string.cmx obj.cmx list.cmx char.cmx buffer.cmx printf.cmi
+printf.cmo: string.cmi obj.cmi list.cmi char.cmi buffer.cmi array.cmi \
+ printf.cmi
+printf.cmx: string.cmx obj.cmx list.cmx char.cmx buffer.cmx array.cmx \
+ printf.cmi
queue.cmo: obj.cmi queue.cmi
queue.cmx: obj.cmx queue.cmi
random.cmo: string.cmi pervasives.cmi nativeint.cmi int64.cmi int32.cmi \
digest.cmi char.cmi array.cmi random.cmi
random.cmx: string.cmx pervasives.cmx nativeint.cmx int64.cmx int32.cmx \
digest.cmx char.cmx array.cmx random.cmi
+regexp.cmo: string.cmi printf.cmi list.cmi lexing.cmi buffer.cmi array.cmi \
+ regexp.cmi
+regexp.cmx: string.cmx printf.cmx list.cmx lexing.cmx buffer.cmx array.cmx \
+ regexp.cmi
rtype.cmo: string.cmi obj.cmi list.cmi format.cmi char.cmi builtintypes.cmi \
rtype.cmi
rtype.cmx: string.cmx obj.cmx list.cmx format.cmx char.cmx builtintypes.cmx \
diff --git a/stdlib/Makefile b/stdlib/Makefile
index b1134f64b4..70710fe129 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -23,6 +23,7 @@ OPTCOMPILER=../ocamlopt
CAMLOPT=$(RUNTIME) $(OPTCOMPILER)
OPTCOMPFLAGS=-warn-error Ag -nostdlib
CAMLDEP=../boot/ocamlrun ../tools/ocamldep
+CAMLLEX=../boot/ocamlrun ../boot/ocamllex
OBJS=builtintypes.cmo pervasives.cmo $(OTHERS)
OTHERS=array.cmo list.cmo char.cmo string.cmo sys.cmo \
@@ -36,7 +37,7 @@ OTHERS=array.cmo list.cmo char.cmo string.cmo sys.cmo \
camlinternalOO.cmo oo.cmo camlinternalMod.cmo \
genlex.cmo weak.cmo \
lazy.cmo filename.cmo complex.cmo \
- rtype.cmo \
+ rtype.cmo regexp.cmo \
arrayLabels.cmo listLabels.cmo stringLabels.cmo moreLabels.cmo stdLabels.cmo
# make MODE=migration when you want to port ocaml to the latest ocaml-cvs
@@ -102,6 +103,11 @@ camlheader camlheader_ur: header.c ../config/Makefile
clean::
rm -f camlheader camlheader_ur
+regexp.cmo: regexp.ml
+
+regexp.ml: regexp.mll
+ $(CAMLLEX) $<
+
.SUFFIXES: .mli .ml .cmi .cmo .cmx .p.cmx
.mli.cmi:
@@ -137,5 +143,5 @@ clean::
include .depend
-depend:
+depend: regexp.ml
$(CAMLDEP) *.mli *.ml > .depend
diff --git a/stdlib/StdlibModules b/stdlib/StdlibModules
index 8b71501871..80d1466677 100644
--- a/stdlib/StdlibModules
+++ b/stdlib/StdlibModules
@@ -47,4 +47,6 @@ STDLIB_MODULES=\
sys \
weak \
rtype \
- builtintypes
+ builtintypes \
+ regexp
+
diff --git a/stdlib/filename.ml b/stdlib/filename.ml
index 62cb63951d..d6c24fc1b3 100644
--- a/stdlib/filename.ml
+++ b/stdlib/filename.ml
@@ -40,7 +40,7 @@ module Unix = struct
String.length name >= String.length suff &&
String.sub name (String.length name - String.length suff)
(String.length suff) = suff
- let temporary_directory =
+ let temp_dir_name =
try Sys.getenv "TMPDIR" with Not_found -> "/tmp"
let quote = generic_quote "'\\''"
end
@@ -71,7 +71,7 @@ module Win32 = struct
(let s = String.sub name (String.length name - String.length suff)
(String.length suff) in
String.lowercase s = String.lowercase suff)
- let temporary_directory =
+ let temp_dir_name =
try Sys.getenv "TEMP" with Not_found -> "."
let quote s =
let l = String.length s in
@@ -98,28 +98,28 @@ module Cygwin = struct
let is_relative = Win32.is_relative
let is_implicit = Win32.is_implicit
let check_suffix = Win32.check_suffix
- let temporary_directory = Unix.temporary_directory
+ let temp_dir_name = Unix.temp_dir_name
let quote = Unix.quote
end
let (current_dir_name, parent_dir_name, dir_sep, is_dir_sep, rindex_dir_sep,
- is_relative, is_implicit, check_suffix, temporary_directory, quote) =
+ is_relative, is_implicit, check_suffix, temp_dir_name, quote) =
match Sys.os_type with
"Unix" ->
(Unix.current_dir_name, Unix.parent_dir_name, Unix.dir_sep,
Unix.is_dir_sep, Unix.rindex_dir_sep,
Unix.is_relative, Unix.is_implicit, Unix.check_suffix,
- Unix.temporary_directory, Unix.quote)
+ Unix.temp_dir_name, Unix.quote)
| "Win32" ->
(Win32.current_dir_name, Win32.parent_dir_name, Win32.dir_sep,
Win32.is_dir_sep, Win32.rindex_dir_sep,
Win32.is_relative, Win32.is_implicit, Win32.check_suffix,
- Win32.temporary_directory, Win32.quote)
+ Win32.temp_dir_name, Win32.quote)
| "Cygwin" ->
(Cygwin.current_dir_name, Cygwin.parent_dir_name, Cygwin.dir_sep,
Cygwin.is_dir_sep, Cygwin.rindex_dir_sep,
Cygwin.is_relative, Cygwin.is_implicit, Cygwin.check_suffix,
- Cygwin.temporary_directory, Cygwin.quote)
+ Cygwin.temp_dir_name, Cygwin.quote)
| _ -> assert false
let concat dirname filename =
@@ -164,7 +164,7 @@ let prng = Random.State.make_self_init ();;
let temp_file_name prefix suffix =
let rnd = (Random.State.bits prng) land 0xFFFFFF in
- concat temporary_directory (Printf.sprintf "%s%06x%s" prefix rnd suffix)
+ concat temp_dir_name (Printf.sprintf "%s%06x%s" prefix rnd suffix)
;;
let temp_file prefix suffix =
diff --git a/stdlib/filename.mli b/stdlib/filename.mli
index 9b98bc74f7..b379352c1d 100644
--- a/stdlib/filename.mli
+++ b/stdlib/filename.mli
@@ -77,10 +77,7 @@ val temp_file : string -> string -> string
(readable and writable only by the file owner). The file is
guaranteed to be different from any other file that existed when
[temp_file] was called.
- Under Unix, the temporary directory is [/tmp] by default; if set,
- the value of the environment variable [TMPDIR] is used instead.
- Under Windows, the name of the temporary directory is the
- value of the environment variable [TEMP], or [C:\temp] by default. *)
+*)
val open_temp_file :
?mode: open_flag list -> string -> string -> string * out_channel
@@ -93,6 +90,14 @@ val open_temp_file :
It can contain one or several of [Open_append], [Open_binary],
and [Open_text]. The default is [[Open_text]] (open in text mode). *)
+val temp_dir_name : string
+(** The name of the temporary directory:
+ Under Unix, the value of the [TMPDIR] environment variable, or "/tmp"
+ if the variable is not set.
+ Under Windows, the value of the [TEMP] environment variable, or "."
+ if the variable is not set.
+*)
+
val quote : string -> string
(** Return a quoted version of a file name, suitable for use as
one argument in a shell command line, escaping all shell
diff --git a/stdlib/printf.mli b/stdlib/printf.mli
index ecf15a2b5b..fe4b8b2f82 100644
--- a/stdlib/printf.mli
+++ b/stdlib/printf.mli
@@ -72,7 +72,7 @@ val fprintf : out_channel -> ('a, out_channel, unit) format -> 'a
[out_channel -> unit]) and apply it to [outchan].
- [\{ fmt %\}]: convert a format string argument. The argument must
have the same type as the internal format string [fmt].
- - [\( fmt %\)]: format string substitution. Takes a format string
+ - [( fmt %)]: format string substitution. Takes a format string
argument and substitutes it to the internal format string [fmt]
to print following arguments. The argument must have the same
type as [fmt].
diff --git a/stdlib/scanf.ml b/stdlib/scanf.ml
index 5070e30baf..eda801c2bc 100644
--- a/stdlib/scanf.ml
+++ b/stdlib/scanf.ml
@@ -958,17 +958,17 @@ let kscanf ib ef fmt f =
| 'B' | 'b' ->
let _x = scan_bool max ib in
scan_fmt (stack f (token_bool ib)) (i + 1)
- | 'l' | 'n' | 'L' as conv ->
+ | 'l' | 'n' | 'L' as typ ->
let i = i + 1 in
- if i > lim then scan_fmt (stack f (get_count conv ib)) i else begin
+ if i > lim then scan_fmt (stack f (get_count typ ib)) i else begin
match fmt.[i] with
| 'd' | 'i' | 'o' | 'u' | 'x' | 'X' as conv ->
let _x = scan_int_conv conv max ib in
- begin match conv with
+ begin match typ with
| 'l' -> scan_fmt (stack f (token_int32 conv ib)) (i + 1)
| 'n' -> scan_fmt (stack f (token_nativeint conv ib)) (i + 1)
| _ -> scan_fmt (stack f (token_int64 conv ib)) (i + 1) end
- | c -> scan_fmt (stack f (get_count conv ib)) i end
+ | c -> scan_fmt (stack f (get_count typ ib)) i end
| 'N' as conv ->
scan_fmt (stack f (get_count conv ib)) (i + 1)
| '!' ->
@@ -1000,7 +1000,7 @@ let kscanf ib ef fmt f =
let _x = scan_String max ib in
let rf = token_string ib in
if not (compatible_format_type mf rf)
- then format_mismatch rf mf ib else
+ then format_mismatch rf mf ib else
if conv = '{' then scan_fmt (stack f rf) j else
let nf = scan_fmt (Obj.magic rf) 0 in
scan_fmt (stack f nf) j
@@ -1029,15 +1029,18 @@ let sscanf s = bscanf (Scanning.from_string s);;
let scanf fmt = bscanf Scanning.stdib fmt;;
-let bscanf_format ib fmt2 f =
+let bscanf_format ib fmt f =
+ let fmt = format_to_string fmt in
let fmt1 = ignore (scan_String max_int ib); token_string ib in
- let fmt2 = format_to_string fmt2 in
- if compatible_format_type fmt1 fmt2
- then let fresh_fmt = String.copy fmt1 in f (string_to_format fresh_fmt)
- else format_mismatch fmt1 fmt2 ib;;
+ if not (compatible_format_type fmt1 fmt) then
+ format_mismatch fmt1 fmt ib else
+ let fresh_fmt1 = String.copy fmt1 in
+ f (string_to_format fresh_fmt1);;
let sscanf_format s fmt =
let fmt = format_to_string fmt in
- if compatible_format_type s fmt
- then let fresh_fmt = String.copy s in string_to_format fresh_fmt
- else bad_input (format_mismatch_err s fmt);;
+ let fmt1 = s in
+ if not (compatible_format_type fmt1 fmt) then
+ bad_input (format_mismatch_err fmt1 fmt) else
+ let fresh_fmt1 = String.copy fmt1 in
+ string_to_format fresh_fmt1;;
diff --git a/stdlib/scanf.mli b/stdlib/scanf.mli
index 4f830e67c9..adf700d1a0 100644
--- a/stdlib/scanf.mli
+++ b/stdlib/scanf.mli
@@ -258,12 +258,14 @@ val kscanf :
val bscanf_format :
Scanning.scanbuf -> ('a, 'b, 'c, 'd) format4 ->
(('a, 'b, 'c, 'd) format4 -> 'e) -> 'e;;
-(** [bscanf_format ib fmt f] reads a [format] argument to the format
- specified by the second argument. The [format] argument read in
- buffer [ib] must have the same type as [fmt]. *)
+
+(** [bscanf_format ib fmt f] reads a format string token in buffer [ib],
+ according to the format string [fmt], and applies the function [f] to the
+ resulting format string value.
+ Raises [Scan_failure] if the format string value read has not the same type
+ as [fmt]. *)
val sscanf_format :
string -> ('a, 'b, 'c, 'd) format4 -> ('a, 'b, 'c, 'd) format4;;
-(** [sscanf_format ib fmt f] reads a [format] argument to the format
- specified by the second argument and returns it. The [format]
- argument read in string [s] must have the same type as [fmt]. *)
+(** Same as {!Scanf.bscanf_format}, but converts the given string to a format
+ string. *)
diff --git a/stdlib/sys.ml b/stdlib/sys.ml
index ddc3c0a852..8a0984205b 100644
--- a/stdlib/sys.ml
+++ b/stdlib/sys.ml
@@ -78,4 +78,4 @@ let catch_break on =
(* OCaml version string, must be in the format described in sys.mli. *)
-let ocaml_version = "3.09.0";;
+let ocaml_version = "3.09.1";;