jmp
This commit is contained in:
parent
af38d14ba7
commit
4b350ccecc
44
C/exec.c
44
C/exec.c
@ -1423,7 +1423,7 @@ static bool exec_absmi(bool top, yap_reset_t reset_mode USES_REGS) {
|
||||
LOCAL_CBorder = LCL0 - (CELL *)B;
|
||||
sigjmp_buf signew, *sighold = LOCAL_RestartEnv;
|
||||
LOCAL_RestartEnv = &signew;
|
||||
|
||||
|
||||
if (top && (lval = sigsetjmp(signew, 1)) != 0) {
|
||||
switch (lval) {
|
||||
case 1: { /* restart */
|
||||
@ -1465,14 +1465,16 @@ static bool exec_absmi(bool top, yap_reset_t reset_mode USES_REGS) {
|
||||
/* abort */
|
||||
/* can be called from anywhere, must reset registers,
|
||||
*/
|
||||
while (B) {
|
||||
Yap_JumpToEnv(TermDAbort);
|
||||
}
|
||||
LOCAL_PrologMode &~ AbortMode;
|
||||
P = (yamop *)FAILCODE;
|
||||
if (OldBorder == 0)
|
||||
break;
|
||||
if (LOCAL_CBorder)
|
||||
LOCAL_CBorder = OldBorder;
|
||||
LOCAL_PrologMode = UserMode;
|
||||
LOCAL_RestartEnv = sighold;
|
||||
return false;
|
||||
return false;
|
||||
break;
|
||||
case 5:
|
||||
// going up, unless there is no up to go to. or someone
|
||||
// but we should inform the caller on what happened.
|
||||
@ -1549,13 +1551,13 @@ void Yap_PrepGoal(arity_t arity, CELL *pt, choiceptr saved_b USES_REGS) {
|
||||
static bool do_goal(yamop *CodeAdr, int arity, CELL *pt, bool top USES_REGS) {
|
||||
choiceptr saved_b = B;
|
||||
bool out;
|
||||
|
||||
|
||||
Yap_PrepGoal(arity, pt, saved_b PASS_REGS);
|
||||
CACHE_A1();
|
||||
P = (yamop *)CodeAdr;
|
||||
// S = CellPtr(RepPredProp(
|
||||
// PredPropByFunc(Yap_MkFunctor(AtomCall, 1), 0))); /* A1 mishaps */
|
||||
|
||||
|
||||
out = exec_absmi(top, YAP_EXEC_ABSMI PASS_REGS);
|
||||
if (top)
|
||||
Yap_flush();
|
||||
@ -1579,7 +1581,7 @@ bool Yap_exec_absmi(bool top, yap_reset_t has_reset) {
|
||||
*/
|
||||
void Yap_fail_all(choiceptr bb USES_REGS) {
|
||||
yamop *saved_p, *saved_cp;
|
||||
|
||||
|
||||
saved_p = P;
|
||||
saved_cp = CP;
|
||||
/* prune away choicepoints */
|
||||
@ -1625,16 +1627,16 @@ bool Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) {
|
||||
yamop *saved_p, *saved_cp;
|
||||
yamop *CodeAdr;
|
||||
bool out;
|
||||
|
||||
|
||||
saved_p = P;
|
||||
saved_cp = CP;
|
||||
LOCAL_PrologMode |= TopGoalMode;
|
||||
|
||||
|
||||
PELOCK(81, ppe);
|
||||
CodeAdr = ppe->CodeOfPred;
|
||||
UNLOCK(ppe->PELock);
|
||||
out = do_goal(CodeAdr, ppe->ArityOfPE, pt, false PASS_REGS);
|
||||
|
||||
|
||||
if (out) {
|
||||
choiceptr cut_B;
|
||||
/* we succeeded, let's prune */
|
||||
@ -1717,14 +1719,14 @@ bool Yap_execute_goal(Term t, int nargs, Term mod, bool pass_ex) {
|
||||
/* visualc*/
|
||||
/* just keep the difference because of possible garbage collections
|
||||
*/
|
||||
|
||||
|
||||
if (IsAtomTerm(t)) {
|
||||
Atom a = AtomOfTerm(t);
|
||||
pt = NULL;
|
||||
pe = PredPropByAtom(a, mod);
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
|
||||
|
||||
if (IsBlobFunctor(f)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call/1");
|
||||
return false;
|
||||
@ -1773,7 +1775,7 @@ Term Yap_RunTopGoal(Term t, bool handle_errors) {
|
||||
Term tmod = CurrentModule;
|
||||
Term goal_out = 0;
|
||||
LOCAL_PrologMode |= TopGoalMode;
|
||||
|
||||
|
||||
t = Yap_YapStripModule(t, &tmod);
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "call/1");
|
||||
@ -1786,7 +1788,7 @@ Term Yap_RunTopGoal(Term t, bool handle_errors) {
|
||||
arity = 0;
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
|
||||
|
||||
if (IsBlobFunctor(f)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t, "call/1");
|
||||
LOCAL_PrologMode &= ~TopGoalMode;
|
||||
@ -1818,7 +1820,7 @@ Term Yap_RunTopGoal(Term t, bool handle_errors) {
|
||||
ts[0] = tmod;
|
||||
ts[1] = t;
|
||||
Functor f = Yap_MkFunctor(Yap_LookupAtom("call"), 1);
|
||||
|
||||
|
||||
pt = &t;
|
||||
t = Yap_MkApplTerm(FunctorModule, 2, ts);
|
||||
pe = Yap_GetPredPropByFunc(f, tmod);
|
||||
@ -1828,7 +1830,7 @@ Term Yap_RunTopGoal(Term t, bool handle_errors) {
|
||||
PELOCK(82, ppe);
|
||||
CodeAdr = ppe->CodeOfPred;
|
||||
UNLOCK(ppe->PELock);
|
||||
|
||||
|
||||
#if !USE_SYSTEM_MALLOC
|
||||
if (LOCAL_TrailTop - HeapTop < 2048) {
|
||||
Yap_Error(RESOURCE_ERROR_TRAIL, TermNil,
|
||||
@ -1844,7 +1846,7 @@ static void do_restore_regs(Term t, int restore_all USES_REGS) {
|
||||
Int i;
|
||||
Int max = ArityOfFunctor(FunctorOfTerm(t)) - 4;
|
||||
CELL *ptr = RepAppl(t) + 5;
|
||||
|
||||
|
||||
P = (yamop *)IntegerOfTerm(ptr[-4]);
|
||||
CP = (yamop *)IntegerOfTerm(ptr[-3]);
|
||||
ENV = (CELL *)(LCL0 - IntegerOfTerm(ptr[-2]));
|
||||
@ -1874,11 +1876,11 @@ static Int restore_regs(USES_REGS1) {
|
||||
* a
|
||||
* call */
|
||||
static Int restore_regs2(USES_REGS1) {
|
||||
|
||||
|
||||
Term t = Deref(ARG1), d0;
|
||||
choiceptr pt0;
|
||||
Int d;
|
||||
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "support for coroutining");
|
||||
return (FALSE);
|
||||
@ -2103,7 +2105,7 @@ static Int jump_env(USES_REGS1) {
|
||||
return false;
|
||||
} else if (IsApplTerm(t) && FunctorOfTerm(t) == FunctorError) {
|
||||
Term t2;
|
||||
|
||||
|
||||
Yap_find_prolog_culprit(PASS_REGS1);
|
||||
// LOCAL_Error_TYPE = ERROR_EVENT;
|
||||
t = ArgOfTerm(1, t);
|
||||
|
@ -197,3 +197,5 @@ typedef struct table_subgoal_answer_frame{
|
||||
#define TgAnsFr_answer(X,N) ((X)->answer[N])
|
||||
#define TgAnsFr_next(X) ((X)->next)
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
|
||||
///@}
|
||||
|
@ -784,9 +784,11 @@ INPUT = /Users/vsc/git/yap-6.3/pl \
|
||||
/Users/vsc/git/yap-6.3/os \
|
||||
/Users/vsc/git/yap-6.3/library \
|
||||
/Users/vsc/git/yap-6.3/packages \
|
||||
/Users/vsc/git/yap-6.3/swi/library \
|
||||
/Users/vsc/git/yap-6.3/docs/md \
|
||||
/Users/vsc/git/yap-6.3/INSTALL.md \
|
||||
/Users/vsc/git/yap-6.3/swi/library
|
||||
|
||||
#\
|
||||
# /Users/vsc/git/yap-6.3/docs/md \
|
||||
# /Users/vsc/git/yap-6.3/INSTALL.md \
|
||||
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
|
@ -58,7 +58,7 @@ PROJECT_LOGO = @CMAKE_SOURCE_DIR@/docs/icons/yap_96x96x32.png
|
||||
# entered, it will be relative to the location where doxygen was started. If
|
||||
# left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY = @PROJECT_BINARY_DIR@/Docs
|
||||
OUTPUT_DIRECTORY = @PROJECT_BINARY_DIR@/docs
|
||||
|
||||
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
|
||||
# directories (in 2 levels) under the output directory of each output format and
|
||||
@ -784,9 +784,9 @@ INPUT = @PROJECT_SOURCE_DIR@/pl \
|
||||
@PROJECT_SOURCE_DIR@/os \
|
||||
@PROJECT_SOURCE_DIR@/library \
|
||||
@PROJECT_SOURCE_DIR@/packages \
|
||||
@PROJECT_SOURCE_DIR@/swi/library \
|
||||
@PROJECT_SOURCE_DIR@/docs/md \
|
||||
@PROJECT_SOURCE_DIR@/INSTALL.md
|
||||
@PROJECT_SOURCE_DIR@/swi/library
|
||||
# @PROJECT_SOURCE_DIR@/docs/md \
|
||||
# @PROJECT_SOURCE_DIR@/INSTALL.md
|
||||
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
@ -829,9 +829,11 @@ RECURSIVE = YES
|
||||
|
||||
EXCLUDE = *pltotex.pl \
|
||||
@PROJECT_SOURCE_DIR@/packages/myddas/sqlite3/src \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/4.0.* \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/3,* \
|
||||
@PROJECT_SOURCE_DIR@/C/traced_absmi_insts.h
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/4.* \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/3.* \
|
||||
@PROJECT_SOURCE_DIR@/C/traced_absmi_insts.h \
|
||||
/Users/vsc/github/yap-6.3/packages/cplint \
|
||||
/Users/vsc/github/yap-6.3/packages/CLPBN/examples
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||
|
@ -3,26 +3,110 @@
|
||||
Installing YAP {#install}
|
||||
==============
|
||||
|
||||
YAP-6.3.4 is a [`cmake`](www.cmake.org) based system. We discuss how to use `cmake`
|
||||
to install YAP, and what are the major options.
|
||||
### Downloading YAP {#download}
|
||||
|
||||
Compiling YAP {#CompilingYAP}
|
||||
The latest development version of Yap-6 is available source-only through GIT repositories. The main references
|
||||
repository is at
|
||||
|
||||
+ [github](https://github.com/vscosta/yap-6.3)
|
||||
|
||||
We store an older version of YAP at:
|
||||
|
||||
+ [sourceforge](http://sourceforge.net/p/yap/yap-6.3)
|
||||
|
||||
Please just use `git clone` to obtain the distribution. Ie, to download YAP from the command line please type:
|
||||
|
||||
~~~~=
|
||||
git clone https://github.com/vscosta/yap-6.3 yap-6.3
|
||||
~~~~~
|
||||
|
||||
The first argument is the repository, the last argument is the (optional) target directory.
|
||||
|
||||
There are a variety of graphical interfaces to `git`, including GitHub's own [GitHub Desktop](https://desktop.github.com/) that supports Microsoft Windows and Apple OSX. A list with GUI applications, editor integration, and much more can be found at the [git Wiki](https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools),
|
||||
|
||||
#### Download Options
|
||||
|
||||
More detailed, maybe useful information:
|
||||
|
||||
+ If you are have limited bandwith or disk room, consider using
|
||||
`git clone --depth XX` to only include the last `XX` commits.
|
||||
|
||||
+ Older versions of YAP were distributed with modules. YAP-6.3.5 is
|
||||
a single package, and it does not need `git submodule`.
|
||||
|
||||
+ The GitHub site includes a number of companion packages,
|
||||
including [doxygen-yap](https://github.com/vscosta/doxygen-yap), a
|
||||
version of doxygen adapted to Prolog that was used to generate
|
||||
these documents.
|
||||
|
||||
### Compiling YAP {#CompilingYAP}
|
||||
-------------
|
||||
|
||||
To compile YAP it should be sufficient to:
|
||||
YAP-6.3.4 is a [cmake](www.cmake.org) based
|
||||
system. We use `cmake` because it supports mosts popular software, can
|
||||
generate Makefiles, Ninja, Apple's XCode, VisualStudio and ANdroid
|
||||
Studio, and because it includes packaging suppport, The steps required
|
||||
to install core YAP under `cmake`:
|
||||
|
||||
0: Install a version of `cmake` 3.0 or above, if you don't have it, and add it to your path, you can find it here: https://cmake.org/
|
||||
* OSX: Create a symbolic link to the command line executables in
|
||||
/usr/local/bin (which should be on your path) with `sudo ln -s /Applications/CMake.app/Contents/bin/* /usr/local/bin/`
|
||||
##### Ensure that you have a working `C/C++` compiler in your system
|
||||
|
||||
1. Status as of early 17
|
||||
|
||||
YAP should compile well under the [GNU-CC](https://gcc.gnu.org/)
|
||||
and the [C-LANG]https://clang.llvm.org/() families, that are
|
||||
available across most configurations. It sshould also compile well
|
||||
undder Intel `icc`.
|
||||
|
||||
We do not recommend using Microoft's VC++. To the best of our
|
||||
knowledge MSC does not support threaded code, which YAP recquires
|
||||
for performance, You can still use the IDE, and experiment with
|
||||
the c-lang plugin.
|
||||
|
||||
YAP compiles cleanly under cross-compilers, and we have used the
|
||||
crosss-compirt [mxe](http://mxe.cc/) system with good results.
|
||||
|
||||
##### Ensure that you have a working `cmake` in your systen,
|
||||
|
||||
All Linux and BSD distributions include `cmake`, so
|
||||
does [Homebrew](https://brew.sh/)
|
||||
and [MacPorts](https://www.macports.org/) for the Mac,
|
||||
and [MSYS2](http://www.msys2.org/) and [cygwin](http://www.cygwin.org/)
|
||||
for WIN32. Android Studio has native support, and there are excellenr
|
||||
plugins for the Visual Codes. The `cmake` site includes pre-compiled
|
||||
binaries. If you have an older Linux you may need to compile from
|
||||
source, available at GitHub.
|
||||
|
||||
##### Ensure that you have other necessary packages installed:
|
||||
|
||||
+ YAP requires [gmp]{https://gmplib.org/} for infinite precision
|
||||
integer and rational. Please ensure the development pacakage
|
||||
is installed in Linux: `(lib)gmp-dev(el). In the Mac and
|
||||
WIN32, you can obtain GMPlib from the pakage collections mentioned above.
|
||||
|
||||
The [MPIR]{http://mpir.org} library is compatible with GMPlib,
|
||||
and has good support for VC++.
|
||||
|
||||
+ The [readline]() library provides line-editing and command
|
||||
history. In Linux, make sure you have the development package.
|
||||
|
||||
Readline is disabled by default in WIN32. OSX is distributed with a line editing library that includes a subset of readline. We advise against using that library.
|
||||
|
||||
- To use YAP as a library in [Python]() you need the [SWIG]()
|
||||
interface generator and python3-dev. SWIG and Python binaries can be
|
||||
easily obtained for all these platfors
|
||||
|
||||
+ make sure to install Python-3, and not Python-2,
|
||||
|
||||
##### Compile and Install
|
||||
|
||||
1: Create a directory, say `Build` and `cd` to the directory (`cd Build`).
|
||||
* Avoid compiling YAP in the src directory, some packages do not allow for that.
|
||||
*YAP should not be compiled at its rootxo directory, some packages do not allow for that.
|
||||
|
||||
2: Run `cmake ../` from within `Build` (or equivalent)
|
||||
|
||||
3: Run `make` from within `Build` (or equivalent)
|
||||
|
||||
4: If the compilation succeeds, try `./yap`. This is your executable.
|
||||
4: If the compilation succeeds, try `./yap`. This is your executable.
|
||||
|
||||
5: If you feel satisfied with the result, do `make install`.
|
||||
* In most systems you will need to be superuser in order to do `make install` and `make info` on the standard directories.
|
@ -2,17 +2,13 @@
|
||||
Downloading YAP {#download}
|
||||
==============
|
||||
|
||||
The latest development version of Yap-6 is yap-6.3.4 and can be
|
||||
The latest development version of Yap-6 is yap-6.3.5 and can be
|
||||
obtained from the repositories
|
||||
|
||||
<http://sourceforge.net/p/yap/yap-6.3>
|
||||
+ [https://github.com/vscosta/yap-6.3]{github}
|
||||
|
||||
and
|
||||
and an older version at:
|
||||
|
||||
<https://github.com/vscosta/yap-6.3>
|
||||
+ [http://sourceforge.net/p/yap/yap-6.3]{sourceforge}
|
||||
|
||||
YAP-6.3.4 does not use modules. Please just use `git clone` to obtain the distribution.
|
||||
|
||||
Most of these repositories are basically copies of the original
|
||||
repositories at the SWI-Prolog site. YAP-6 will work either with or
|
||||
without these packages.
|
||||
YAP-6.3.5 does not use git submodules. Please just use `git clone` to obtain the distribution.
|
||||
|
@ -1,4 +1,4 @@
|
||||
YAP 6-3.4 Manual {#mainpage}
|
||||
YAP 6-3.5 Manual {#mainpage}
|
||||
====================
|
||||
|
||||
This file documents the YAP Prolog System version 6.3.4, a high-performance Prolog compiler developed at LIACC, Universidade do Porto. YAP is based on David H. D. Warren's WAM (Warren Abstract Machine), with several optimizations for better performance. YAP follows the Edinburgh tradition, and is largely compatible with DEC-10 Prolog, Quintus Prolog, and originally with C-Prolog.
|
||||
|
@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# yap documentation build configuration file, created by
|
||||
# sphinx-quickstart on Tue Jan 5 11:01:36 2016.
|
||||
# YAP documentation build configuration file, created by
|
||||
# sphinx-quickstart on Sun Mar 26 10:27:55 2017.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
@ -12,25 +13,26 @@
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import shlex
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
#
|
||||
# import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
from recommonmark.parser import CommonMarkParser
|
||||
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
#
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
extensions = ['sphinx.ext.autodoc',
|
||||
'sphinx.ext.doctest',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.todo',
|
||||
@ -38,37 +40,38 @@ extensions = [
|
||||
'sphinx.ext.mathjax',
|
||||
'sphinx.ext.ifconfig',
|
||||
'sphinx.ext.viewcode',
|
||||
'sphinx.ext.pngmath',
|
||||
'breathe'
|
||||
'sphinx.ext.githubpages',
|
||||
'breathe'
|
||||
]
|
||||
|
||||
breathe_projects = { "yap": "/Users/vsc/github/yap-6.3/Debug/docs/xml" }
|
||||
breathe_default_project = "yap"
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
#
|
||||
source_suffix = ['.rst', '.md']
|
||||
# source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'yap'
|
||||
copyright = u'2016, Vitor Santos Costa'
|
||||
author = u'Vitor Santos Costa'
|
||||
project = 'YAP'
|
||||
copyright = '2017, Vitor Santos Costa'
|
||||
author = 'Vitor Santos Costa'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = u'4.6.3'
|
||||
version = '6.3'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = u'4.6.3'
|
||||
release = '6.3.5'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
@ -77,199 +80,83 @@ release = u'4.6.3'
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This patterns also effect to html_static_path and html_extra_path
|
||||
exclude_patterns = []
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
#keep_warnings = False
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
||||
|
||||
|
||||
source_parsers = {
|
||||
'.md': 'recommonmark.parser.CommonMarkParser',
|
||||
}
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'alabaster'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
#
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
# directly to the root of the documentation.
|
||||
#html_extra_path = []
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Language to be used for generating the HTML full-text search index.
|
||||
# Sphinx supports the following languages:
|
||||
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
|
||||
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
|
||||
#html_search_language = 'en'
|
||||
|
||||
# A dictionary with options for the search language support, empty by default.
|
||||
# Now only 'ja' uses this config value
|
||||
#html_search_options = {'type': 'default'}
|
||||
|
||||
# The name of a javascript file (relative to the configuration directory) that
|
||||
# implements a search results scorer. If empty, the default will be used.
|
||||
#html_search_scorer = 'scorer.js'
|
||||
# -- Options for HTMLHelp output ------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'yapdoc'
|
||||
htmlhelp_basename = 'YAPdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#'figure_align': 'htbp',
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'yap.tex', u'yap Documentation',
|
||||
u'Vitor Santos Costa', 'manual'),
|
||||
(master_doc, 'YAP.tex', 'YAP Documentation',
|
||||
'Vitor Santos Costa', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'yap', u'yap Documentation',
|
||||
(master_doc, 'yap', 'YAP Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
@ -277,27 +164,34 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'yap', u'yap Documentation',
|
||||
author, 'yap', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(master_doc, 'YAP', 'YAP Documentation',
|
||||
author, 'YAP', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
# -- Options for Epub output ----------------------------------------------
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = project
|
||||
epub_author = author
|
||||
epub_publisher = author
|
||||
epub_copyright = copyright
|
||||
|
||||
# The unique identifier of the text. This can be a ISBN number
|
||||
# or the project homepage.
|
||||
#
|
||||
# epub_identifier = ''
|
||||
|
||||
# A unique identification for the text.
|
||||
#
|
||||
# epub_uid = ''
|
||||
|
||||
# A list of files that should not be packed into the epub file.
|
||||
epub_exclude_files = ['search.html']
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {'https://docs.python.org/': None}
|
||||
|
||||
breathe_projects = { "yap": "/Users/vsc/git/yap-6.3/Release/docs/xml/" }
|
||||
breathe_default_project = "yap"
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
extensions = [
|
||||
breathe_projects = { "yap": "/Users/vsc/git/yap-6.3/Release/doc/xml/" }i
|
||||
breathe_default_project = "yap"
|
||||
.. doxygenindex::
|
||||
.. doxygenfunction::
|
||||
.. doxygenstruct::
|
||||
.. doxygenenum::
|
||||
.. doxygentypedef::
|
||||
.. doxygenclass::
|
||||
|
@ -1,16 +1,11 @@
|
||||
.. yap documentation master file, created by
|
||||
sphinx-quickstart on Tue Jan 5 11:01:36 2016.
|
||||
.. YAP documentation master file, created by
|
||||
sphinx-quickstart on Sun Mar 26 10:27:55 2017.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to yap's documentation!
|
||||
Welcome to YAP's documentation!
|
||||
===============================
|
||||
|
||||
Contents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
.. doxygenindex::
|
||||
.. doxygenfunction::
|
||||
.. doxygenstruct::
|
||||
@ -18,12 +13,33 @@ Contents:
|
||||
.. doxygentypedef::
|
||||
.. doxygenclass::
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
'../../md/attributes.md'
|
||||
'../../md'/builtins.md'
|
||||
'../../md'/download.md'
|
||||
'../../md'/extensions.md'
|
||||
'../../md'/fli.md'
|
||||
'../../md'/library.md'
|
||||
'../../md'/load_files.md'
|
||||
'../../md'/modules.md'
|
||||
'../../md'/packages.md'
|
||||
'../../md'/run.md'
|
||||
'../../md'/swi.md'
|
||||
'../../md'/syntax.md'
|
||||
'../../md'/yap.md'
|
||||
'classlist.rst'
|
||||
'file.rst'
|
||||
'group.rst'
|
||||
'section.rst'
|
||||
'union.rst'
|
||||
'namespace.rst'
|
||||
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @date Tue Nov 17 01:08:55 2015
|
||||
*
|
||||
* @brief arg/3 and friends
|
||||
* @brief
|
||||
*/
|
||||
|
||||
|
||||
@ -20,6 +20,10 @@
|
||||
]).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup arg Term Argument Manipulation.
|
||||
|
||||
@ -40,8 +44,7 @@ to sub-arguments,
|
||||
|
||||
It is based on the Quintus Prolog arg library. Except for project, all
|
||||
predicates use the arg/3 argument pattern.
|
||||
|
||||
This file has been included in the YAP library by Vitor Santos Costa, 2008. No error checking is actuallly performed within the package: this left to the C-code thaat implements arg/3 and
|
||||
This file has been included in the YAP library by Vitor Santos Costa, 2008. No error checking is actuallly performed within the package: this left to the C-code thaat implements arg``/3 and
|
||||
genarg/3.
|
||||
*/
|
||||
|
||||
|
@ -30,7 +30,7 @@ static char SccsId[] = "%W% %G%";
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup Aliases
|
||||
* @defgroup Aliases File Aliases
|
||||
* @ingroup InputOutput
|
||||
*
|
||||
* Aliases:
|
||||
|
@ -40,6 +40,13 @@ but are strict in argument checking.
|
||||
+ Symbols are processed as Prolog symbols, exception are modifiers
|
||||
that are handled as lower-case letters.
|
||||
|
||||
Predicates are:
|
||||
|
||||
+ @ref char_type/2
|
||||
+ @ref code_type/2
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/** @predicate char_type(?_Char_ , ?Type)
|
||||
@ -261,7 +268,7 @@ p_code_type( LOWER , lower) :-
|
||||
p_code_type( LOWER, lower( Upper)) :-
|
||||
toupper( LOWER, Upper),
|
||||
code_type_lower( LOWER ).
|
||||
p_code_type( LOWER, to_lower( Upper)) :-
|
||||
vp_code_type( LOWER, to_lower( Upper)) :-
|
||||
toupper( LOWER, Upper).
|
||||
p_code_type( UPPER, upper ) :-
|
||||
code_type_upper( UPPER ).
|
||||
@ -372,7 +379,7 @@ digit_weight( 0x1D7CE, 0).
|
||||
digit_weight( 0x1D7D8, 0).
|
||||
digit_weight( 0x1D7E2, 0).
|
||||
digit_weight( 0x1D7EC, 0).
|
||||
digit_weight( 0x1D7F6, 0).
|
||||
vdigit_weight( 0x1D7F6, 0).
|
||||
digit_weight( 0x1F100, 0x1F101, 0).
|
||||
digit_weight( 0x1F10B, 0x1F10C, 0).
|
||||
digit_weight( 0x09F4, 1/16).
|
||||
@ -1379,6 +1386,7 @@ digit_weight( 0x1D7D7, 9).
|
||||
digit_weight( 0x1D7E1, 9).
|
||||
digit_weight( 0x1D7EB, 9).
|
||||
digit_weight( 0x1D7F5, 9).
|
||||
x
|
||||
digit_weight( 0x1D7FF, 9).
|
||||
digit_weight( 0x1E8CF, 9).
|
||||
digit_weight( 0x1F10A, 9).
|
||||
@ -1909,3 +1917,5 @@ paren_paren( 0xFF5F, 0xFF60).
|
||||
paren_paren( 0xFF60, 0xFF5F).
|
||||
paren_paren( 0xFF62, 0xFF63).
|
||||
paren_paren( 0xFF63, 0xFF62).
|
||||
|
||||
/// @}
|
@ -1,5 +1,4 @@
|
||||
bplist00Ñ_WebMainResourceÕ
|
||||
_WebResourceTextEncodingName_WebResourceFrameName^WebResourceURL_WebResourceData_WebResourceMIMETypeUUTF-8P_Phttps://raw.githubusercontent.com/j-jorge/android-stdioext/master/src/fmemopen.cO#H<html><head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/* Copyright (C) 2007 Eric Blake
|
||||
* Copyright (C) 2007 Eric Blake
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* is freely granted, provided that this notice is preserved.
|
||||
*
|
||||
@ -8,68 +7,68 @@ bplist00
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<fmemopen>>---open a stream around a fixed-length string
|
||||
<fmemopen>>---open a stream around a fixed-length string
|
||||
|
||||
INDEX
|
||||
fmemopen
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
FILE *fmemopen(void *restrict <[buf]>, size_t <[size]>,
|
||||
const char *restrict <[mode]>);
|
||||
#include <stdio.h>
|
||||
FILE *fmemopen(void *restrict <[buf]>, size_t <[size]>,
|
||||
const char *restrict <[mode]>);
|
||||
|
||||
DESCRIPTION
|
||||
<<fmemopen>> creates a seekable <<FILE>> stream that wraps a
|
||||
fixed-length buffer of <[size]> bytes starting at <[buf]>. The stream
|
||||
is opened with <[mode]> treated as in <<fopen>>, where append mode
|
||||
starts writing at the first NUL byte. If <[buf]> is NULL, then
|
||||
<[size]> bytes are automatically provided as if by <<malloc>>, with
|
||||
the initial size of 0, and <[mode]> must contain <<+>> so that data
|
||||
<<fmemopen>> creates a seekable <<FILE>> stream that wraps a
|
||||
fixed-length buffer of <[size]> bytes starting at <[buf]>. The stream
|
||||
is opened with <[mode]> treated as in <<fopen>>, where append mode
|
||||
starts writing at the first NUL byte. If <[buf]> is NULL, then
|
||||
<[size]> bytes are automatically provided as if by <<malloc>>, with
|
||||
the initial size of 0, and <[mode]> must contain <<+>> so that data
|
||||
can be read after it is written.
|
||||
|
||||
The stream maintains a current position, which moves according to
|
||||
bytes read or written, and which can be one past the end of the array.
|
||||
The stream also maintains a current file size, which is never greater
|
||||
than <[size]>. If <[mode]> starts with <<r>>, the position starts at
|
||||
<<0>>, and file size starts at <[size]> if <[buf]> was provided. If
|
||||
<[mode]> starts with <<w>>, the position and file size start at <<0>>,
|
||||
and if <[buf]> was provided, the first byte is set to NUL. If
|
||||
<[mode]> starts with <<a>>, the position and file size start at the
|
||||
location of the first NUL byte, or else <[size]> if <[buf]> was
|
||||
than <[size]>. If <[mode]> starts with <<r>>, the position starts at
|
||||
<<0>>, and file size starts at <[size]> if <[buf]> was provided. If
|
||||
<[mode]> starts with <<w>>, the position and file size start at <<0>>,
|
||||
and if <[buf]> was provided, the first byte is set to NUL. If
|
||||
<[mode]> starts with <<a>>, the position and file size start at the
|
||||
location of the first NUL byte, or else <[size]> if <[buf]> was
|
||||
provided.
|
||||
|
||||
When reading, NUL bytes have no significance, and reads cannot exceed
|
||||
the current file size. When writing, the file size can increase up to
|
||||
<[size]> as needed, and NUL bytes may be embedded in the stream (see
|
||||
<<open_memstream>> for an alternative that automatically enlarges the
|
||||
<[size]> as needed, and NUL bytes may be embedded in the stream (see
|
||||
<<open_memstream>> for an alternative that automatically enlarges the
|
||||
buffer). When the stream is flushed or closed after a write that
|
||||
changed the file size, a NUL byte is written at the current position
|
||||
if there is still room; if the stream is not also open for reading, a
|
||||
NUL byte is additionally written at the last byte of <[buf]> when the
|
||||
stream has exceeded <[size]>, so that a write-only <[buf]> is always
|
||||
NUL byte is additionally written at the last byte of <[buf]> when the
|
||||
stream has exceeded <[size]>, so that a write-only <[buf]> is always
|
||||
NUL-terminated when the stream is flushed or closed (and the initial
|
||||
<[size]> should take this into account). It is not possible to seek
|
||||
outside the bounds of <[size]>. A NUL byte written during a flush is
|
||||
<[size]> should take this into account). It is not possible to seek
|
||||
outside the bounds of <[size]>. A NUL byte written during a flush is
|
||||
restored to its previous value when seeking elsewhere in the string.
|
||||
|
||||
RETURNS
|
||||
The return value is an open FILE pointer on success. On error,
|
||||
<<NULL>> is returned, and <<errno>> will be set to EINVAL if <[size]>
|
||||
is zero or <[mode]> is invalid, ENOMEM if <[buf]> was NULL and memory
|
||||
<<NULL>> is returned, and <<errno>> will be set to EINVAL if <[size]>
|
||||
is zero or <[mode]> is invalid, ENOMEM if <[buf]> was NULL and memory
|
||||
could not be allocated, or EMFILE if too many streams are already
|
||||
open.
|
||||
|
||||
PORTABILITY
|
||||
This function is being added to POSIX 200x, but is not in POSIX 2001.
|
||||
|
||||
Supporting OS subroutines required: <<sbrk>>.
|
||||
Supporting OS subroutines required: <<sbrk>>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include "stdioext.h"
|
||||
|
||||
/* Describe details of an open memstream. */
|
||||
@ -91,12 +90,12 @@ fmemread(void *cookie, char *buf, int n)
|
||||
{
|
||||
fmemcookie *c = (fmemcookie *) cookie;
|
||||
/* Can't read beyond current size, but EOF condition is not an error. */
|
||||
if (c->pos > c->eof)
|
||||
if (c->pos > c->eof)
|
||||
return 0;
|
||||
if (n >= c->eof - c->pos)
|
||||
n = c->eof - c->pos;
|
||||
memcpy (buf, c->buf + c->pos, n);
|
||||
c->pos += n;
|
||||
if (n >= c->eof - c->pos)
|
||||
n = c->eof - c->pos;
|
||||
memcpy (buf, c->buf + c->pos, n);
|
||||
c->pos += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -110,40 +109,40 @@ fmemwrite(void *cookie, const char *buf, int n)
|
||||
|
||||
/* Append always seeks to eof; otherwise, if we have previously done
|
||||
a seek beyond eof, ensure all intermediate bytes are NUL. */
|
||||
if (c->append)
|
||||
c->pos = c->eof;
|
||||
else if (c->pos > c->eof)
|
||||
memset (c->buf + c->eof, '\0', c->pos - c->eof);
|
||||
if (c->append)
|
||||
c->pos = c->eof;
|
||||
else if (c->pos > c->eof)
|
||||
memset (c->buf + c->eof, '\0', c->pos - c->eof);
|
||||
/* Do not write beyond EOF; saving room for NUL on write-only stream. */
|
||||
if (c->pos + n > c->max - c->writeonly)
|
||||
if (c->pos + n > c->max - c->writeonly)
|
||||
{
|
||||
adjust = c->writeonly;
|
||||
n = c->max - c->pos;
|
||||
adjust = c->writeonly;
|
||||
n = c->max - c->pos;
|
||||
}
|
||||
/* Now n is the number of bytes being modified, and adjust is 1 if
|
||||
the last byte is NUL instead of from buf. Write a NUL if
|
||||
write-only; or if read-write, eof changed, and there is still
|
||||
room. When we are within the file contents, remember what we
|
||||
overwrite so we can restore it if we seek elsewhere later. */
|
||||
if (c->pos + n > c->eof)
|
||||
if (c->pos + n > c->eof)
|
||||
{
|
||||
c->eof = c->pos + n;
|
||||
if (c->eof - adjust < c->max)
|
||||
c->saved = c->buf[c->eof - adjust] = '\0';
|
||||
c->eof = c->pos + n;
|
||||
if (c->eof - adjust < c->max)
|
||||
c->saved = c->buf[c->eof - adjust] = '\0';
|
||||
}
|
||||
else if (c->writeonly)
|
||||
else if (c->writeonly)
|
||||
{
|
||||
if (n)
|
||||
{
|
||||
c->saved = c->buf[c->pos + n - adjust];
|
||||
c->buf[c->pos + n - adjust] = '\0';
|
||||
c->saved = c->buf[c->pos + n - adjust];
|
||||
c->buf[c->pos + n - adjust] = '\0';
|
||||
}
|
||||
else
|
||||
adjust = 0;
|
||||
}
|
||||
c->pos += n;
|
||||
c->pos += n;
|
||||
if (n - adjust)
|
||||
memcpy (c->buf + c->pos - n, buf, n - adjust);
|
||||
memcpy (c->buf + c->pos - n, buf, n - adjust);
|
||||
else
|
||||
{
|
||||
return EOF;
|
||||
@ -160,29 +159,29 @@ fmemseek(void *cookie, fpos_t pos, int whence)
|
||||
off_t offset = (off_t) pos;
|
||||
|
||||
if (whence == SEEK_CUR)
|
||||
offset += c->pos;
|
||||
offset += c->pos;
|
||||
else if (whence == SEEK_END)
|
||||
offset += c->eof;
|
||||
if (offset < 0)
|
||||
offset += c->eof;
|
||||
if (offset < 0)
|
||||
{
|
||||
offset = -1;
|
||||
}
|
||||
else if (offset > c->max)
|
||||
else if (offset > c->max)
|
||||
{
|
||||
offset = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c->writeonly && c->pos < c->eof)
|
||||
if (c->writeonly && c->pos < c->eof)
|
||||
{
|
||||
c->buf[c->pos] = c->saved;
|
||||
c->saved = '\0';
|
||||
c->buf[c->pos] = c->saved;
|
||||
c->saved = '\0';
|
||||
}
|
||||
c->pos = offset;
|
||||
if (c->writeonly && c->pos < c->eof)
|
||||
c->pos = offset;
|
||||
if (c->writeonly && c->pos < c->eof)
|
||||
{
|
||||
c->saved = c->buf[c->pos];
|
||||
c->buf[c->pos] = '\0';
|
||||
c->saved = c->buf[c->pos];
|
||||
c->buf[c->pos] = '\0';
|
||||
}
|
||||
}
|
||||
return (fpos_t) offset;
|
||||
@ -193,7 +192,7 @@ static int
|
||||
fmemclose(void *cookie)
|
||||
{
|
||||
fmemcookie *c = (fmemcookie *) cookie;
|
||||
free (c->storage);
|
||||
free (c->storage);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -217,63 +216,61 @@ fmemopen(void *buf, size_t size, const char *mode)
|
||||
return NULL;
|
||||
if ((c = (fmemcookie *) malloc (sizeof *c + (buf ? 0 : size))) == NULL)
|
||||
{
|
||||
fp->_flags = 0; /* release */
|
||||
fp->_flags = 0; /* release */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
c->storage = c;
|
||||
c->max = size;
|
||||
c->storage = c;
|
||||
c->max = size;
|
||||
/* 9 modes to worry about. */
|
||||
/* w/a, buf or no buf: Guarantee a NUL after any file writes. */
|
||||
c->writeonly = (flags & __SWR) != 0;
|
||||
c->saved = '\0';
|
||||
c->writeonly = (flags & __SWR) != 0;
|
||||
c->saved = '\0';
|
||||
if (!buf)
|
||||
{
|
||||
/* r+/w+/a+, and no buf: file starts empty. */
|
||||
c->buf = (char *) (c + 1);
|
||||
c->buf = (char *) (c + 1);
|
||||
*(char *) buf = '\0';
|
||||
c->pos = c->eof = 0;
|
||||
c->append = (flags & __SAPP) != 0;
|
||||
c->pos = c->eof = 0;
|
||||
c->append = (flags & __SAPP) != 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
c->buf = (char *) buf;
|
||||
c->buf = (char *) buf;
|
||||
switch (*mode)
|
||||
{
|
||||
case 'a':
|
||||
/* a/a+ and buf: position and size at first NUL. */
|
||||
buf = memchr (c->buf, '\0', size);
|
||||
c->eof = c->pos = buf ? (char *) buf - c->buf : size;
|
||||
if (!buf && c->writeonly)
|
||||
buf = memchr (c->buf, '\0', size);
|
||||
c->eof = c->pos = buf ? (char *) buf - c->buf : size;
|
||||
if (!buf && c->writeonly)
|
||||
/* a: guarantee a NUL within size even if no writes. */
|
||||
c->buf[size - 1] = '\0';
|
||||
c->append = 1;
|
||||
c->buf[size - 1] = '\0';
|
||||
c->append = 1;
|
||||
break;
|
||||
case 'r':
|
||||
/* r/r+ and buf: read at beginning, full size available. */
|
||||
c->pos = c->append = 0;
|
||||
c->eof = size;
|
||||
c->pos = c->append = 0;
|
||||
c->eof = size;
|
||||
break;
|
||||
case 'w':
|
||||
/* w/w+ and buf: write at beginning, truncate to empty. */
|
||||
c->pos = c->append = c->eof = 0;
|
||||
*c->buf = '\0';
|
||||
c->pos = c->append = c->eof = 0;
|
||||
*c->buf = '\0';
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fp->_file = -1;
|
||||
fp->_flags = flags;
|
||||
fp->_cookie = c;
|
||||
fp->_read = flags & (__SRD | __SRW) ? fmemread : NULL;
|
||||
fp->_write = flags & (__SWR | __SRW) ? fmemwrite : NULL;
|
||||
fp->_seek = fmemseek;
|
||||
fp->_close = fmemclose;
|
||||
fp->_file = -1;
|
||||
fp->_flags = flags;
|
||||
fp->_cookie = c;
|
||||
fp->_read = flags & (__SRD | __SRW) ? fmemread : NULL;
|
||||
fp->_write = flags & (__SWR | __SRW) ? fmemwrite : NULL;
|
||||
fp->_seek = fmemseek;
|
||||
fp->_close = fmemclose;
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
||||
</pre></body></html>Ztext/plain |