Commit a4835ae2 authored by rrt's avatar rrt
Browse files

[project @ 2001-02-28 10:45:40 by rrt]

Various bits of modernisation; in particular, in cg026, do the Char test the
same way as all the others, rather than in a way that fails on Windows.
parent dcf5ea1a
#-----------------------------------------------------------------------------
# $Id: Makefile,v 1.16 2000/12/12 17:21:40 simonmar Exp $
# $Id: Makefile,v 1.17 2001/02/28 10:45:40 rrt Exp $
TOP = ../..
include $(TOP)/mk/boilerplate.mk
......@@ -18,7 +18,7 @@ SRC_HC_OPTS += -dcore-lint
cg012_HC_OPTS = -fglasgow-exts
cg015_HC_OPTS = -fglasgow-exts
cg018_HC_OPTS = -fglasgow-exts
cg025_HC_OPTS = -package lang
cg025_HC_OPTS = -package lang -package text
cg026_HC_OPTS = -package lang -fglasgow-exts -fvia-C
cg029_HC_OPTS = -package lang -fglasgow-exts
cg030_HC_OPTS = -package lang -fglasgow-exts
......
......@@ -4,10 +4,13 @@
import IO
import System
import IOExts (trace)
import RegexString
import Maybe
main = do
prog <- getProgName
hPutStr stderr (shows prog "\n")
let Just (name:_) = matchRegex (mkRegex ".*(cg025.bin)") prog
hPutStr stderr (shows name "\n")
args <- getArgs
hPutStr stderr (shows args "\n")
path <- getEnv "PATH"
......
......@@ -7,10 +7,13 @@ GOT PATH
import IO
import System
import IOExts (trace)
import RegexString
import Maybe
main = do
prog <- getProgName
hPutStr stderr (shows prog "\n")
let Just (name:_) = matchRegex (mkRegex ".*(cg025.bin)") prog
hPutStr stderr (shows name "\n")
args <- getArgs
hPutStr stderr (shows args "\n")
path <- getEnv "PATH"
......
......@@ -5,12 +5,10 @@ module Main ( main ) where
import PrelBase
import Addr
import ST
import IOExts
import ST
import MutableArray
import ByteArray
import Int( Num(fromInt) )
import CString (packString)
import Ratio
import Array
......@@ -27,21 +25,41 @@ main = putStr
-- Arr# Char# -------------------------------------------
-- (main effort is in packString#)
foreign label "stdout" addrOfStdout :: Addr
stdout :: Addr
stdout = indexAddrOffAddr addrOfStdout 0
test_chars :: String
test_chars
= let str = reverse "Now is the time for all good men to come to...\n"
= let arr# = f 1000
in
unsafePerformIO (
_ccall_ fprintf stdout (packString "%d %s\n") (93::Int) (packString str) >>
_ccall_ fflush stdout >>
return ""
shows (lookup_range arr# 42# 416#) "\n"
where
f :: Int -> ByteArray Int
f size@(I# size#)
= runST (
-- allocate an array of the specified size
newCharArray (0, (size-1)) >>= \ arr# ->
-- fill in all elements; elem i has "i" put in it
fill_in arr# 0# (size# -# 1#) >>
-- freeze the puppy:
freezeByteArray arr#
)
fill_in :: MutableByteArray s Int -> Int# -> Int# -> ST s ()
fill_in arr_in# first# last#
= if (first# ># last#)
then return ()
else writeCharArray arr_in# (I# first#) ((chr (I# first#))) >>
fill_in arr_in# (first# +# 1#) last#
lookup_range :: ByteArray Int -> Int# -> Int# -> [Char]
lookup_range arr from# to#
= if (from# ># to#)
then []
else (indexCharArray arr (I# from#))
: (lookup_range arr (from# +# 1#) to#)
-- Arr# Int# -------------------------------------------
test_ints :: String
......
93
...ot emoc ot nem doog lla rof emit eht si woN
"*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\DEL\128\129\130\131\132\133\134\135\136\137\138\139\140\141\142\143\144\145\146\147\148\149\150\151\152\153\154\155\156\157\158\159\160\161\162\163\164\165\166\167\168\169\170\171\172\173\174\175\176\177\178\179\180\181\182\183\184\185\186\187\188\189\190\191\192\193\194\195\196\197\198\199\200\201\202\203\204\205\206\207\208\209\210\211\212\213\214\215\216\217\218\219\220\221\222\223\224\225\226\227\228\229\230\231\232\233\234\235\236\237\238\239\240\241\242\243\244\245\246\247\248\249\250\251\252\253\254\255\NUL\SOH\STX\ETX\EOT\ENQ\ACK\a\b\t\n\v\f\r\SO\SI\DLE\DC1\DC2\DC3\DC4\NAK\SYN\ETB\CAN\EM\SUB\ESC\FS\GS\RS\US !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\DEL\128\129\130\131\132\133\134\135\136\137\138\139\140\141\142\143\144\145\146\147\148\149\150\151\152\153\154\155\156\157\158\159\160"
[1764,1849,1936,2025,2116,2209,2304,2401,2500,2601,2704,2809,2916,3025,3136,3249,3364,3481,3600,3721,3844,3969,4096,4225,4356,4489,4624,4761,4900,5041,5184,5329,5476,5625,5776,5929,6084,6241,6400,6561,6724,6889,7056,7225,7396,7569,7744,7921,8100,8281,8464,8649,8836,9025,9216,9409,9604,9801,10000,10201,10404,10609,10816,11025,11236,11449,11664,11881,12100,12321,12544,12769,12996,13225,13456,13689,13924,14161,14400,14641,14884,15129,15376,15625,15876,16129,16384,16641,16900,17161,17424,17689,17956,18225,18496,18769,19044,19321,19600,19881,20164,20449,20736,21025,21316,21609,21904,22201,22500,22801,23104,23409,23716,24025,24336,24649,24964,25281,25600,25921,26244,26569,26896,27225,27556,27889,28224,28561,28900,29241,29584,29929,30276,30625,30976,31329,31684,32041,32400,32761,33124,33489,33856,34225,34596,34969,35344,35721,36100,36481,36864,37249,37636,38025,38416,38809,39204,39601,40000,40401,40804,41209,41616,42025,42436,42849,43264,43681,44100,44521,44944,45369,45796,46225,46656,47089,47524,47961,48400,48841,49284,49729,50176,50625,51076,51529,51984,52441,52900,53361,53824,54289,54756,55225,55696,56169,56644,57121,57600,58081,58564,59049,59536,60025,60516,61009,61504,62001,62500,63001,63504,64009,64516,65025,65536,66049,66564,67081,67600,68121,68644,69169,69696,70225,70756,71289,71824,72361,72900,73441,73984,74529,75076,75625,76176,76729,77284,77841,78400,78961,79524,80089,80656,81225,81796,82369,82944,83521,84100,84681,85264,85849,86436,87025,87616,88209,88804,89401,90000,90601,91204,91809,92416,93025,93636,94249,94864,95481,96100,96721,97344,97969,98596,99225,99856,100489,101124,101761,102400,103041,103684,104329,104976,105625,106276,106929,107584,108241,108900,109561,110224,110889,111556,112225,112896,113569,114244,114921,115600,116281,116964,117649,118336,119025,119716,120409,121104,121801,122500,123201,123904,124609,125316,126025,126736,127449,128164,128881,129600,130321,131044,131769,132496,133225,133956,134689,135424,136161,136900,137641,138384,139129,139876,140625,141376,142129,142884,143641,144400,145161,145924,146689,147456,148225,148996,149769,150544,151321,152100,152881,153664,154449,155236,156025,156816,157609,158404,159201,160000,160801,161604,162409,163216,164025,164836,165649,166464,167281,168100,168921,169744,170569,171396,172225,173056]
......
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