Commit a1c598a2 authored by Akim Demaille's avatar Akim Demaille
Browse files

2004-07-06 Arnaud Fabre <fabre_a@epita.fr>

	* src/RuntimeString.hs, src/Runtime.hs (stringEqual): New builtin,
	a better implementation for string equality than strcmp.
parent 3f8a21d1
2004-07-06 Arnaud Fabre <fabre_a@epita.fr>
* src/RuntimeString.hs, src/Runtime.hs (stringEqual): New builtin,
a better implementation for string equality than strcmp.
2004-06-28 Clement Vasseur <clement.vasseur@lrde.epita.fr>
* debian/Makefile.am (deb): Do not sign the source package and the
......
-*- text -*-
New in 0.21a:
* New builtin stringEqual
* The parser is shipped, so that happy is not required (unless you
change it!).
New in 0.21:
Released 2003-10-29.
......@@ -55,7 +58,7 @@ FIXME: Complete from ChangeLog.
--
Copyright (C) 2003 Laboratoire de Recherche et Développement de l'EPITA
Copyright (C) 2003, 2004 Laboratoire de Recherche et Développement de l'EPITA
This file is part of HAVM. This program is free software; you can
redistribute it and/or modify it under the terms of the GNU General
......@@ -71,3 +74,9 @@ You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
Local Variables:
mode: outline
ispell-local-dictionary: "american"
End:
People who contributed to Havm:
* Arnaud Fabre fabre_a@epita.fr
- Builtin stringEqual
Local Variables:
mode: outline
ispell-local-dictionary: "american"
End:
......@@ -15,10 +15,10 @@
# the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA.
AC_PREREQ([2.57])
AC_PREREQ([2.59])
AC_INIT([HAVM], [0.21a], [anisko_r@epita.fr])
AC_CONFIG_AUX_DIR([config])
AM_INIT_AUTOMAKE([1.7.8 dist-bzip2])
AM_INIT_AUTOMAKE([1.8.5 dist-bzip2])
AC_CHECK_TOOL([GHC], [ghc], [no])
if test $GHC = no; then
......
......@@ -78,6 +78,13 @@ and 1 otherwise.
@end deffn
@end ifset
@ifset havm
@deffn int stringEqual (@var{a}: string, @var{b}: string)
Test if @var{a} and @var{b} are equal: return 1 if @var{a} equal @var{b}, 0 otherwise.
The same effect can be obtained with @code{strcmp(@var{a}, @var{b}) = 0}.
@end deffn
@end ifset
@deffn string substring (@var{string}: string, @var{first}: int, @var{length}: int)
Return a string composed of the characters of @var{string} starting at
the @var{first} character (0 being the origin), and composed of
......
......@@ -9,7 +9,7 @@ import RuntimeInt (rtNot)
import RuntimeChar (rtChr, rtOrd)
import RuntimeInput (rtGetChar)
import RuntimePrint (rtPrint, rtPrintInt)
import RuntimeString (rtSize, rtConcat, rtCompare, rtSubstring)
import RuntimeString (rtSize, rtConcat, rtCompare, rtStringEqual, rtSubstring)
import RuntimeSystem (rtExit, rtFlush, rtMalloc, rtInitArray)
rtLib :: FiniteMap String ([Res] -> Mnd Res)
......@@ -28,4 +28,5 @@ rtLib = listToFM [("chr", rtChr),
("printint", rtPrintInt),
("size", rtSize),
("strcmp", rtCompare),
("stringEqual", rtStringEqual),
("substring", rtSubstring)]
module RuntimeString (rtSize, rtConcat, rtCompare, rtSubstring)
module RuntimeString (rtSize, rtConcat, rtCompare, rtStringEqual, rtSubstring)
where
import Monad (Mnd, mfetch, mstore, mreserve)
......@@ -52,6 +52,20 @@ rtCompare [IntRes str1, IntRes str2] =
rtCompare _ =
error "strcmp: invalid arguments"
rtStringEqual :: [Res] -> Mnd Res
rtStringEqual [IntRes str1, IntRes str2] =
rtStringEqual' str1 str2
where rtStringEqual' str1 str2 =
do char1 <- mfetch str1
char2 <- mfetch str2
case (char1 == 0 && char2 == 0, char1 - char2) of
(True, _) -> return $ IntRes 1
(False, 0) -> rtStringEqual' (str1 + 4) (str2 + 4)
(False, n) -> return $ IntRes 0
rtStringEqual _ =
error "stringEqual: invalid arguments"
rtSubstring :: [Res] -> Mnd Res
rtSubstring [s@(IntRes string), IntRes from, IntRes len] =
do (IntRes size) <- rtSize [s]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment