Commit Graph

58 Commits (5825ef8b076677649d902643d57a5364a313d2b2)

Author SHA1 Message Date
Damien Doligez 4b9e196d52 restore compatibility for String.{unsafe_set,create,fill} 2016-12-14 13:20:17 +00:00
Hongbo Zhang 026248378b change primitive names back to %string_safe_set 2016-12-14 13:20:12 +00:00
David Allsopp 029bcc1b65 Optimised versions of _opt String functions
Provided by Gabriel Scherer.
2016-12-14 13:14:21 +00:00
David Allsopp a0ce2a22b7 Merge PR#801 into 4.04 2016-12-14 13:14:21 +00:00
Hongbo Zhang 8fef6b380d avoid to from bytes conversion for some string operations: such conversion is expensive in Backends which has different representation for string and bytes 2016-12-14 13:14:21 +00:00
Alain Frisch 69263a9893 Option-returning variants of stdlib functions (#885)
Provide an xxx_opt alternative for functions raising Not_found
and many instances of Failure/Invalid_arg.

The only exception is the rarely used Buffer.add_substitute, where
the [Not_found] can really be interpreted as an error condition.

Most new functions are implemented directly (instead of wrapping the
raising version).  This is for performance reasons and also to avoid
destroying the stacktrace (if the function is used in an exception
handler).  One could instead implement the raising versions on top of
the new functions, but there might be a small penalty.
2016-11-07 16:11:35 +00:00
yallop 7a7a7d81c1 Fix an overflow bug in String.concat (#833)
Fix an overflow bug in String.concat and make the function faster.
2016-10-04 14:01:05 +02:00
Hongbo Zhang 82d2375cc6 apply changes to stdlib and test suite 2016-08-07 11:19:26 -04:00
alainfrisch d88ac0ac7d Rename String.split to String.split_on_char (#626). 2016-07-11 14:50:56 +02:00
alainfrisch 4c979b80a8 String.split 2016-07-09 23:05:25 +02:00
Damien Doligez 5401ce8473 Update headers for the new license.
Remains to be done: remove all headers in testsuite/tests.
2016-02-18 16:59:16 +01:00
Jérémie Dimino 62b89a3a5c Replace uses of "noalloc" by [@@noalloc]
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16455 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-06 10:58:22 +00:00
Pierre Weis 24b8bf59f9 Escaping " in character constants
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16420 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-09-13 13:17:23 +00:00
Damien Doligez e60a2db81c PR#6521: {Bytes,Char,String}.escaped are locale-dependent
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15901 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-03-11 18:41:15 +00:00
Gabriel Scherer bcaa58a035 PR6694: Deprecate Latin-1 string manipulation functions.
Also, add documentation for the US-ASCII variants.

From: Peter Zotov <whitequark@whitequark.org>

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15729 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-12-21 11:46:18 +00:00
Gabriel Scherer a533618a7a PR6695: Add ASCII counterparts to case-mapping functions.
This updates Char, String, Bytes in the stdlib.

For now, they are hidden from documentation and are only for
internal compiler use.

From: Peter Zotov <whitequark@whitequark.org>

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15726 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-12-21 11:46:10 +00:00
Gabriel Scherer 85b75d7963 PR#6494: Add equal function in modules Big_int, Bytes, Char, Digest, Int32, Int64, Nativeint, Num and String
(Romain Calascibetta)

From: Romain Calascibetta <romain.calascibetta@gmail.com>

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15725 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-12-21 11:46:08 +00:00
Damien Doligez cbfe627f92 merge changes from branch 4.02 from branching (rev 14852) to 4.02.0+rc1 (rev 15121)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15125 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-08-22 13:45:02 +00:00
Gabriel Scherer 2c4b259f60 remove the Obj.magic from the string.ml implementation
It is important not to assume that String.t and Bytes.t will always
share the same representation. Using Obj.magic to convert between
functions would give a very bad example to users considering
a migration, which are very quick to imitate any moral turpitude found
in the standard library.

An unfortunate consequence of the change is the duplication of
String.concat code; other designs would be possible to share more
implementation details between Bytes and String (eg. defined
factorized operations on both in a shared internal module), but if we
consider that String representation may evolve in the future this
coincidence of implementation is really a temporary coindence rather
than an definitive duplication.

I checked that all the small functions introduced are marked as
inlinable. In the case of coercions like this, we could even have the
compiler recognize eta-expansions of the identity function and turn
them into simple rebindings.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15060 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-08-06 16:31:52 +00:00
Gabriel Scherer b7dd6d2c91 implement {Bytes,String}.mapi
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15058 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-08-06 15:57:38 +00:00
Alain Frisch aeead32662 #6500: add String.init, Bytes.init, Labels couterparts, Stream.of_byte. (Cherry-picked from 15029 on 4.02.)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15030 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-07-28 13:29:50 +00:00
Damien Doligez 5b8df637d2 merge branch "safe-string"
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14705 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-04-29 11:56:17 +00:00
Fabrice Le Fessant 504e86d722 Revert r13746 (demanded by Xavier)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13748 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-06-05 17:54:20 +00:00
Fabrice Le Fessant 1f9f68a328 Add String.split and String.cut_at from Misc
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13746 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-06-05 13:27:05 +00:00
Damien Doligez def31744f9 remove all $Id keywords
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13013 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-10-15 17:50:56 +00:00
Damien Doligez 6c24f4f90b merge version 3.12 from 3.12.1 to r12205
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12210 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-03-08 19:52:03 +00:00
Damien Doligez 3b507dd1aa renaming of Objective Caml to OCaml and cleanup of copyright headers
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11156 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-07-27 14:17:02 +00:00
Damien Doligez c91db736b1 merge changes from 3.12.0 to 3.12.1
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11123 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-07-20 09:17:07 +00:00
Alain Frisch f537ba28b0 Adding String.iteri.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10762 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-11-05 08:15:36 +00:00
Damien Doligez 04f20f8b83 PR#4582, PR#4637 - revert functions to old behaviour
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9132 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2008-11-18 10:29:26 +00:00
Pierre Weis 30b2585b6c Correction bug #4582 sur index_from et al. Tests a venir. Invariants itou.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8924 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2008-07-22 11:29:00 +00:00
Pierre Weis 8c9e42862c The functions that escape characters ([escaped]) now handle characters
consistently with the compiler's lexer (PR#4220).


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8189 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2007-04-16 11:06:51 +00:00
Xavier Leroy 6ce858f4a8 Ensure type specialization for the 'compare' functions (PR#4194)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7818 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2007-01-30 09:34:36 +00:00
Damien Doligez aa46693dc5 depollution (PR#1914, PR#1956)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6023 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-12-16 18:09:44 +00:00
Xavier Leroy ede12e6163 Remplacement des tests ofs + len > length par ofs > len - length, pour eviter le debordement lors de l'addition (PR#1229)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4993 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-07-12 09:47:54 +00:00
Xavier Leroy 9e3dc0cd97 Ajout d'un type t et d'une fonction compare pour permettre l'utilisation de ce module avec la signature OrderedType
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4948 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-06-26 09:13:59 +00:00
Xavier Leroy 7501784c80 MAJ en-tetes pour mentionner la 'special exception' sur la LGPL
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4144 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2001-12-07 13:41:02 +00:00
Jacques Garrigue ea299bbbc1 passage aux labels stricts
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3696 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2001-09-06 08:52:32 +00:00
Pierre Weis 2116da4220 Getting rid of obsolete boolean operators & and or
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3359 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2000-12-28 13:07:42 +00:00
Damien Doligez 7767bb2ef1 petit bug de rindex_from
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2755 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2000-01-12 15:53:18 +00:00
Xavier Leroy cc0f32b054 Changement de la licence
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2553 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1999-11-17 18:59:06 +00:00
Xavier Leroy 4d4933677d Tests de borne moins severes dans contains
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2317 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1999-03-01 20:59:54 +00:00
Xavier Leroy 5038f3cdb6 Ajout de Pervasives.ignore. List.remove -> List.remove_ass*
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2304 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1999-02-24 15:21:50 +00:00
Pierre Weis d5a3eb307b Correction de la fonction String.contains lorsque la chaîne argument
est vide.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2273 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1999-02-12 08:08:57 +00:00
Pierre Weis 4508b80100 Éviction des alertes des séquences: ajout de fonctions rendant unit ou
de prédicats dans le cas où l'on appelait une fonction pour savoir si
ça pouvait marcher en capturant une exception.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2172 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1998-11-12 14:53:46 +00:00
Xavier Leroy b993d10bd1 Ajout tests de bornes dans *index*
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1838 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-12-09 09:12:05 +00:00
Xavier Leroy 55bb148630 Retour au code d'origine pour List.iter. Je veux un seul test par
iteration, dammit.
Suppression de dependances spurieuses dans Array et String.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1756 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-11-06 17:28:16 +00:00
Xavier Leroy 32664ffdc0 Ajout de String.[r]index_from, Obj.[un]marshal
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1744 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-10-28 13:17:11 +00:00
Xavier Leroy 56e001e1c4 Array.iteri Array.mapi Array.fold_left Array.fold_right
String.index String.rindex
Filename: utiliser String.rindex
Genlex: erreur dans doc


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1741 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-10-24 15:54:07 +00:00
Xavier Leroy 81cb9ac7c0 Typo dans lowercase
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1379 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-03-13 14:41:27 +00:00