Changeset 14599
- Timestamp:
- 11/03/06 05:30:51 (2 years ago)
- svk:copy_cache_prev:
- 41990
- Files:
-
- 8 modified
-
AUTHORS (modified) (1 diff)
-
src/Pugs/AST.hs (modified) (3 diffs)
-
src/Pugs/Compat.hs (modified) (2 diffs)
-
src/Pugs/Internals.hs (modified) (2 diffs)
-
src/Pugs/Prim.hs (modified) (3 diffs)
-
src/Pugs/Prim/FileTest.hs (modified) (3 diffs)
-
src/Pugs/Run.hs (modified) (3 diffs)
-
t/operators/filetest.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
AUTHORS
r14530 r14599 35 35 Brad "bsb" Bowman (BOWMANBS) 36 36 Brandon Michael "skew" Moore 37 Brandon S Allbery KF8NH 37 38 Bryan Donlan (BDONLAN) 38 39 Bryan "mrborisguy" Burgers -
src/Pugs/AST.hs
r14303 r14599 342 342 isPrimVal _ = False 343 343 344 {-| 345 Filter out reserved symbols from the specified Pad. 346 -} 344 347 filterUserDefinedPad :: Pad -> Pad 345 348 filterUserDefinedPad (MkPad pad) = MkPad $ Map.filterWithKey doFilter pad … … 347 350 doFilter key _ = (not . Set.member key) _reserved 348 351 352 {-| 353 Symbols which are reserved for the current interpreter/compiler instance and 354 should not be set from the preamble or other sources. See 355 @Pugs.AST.filterUserDefinedPad@. 356 -} 349 357 _reserved :: Set Var 350 358 _reserved = Set.fromList . cast . words $ … … 352 360 "$*PROGRAM_NAME $*PID $*UID $*EUID $*GID $*EGID @*CHECK @*INIT $*IN " ++ 353 361 "$*OUT $*ERR $*ARGS $/ %*ENV $*CWD @=POD $=POD $?PUGS_VERSION " ++ 354 "$*OS %?CONFIG $*_ $*AUTOLOAD $*PUGS_VERSION "362 "$*OS %?CONFIG $*_ $*AUTOLOAD $*PUGS_VERSION $*BASETIME" 355 363 356 364 typeOfParam :: Param -> Type -
src/Pugs/Compat.hs
r13464 r14599 25 25 getArg0, 26 26 statFileSize, 27 statFileMTime, 28 statFileCTime, 29 statFileATime, 27 30 getProcessID, 28 31 getRealUserID, … … 97 100 return (toInteger (fileSize s)) 98 101 102 statFileTime :: (FileStatus -> EpochTime) -> FilePath -> IO Integer 103 statFileTime op f = do 104 s <- getFileStatus f 105 return (toInteger $ fromEnum $ op s) 106 107 statFileMTime :: FilePath -> IO Integer 108 statFileMTime f = statFileTime modificationTime f >>= return 109 110 statFileCTime :: FilePath -> IO Integer 111 statFileCTime f = statFileTime statusChangeTime f >>= return 112 113 statFileATime :: FilePath -> IO Integer 114 statFileATime f = statFileTime accessTime f >>= return 115 99 116 type Signal = System.Posix.Signals.Signal 100 117 signalProcess :: Signal -> ProcessID -> IO () -
src/Pugs/Internals.hs
r14467 r14599 92 92 __, (+++), nullID, addressOf, showAddressOf, 93 93 94 hashNew, hashList 94 hashNew, hashList, 95 pugsTimeSpec, 95 96 ) where 96 97 … … 575 576 where 576 577 addr = addressOf x 578 579 {-| 580 Convert an internal @ClockTime@ to a Pugs-style fractional time. 581 Used by op0 "time", @Pugs.Run.prepareEnv@, and the file time tests. 582 -} 583 pugsTimeSpec :: ClockTime -> Rational 584 pugsTimeSpec clkt = fdiff $ diffClockTimes clkt epochClkT 585 where 586 epochClkT = toClockTime epoch 587 epoch = CalendarTime 2000 January 1 0 0 0 0 Saturday 0 "UTC" 0 False 588 -- 10^12 is expanded because the alternatives tried gave type warnings. 589 fdiff = \d -> (fromInteger $ tdPicosec d) 590 / (clocksPerSecond * clocksPerSecond) 591 + (fromIntegral $ tdSec d) -
src/Pugs/Prim.hs
r14574 r14599 73 73 op0 "time" = const $ do 74 74 clkt <- guardIO getClockTime 75 return $ VRat $ fdiff $ diffClockTimes clkt epochClkT 76 where 77 epochClkT = toClockTime epoch 78 epoch = CalendarTime 2000 January 1 0 0 0 0 Saturday 0 "UTC" 0 False 79 -- 10^12 is expanded because the alternatives tried gave type warnings. 80 fdiff = \d -> (fromInteger $ tdPicosec d) 81 / (clocksPerSecond * clocksPerSecond) 82 + (fromIntegral $ tdSec d) 75 return $ VRat $ pugsTimeSpec clkt 83 76 op0 "times" = const $ do 84 77 ProcessTimes _ u s cu cs <- guardIO getProcessTimes … … 430 423 op1 "-z" = FileTest.sizeIsZero 431 424 op1 "-s" = FileTest.fileSize 425 op1 "-M" = FileTest.fileMTime 426 op1 "-A" = FileTest.fileATime 427 op1 "-C" = FileTest.fileCTime 432 428 op1 "-f" = FileTest.isFile 433 429 op1 "-d" = FileTest.isDirectory … … 1824 1820 \\n Bool spre -e unsafe (Str)\ 1825 1821 \\n Int spre -s unsafe (Str)\ 1822 \\n Num spre -M unsafe (Str)\ 1823 \\n Num spre -A unsafe (Str)\ 1824 \\n Num spre -C unsafe (Str)\ 1826 1825 \\n Bool spre -f unsafe (Str)\ 1827 1826 \\n Bool spre -d unsafe (Str)\ -
src/Pugs/Prim/FileTest.hs
r10466 r14599 3 3 exists, isFile, isDirectory, 4 4 fileSize, sizeIsZero, 5 fileMTime, fileCTime, fileATime, 5 6 ) where 6 7 import Pugs.Internals … … 34 35 sizeIsZero :: Val -> Eval Val 35 36 sizeIsZero = fileTestIO fileTestSizeIsZero 37 fileMTime :: Val -> Eval Val 38 fileMTime = fileTime statFileMTime 39 fileCTime :: Val -> Eval Val 40 fileCTime = fileTime statFileCTime 41 fileATime :: Val -> Eval Val 42 fileATime = fileTime statFileATime 43 44 fileTime :: (FilePath -> IO Integer) -> Val -> Eval Val 45 fileTime test f = do 46 t <- fileTestIO (fileTestDo test) f 47 if (t == undef) then return VUndef else do 48 t' <- fromVal t 49 b <- (readVar $ cast "$*BASETIME") >>= fromVal 50 return $ VRat $ (b - (pugsTimeSpec $ TOD t' 0)) / 86400 36 51 37 52 fileTestIO :: (Value n) => (n -> IO Val) -> Val -> Eval Val … … 74 89 n <- statFileSize f 75 90 return $ if n == 0 then VBool True else VBool False 91 92 fileTestDo :: (FilePath -> IO Integer) -> FilePath -> IO Val 93 fileTestDo test f = test f >>= return . VInt -
src/Pugs/Run.hs
r14438 r14599 36 36 import System.IO 37 37 import System.FilePath (joinFileName) 38 import System.Posix.Time 38 39 39 40 … … 115 116 classes <- initClassObjects (MkObjectId $ -1) [] initTree 116 117 strictSV <- newScalar $ VBool (name /= "-e") 118 -- XXX factor "time" and use it here and in filetime tests 119 baset <- getClockTime 117 120 #if defined(PUGS_HAVE_HSPLUGINS) 118 121 hspluginsSV <- newScalar (VInt 1) … … 164 167 , gen "$*AUTOLOAD" $ MkRef autoSV 165 168 , gen "$*STRICT" $ MkRef strictSV 169 -- XXX do we want hideInSafemode? 170 , gen "$*BASETIME" $ MkRef $ constScalar (VRat $ pugsTimeSpec baset) 166 171 ] ++ classes 167 172 -- defSVcell <- (gen "$_" . MkRef) =<< newScalar undef -
t/operators/filetest.t
r14516 r14599 9 9 =cut 10 10 11 plan 41;11 plan 50; 12 12 13 13 #if $*OS eq any <MSWin32 mingw msys cygwin> { … … 118 118 my $fh = open("test_file", :w); 119 119 close $fh; 120 ok (-M "test_file") > 0, "-M works"; 121 ok (-C "test_file") > 0, "-C works"; 122 ok (-A "test_file") > 0, "-A works"; 120 sleep 1; # just to make sure 121 ok (-M "test_file") < 0, "-M works on new file"; 122 ok (-C "test_file") < 0, "-C works on new file"; 123 ok (-A "test_file") < 0, "-A works on new file"; 123 124 unlink "test_file"; 124 125 126 if (! -f "README") { 127 skip 3, "no file README"; 128 } else { 129 ok (-M "README") > 0, "-M works on existing file"; 130 ok (-C "README") > 0, "-C works on existing file"; 131 ok (-A "README") > 0, "-A works on existing file"; 132 } 133 134 ok not -M "xyzzy", "-M returns undef when no file"; 135 ok not -C "xyzzy", "-C returns undef when no file"; 136 ok not -A "xyzzy", "-A returns undef when no file";
