fix regression: checking for EOT should first peek, and if happy consume the blank after the dot.

This commit is contained in:
Vítor Santos Costa 2016-02-18 22:10:40 +00:00
parent 091be7677a
commit ad91eb0ec9
5 changed files with 28 additions and 8 deletions

4
.gitignore vendored
View File

@ -140,3 +140,7 @@ xcode
Threads
mxe
caret
configure
cmake/cmake-android

View File

@ -1745,6 +1745,8 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
if (ch == '.' && (pch = Yap_peek(inp_stream - GLOBAL_Stream)) &&
(chtype(pch) == BS || chtype(pch) == EF || pch == '%')) {
t->Tok = Ord(kind = eot_tok);
// consume...
ch = getchr(inp_stream);
if (chtype(ch) == EF) {
mark_eof(inp_stream);
t->TokInfo = TermEof;

View File

@ -2003,9 +2003,10 @@ case ENC_ISO_UTF32_LE: // check http://unicode.org/faq/utf_bom.html#utf16-3
t[ABSOLUTE_FILE_NAME_EXPAND] = args[ABSOLUTE_FILE_NAME_EXPAND].tvalue;
else
t[ABSOLUTE_FILE_NAME_EXPAND] = TermFalse;
if (args[ABSOLUTE_FILE_NAME_GLOB].used)
if (args[ABSOLUTE_FILE_NAME_GLOB].used) {
t[ABSOLUTE_FILE_NAME_GLOB] = args[ABSOLUTE_FILE_NAME_GLOB].tvalue;
else
t[ABSOLUTE_FILE_NAME_EXPAND] = TermTrue;
} else
t[ABSOLUTE_FILE_NAME_GLOB] = TermEmptyAtom;
if (args[ABSOLUTE_FILE_NAME_VERBOSE_FILE_SEARCH].used)
t[ABSOLUTE_FILE_NAME_VERBOSE_FILE_SEARCH] =

View File

@ -946,10 +946,24 @@ do_expand_file_name(Term t1, Term opts USES_REGS)
return tf;
}
/* @pred expand_file_name( +Pattern, -ListOfPaths) is det
This builtin receives a pattern and expands it into a list of files.
In Unix-like systems, YAP applies glob to expand patterns such as '*', '.', and '?'. Further variable expansion
may also happen. glob is shell-dependent: som Yap_InitCPred ("absolute_file_system_path", 2, absolute_file_system_path, 0);
Yap_InitCPred ("real_path", 2, prolog_realpath, 0);
Yap_InitCPred ("true_file_name", 2,
true_file_name, SyncPredFlag);
Yap_InitCPred ("true_file_name", 3, true_file_name3, SyncPredFlag);
e shells allow command execution and brace-expansion.
*/
static Int
expand_file_name( USES_REGS1)
{
Term tf = do_expand_file_name( Deref(ARG1), TermNil PASS_REGS);
if (tf == 0)
return false;
return
Yap_unify( tf, ARG2);
}
@ -2298,16 +2312,15 @@ Yap_InitSysPreds(void)
Yap_InitCPred ("expand_file_name", 2, expand_file_name, SyncPredFlag);
Yap_InitCPred ("working_directory", 2,working_directory, SyncPredFlag);
Yap_InitCPred ("prolog_to_os_filename", 2, prolog_to_os_filename, SyncPredFlag);
Yap_InitCPred ("prolog_to_os_filename", 2, prolog_to_os_filename, SyncPredFlag);
#ifdef _WIN32
Yap_InitCPred ("win_registry_get_value", 3, p_win_registry_get_value,0);
#endif
Yap_InitCPred ("absolute_file_system_path", 2, absolute_file_system_path, 0);
Yap_InitCPred ("real_path", 2, prolog_realpath, 0);
Yap_InitCPred ("true_file_name", 2,
true_file_name, SyncPredFlag);
Yap_InitCPred ("true_file_name", 3, true_file_name3, SyncPredFlag);
Yap_InitCPred ("rmdir", 2, p_rmdir, SyncPredFlag);
#ifdef _WIN32
Yap_InitCPred ("win_registry_get_value", 3, p_win_registry_get_value,0);
#endif
Yap_InitCPred ("rmdir", 2, p_rmdir, SyncPredFlag);
Yap_InitCPred ("make_directory", 1, make_directory, SyncPredFlag);
}

View File

@ -927,7 +927,7 @@ number of steps.
'$sort'(IVs, NVs),
'$prep_answer_var_by_var'(NVs, LAnsw, LBlk),
'$name_vars_in_goals'(LAnsw, Vs, NLAnsw),
'$write_vars_and_goals'(NLAnsw, first, FLAnsw).
'$write_vars_and_goals'(NLAnsw, first, FLAnsw).
'$purge_dontcares'([],[]).
'$purge_dontcares'([Name=_|Vs],NVs) :-