<commit_before>{-# OPTIONS -fffi -cpp #-}

------------------------------------------------------------------------
-- $Id: Main.hs,v 1.63 2005/01/05 15:06:25 ross Exp $
--
-- Program for converting .hsc files to .hs files, by converting the
-- file into a C program which is run to generate the Haskell source.
-- Certain items known only to the C compiler can then be used in
-- the Haskell module; for example #defined constants, byte offsets
-- within structures, etc.
--
-- See the documentation in the Users' Guide for more details.

#if __GLASGOW_HASKELL__ >= 504 || __NHC__ >= 114
import System.Console.GetOpt
#else
import GetOpt
#endif

import System        (getProgName, getArgs, ExitCode(..), exitWith, system)
import Directory     (removeFile,doesFileExist)
import Monad         (MonadPlus(..), liftM, liftM2, when)
import Char          (isAlpha, isAlphaNum, isSpace, isDigit, toUpper, intToDigit, ord)
import List          (intersperse, isSuffixOf)
import IO            (hPutStr, hPutStrLn, stderr)

#if defined(mingw32_HOST_OS)
import Foreign
#if __GLASGOW_HASKELL__ >= 504 || __NHC__ >= 114
import Foreign.C.String
#else
import CString
#endif
#endif


#ifdef __GLASGOW_HASKELL__
import Compat.RawSystem 	( rawSystem )
#elif __HUGS__ || __NHC__ >= 117
import System.Cmd	 	( rawSystem )
#else
rawSystem prog args = system (prog++unwords args)
#endif

version :: String
version = "hsc2hs version 0.66\n"

data Flag
    = Help
    | Version
    | Template  String
    | Compiler  String
    | Linker    String
    | CompFlag  String
    | LinkFlag  String
    | NoCompile
    | Include   String
    | Define    String (Maybe String)
    | Output    String
    | Verbose

template_flag :: Flag -> Bool
template_flag (Template _) = True
template_flag _		   = False

include :: String -> Flag
include s@('\"':_) = Include s
include s@('<' :_) = Include s
include s          = Include ("\""++s++"\"")

define :: String -> Flag
define s = case break (== '=') s of<commit_msg>[project @ 2005-01-06 10:44:14 by malcolm] It seems that ghc-6.2.x doesn't have Compat.RawSystem, so should use System.Cmd instead.  And ghc-5.04.x doesn't export rawSystem from there either, so should use the simple inline definition.<commit_after>{-# OPTIONS -fffi -cpp #-}

------------------------------------------------------------------------
-- $Id: Main.hs,v 1.64 2005/01/06 10:44:14 malcolm Exp $
--
-- Program for converting .hsc files to .hs files, by converting the
-- file into a C program which is run to generate the Haskell source.
-- Certain items known only to the C compiler can then be used in
-- the Haskell module; for example #defined constants, byte offsets
-- within structures, etc.
--
-- See the documentation in the Users' Guide for more details.

#if __GLASGOW_HASKELL__ >= 504 || __NHC__ >= 114
import System.Console.GetOpt
#else
import GetOpt
#endif

import System        (getProgName, getArgs, ExitCode(..), exitWith, system)
import Directory     (removeFile,doesFileExist)
import Monad         (MonadPlus(..), liftM, liftM2, when)
import Char          (isAlpha, isAlphaNum, isSpace, isDigit, toUpper, intToDigit, ord)
import List          (intersperse, isSuffixOf)
import IO            (hPutStr, hPutStrLn, stderr)

#if defined(mingw32_HOST_OS)
import Foreign
#if __GLASGOW_HASKELL__ >= 504 || __NHC__ >= 114
import Foreign.C.String
#else
import CString
#endif
#endif


#if __GLASGOW_HASKELL__ >= 603
import Compat.RawSystem 	( rawSystem )
#elif __HUGS__ || __NHC__ >= 117 || __GLASGOW_HASKELL__ >= 600
import System.Cmd	 	( rawSystem )
#else
rawSystem prog args = system (prog++" "++unwords args)
#endif

version :: String
version = "hsc2hs version 0.66\n"

data Flag
    = Help
    | Version
    | Template  String
    | Compiler  String
    | Linker    String
    | CompFlag  String
    | LinkFlag  String
    | NoCompile
    | Include   String
    | Define    String (Maybe String)
    | Output    String
    | Verbose

template_flag :: Flag -> Bool
template_flag (Template _) = True
template_flag _		   = False

include :: String -> Flag
include s@('\"':_) = Include s
include s@('<' :_) = Include s
include s          = Include ("\""++s++"\"")

define :: String -> Flag
define s = case break (== '=') s of
{'fraction_non_alphanumeric': 0.14032181732134405, 'fraction_numerical': 0.024372929484145763, 'mean_word_length': 2.8184281842818426, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1647558', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1326, 'n_words': 460}