mostly indenting

This commit is contained in:
Vítor Santos Costa 2015-10-05 10:33:52 +01:00
parent e5fc818c37
commit 166d4892f9

View File

@ -360,7 +360,7 @@ Yap_InitStdStreams (void)
Int
PlIOError__ (const char *function, int lineno, const char *file, yap_error_number type, Term culprit, ...)
PlIOError__ (const char *file, const char *function, int lineno, yap_error_number type, Term culprit, ...)
{
if (trueLocalPrologFlag(FILEERRORS_FLAG) == MkIntTerm(1) ||
@ -373,7 +373,7 @@ PlIOError__ (const char *function, int lineno, const char *file, yap_error_numbe
format = va_arg(args, char *);
vsnprintf(who, 1023, format, args);
va_end( args );
Yap_Error__(function, lineno,file, type, culprit, who);
Yap_Error__(file, function, lineno, type, culprit, who);
/* and fail */
return FALSE;
} else {
@ -1229,11 +1229,11 @@ binary_file(char *file_name)
#else
return(FALSE);
#endif
}
}
static int
write_bom(int sno, StreamDesc *st)
{
static int
write_bom(int sno, StreamDesc *st)
{
/* dump encoding */
switch (st->encoding) {
case ENC_ISO_UTF8:
@ -1278,12 +1278,12 @@ binary_file(char *file_name)
default:
return TRUE;
}
}
}
static void
check_bom(int sno, StreamDesc *st)
{
static void
check_bom(int sno, StreamDesc *st)
{
int ch;
@ -1407,11 +1407,11 @@ binary_file(char *file_name)
st->stream_gets = DefaultGets;
return;
}
}
}
static bool
initStream(int sno, FILE *fd, const char *name, Term file_name, encoding_t encoding, stream_flags_t flags, Atom open_mode )
{
static bool
initStream(int sno, FILE *fd, const char *name, Term file_name, encoding_t encoding, stream_flags_t flags, Atom open_mode )
{
StreamDesc *st = &GLOBAL_Stream[sno];
st->status = flags;
@ -1449,47 +1449,47 @@ binary_file(char *file_name)
#define OPEN_DEFS() \
PAR( "alias", isatom, OPEN_ALIAS), \
PAR( "bom", boolean, OPEN_BOM ), \
PAR( "buffer", isatom, OPEN_BUFFER ), \
PAR( "close_on_abort", boolean, OPEN_CLOSE_ON_ABORT ), \
PAR( "create", isatom, OPEN_CREATE ), \
PAR( "encoding", isatom, OPEN_ENCODING ), \
PAR( "eof_action", isatom, OPEN_EOF_ACTION ), \
PAR( "expand_filename", boolean, OPEN_EXPAND_FILENAME ), \
PAR( "file_name", isatom, OPEN_FILE_NAME ), \
PAR( "input", ok, OPEN_INPUT ), \
PAR( "locale", isatom, OPEN_LOCALE ), \
PAR( "lock", isatom, OPEN_LOCK ), \
PAR( "mode", isatom, OPEN_MODE ), \
PAR( "output", ok, OPEN_OUTPUT ), \
PAR( "representation_errors", boolean, OPEN_REPRESENTATION_ERRORS ), \
PAR( "reposition", boolean, OPEN_REPOSITION ), \
PAR( "type", isatom, OPEN_TYPE ), \
PAR( "wait", boolean, OPEN_WAIT ), \
PAR( NULL, ok, OPEN_END )
PAR( "alias", isatom, OPEN_ALIAS), \
PAR( "bom", boolean, OPEN_BOM ), \
PAR( "buffer", isatom, OPEN_BUFFER ), \
PAR( "close_on_abort", boolean, OPEN_CLOSE_ON_ABORT ), \
PAR( "create", isatom, OPEN_CREATE ), \
PAR( "encoding", isatom, OPEN_ENCODING ), \
PAR( "eof_action", isatom, OPEN_EOF_ACTION ), \
PAR( "expand_filename", boolean, OPEN_EXPAND_FILENAME ), \
PAR( "file_name", isatom, OPEN_FILE_NAME ), \
PAR( "input", ok, OPEN_INPUT ), \
PAR( "locale", isatom, OPEN_LOCALE ), \
PAR( "lock", isatom, OPEN_LOCK ), \
PAR( "mode", isatom, OPEN_MODE ), \
PAR( "output", ok, OPEN_OUTPUT ), \
PAR( "representation_errors", boolean, OPEN_REPRESENTATION_ERRORS ), \
PAR( "reposition", boolean, OPEN_REPOSITION ), \
PAR( "type", isatom, OPEN_TYPE ), \
PAR( "wait", boolean, OPEN_WAIT ), \
PAR( NULL, ok, OPEN_END )
#define PAR(x,y,z) z
typedef enum open_enum_choices
{
typedef enum open_enum_choices
{
OPEN_DEFS()
} open_choices_t;
} open_choices_t;
#undef PAR
#define PAR(x,y,z) { x , y, z }
static const param_t open_defs[] =
{
static const param_t open_defs[] =
{
OPEN_DEFS()
};
};
#undef PAR
static Int
do_open ( Term file_name, Term t2, Term tlist USES_REGS )
{ /* '$open'(+File,+Mode,?Stream,-ReturnCode) */
static Int
do_open ( Term file_name, Term t2, Term tlist USES_REGS )
{ /* '$open'(+File,+Mode,?Stream,-ReturnCode) */
Atom open_mode;
int sno;
SMALLUNSGN s;
@ -1676,7 +1676,7 @@ binary_file(char *file_name)
Term t = Yap_MkStream (sno);
return (Yap_unify (ARG3, t));
}
}
}
static Int
open3 ( USES_REGS1 )
@ -1690,9 +1690,9 @@ open4 ( USES_REGS1 )
return do_open(Deref(ARG1), Deref(ARG2), Deref( ARG4 ) PASS_REGS );
}
static Int
p_file_expansion (USES_REGS1)
{ /* '$file_expansion'(+File,-Name) */
static Int
p_file_expansion (USES_REGS1)
{ /* '$file_expansion'(+File,-Name) */
Term file_name = Deref(ARG1);
/* we know file_name is bound */
@ -1703,11 +1703,11 @@ open4 ( USES_REGS1 )
if (!Yap_TrueFileName (RepAtom (AtomOfTerm (file_name))->StrOfAE, LOCAL_FileNameBuf, FALSE))
return (PlIOError (EXISTENCE_ERROR_SOURCE_SINK,file_name,"absolute_file_name/3"));
return(Yap_unify(ARG2,MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf))));
}
}
static Int
p_open_null_stream (USES_REGS1)
{
static Int
p_open_null_stream (USES_REGS1)
{
Term t;
StreamDesc *st;
int sno = GetFreeStreamD();
@ -1741,9 +1741,9 @@ open4 ( USES_REGS1 )
UNLOCK(st->streamlock);
t = Yap_MkStream (sno);
return (Yap_unify (ARG1, t));
}
}
int
int
Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
{
CACHE_REGS
@ -1762,11 +1762,11 @@ Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
at = AtomRead;
initStream(sno, fd, name, file_name, LOCAL_encoding, flags, at );
return sno;
}
}
static int
CheckStream (Term arg, int kind, const char *msg)
{
static int
CheckStream (Term arg, int kind, const char *msg)
{
int sno = -1;
arg = Deref (arg);
if (IsVarTerm (arg)) {
@ -1787,11 +1787,13 @@ Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
sname = AtomUserOut;
}
}
LOCK(GLOBAL_StreamDescLock);
if ((sno = Yap_CheckAlias(sname)) == -1) {
UNLOCK(GLOBAL_StreamDescLock);
if ((sno = Yap_CheckAlias(sname)) < 0) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(EXISTENCE_ERROR_STREAM, arg, msg);
return -1;
} else {
LOCK(GLOBAL_Stream[sno].streamlock);
return sno;
}
} else if (IsApplTerm (arg) && FunctorOfTerm (arg) == FunctorStream) {
arg = ArgOfTerm (1, arg);
@ -1802,17 +1804,14 @@ Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
if (sno < 0)
{
Yap_Error(DOMAIN_ERROR_STREAM_OR_ALIAS, arg, msg);
UNLOCK(GLOBAL_StreamDescLock);
return (-1);
}
if (GLOBAL_Stream[sno].status & Free_Stream_f)
{
PlIOError(EXISTENCE_ERROR_STREAM, arg, msg);
UNLOCK(GLOBAL_StreamDescLock);
return (-1);
}
LOCK(GLOBAL_Stream[sno].streamlock);
UNLOCK(GLOBAL_StreamDescLock);
if ((GLOBAL_Stream[sno].status & kind) == 0)
{
UNLOCK(GLOBAL_Stream[sno].streamlock);
@ -1823,19 +1822,19 @@ Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
return (-1);
}
return (sno);
}
}
int
Yap_CheckStream (Term arg, int kind, const char *msg)
{
int
Yap_CheckStream (Term arg, int kind, const char *msg)
{
return CheckStream(arg, kind, (char *)msg);
}
}
static Int
always_prompt_user( USES_REGS1 )
{
static Int
always_prompt_user( USES_REGS1 )
{
StreamDesc *s = GLOBAL_Stream+StdInStream;
s->status |= Promptable_Stream_f;
@ -1849,12 +1848,12 @@ Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
} else
Yap_ConsoleOps( s );
return(TRUE);
}
}
static Int
close1 (USES_REGS1)
{ /* '$close'(+GLOBAL_Stream) */
static Int
close1 (USES_REGS1)
{ /* '$close'(+GLOBAL_Stream) */
Int sno = CheckStream (ARG1, (Input_Stream_f | Output_Stream_f | Socket_Stream_f), "close/2");
if (sno < 0)
return (FALSE);
@ -1865,33 +1864,33 @@ Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
Yap_CloseStream(sno);
UNLOCK(GLOBAL_Stream[sno].streamlock);
return (TRUE);
}
}
#define CLOSE_DEFS() \
PAR( "force", boolean, CLOSE_FORCE), \
PAR( NULL, ok, CLOSE_END )
PAR( "force", boolean, CLOSE_FORCE), \
PAR( NULL, ok, CLOSE_END )
#define PAR(x,y,z) z
typedef enum close_enum_choices
{
typedef enum close_enum_choices
{
CLOSE_DEFS()
} close_choices_t;
} close_choices_t;
#undef PAR
#define PAR(x,y,z) { x , y, z }
static const param_t close_defs[] =
{
static const param_t close_defs[] =
{
CLOSE_DEFS()
};
};
#undef PAR
static Int
close2 (USES_REGS1)
{ /* '$close'(+GLOBAL_Stream) */
static Int
close2 (USES_REGS1)
{ /* '$close'(+GLOBAL_Stream) */
Int sno = CheckStream (ARG1, (Input_Stream_f | Output_Stream_f | Socket_Stream_f), "close/2");
Term tlist;
if (sno < 0)
@ -1908,12 +1907,12 @@ Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
Yap_CloseStream(sno);
UNLOCK(GLOBAL_Stream[sno].streamlock);
return (TRUE);
}
}
Term
read_line(int sno)
{
Term
read_line(int sno)
{
CACHE_REGS
Term tail;
Int ch;
@ -1923,41 +1922,41 @@ Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
}
tail = read_line(sno);
return(MkPairTerm(MkIntTerm(ch),tail));
}
}
#define ABSOLUTE_FILE_NAME_DEFS() \
PAR( "extensions", ok, ABSOLUTE_FILE_NAME_EXTENSIONS), \
PAR( "relative_to", isatom, ABSOLUTE_FILE_NAME_RELATIVE_TO ), \
PAR( "access", isatom, ABSOLUTE_FILE_NAME_ACCESS ), \
PAR( "file_type", is_file_type, ABSOLUTE_FILE_NAME_FILE_TYPE ), \
PAR( "file_errors", is_file_errors, ABSOLUTE_FILE_NAME_FILE_ERRORS ), \
PAR( "solutions", issolutions, ABSOLUTE_FILE_NAME_SOLUTIONS ), \
PAR( "expand", boolean, ABSOLUTE_FILE_NAME_EXPAND ), \
PAR( "verbose_file_search", boolean, ABSOLUTE_FILE_NAME_VERBOSE_FILE_SEARCH), \
PAR( NULL, ok, ABSOLUTE_FILE_NAME_END )
PAR( "extensions", ok, ABSOLUTE_FILE_NAME_EXTENSIONS), \
PAR( "relative_to", isatom, ABSOLUTE_FILE_NAME_RELATIVE_TO ), \
PAR( "access", isatom, ABSOLUTE_FILE_NAME_ACCESS ), \
PAR( "file_type", is_file_type, ABSOLUTE_FILE_NAME_FILE_TYPE ), \
PAR( "file_errors", is_file_errors, ABSOLUTE_FILE_NAME_FILE_ERRORS ), \
PAR( "solutions", issolutions, ABSOLUTE_FILE_NAME_SOLUTIONS ), \
PAR( "expand", boolean, ABSOLUTE_FILE_NAME_EXPAND ), \
PAR( "verbose_file_search", boolean, ABSOLUTE_FILE_NAME_VERBOSE_FILE_SEARCH), \
PAR( NULL, ok, ABSOLUTE_FILE_NAME_END )
#define PAR(x,y,z) z
typedef enum ABSOLUTE_FILE_NAME_enum_
{
typedef enum ABSOLUTE_FILE_NAME_enum_
{
ABSOLUTE_FILE_NAME_DEFS()
} absolute_file_name_choices_t;
} absolute_file_name_choices_t;
#undef PAR
#define PAR(x,y,z) { x , y, z }
static const param_t absolute_file_name_search_defs[] =
{
static const param_t absolute_file_name_search_defs[] =
{
ABSOLUTE_FILE_NAME_DEFS()
};
};
#undef PAR
static Int abs_file_parameters ( USES_REGS1 )
{
{
Term t[ABSOLUTE_FILE_NAME_END];
Term tlist = Deref(ARG1), tf;
/* get options */
@ -2003,7 +2002,7 @@ static Int abs_file_parameters ( USES_REGS1 )
}
static Int get_abs_file_parameter ( USES_REGS1 )
{
{
Term t = Deref(ARG1), topts = ARG2;
/* get options */
/* done */
@ -2027,9 +2026,9 @@ static Int get_abs_file_parameter ( USES_REGS1 )
}
void
Yap_InitPlIO (void)
{
void
Yap_InitPlIO (void)
{
Int i;
Yap_stdin = stdin;
@ -2041,11 +2040,11 @@ static Int get_abs_file_parameter ( USES_REGS1 )
GLOBAL_Stream[i].status = Free_Stream_f;
}
InitStdStreams();
}
}
void
Yap_InitIOPreds(void)
{
void
Yap_InitIOPreds(void)
{
/* here the Input/Output predicates */
Yap_InitCPred ("always_prompt_user", 0, always_prompt_user, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("close", 1, close1, SafePredFlag|SyncPredFlag);
@ -2070,4 +2069,4 @@ static Int get_abs_file_parameter ( USES_REGS1 )
Yap_InitReadline();
Yap_InitSockets();
Yap_InitSysPreds();
}
}