support open as script option, to avoid spurious warning message

This commit is contained in:
Vítor Santos Costa
2014-08-05 09:06:35 -05:00
parent 01bd6fa446
commit 45c0671fa2
4 changed files with 194 additions and 180 deletions

View File

@@ -3113,6 +3113,7 @@ static const opt_spec open4_options[] =
{ ATOM_wait, OPT_BOOL },
{ ATOM_encoding, OPT_ATOM },
{ ATOM_bom, OPT_BOOL },
{ ATOM_scripting, OPT_BOOL },
#ifdef O_LOCALE
{ ATOM_locale, OPT_LOCALE },
#endif
@@ -3139,6 +3140,7 @@ openStream(term_t file, term_t mode, term_t options)
#endif
int close_on_abort = TRUE;
int bom = -1;
int scripting = FALSE;
char how[10];
char *h = how;
char *path;
@@ -3149,7 +3151,7 @@ openStream(term_t file, term_t mode, term_t options)
{ if ( !scan_options(options, 0, ATOM_stream_option, open4_options,
&type, &reposition, &alias, &eof_action,
&close_on_abort, &buffer, &lock, &wait,
&encoding, &bom
&encoding, &bom, &scripting
#ifdef O_LOCALE
, &locale
#endif
@@ -3323,6 +3325,15 @@ openStream(term_t file, term_t mode, term_t options)
streamStatus(getStream(s));
return NULL;
}
if ( scripting) {
int c;
while (( c = Sgetc(s)) == '#') {
while( (c = Sgetc(s)) != EOF && c != 10);
}
if ( c != EOF )
Sungetc(c, s);
else goto bom_error;
}
} else
{ if ( mname == ATOM_write ||
( (mname == ATOM_append || mname == ATOM_update) &&