Compare commits

...

8 Commits
main ... dev_yi

Author SHA1 Message Date
0d7d8311d0 edit Dockerfile 2025-05-22 11:20:55 +08:00
96793dc190 update dockerfile 2025-05-16 10:53:30 +08:00
bfa8429b54 update dockerfile 2025-05-13 16:44:42 +08:00
62e7fc7cba add gnuplot to dockerfile 2025-05-13 12:04:17 +08:00
efc3e7c70c update docker support 2025-05-13 10:17:17 +08:00
70723fd147 add docker support 2025-05-13 08:40:01 +08:00
0411d8c19b cleanup 2025-05-12 19:58:45 +08:00
3377641ee3 tmp 2025-05-12 10:41:04 +08:00
76 changed files with 54112 additions and 51 deletions

View File

@ -1,24 +1,57 @@
cmake_minimum_required(VERSION 3.15.2)
project(GCTL_TOOLKITS VERSION 1.0)
project(GCTL_TOOLKITS VERSION 2.0)
find_package(GCTL REQUIRED)
find_package(GCTL_MESH REQUIRED)
find_package(GCTL_OPTIMIZATION REQUIRED)
find_package(GCTL_POTENTIAL REQUIRED)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# ExprTKmacOS 15.4
add_compile_options(-Wno-missing-template-arg-list-after-template-kw)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
find_package(PkgConfig)
pkg_search_module(EDITLINE QUIET libeditline)
find_package(GCTL QUIET)
find_package(GCTL_MESH QUIET)
find_package(GCTL_OPTIMIZATION QUIET)
find_package(GCTL_POTENTIAL QUIET)
include_directories(${GCTL_INC_DIR})
include_directories(${GCTL_MESH_INC_DIR})
include_directories(${GCTL_OPTIMIZATION_INC_DIR})
include_directories(${GCTL_POTENTIAL_INC_DIR})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${BIN_DIR})
message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME})
message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX})
message(STATUS "Processor: " ${CMAKE_HOST_SYSTEM_PROCESSOR})
if(GCTL_FOUND)
message(STATUS "GCTL Version: " ${GCTL_VERSION})
endif()
if(GCTL_MESH_FOUND)
message(STATUS "GCTL_MESH Version: " ${GCTL_MESH_VERSION})
endif()
if(GCTL_OPTIMIZATION_FOUND)
message(STATUS "GCTL_OPTIMIZATION Version: " ${GCTL_OPTIMIZATION_VERSION})
endif()
if(GCTL_POTENTIAL_FOUND)
message(STATUS "GCTL_POTENTIAL Version: " ${GCTL_POTENTIAL_VERSION})
endif()
#
option(GCTL_TOOLKITS_INSTALL_PREFIX "Pass install directory." ON)
set(DIR_VAR ${CMAKE_INSTALL_PREFIX})
# cmake
configure_file(
"${PROJECT_SOURCE_DIR}/config.h.in"
"${PROJECT_SOURCE_DIR}/gctl_toolkits_config.h"
)
macro(add_toolkit name lib1 lib2 lib3 lib4)
aux_source_directory(${name} ${name}_src)
add_executable(${name} ${${name}_src})
@ -44,27 +77,63 @@ macro(add_toolkit name lib1 lib2 lib3 lib4)
install(TARGETS ${name} RUNTIME DESTINATION sbin)
endmacro()
add_toolkit(2minfo ON ON OFF OFF)
add_toolkit(addnoise ON OFF OFF OFF)
add_toolkit(cutprofile ON OFF OFF OFF)
add_toolkit(fractopo ON OFF OFF OFF)
add_toolkit(gm3d ON OFF OFF OFF)
add_toolkit(gmsh2vtk ON OFF OFF OFF)
add_toolkit(gmshinfo ON OFF OFF OFF)
add_toolkit(grd2xyz ON OFF OFF OFF)
add_toolkit(handyman ON OFF OFF OFF)
add_toolkit(lbsi ON OFF ON OFF)
add_toolkit(lki ON OFF ON OFF)
add_toolkit(nc2other ON OFF OFF OFF)
add_toolkit(ncget ON OFF OFF OFF)
add_toolkit(ncinfo ON OFF OFF OFF)
add_toolkit(shc2xyz ON OFF OFF OFF)
add_toolkit(slbsi ON OFF ON OFF)
add_toolkit(sph2plane ON OFF OFF OFF)
add_toolkit(tetgen2gmsh ON OFF OFF OFF)
add_toolkit(tetgm ON OFF ON ON)
add_toolkit(trackline ON OFF OFF OFF)
add_toolkit(triangle2gmsh ON OFF OFF OFF)
add_toolkit(txtinfo ON OFF OFF OFF)
add_toolkit(xyz2nc ON OFF OFF OFF)
add_toolkit(xyz2sph ON OFF OFF OFF)
if(GCTL_FOUND)
add_toolkit(addnoise ON OFF OFF OFF)
add_toolkit(cutprofile ON OFF OFF OFF)
add_toolkit(fractopo ON OFF OFF OFF)
add_toolkit(gm3d ON OFF OFF OFF)
add_toolkit(gmsh2vtk ON OFF OFF OFF)
add_toolkit(gmshinfo ON OFF OFF OFF)
add_toolkit(grd2xyz ON OFF OFF OFF)
add_toolkit(handyman ON OFF OFF OFF)
add_toolkit(nc2other ON OFF OFF OFF)
add_toolkit(ncget ON OFF OFF OFF)
add_toolkit(ncinfo ON OFF OFF OFF)
add_toolkit(shc2xyz ON OFF OFF OFF)
add_toolkit(sph2plane ON OFF OFF OFF)
add_toolkit(tetgen2gmsh ON OFF OFF OFF)
add_toolkit(trackline ON OFF OFF OFF)
add_toolkit(triangle2gmsh ON OFF OFF OFF)
add_toolkit(txtinfo ON OFF OFF OFF)
add_toolkit(xyz2nc ON OFF OFF OFF)
add_toolkit(xyz2sph ON OFF OFF OFF)
endif()
if(GCTL_FOUND AND GCTL_MESH_FOUND)
add_toolkit(2minfo ON ON OFF OFF)
endif()
if(GCTL_FOUND AND GCTL_OPTIMIZATION_FOUND)
add_toolkit(slbsi ON OFF ON OFF)
add_toolkit(lbsi ON OFF ON OFF)
add_toolkit(lki ON OFF ON OFF)
add_toolkit(levy_planner ON OFF ON OFF)
endif()
if(GCTL_FOUND AND GCTL_OPTIMIZATION_FOUND AND GCTL_POTENTIAL_FOUND)
add_toolkit(tetgm ON OFF ON ON)
endif()
if(EDITLINE_FOUND AND GCTL_FOUND)
add_toolkit(dsviewer ON OFF OFF OFF)
target_link_libraries(dsviewer PRIVATE ${EDITLINE_LIBRARIES})
file(GLOB HELP_DOC dsviewer/dsviewer.md)
install(FILES ${HELP_DOC} DESTINATION sbin/share)
endif()
if(EDITLINE_FOUND AND GCTL_FOUND AND GCTL_MESH_FOUND)
add_toolkit(gridmanager ON ON OFF OFF)
target_link_libraries(gridmanager PRIVATE ${EDITLINE_LIBRARIES})
file(GLOB HELP_DOC gridmanager/readme_gridmanager.md)
install(FILES ${HELP_DOC} DESTINATION sbin/share)
endif()
if(EDITLINE_FOUND AND GCTL_FOUND AND GCTL_POTENTIAL_FOUND)
add_toolkit(gridmanager-potential ON ON OFF ON)
target_link_libraries(gridmanager-potential PRIVATE ${EDITLINE_LIBRARIES})
file(GLOB HELP_DOC gridmanager-potential/readme_gridmanager_potential.md)
install(FILES ${HELP_DOC} DESTINATION sbin/share)
endif()

100
Dockerfile Normal file
View File

@ -0,0 +1,100 @@
# 导入代码库镜像 视包含的代码库多少编译后的镜像可包含部分至全部GCTL代码库内容
FROM gctl:2.0 AS gctl_library
FROM gctl_mesh:2.0 AS gctl_mesh_library
FROM gctl_optimization:2.0 AS gctl_optimization_library
FROM gctl_ai:2.0 AS gctl_ai_library
FROM gctl_potential:2.0 AS gctl_potential_library
FROM gctl_seismic:2.0 AS gctl_seismic_library
FROM gctl_elecmag:2.0 AS gctl_elecmag_library
# 编译平台
FROM ubuntu:20.04 AS builder
# 从代码库镜像中复制库文件和头文件
COPY --from=gctl_library /usr/local/lib /usr/local/lib
COPY --from=gctl_library /usr/local/include /usr/local/include
COPY --from=gctl_mesh_library /usr/local/lib /usr/local/lib
COPY --from=gctl_mesh_library /usr/local/include /usr/local/include
COPY --from=gctl_optimization_library /usr/local/lib /usr/local/lib
COPY --from=gctl_optimization_library /usr/local/include /usr/local/include
COPY --from=gctl_ai_library /usr/local/lib /usr/local/lib
COPY --from=gctl_ai_library /usr/local/include /usr/local/include
COPY --from=gctl_potential_library /usr/local/lib /usr/local/lib
COPY --from=gctl_potential_library /usr/local/include /usr/local/include
COPY --from=gctl_seismic_library /usr/local/lib /usr/local/lib
COPY --from=gctl_seismic_library /usr/local/include /usr/local/include
COPY --from=gctl_elecmag_library /usr/local/lib /usr/local/lib
COPY --from=gctl_elecmag_library /usr/local/include /usr/local/include
# 安装编译工具
RUN apt-get update && apt-get install -y g++ make cmake
# 安装依赖库
RUN apt-get install -y --no-install-recommends libfftw3-dev libnetcdf-dev gmt libgmt-dev libgsl-dev libncurses-dev
RUN apt-get install -y --no-install-recommends libopenblas-dev libeigen3-dev
RUN apt-get install -y pkg-config
RUN apt-get install -y autoconf automake
# 创建工作目录
WORKDIR /app
# 编译依赖库
COPY dep/editline-1.17.1 /app/dep/editline
RUN cd /app/dep/editline && ./configure --prefix=/usr/local && make && make install
# 拷贝源代码
COPY addnoise /app/addnoise
COPY cutprofile /app/cutprofile
COPY fractopo /app/fractopo
COPY gm3d /app/gm3d
COPY gmsh2vtk /app/gmsh2vtk
COPY gmshinfo /app/gmshinfo
COPY grd2xyz /app/grd2xyz
COPY handyman /app/handyman
COPY nc2other /app/nc2other
COPY ncget /app/ncget
COPY ncinfo /app/ncinfo
COPY shc2xyz /app/shc2xyz
COPY sph2plane /app/sph2plane
COPY tetgen2gmsh /app/tetgen2gmsh
COPY trackline /app/trackline
COPY triangle2gmsh /app/triangle2gmsh
COPY txtinfo /app/txtinfo
COPY xyz2nc /app/xyz2nc
COPY xyz2sph /app/xyz2sph
COPY 2minfo /app/2minfo
COPY slbsi /app/slbsi
COPY lbsi /app/lbsi
COPY lki /app/lki
COPY levy_planner /app/levy_planner
COPY tetgm /app/tetgm
COPY dsviewer /app/dsviewer
COPY gridmanager /app/gridmanager
COPY gridmanager-potential /app/gridmanager-potential
COPY CMakeLists.txt .
COPY config.h.in .
# 编译gctl动态库
RUN mkdir build && cd build && cmake .. && make && make install
# 运行平台
FROM ubuntu:20.04
# 设置非交互式安装
ENV DEBIAN_FRONTEND=noninteractive
# 安装运行时必要依赖
RUN apt-get update && apt-get install -y g++ make cmake
RUN apt-get install -y --no-install-recommends libfftw3-dev libnetcdf-dev gmt libgmt-dev libgsl-dev libncurses-dev
RUN apt-get install -y --no-install-recommends libopenblas-dev libeigen3-dev
RUN apt-get install -y gnuplot
RUN apt-get install -y pkg-config
RUN apt-get install -y autoconf automake
RUN apt-get install -y ghostscript
# 从构建阶段复制编译后的库和头文件
COPY --from=builder /usr/local/lib /usr/local/lib
COPY --from=builder /usr/local/include /usr/local/include
COPY --from=builder /usr/local/sbin /usr/local/sbin
# 设置可执行文件列表
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
ENV PATH=$PATH:/usr/local/sbin

522
LICENSE Normal file
View File

@ -0,0 +1,522 @@
GCTL License
--------------
GCTL is distributed under a dual licensing scheme. You can redistribute
it and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, either version 2
of the License, or (at your option) any later version. A copy of the GNU
Lesser General Public License is reproduced below.
If the terms and conditions of the LGPL v.2. would prevent you from using
the GCTL, please consider the option to obtain a commercial license for a
fee. These licenses are offered by the GCTL's original author. As a rule,
licenses are provided "as-is", unlimited in time for a one time fee. Please
send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
to include some description of your company and the realm of its activities.
Also add information on how to contact you by electronic and paper mail.
=====================================================================
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random
Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

1
config.h.in Normal file
View File

@ -0,0 +1 @@
#cmakedefine GCTL_TOOLKITS_INSTALL_PREFIX "${DIR_VAR}"

View File

@ -30,7 +30,7 @@
#include "gctl/core.h"
#include "gctl/utility.h"
#include "gctl/algorithms.h"
#include "gctl/math.h"
struct node
{

View File

@ -0,0 +1,271 @@
Change Log
==========
All notable changes to the project are documented in this file.
[1.17.1][] - 2020-02-23
-----------------------
### Fixes
- Fix #38: Fix for multiline representing as one line
- Fix packaging, missing files in libeditline1, regression from 1.16.0
- Fix packaging, update to latest std version
- Fix formatting of function names in man page
- Restore tar.gz distribution, for usability on systems that do not
have xz in their default install
[1.17.0][] - 2020-01-05
-----------------------
### Changes
- Simple multi-line support by Dima Volynets, @dvolynets
### Fixes
- Fix return value from `read_history()` and `write_history()`, could
return `errno` instead of `EOF` to indicate error. Now both functions
have uniform return values on error
- Handle internal `realloc()` errors better. Now memory is not leaked
if `realloc()` fails
- Fix possible NULL pointer dereference in key binding lookup function
[1.16.1][] - 2019-06-07
-----------------------
### Changes
- Major updates to the `editline.3` man page
- Cleanup of examples `cli.c` and `fileman.c`
- Add example of hidden input prompt to `cli.c`
### Fixes
- Fix #20: `configure --disable-eof` does not bite
- Fix #23: Make Ctrl-L clear the screan instead of starting a new line
Like Ctrl-D, which exits, Ctrl-L only clears the screen when the line
is empty and the cursor is at the start of the line, otherwise Ctrl-L
will redraw/refresh the current line.
- Fix #24: Fix behavior when TTY is narrower than column width, by Will Dietz
- Fix #25: Avoid continuously duplicate commands in history
- Fix #31: Aborting i-search with Ctrl-C should not generate signal
[1.16.0][] - 2018-09-16
-----------------------
Event loop callback support.
### Changes
- `rl_unintialize()`, new function to free all memory, by Claus Fischer
- `rl_insert_text()`, new GNU Readline compat function
- `rl_refresh_line()`, new GNU Readline compat function
- `rl_callback_*()`, alternate interface to plain `readline()` for event
loops. Modeled after the GNU Readline API
- `rl_completion_entry_function`, and `rl_attempted_completion_function`
are two new GNU Readline compat user hooks for the completion framework
- `rl_completion_matches()` and `rl_filename_completion_function()`
are two new GNU Readline compat functions
- Add new example: `fileman.c` from GNU Readline to demonstrate the
level of compatibility of the revamped completion framework
- Add support for Ctrl-Right and Ctrl-Left, forward/backward word
- Add .deb package to official release target
### Fixes
- Fixed header guards, avoid using leading `__`
- Spell check fixes
- Remove duplicate code in history check
- Use `NULL` instead of `0`, and `-1` instead of `NULL`, where applicable
- Misc. minor Coverity Scan fixes
- Misc. minor fixes to `testit.c` example code
- Add `-Wextra` to std `CFLAGS`
- Check `fclose()` return value in in `write_history()` and `read_history()`
- Initialize global variables and reset to `NULL` on `free()`
- Fix off-by-one in forward kill word, avoid deleting too much
- Skip (or kill) leading whitespace when skipping (or killing) forwards
[1.15.3][] - 2017-09-07
-----------------------
Bug fix release.
### Changes
- Refactor all enable/disable configure options, same problem as in #7
### Fixes
- Fix #7: `--enable-termcap` configure option does not work. The script
enabled termcap by default rather than the other way around.
Also, check for terminfo as well, when `--enable-termcap` is selected.
[1.15.2][] - 2016-06-06
-----------------------
Bug fixes and minor feature creep in `pkg-config` support.
### Changes
- Prevent mangling of symbols when linking with C++. Patch courtesy of
Jakub Pawlowski
- Add `libeditline.pc` for `pkg-config`
### Fixes
- Do not assume a termcap library exists, check for `tgetent()` in
curses, ncurses, tinfo and termcap libraries
- Call `tty_flush()` when user calls `rl_forced_update_display()`
to prevent screen becoming garbled. Patch by Jakub Pawlowski
[1.15.1][] - 2015-11-16
-----------------------
Bug fixes only.
### Changes
- Update README with origin of this version of editline
### Fixes
- Fix build system, don't force automake v1.11, require at least v1.11
- Fix build problem with examples using `--enable-termcap`
[1.15.0][] - 2015-09-10
-----------------------
### Changes
- Add support for `--disable-eof` and `--disable-sigint` to disable
default Ctrl-D and Ctrl-C behavior
- Add support for `el_no_hist` to disable access to and auto-save of history
- GNU readline compat functions for prompt handling and redisplay
- Refactor: replace variables named 'new' with non-reserved word
- Add support for [Travis-CI][], continuous integration with GitHub
- Add support for [Coverity Scan][], the best static code analyzer,
integrated with [Travis-CI][] -- scan runs for each push to master
- Rename NEWS.md --> ChangeLog.md, with symlinks for <kbd>make install</kbd>
- Attempt to align with http://keepachangelog.com/ for this file
- Cleanup and improve Markdown syntax in [README.md][]
- Add API and example to [README.md][], inspired by [libuEv][]
- Removed generated files from version control. Use `./autogen.sh`
to generate the `configure` script when working from GIT. This
does not affect distributed tarballs
### Fixes
- Fix issue #2, regression in Ctrl-D (EOF) behavior. Regression
introduced in [1.14.1][]. Fixed by @TobyGoodwin
- Fix memory leak in completion handler. Found by [Coverity Scan][].
- Fix suspicious use of `sizeof(char **)`, same as `sizeof(char *)` but
non-portable. Found by [Coverity Scan][]
- Fix out-of-bounds access in user key binding routines
Found by [Coverity Scan][].
- Fix invisible example code in man page
[1.14.2][] - 2014-09-14
-----------------------
Bug fixes only.
### Fixes
- Fix `el_no_echo` bug causing secrets to leak when disabling no-echo
- Handle `EINTR` in syscalls better
[1.14.1][] - 2014-09-14
-----------------------
Minor fixes and additions.
### Changes
- Don't print status message on `stderr` in key binding funcions
- Export `el_del_char()`
- Check for and return pending signals when detected
- Allow custom key bindings ...
### Fixes
- Bug fixes ...
[1.14.0][] - 2010-08-10
-----------------------
Major cleanups and further merges with Debian editline package.
### Changes
- Merge in changes to `debian/` from `editline_1.12-6.debian.tar.gz`
- Migrate to use libtool
- Make `UNIQUE_HISTORY` configurable
- Make scrollback history (`HIST_SIZE`) configurable
- Configure options for toggling terminal bell and `SIGSTOP` (Ctrl-Z)
- Configure option for using termcap to read/control terminal size
- Rename Signal to `el_intr_pending`, from Festival speech-tools
- Merge support for capitalizing words (`M-c`) from Festival
speech-tools by Alan W Black <mailto:awb()cstr!ed!ac!uk>
- Fallback backspace handling, in case `tgetstr("le")` fails
### Fixes
- Cleanups and fixes thanks to the Sparse static code analysis tool
- Merge `el_no_echo` patch from Festival speech-tools
- Merge fixes from Heimdal project
- Completely refactor `rl_complete()` and `rl_list_possib()` with
fixes from the Heimdal project. Use `rl_set_complete_func()` and
`rl_set_list_possib_func()`. Default completion callbacks are now
available as a configure option `--enable-default-complete`
- Memory leak fixes
- Actually fix 8-bit handling by reverting old Debian patch
- Merge patch to improve compatibility with GNU readline, thanks to
Steve Tell from way back in 1997 and 1998
[1.13.0][] - 2010-03-09
-----------------------
Adaptations to Debian editline package.
### Changes
- Major version number bump, adapt to Jim Studt's v1.12
- Import `debian/` directory and adapt it to configure et al.
- Change library name to libeditline to distinguish it from BSD libedit
[0.3.0][] - 2009-02-08
----------------------
### Changes
- Support for ANSI arrow keys using <kbd>configure --enable-arrow-keys</kbd>
[0.2.3][] - 2008-12-02
----------------------
### Changes
- Patches from Debian package merged
- Support for custom command completion
[0.1.0][] - 2008-06-07
----------------------
### Changes
- First version, forked from Minix current 2008-06-06
[UNRELEASED]: https://github.com/troglobit/finit/compare/1.17.1...HEAD
[1.17.1]: https://github.com/troglobit/finit/compare/1.17.0...1.17.1
[1.17.0]: https://github.com/troglobit/finit/compare/1.16.1...1.17.0
[1.16.1]: https://github.com/troglobit/finit/compare/1.16.0...1.16.1
[1.16.0]: https://github.com/troglobit/finit/compare/1.15.3...1.16.0
[1.15.3]: https://github.com/troglobit/finit/compare/1.15.2...1.15.3
[1.15.2]: https://github.com/troglobit/finit/compare/1.15.1...1.15.2
[1.15.1]: https://github.com/troglobit/finit/compare/1.15.0...1.15.1
[1.15.0]: https://github.com/troglobit/finit/compare/1.14.2...1.15.0
[1.14.2]: https://github.com/troglobit/finit/compare/1.14.1...1.14.2
[1.14.1]: https://github.com/troglobit/finit/compare/1.14.0...1.14.1
[1.14.0]: https://github.com/troglobit/finit/compare/1.13.0...1.14.0
[1.13.0]: https://github.com/troglobit/finit/compare/0.3.0...1.13.0
[0.3.0]: https://github.com/troglobit/finit/compare/0.2.3...0.3.0
[0.2.3]: https://github.com/troglobit/finit/compare/0.1.0...0.2.3
[0.1.0]: https://github.com/troglobit/finit/compare/0.0.0...0.1.0
[libuEv]: http://github.com/troglobit/libuev
[Travis-CI]: https://travis-ci.org/troglobit/uftpd
[Coverity Scan]: https://scan.coverity.com/projects/2947
[README.md]: https://github.com/troglobit/editline/blob/master/README.md

View File

@ -0,0 +1,46 @@
HowTo Build Minix Editline
==========================
Minix editline use the GNU configure tools, which includes autoconf,
automake and libtool. This enables high levels of portability and ease
of use. In most cases all you need to do is unpack the tarball, enter
the directory and type:
./configure
There are are, however, more options available. For instance, sometimes
it is useful to build editline as a static library, type:
./configure --disable-shared
By default editline employs a default handler for the TAB key, pressing
it once completes to the nearest matching filename in the current
working directory, or it can display a listing of possible completions.
For some uses this default is not desirable at all, type:
./configure --disable-default-complete
An even more common desire is to change the default install location.
By default all configure scripts setup /usr/local as the install
"prefix", to change this type:
./configure --prefix=/home/troglobit/tmp
Advanced users are encouraged to read up on --libdir, --mandir, etc. in
the GNU Configure and Build System.
For more available options, type:
./configure --help
To build and install, simply type:
make
followed by
sudo make install
Good Luck!
//Joachim

View File

@ -0,0 +1,18 @@
Copyright 1992,1993 Simmule Turner and Rich Salz
All rights reserved.
This software is not subject to any license of the American Telephone
and Telegraph Company or of the Regents of the University of California.
Permission is granted to anyone to use this software for any purpose on
any computer system, and to alter it and redistribute it freely, subject
to the following restrictions:
1. The authors are not responsible for the consequences of use of this
software, no matter how awful, even if they arise from flaws in it.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission. Since few users ever read sources,
credits must appear in the documentation.
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software. Since few users
ever read sources, credits must appear in the documentation.
4. This notice may not be removed or altered.

View File

@ -0,0 +1,48 @@
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libeditline.pc
doc_DATA = README.md LICENSE
EXTRA_DIST = README.md LICENSE ChangeLog.md INSTALL.md
SUBDIRS = src include man examples
## Generate MD5 checksum file
MD5 = md5sum
md5-dist:
@for file in $(DIST_ARCHIVES); do \
$(MD5) $$file > ../$$file.md5; \
mv $$file ../; \
done
## Check if tagged in git
release-hook:
if [ ! `git tag | grep $(PACKAGE_VERSION)` ]; then \
echo; \
printf "\e[1m\e[41mCannot find release tag $(PACKAGE_VERSION)\e[0m\n"; \
printf "\e[1m\e[5mDo release anyway?\e[0m "; read yorn; \
if [ "$$yorn" != "y" -a "$$yorn" != "Y" ]; then \
printf "OK, aborting release.\n"; \
exit 1; \
fi; \
echo; \
else \
echo; \
printf "\e[1m\e[42mFound GIT release tag $(PACKAGE_VERSION)\e[0m\n"; \
printf "\e[1m\e[44m>>Remember to push tags!\e[0m\n"; \
echo; \
fi
# lintian --profile debian -i -I --show-overrides ../$PKG.changes
package:
dpkg-buildpackage -uc -us -B
## Target to run when building a release
release: release-hook distcheck md5-dist package
@echo
@echo "Resulting release files:"
@echo "========================================================================="
@for file in $(DIST_ARCHIVES); do \
printf "%-40s Distribution tarball\n" $$file; \
printf "%-40s " $$file.md5; cat ../$$file.md5 | cut -f1 -d' '; \
done
@for file in `cd ..; ls *$(PACKAGE)*_$(subst _,.,$(VERSION))*`; do \
printf "%-40s Debian/Ubuntu package file\n" $$file; \
done

View File

@ -0,0 +1,936 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
$(am__configure_deps) $(am__DIST_COMMON)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES = libeditline.pc
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)"
DATA = $(doc_DATA) $(pkgconfig_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
cscope distdir distdir-am dist dist-all distcheck
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)config.h.in
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(srcdir)/libeditline.pc.in $(top_srcdir)/aux/compile \
$(top_srcdir)/aux/config.guess $(top_srcdir)/aux/config.sub \
$(top_srcdir)/aux/install-sh $(top_srcdir)/aux/ltmain.sh \
$(top_srcdir)/aux/missing aux/compile aux/config.guess \
aux/config.sub aux/install-sh aux/ltmain.sh aux/missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
if test -d "$(distdir)"; then \
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -rf "$(distdir)" \
|| { sleep 5 && rm -rf "$(distdir)"; }; \
else :; fi
am__post_remove_distdir = $(am__remove_distdir)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.xz
GZIP_ENV = --best
DIST_TARGETS = dist-xz dist-gzip
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libeditline.pc
doc_DATA = README.md LICENSE
EXTRA_DIST = README.md LICENSE ChangeLog.md INSTALL.md
SUBDIRS = src include man examples
MD5 = md5sum
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
.SUFFIXES:
am--refresh: Makefile
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
$(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
$(am__cd) $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps):
config.h: stamp-h1
@test -f $@ || rm -f stamp-h1
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: $(am__configure_deps)
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
libeditline.pc: $(top_builddir)/config.status $(srcdir)/libeditline.pc.in
cd $(top_builddir) && $(SHELL) ./config.status $@
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool config.lt
install-docDATA: $(doc_DATA)
@$(NORMAL_INSTALL)
@list='$(doc_DATA)'; test -n "$(docdir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \
done
uninstall-docDATA:
@$(NORMAL_UNINSTALL)
@list='$(doc_DATA)'; test -n "$(docdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir)
install-pkgconfigDATA: $(pkgconfig_DATA)
@$(NORMAL_INSTALL)
@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
done
uninstall-pkgconfigDATA:
@$(NORMAL_UNINSTALL)
@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscope: cscope.files
test ! -s cscope.files \
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
clean-cscope:
-rm -f cscope.files
cscope.files: clean-cscope cscopelist
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
-test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__post_remove_distdir)
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__post_remove_distdir)
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__post_remove_distdir)
dist dist-all:
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
$(am__post_remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
*.tar.xz*) \
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build/sub \
&& ../../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
&& cd "$$am__cwd" \
|| exit 1
$(am__post_remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@test -n '$(distuninstallcheck_dir)' || { \
echo 'ERROR: trying to run $@ with an empty' \
'$$(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
$(am__cd) '$(distuninstallcheck_dir)' || { \
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile $(DATA) config.h
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-hdr \
distclean-libtool distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am: install-docDATA install-pkgconfigDATA
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-docDATA uninstall-pkgconfigDATA
.MAKE: $(am__recursive_targets) all install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-am clean clean-cscope clean-generic \
clean-libtool cscope cscopelist-am ctags ctags-am dist \
dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \
dist-xz dist-zip distcheck distclean distclean-generic \
distclean-hdr distclean-libtool distclean-tags distcleancheck \
distdir distuninstallcheck dvi dvi-am html html-am info \
info-am install install-am install-data install-data-am \
install-docDATA install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-pkgconfigDATA install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs installdirs-am \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-docDATA \
uninstall-pkgconfigDATA
.PRECIOUS: Makefile
md5-dist:
@for file in $(DIST_ARCHIVES); do \
$(MD5) $$file > ../$$file.md5; \
mv $$file ../; \
done
release-hook:
if [ ! `git tag | grep $(PACKAGE_VERSION)` ]; then \
echo; \
printf "\e[1m\e[41mCannot find release tag $(PACKAGE_VERSION)\e[0m\n"; \
printf "\e[1m\e[5mDo release anyway?\e[0m "; read yorn; \
if [ "$$yorn" != "y" -a "$$yorn" != "Y" ]; then \
printf "OK, aborting release.\n"; \
exit 1; \
fi; \
echo; \
else \
echo; \
printf "\e[1m\e[42mFound GIT release tag $(PACKAGE_VERSION)\e[0m\n"; \
printf "\e[1m\e[44m>>Remember to push tags!\e[0m\n"; \
echo; \
fi
# lintian --profile debian -i -I --show-overrides ../$PKG.changes
package:
dpkg-buildpackage -uc -us -B
release: release-hook distcheck md5-dist package
@echo
@echo "Resulting release files:"
@echo "========================================================================="
@for file in $(DIST_ARCHIVES); do \
printf "%-40s Distribution tarball\n" $$file; \
printf "%-40s " $$file.md5; cat ../$$file.md5 | cut -f1 -d' '; \
done
@for file in `cd ..; ls *$(PACKAGE)*_$(subst _,.,$(VERSION))*`; do \
printf "%-40s Debian/Ubuntu package file\n" $$file; \
done
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,272 @@
Editline
========
[![License Badge][]][License] [![Travis Status]][Travis] [![Coverity Status]][Coverity Scan]
Table of Contents
-----------------
* [Introduction](#introduction)
* [API](#api)
* [Example](#example)
* [Build & Install](#build--install)
* [Origin & References](#origin--references)
Introduction
------------
This is a small [line editing][] library. It can be linked into almost
any program to provide command line editing and history functions. It
is call compatible with the [FSF readline][] library, but at a fraction
of the size, and as a result fewer features. It is also distributed
under a much more liberal [License][].
The small size (<30k), lack of dependencies (ncurses not needed!), and
the free license should make this library interesting to many embedded
developers.
Editline has several optional build-time features that can be enabled by
supplying different options to the GNU configure script. See the output
from <kbd>configure --help</kbd> for details. Some useful hints on how
to use the library is available in the `examples/` directory.
Editline is maintained collaboratively at [GitHub][].
Example
-------
Below is a very brief example to illustrate how one can use Editline to
create a simple CLI, Ctrl-D exits the program. A slightly more advanced
example is Jush, <https://github.com/troglobit/jush/>, a small and very
simplistic UNIX shell. The Editline sources also include an `examples/`
sub-directory.
1. Build and install the library, preferably using a [release tarball][]
The configure script defaults to a `/usr/local` prefix.
tar xf editline-1.15.3.tar.xz
cd editline-1.15.3/
./configure --prefix=/usr
make all
sudo make install
2. Place the below source code in a separate project directory,
e.g. `~/src/example.c`
```C
#include <stdlib.h>
#include <editline.h>
int main(void)
{
char *p;
while ((p = readline("CLI> ")) != NULL) {
puts(p);
free(p);
}
return 0;
}
```
3. Compile the example:
cd ~/src/
make LDLIBS=-leditline example
Here I use `make` and rely on its implicit (built-in) rules to handle
all the compiler magic, but you may want to create your own Makefile for
the project. In particular if you don't change the default prefix
(above), because then you need to specify the search path for the
include file(s) and the library manually.
A simple `~/src/Makefile` could look like this:
CFLAGS = -I/usr/local/include
LDFLAGS = -L/usr/local/lib
LDLIBS = -leditline
EXEC = example
OBJS = example.o
all: $(EXEC)
$(EXEC): $(OBJS)
clean:
$(RM) $(OBJS) $(EXEC)
distclean: clean
$(RM) *.o *~ *.bak
Then simply type `make` from your `~/src/` directory. You can also use
`pkg-config` for your `~/src/Makefile`, replace the following lines:
CFLAGS = $(shell pkg-config --cflags libeditline)
LDFLAGS = $(shell pkg-config --libs-only-L libeditline)
LDLIBS = $(shell pkg-config --libs-only-l libeditline)
Then simply type <kbd>make</kbd>, like above.
However, most `.rpm` based distributions `pkg-config` doesn't search in
`/usr/local` anymore, so you need to call make like this:
PKG_CONFIG_LIBDIR=/usr/local/lib/pkgconfig make
Debian/Ubuntu based systems do not have this problem.
API
---
Here is the libeditline interfaces. It has a small compatibility layer
to [FSF readline][], which may not be entirely up-to-date.
```C
/* Editline specific global variables. */
int el_no_echo; /* Do not echo input characters */
int el_no_hist; /* Disable auto-save of and access to history,
* e.g. for password prompts or wizards */
int el_hist_size; /* Size of history scrollback buffer, default: 15 */
/* Editline specific functions. */
char * el_find_word (void);
void el_print_columns (int ac, char **av);
el_status_t el_ring_bell (void);
el_status_t el_del_char (void);
/* Callback function for key binding */
typedef el_status_t el_keymap_func_t(void);
/* Bind key to a callback, use CTL('f') to change Ctrl-F, for example */
el_status_t el_bind_key (int key, el_keymap_func_t function);
el_status_t el_bind_key_in_metamap (int key, el_keymap_func_t function);
/* For compatibility with FSF readline. */
int rl_point;
int rl_mark;
int rl_end;
int rl_inhibit_complete;
char *rl_line_buffer;
const char *rl_readline_name;
void (*rl_deprep_term_function)(void);
void rl_deprep_terminal (void);
void rl_reset_terminal (const char *terminal_name);
void rl_initialize (void);
void rl_uninitialize (void); /* Free all internal memory */
void rl_save_prompt (void);
void rl_restore_prompt (void);
void rl_set_prompt (const char *prompt);
void rl_clear_message (void);
void rl_forced_update_display (void);
/* Main function to use, saves history by default */
char *readline (const char *prompt);
/* Use to save a read line to history, when el_no_hist is set */
void add_history (const char *line);
/* Load and save editline history from/to a file. */
int read_history (const char *filename);
int write_history (const char *filename);
/* Magic completion API, see examples/cli.c for more info */
rl_complete_func_t *rl_set_complete_func (rl_complete_func_t *func);
rl_list_possib_func_t *rl_set_list_possib_func (rl_list_possib_func_t *func);
/* Alternate interface to plain readline(), for event loops */
void rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *lhandler);
void rl_callback_read_char (void);
void rl_callback_handler_remove (void);
```
Build & Install
---------------
Editline was originally designed for older UNIX systems and Plan 9. The
current maintainer works exclusively on GNU/Linux systems, so it may use
GCC and GNU Make specific extensions here and there. This is not on
purpose and patches or pull requests to correct this are most welcome!
1. Configure editline with default features: <kbd>./configure</kbd>
2. Build the library and examples: <kbd>make all</kbd>
3. Install using <kbd>make install</kbd>
The `$DESTDIR` environment variable is honored at install. For more
options, see <kbd>./configure --help</kbd>
Remember to run `ldconfig` after install to update the linker cache. If
you've installed to a non-standard location (`--prefix`) you may also
have to update your `/etc/ld.so.conf`, or use `pkg-confg` to build your
application (above).
**NOTE:** RedHat/Fedora/CentOS and other `.rpm`-based distributions do
not consider `/usr/local` as standard path anymore. So make sure to
`./configure --prefix=/usr`, otherwise the build system use the GNU
default, which is `/usr/local`. The Debian based distributions, like
Ubuntu, do not have this problem.
Origin & References
--------------------
This [line editing][] library was created by [Rich Salz][] and Simmule
Turner and in 1992. It is distributed with a “[C News][]-like” license,
similar to the [BSD license][]. Rich's current version is however under
the Apache license. For details on the licensing terms of this version
of the software, see [License][].
This version of the editline library was forked from the [Minix 2][]
source tree and is *not* related to the similarily named NetBSD version
that [Jess Thrysøe][jess] disitributes to the world outside *BSD. The
libraries have much in common, but the latter is heavily refactored and
also relies on libtermcap (usually supplied by ncurses), whereas this
library only uses termios from the standard C library.
Patches and bug fixes from the following forks, based on the original
[comp.sources.unix][] posting, have been merged:
* Debian [libeditline][]
* [Heimdal][]
* [Festival][] speech-tools
* [Steve Tell][]'s editline patches
The version numbering scheme today follows that of the Debian version,
details available in the [ChangeLog.md][]. The current [maintainer][]
was unaware of the Debian version for quite some time, so a different
name and versioning scheme was used. In June 2009 this was changed to
line up alongside Debian, with the intent is to eventually merge the
efforts.
Outstanding issues are listed in the [TODO.md][] file.
[GitHub]: https://github.com/troglobit/editline
[line editing]: https://github.com/troglobit/editline/blob/master/docs/README
[release tarball]: https://github.com/troglobit/editline/releases
[maintainer]: http://troglobit.com
[C News]: https://en.wikipedia.org/wiki/C_News
[TODO.md]: https://github.com/troglobit/editline/blob/master/docs/TODO.md
[ChangeLog.md]: https://github.com/troglobit/editline/blob/master/ChangeLog.md
[FSF readline]: http://www.gnu.org/software/readline/
[Rich Salz]: https://github.com/richsalz/editline/
[comp.sources.unix]: http://ftp.cs.toronto.edu/pub/white/pub/rc/editline.shar
[Minix 2]: http://www.cise.ufl.edu/~cop4600/cgi-bin/lxr/http/source.cgi/lib/editline/
[jess]: http://thrysoee.dk/editline/
[BSD license]: http://en.wikipedia.org/wiki/BSD_licenses
[libeditline]: http://packages.qa.debian.org/e/editline.html
[Heimdal]: http://www.h5l.org
[Festival]: http://festvox.org/festival/
[Steve Tell]: http://www.cs.unc.edu/~tell/dist.html
[License]: https://github.com/troglobit/editline/blob/master/LICENSE
[License Badge]: https://img.shields.io/badge/License-C%20News-orange.svg
[Travis]: https://travis-ci.org/troglobit/editline
[Travis Status]: https://travis-ci.org/troglobit/editline.png?branch=master
[Coverity Scan]: https://scan.coverity.com/projects/2982
[Coverity Status]: https://scan.coverity.com/projects/2982/badge.svg

1140
dep/editline-1.17.1/aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

348
dep/editline-1.17.1/aux/compile Executable file
View File

@ -0,0 +1,348 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

1480
dep/editline-1.17.1/aux/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1801
dep/editline-1.17.1/aux/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

791
dep/editline-1.17.1/aux/depcomp Executable file
View File

@ -0,0 +1,791 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

View File

@ -0,0 +1,518 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2018-03-11.20; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" $tab$nl"
# Set DOITPROG to "echo" to test this script.
doit=${DOITPROG-}
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename.
if test -d "$dst"; then
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dstbase=`basename "$src"`
case $dst in
*/) dst=$dst$dstbase;;
*) dst=$dst/$dstbase;;
esac
dstdir_status=0
else
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
fi
case $dstdir in
*/) dstdirslash=$dstdir;;
*) dstdirslash=$dstdir/;;
esac
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
# Note that $RANDOM variable is not portable (e.g. dash); Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p' feature.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
oIFS=$IFS
IFS=/
set -f
set fnord $dstdir
shift
set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=${dstdirslash}_inst.$$_
rmtmp=${dstdirslash}_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

File diff suppressed because it is too large Load Diff

215
dep/editline-1.17.1/aux/missing Executable file
View File

@ -0,0 +1,215 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
case $1 in
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Back-compat with the calling convention used by older automake.
shift
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
esac
# Run the given program, remember its exit status.
"$@"; st=$?
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=https://www.perl.org/
flex_URL=https://github.com/westes/flex
gnu_software_URL=https://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

View File

@ -0,0 +1,168 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if the `closedir' function returns void instead of `int'. */
#undef CLOSEDIR_VOID
/* Define to include ANSI arrow keys support. */
#undef CONFIG_ANSI_ARROWS
/* Define to enable EOF (Ctrl-D) key. */
#undef CONFIG_EOF
/* Define to enable SIGINT (Ctrl-C) key. */
#undef CONFIG_SIGINT
/* Define to enable SIGSTOP (Ctrl-Z) key. */
#undef CONFIG_SIGSTOP
/* Define to enable terminal bell on completion. */
#undef CONFIG_TERMINAL_BELL
/* Define to skip duplicate lines in the scrollback history. */
#undef CONFIG_UNIQUE_HISTORY
/* Define to use the termcap library for terminal size. */
#undef CONFIG_USE_TERMCAP
/* Define to 1 if `TIOCGWINSZ' requires <sys/ioctl.h>. */
#undef GWINSZ_IN_SYS_IOCTL
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `curses' library (-lcurses). */
#undef HAVE_LIBCURSES
/* Define to 1 if you have the `ncurses' library (-lncurses). */
#undef HAVE_LIBNCURSES
/* Define to 1 if you have the `termcap' library (-ltermcap). */
#undef HAVE_LIBTERMCAP
/* Define to 1 if you have the `terminfo' library (-lterminfo). */
#undef HAVE_LIBTERMINFO
/* Define to 1 if you have the `tinfo' library (-ltinfo). */
#undef HAVE_LIBTINFO
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
/* Define to 1 if you have the `perror' function. */
#undef HAVE_PERROR
/* Define to 1 if you have the <sgtty.h> header file. */
#undef HAVE_SGTTY_H
/* Define to 1 if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
/* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */
#undef HAVE_STAT_EMPTY_STRING_BUG
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strchr' function. */
#undef HAVE_STRCHR
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strrchr' function. */
#undef HAVE_STRRCHR
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_DIR_H
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_NDIR_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the `tcgetattr' function. */
#undef HAVE_TCGETATTR
/* Define to 1 if you have the <termcap.h> header file. */
#undef HAVE_TERMCAP_H
/* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H
/* Define to 1 if you have the <termio.h> header file. */
#undef HAVE_TERMIO_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
#undef STAT_MACROS_BROKEN
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Default to UNIX backend, should be detected. */
#undef SYS_UNIX
/* Version number of package */
#undef VERSION
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t

15308
dep/editline-1.17.1/configure vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,100 @@
AC_INIT(editline, 1.17.1, https://github.com/troglobit/editline/issues)
AC_CONFIG_AUX_DIR(aux)
AM_INIT_AUTOMAKE([1.11 foreign dist-xz])
AM_SILENT_RULES([yes])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src/editline.c])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([Makefile libeditline.pc src/Makefile include/Makefile man/Makefile examples/Makefile])
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
# Checks for libraries.
LT_INIT
# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STAT
AC_HEADER_STDC
# Check for malloc.h instead of AC_FUNC_MALLOC/REALLOC AIX and others
# mess up the traditional malloc check.
AC_CHECK_HEADERS([malloc.h signal.h stdlib.h string.h termcap.h termio.h termios.h sgtty.h unistd.h])
# In termios.h or in sys/ioctl.g?
AC_HEADER_TIOCGWINSZ
# Overrides and types, should be a check.
AC_DEFINE([SYS_UNIX], [1], [Default to UNIX backend, should be detected.])
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_CLOSEDIR_VOID
AC_PROG_GCC_TRADITIONAL
AC_FUNC_STAT
AC_CHECK_FUNCS([strchr strdup strrchr tcgetattr perror])
#
# Available features
#
AC_ARG_ENABLE(unique-history,
[AS_HELP_STRING([--disable-unique-history],
[Disable uniqify of scrollback. Default: duplicate entries are ignored. Use this to save dupes.])])
AC_ARG_ENABLE(arrow-keys,
[AS_HELP_STRING([--disable-arrow-keys], [Disable ANSI arrow keys.])])
AC_ARG_ENABLE(eof,
[AS_HELP_STRING([--disable-eof], [Disable default EOF (Ctrl-D) behavior.])])
AC_ARG_ENABLE(sigint,
[AS_HELP_STRING([--disable-sigint], [Disable default SIGINT (Ctrl-C) behavior.])])
AC_ARG_ENABLE(sigstop,
[AS_HELP_STRING([--enable-sigstop], [Enable SIGSTOP (Ctrl-Z) behavior.])])
AC_ARG_ENABLE(terminal-bell,
[AS_HELP_STRING([--enable-terminal-bell], [Enable terminal bell on completion.])])
AC_ARG_ENABLE(termcap,
AS_HELP_STRING([--enable-termcap], [Use termcap library to query terminal size.]))
#
# Check what features have been enabled
#
AS_IF([test "x$enable_unique_history" != "xno"],
AC_DEFINE(CONFIG_UNIQUE_HISTORY, 1, [Define to skip duplicate lines in the scrollback history.]))
AS_IF([test "x$enable_terminal_bell" != "xno"],
AC_DEFINE(CONFIG_ANSI_ARROWS, 1, [Define to include ANSI arrow keys support.]))
AS_IF([test "x$enable_eof" != "xno"],
AC_DEFINE(CONFIG_EOF, 1, [Define to enable EOF (Ctrl-D) key.]))
AS_IF([test "x$enable_sigint" != "xno"],
AC_DEFINE(CONFIG_SIGINT, 1, [Define to enable SIGINT (Ctrl-C) key.]))
AS_IF([test "x$enable_sigstop" = "xyes"],
AC_DEFINE(CONFIG_SIGSTOP, 1, [Define to enable SIGSTOP (Ctrl-Z) key.]))
AS_IF([test "x$enable_terminal_bell" = "xyes"],
AC_DEFINE(CONFIG_TERMINAL_BELL, 1, [Define to enable terminal bell on completion.]))
# Check for a termcap compatible library if enabled
AS_IF([test "x$enable_termcap" = "xyes"],
AC_DEFINE(CONFIG_USE_TERMCAP, 1, [Define to use the termcap library for terminal size.])
AC_CHECK_LIB(terminfo, tgetent, , [
AC_CHECK_LIB(termcap, tgetent, , [
AC_CHECK_LIB(tinfo, tgetent, , [
AC_CHECK_LIB(curses, tgetent, , [
AC_CHECK_LIB(ncurses, tgetent, , [
AC_MSG_ERROR([Cannot find a termcap capable library, try installing Ncurses.])])
])
])
])
]))
# Generate all files
AC_OUTPUT

View File

@ -0,0 +1,5 @@
noinst_PROGRAMS = testit cli excallback fileman
LDADD = $(top_builddir)/src/libeditline.la
AM_CPPFLAGS = -DEDITLINE_LIBRARY
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include
AM_LDFLAGS = -static

View File

@ -0,0 +1,631 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
noinst_PROGRAMS = testit$(EXEEXT) cli$(EXEEXT) excallback$(EXEEXT) \
fileman$(EXEEXT)
subdir = examples
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
PROGRAMS = $(noinst_PROGRAMS)
cli_SOURCES = cli.c
cli_OBJECTS = cli.$(OBJEXT)
cli_LDADD = $(LDADD)
cli_DEPENDENCIES = $(top_builddir)/src/libeditline.la
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
excallback_SOURCES = excallback.c
excallback_OBJECTS = excallback.$(OBJEXT)
excallback_LDADD = $(LDADD)
excallback_DEPENDENCIES = $(top_builddir)/src/libeditline.la
fileman_SOURCES = fileman.c
fileman_OBJECTS = fileman.$(OBJEXT)
fileman_LDADD = $(LDADD)
fileman_DEPENDENCIES = $(top_builddir)/src/libeditline.la
testit_SOURCES = testit.c
testit_OBJECTS = testit.$(OBJEXT)
testit_LDADD = $(LDADD)
testit_DEPENDENCIES = $(top_builddir)/src/libeditline.la
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/aux/depcomp
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/cli.Po ./$(DEPDIR)/excallback.Po \
./$(DEPDIR)/fileman.Po ./$(DEPDIR)/testit.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = cli.c excallback.c fileman.c testit.c
DIST_SOURCES = cli.c excallback.c fileman.c testit.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/aux/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
LDADD = $(top_builddir)/src/libeditline.la
AM_CPPFLAGS = -DEDITLINE_LIBRARY
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include
AM_LDFLAGS = -static
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign examples/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstPROGRAMS:
@list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
cli$(EXEEXT): $(cli_OBJECTS) $(cli_DEPENDENCIES) $(EXTRA_cli_DEPENDENCIES)
@rm -f cli$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(cli_OBJECTS) $(cli_LDADD) $(LIBS)
excallback$(EXEEXT): $(excallback_OBJECTS) $(excallback_DEPENDENCIES) $(EXTRA_excallback_DEPENDENCIES)
@rm -f excallback$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(excallback_OBJECTS) $(excallback_LDADD) $(LIBS)
fileman$(EXEEXT): $(fileman_OBJECTS) $(fileman_DEPENDENCIES) $(EXTRA_fileman_DEPENDENCIES)
@rm -f fileman$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(fileman_OBJECTS) $(fileman_LDADD) $(LIBS)
testit$(EXEEXT): $(testit_OBJECTS) $(testit_DEPENDENCIES) $(EXTRA_testit_DEPENDENCIES)
@rm -f testit$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(testit_OBJECTS) $(testit_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cli.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/excallback.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileman.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testit.Po@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
am--depfiles: $(am__depfiles_remade)
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
mostlyclean-am
distclean: distclean-am
-rm -f ./$(DEPDIR)/cli.Po
-rm -f ./$(DEPDIR)/excallback.Po
-rm -f ./$(DEPDIR)/fileman.Po
-rm -f ./$(DEPDIR)/testit.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/cli.Po
-rm -f ./$(DEPDIR)/excallback.Po
-rm -f ./$(DEPDIR)/fileman.Po
-rm -f ./$(DEPDIR)/testit.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,180 @@
/* Custom CLI command completion.
*
* Copyright (c) 1992, 1993 Simmule Turner and Rich Salz. All rights reserved.
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
* 1. The authors are not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
* 4. This notice may not be removed or altered.
*/
#include "editline.h"
#include <string.h>
#define HISTORY "/tmp/.cli-history"
static char *list[] = {
"foo ", "bar ", "bsd ", "cli ", "ls ", "cd ", "malloc ", "tee ", NULL
};
/* Attempt to complete the pathname, returning an allocated copy.
* Fill in *unique if we completed it, or set it to 0 if ambiguous. */
static char *my_rl_complete(char *token, int *match)
{
int i;
int index = -1;
int matchlen = 0;
int count = 0;
for (i = 0; list[i]; i++) {
int partlen = strlen(token); /* Part of token */
if (!strncmp(list[i], token, partlen)) {
index = i;
matchlen = partlen;
count ++;
}
}
if (count == 1) {
*match = 1;
return strdup(list[index] + matchlen);
}
return NULL;
}
/* Return all possible completions. */
static int my_rl_list_possib(char *token, char ***av)
{
int i, num, total = 0;
char **copy;
for (num = 0; list[num]; num++)
;
if (!num)
return 0;
copy = malloc(num * sizeof(char *));
for (i = 0; i < num; i++) {
if (!strncmp(list[i], token, strlen (token))) {
copy[total] = strdup(list[i]);
total++;
}
}
*av = copy;
return total;
}
el_status_t list_possible(void)
{
char **av;
char *word;
int ac;
word = el_find_word();
ac = rl_list_possib(word, &av);
if (word)
free(word);
if (ac) {
el_print_columns(ac, av);
while (--ac >= 0)
free(av[ac]);
free(av);
return CSmove;
}
return el_ring_bell();
}
el_status_t do_suspend(void)
{
puts("Abort!");
return CSstay;
}
static void breakit(int signo)
{
(void)signo;
puts("Got SIGINT");
}
/* Use el_no_echo when reading passwords and similar */
static int unlock(const char *passwd)
{
char *prompt = "Enter password: ";
char *line;
int rc = 1;
el_no_echo = 1;
while ((line = readline(prompt))) {
rc = strncmp(line, passwd, strlen(passwd));
free(line);
if (rc) {
printf("\nWrong password, please try again, it's secret.\n");
continue;
}
printf("\nAchievement unlocked!\n");
break;
}
el_no_echo = 0;
return rc;
}
int main(void)
{
char *line;
char *prompt = "cli> ";
signal(SIGINT, breakit);
/* Setup callbacks */
rl_set_complete_func(&my_rl_complete);
rl_set_list_possib_func(&my_rl_list_possib);
el_bind_key('?', list_possible);
el_bind_key(CTL('Z'), do_suspend);
read_history(HISTORY);
while ((line = readline(prompt))) {
if (!strncmp(line, "unlock", 6) && unlock("secret")) {
free(line);
fprintf(stderr, "\nSecurity breach, user logged out!\n");
break;
}
if (*line != '\0')
printf("\t\t\t|%s|\n", line);
free(line);
}
write_history(HISTORY);
return 0;
}
/**
* Local Variables:
* c-file-style: "k&r"
* c-basic-offset: 4
* End:
*/

View File

@ -0,0 +1,195 @@
/*
From: Jeff Solomon <jsolomon@stanford.edu>
Date: Fri, 9 Apr 1999 10:13:27 -0700 (PDT)
To: chet@po.cwru.edu
Subject: new readline example
Message-ID: <14094.12094.527305.199695@mrclean.Stanford.EDU>
Chet,
I've been using readline 4.0. Specifically, I've been using the perl
version Term::ReadLine::Gnu. It works great.
Anyway, I've been playing around the alternate interface and I wanted
to contribute a little C program, callback.c, to you that you could
use as an example of the alternate interface in the /examples
directory of the readline distribution.
My example shows how, using the alternate interface, you can
interactively change the prompt (which is very nice imo). Also, I
point out that you must roll your own terminal setting when using the
alternate interface because readline depreps (using your parlance) the
terminal while in the user callback. I try to demostrate what I mean
with an example. I've included the program below.
To compile, I just put the program in the examples directory and made
the appropriate changes to the EXECUTABLES and OBJECTS line and added
an additional target 'callback'.
I compiled on my Sun Solaris2.6 box using Sun's cc.
Let me know what you think.
Jeff
*/
#if defined (HAVE_CONFIG_H)
#include <config.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <termios.h> /* xxx - should make this more general */
#ifdef EDITLINE_LIBRARY
# include "editline.h"
#else
# include <readline/readline.h>
#endif
/* This little examples demonstrates the alternate interface to using readline.
* In the alternate interface, the user maintains control over program flow and
* only calls readline when STDIN is readable. Using the alternate interface,
* you can do anything else while still using readline (like talking to a
* network or another program) without blocking.
*
* Specifically, this program highlights two importants features of the
* alternate interface. The first is the ability to interactively change the
* prompt, which can't be done using the regular interface since rl_prompt is
* read-only.
*
* The second feature really highlights a subtle point when using the alternate
* interface. That is, readline will not alter the terminal when inside your
* callback handler. So let's so, your callback executes a user command that
* takes a non-trivial amount of time to complete (seconds). While your
* executing the command, the user continues to type keystrokes and expects them
* to be re-echoed on the new prompt when it returns. Unfortunately, the default
* terminal configuration doesn't do this. After the prompt returns, the user
* must hit one additional keystroke and then will see all of his previous
* keystrokes. To illustrate this, compile and run this program. Type "sleep" at
* the prompt and then type "bar" before the prompt returns (you have 3
* seconds). Notice how "bar" is re-echoed on the prompt after the prompt
* returns? This is what you expect to happen. Now comment out the 4 lines below
* the line that says COMMENT LINE BELOW. Recompile and rerun the program and do
* the same thing. When the prompt returns, you should not see "bar". Now type
* "f", see how "barf" magically appears? This behavior is un-expected and not
* desired.
*/
void process_line(char *line);
int change_prompt(void);
char *get_prompt(void);
int prompt = 1;
char prompt_buf[40], line_buf[256];
tcflag_t old_lflag;
cc_t old_vtime;
struct termios term;
int
main()
{
fd_set fds;
/* Adjust the terminal slightly before the handler is installed. Disable
* canonical mode processing and set the input character time flag to be
* non-blocking.
*/
if( tcgetattr(STDIN_FILENO, &term) < 0 ) {
perror("tcgetattr");
exit(1);
}
old_lflag = term.c_lflag;
old_vtime = term.c_cc[VTIME];
term.c_lflag &= ~ICANON;
term.c_cc[VTIME] = 1;
/* COMMENT LINE BELOW - see above */
if( tcsetattr(STDIN_FILENO, TCSANOW, &term) < 0 ) {
perror("tcsetattr");
exit(1);
}
// rl_add_defun("change-prompt", change_prompt, CTRL('t'));
rl_callback_handler_install(get_prompt(), process_line);
while(1) {
FD_ZERO(&fds);
FD_SET(fileno(stdin), &fds);
if( select(FD_SETSIZE, &fds, NULL, NULL, NULL) < 0) {
perror("select");
exit(1);
}
if( FD_ISSET(fileno(stdin), &fds) ) {
rl_callback_read_char();
}
}
return 0;
}
void
process_line(char *line)
{
if( line == NULL ) {
fprintf(stderr, "\n");
/* reset the old terminal setting before exiting */
term.c_lflag = old_lflag;
term.c_cc[VTIME] = old_vtime;
if( tcsetattr(STDIN_FILENO, TCSANOW, &term) < 0 ) {
perror("tcsetattr");
exit(1);
}
exit(0);
}
if( strcmp(line, "sleep") == 0 ) {
sleep(3);
} else {
fprintf(stderr, "|%s|\n", line);
}
free (line);
}
int
change_prompt(void)
{
/* toggle the prompt variable */
prompt = !prompt;
/* save away the current contents of the line */
strncpy(line_buf, rl_line_buffer, sizeof(line_buf));
line_buf[sizeof(line_buf) - 1] = 0;
/* install a new handler which will change the prompt and erase the current line */
rl_callback_handler_install(get_prompt(), process_line);
/* insert the old text on the new line */
rl_insert_text(line_buf);
/* redraw the current line - this is an undocumented function. It invokes the
* redraw-current-line command.
*/
return rl_refresh_line(0, 0);
}
char *
get_prompt(void)
{
/* The prompts can even be different lengths! */
sprintf(prompt_buf, "%s",
prompt ? "Hit ctrl-t to toggle prompt> " : "Pretty cool huh?> ");
return prompt_buf;
}

View File

@ -0,0 +1,431 @@
/* fileman.c -- A tiny application which demonstrates how to use the
GNU Readline library. This application interactively allows users
to manipulate files and their modes.
NOTE: this was taken from the GNU Readline documentation and ported
to libedit. A command to output the history list was added.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <locale.h>
#include <time.h>
#include "editline.h"
void too_dangerous(char *caller);
void initialize_readline();
int execute_line(char *line);
int valid_argument(char *caller, char *arg);
/* The names of functions that actually do the manipulation. */
int com_list(char *);
int com_view(char *);
int com_history(char *);
int com_rename(char *);
int com_stat(char *);
int com_pwd(char *);
int com_delete(char *);
int com_help(char *);
int com_cd(char *);
int com_quit(char *);
struct cmd {
char *name; /* User printable name of the function. */
int (*func)(char *); /* Function to call to do the job. */
char *doc; /* Documentation for this function. */
};
struct cmd commands[] = {
{ "cd", com_cd, "Change to directory DIR"},
{ "delete", com_delete, "Delete FILE"},
{ "help", com_help, "Display this text"},
{ "?", com_help, "Synonym for `help'"},
{ "list", com_list, "List files in DIR"},
{ "ls", com_list, "Synonym for `list'"},
{ "pwd", com_pwd, "Print the current working directory"},
{ "quit", com_quit, "Quit using Fileman"},
{ "rename", com_rename, "Rename FILE to NEWNAME"},
{ "stat", com_stat, "Print out statistics on FILE"},
{ "view", com_view, "View the contents of FILE"},
{ "history", com_history, "List editline history"},
{ NULL, NULL, NULL },
};
/* Forward declarations. */
char *stripwhite();
struct cmd *find_command();
/* When non-zero, this means the user is done using this program. */
int done;
int main(int argc, char **argv)
{
char *line, *s;
setlocale(LC_CTYPE, "");
initialize_readline(); /* Bind our completer. */
/* Loop reading and executing lines until the user quits. */
for (; done == 0;) {
line = readline("FileMan: ");
if (!line)
break;
/* Remove leading and trailing whitespace from the line.
Then, if there is anything left, add it to the history list
and execute it. */
s = stripwhite(line);
#if 0
if (*s) {
char *expansion;
int result;
result = history_expand(s, &expansion);
if (result < 0 || result == 2) {
fprintf(stderr, "%s\n", expansion);
} else {
add_history(expansion);
execute_line(expansion);
}
free(expansion);
}
#else
execute_line(s);
#endif
free(line);
}
return 0;
}
/* Execute a command line. */
int execute_line(char *line)
{
int i;
struct cmd *command;
char *word;
/* Isolate the command word. */
i = 0;
while (line[i] && isspace(line[i]))
i++;
word = line + i;
while (line[i] && !isspace(line[i]))
i++;
if (line[i])
line[i++] = '\0';
command = find_command(word);
if (!command) {
fprintf(stderr, "%s: No such command for FileMan.\n", word);
return -1;
}
/* Get argument to command, if any. */
while (isspace(line[i]))
i++;
word = line + i;
/* Call the function. */
return command->func(word);
}
/* Look up NAME as the name of a command, and return a pointer to that
command. Return a NULL pointer if NAME isn't a command name. */
struct cmd *find_command(char *name)
{
int i;
for (i = 0; commands[i].name; i++)
if (strcmp(name, commands[i].name) == 0)
return &commands[i];
return NULL;
}
/*
* Strip whitespace from the start and end of STRING. Return a pointer
* into STRING.
*/
char *stripwhite(char *string)
{
char *s, *t;
for (s = string; isspace(*s); s++) ;
if (*s == 0)
return s;
t = s + strlen(s) - 1;
while (t > s && isspace(*t))
t--;
*++t = '\0';
return s;
}
/* **************************************************************** */
/* */
/* Interface to Readline Completion */
/* */
/* **************************************************************** */
char *command_generator(const char *, int);
char **fileman_completion(const char *, int, int);
/*
* Tell the GNU Readline library how to complete. We want to try to
* complete on command names if this is the first word in the line, or
* on filenames if not.
*/
void initialize_readline(void)
{
/* Allow conditional parsing of the ~/.inputrc file. */
rl_readline_name = "FileMan";
/* Tell the completer that we want a crack first. */
rl_attempted_completion_function = fileman_completion;
}
/*
* Attempt to complete on the contents of TEXT. START and END
* bound the region of rl_line_buffer that contains the word to
* complete. TEXT is the word to complete. We can use the entire
* contents of rl_line_buffer in case we want to do some simple
* parsing. Returnthe array of matches, or NULL if there aren't any.
*/
char **fileman_completion(const char *text, int start, int end)
{
char **matches = NULL;
/* If this word is at the start of the line, then it is a command
to complete. Otherwise it is the name of a file in the current
directory. */
if (start == 0)
matches = rl_completion_matches(text, command_generator);
return matches;
}
/* Generator function for command completion. STATE lets us
know whether to start from scratch; without any state
(i.e. STATE == 0), then we start at the top of the list. */
char *command_generator(const char *text, int state)
{
static int list_index, len;
char *name;
/* If this is a new word to complete, initialize now. This
includes saving the length of TEXT for efficiency, and
initializing the index variable to 0. */
if (!state) {
list_index = 0;
len = strlen(text);
}
/* Return the next name which partially matches from the
command list. */
while ((name = commands[list_index].name)) {
list_index++;
if (strncmp(name, text, len) == 0)
return strdup(name);
}
/* If no names matched, then return NULL. */
return NULL;
}
/* **************************************************************** */
/* */
/* FileMan Commands */
/* */
/* **************************************************************** */
/* String to pass to system (). This is for the LIST, VIEW and RENAME
commands. */
static char syscom[1024];
/* List the file(s) named in arg. */
int com_list(char *arg)
{
if (!arg)
arg = "";
sprintf(syscom, "ls -FClg %s", arg);
return system(syscom);
}
int com_view(char *arg)
{
if (!valid_argument("view", arg))
return 1;
sprintf(syscom, "more %s", arg);
return system(syscom);
}
int com_history(char *arg)
{
const char *he;
/* rewind history */
while (el_prev_hist()) ;
for (he = el_next_hist(); he != NULL; he = el_next_hist())
printf("%s\n", he);
return 0;
}
int com_rename(char *arg)
{
too_dangerous("rename");
return 1;
}
int com_stat(char *arg)
{
struct stat finfo;
if (!valid_argument("stat", arg))
return 1;
if (stat(arg, &finfo) == -1) {
perror(arg);
return 1;
}
printf("Statistics for `%s':\n", arg);
printf("%s has %ld link%s, and is %lld byte%s in length.\n", arg,
(long)finfo.st_nlink,
(finfo.st_nlink == 1) ? "" : "s",
(long long)finfo.st_size, (finfo.st_size == 1) ? "" : "s");
printf("Inode Last Change at: %s", ctime(&finfo.st_ctime));
printf(" Last access at: %s", ctime(&finfo.st_atime));
printf(" Last modified at: %s", ctime(&finfo.st_mtime));
return 0;
}
int com_delete(char *arg)
{
too_dangerous("delete");
return 1;
}
/* Print out help for ARG, or for all of the commands if ARG is
not present. */
int com_help(char *arg)
{
int i;
int printed = 0;
for (i = 0; commands[i].name; i++) {
if (!*arg || (strcmp(arg, commands[i].name) == 0)) {
printf("%s\t\t%s.\n", commands[i].name,
commands[i].doc);
printed++;
}
}
if (!printed) {
printf("No commands match `%s'. Possibilties are:\n", arg);
for (i = 0; commands[i].name; i++) {
/* Print in six columns. */
if (printed == 6) {
printed = 0;
printf("\n");
}
printf("%s\t", commands[i].name);
printed++;
}
if (printed)
printf("\n");
}
return 0;
}
/* Change to the directory ARG. */
int com_cd(char *arg)
{
if (chdir(arg) == -1) {
perror(arg);
return 1;
}
com_pwd("");
return 0;
}
/* Print out the current working directory. */
int com_pwd(char *ignore)
{
char dir[1024], *s;
s = getcwd(dir, sizeof(dir) - 1);
if (!s) {
printf("Error getting pwd: %s\n", dir);
return 1;
}
printf("Current directory is %s\n", dir);
return 0;
}
/* The user wishes to quit using this program. Just set DONE
non-zero. */
int com_quit(char *arg)
{
done = 1;
return 0;
}
/* Function which tells you that you can't do this. */
void too_dangerous(char *caller)
{
fprintf(stderr, "%s: Too dangerous for me to distribute.\n", caller);
fprintf(stderr, "Write it yourself.\n");
}
/* Return non-zero if ARG is a valid argument for CALLER,
else print an error message and return zero. */
int valid_argument(char *caller, char *arg)
{
if (!arg || !*arg) {
fprintf(stderr, "%s: Argument required.\n", caller);
return 0;
}
return 1;
}
/**
* Local Variables:
* c-file-style: "k&r"
* c-basic-offset: 4
* End:
*/

View File

@ -0,0 +1,78 @@
/* A "micro-shell" to test editline library.
* If given any arguments, commands aren't executed.
*
* Copyright (c) 1992, 1993 Simmule Turner and Rich Salz. All rights reserved.
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
* 1. The authors are not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
* 4. This notice may not be removed or altered.
*/
#include <config.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "editline.h"
#ifndef HAVE_PERROR
extern int errno;
void perror(char *s)
{
fprintf(stderr, "%s: error %d\n", s, errno);
}
#endif /* !HAVE_PERROR */
int main(int argc, char *argv[] __attribute__ ((unused)))
{
int doit;
char *prompt, *p;
read_history(".testit_history");
doit = argc == 1;
if ((prompt = getenv("TESTPROMPT")) == NULL)
prompt = "testit> ";
while ((p = readline(prompt)) != NULL) {
printf("\t\t\t|%s|\n", p);
if (doit) {
if (strncmp(p, "cd ", 3) == 0) {
if (chdir(&p[3]) < 0)
perror(&p[3]);
} else if (system(p) != 0) {
perror(p);
}
}
free(p);
}
write_history(".testit_history");
rl_uninitialize();
return 0;
}
/**
* Local Variables:
* c-file-style: "k&r"
* c-basic-offset: 4
* End:
*/

View File

@ -0,0 +1,2 @@
library_includedir = $(includedir)
library_include_HEADERS = editline.h

View File

@ -0,0 +1,561 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = include
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(library_include_HEADERS) \
$(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(library_includedir)"
HEADERS = $(library_include_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
library_includedir = $(includedir)
library_include_HEADERS = editline.h
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign include/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-library_includeHEADERS: $(library_include_HEADERS)
@$(NORMAL_INSTALL)
@list='$(library_include_HEADERS)'; test -n "$(library_includedir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(library_includedir)'"; \
$(MKDIR_P) "$(DESTDIR)$(library_includedir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(library_includedir)'"; \
$(INSTALL_HEADER) $$files "$(DESTDIR)$(library_includedir)" || exit $$?; \
done
uninstall-library_includeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(library_include_HEADERS)'; test -n "$(library_includedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(library_includedir)'; $(am__uninstall_files_from_dir)
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(library_includedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-library_includeHEADERS
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-library_includeHEADERS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool cscopelist-am ctags ctags-am distclean \
distclean-generic distclean-libtool distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-library_includeHEADERS \
install-man install-pdf install-pdf-am install-ps \
install-ps-am install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am tags tags-am uninstall uninstall-am \
uninstall-library_includeHEADERS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,132 @@
/*
* Copyright (c) 1992, 1993 Simmule Turner and Rich Salz
* All rights reserved.
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
* 1. The authors are not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
* 4. This notice may not be removed or altered.
*/
#ifndef EDITLINE_H_
#define EDITLINE_H_
/* Handy macros when binding keys. */
#define CTL(x) ((x) & 0x1F)
#define ISCTL(x) ((x) && (x) < ' ')
#define UNCTL(x) ((x) + 64)
#define META(x) ((x) | 0x80)
#define ISMETA(x) ((x) & 0x80)
#define UNMETA(x) ((x) & 0x7F)
#ifdef __cplusplus
extern "C" {
#endif
/* Command status codes. */
typedef enum {
CSdone = 0, /* OK */
CSeof, /* Error, or EOF */
CSmove,
CSdispatch,
CSstay,
CSsignal
} el_status_t;
/* Editline specific types, despite rl_ prefix. From Heimdal project. */
typedef int rl_list_possib_func_t(char*, char***);
typedef el_status_t el_keymap_func_t(void);
typedef int rl_hook_func_t(void);
typedef int rl_getc_func_t(void);
typedef void rl_voidfunc_t(void);
typedef void rl_vintfunc_t(int);
typedef void rl_vcpfunc_t(char *);
/* FSF Readline compat tupes */
typedef char *rl_complete_func_t (char *, int*);
typedef char *rl_compentry_func_t (const char *, int);
typedef char **rl_completion_func_t (const char *, int, int);
/* Display 8-bit chars "as-is" or as `M-x'? Toggle with M-m. (Default:0 - "as-is") */
extern int rl_meta_chars;
/* Editline specific functions. */
extern char * el_find_word(void);
extern void el_print_columns(int ac, char **av);
extern el_status_t el_ring_bell(void);
extern el_status_t el_del_char(void);
extern el_status_t el_bind_key(int key, el_keymap_func_t function);
extern el_status_t el_bind_key_in_metamap(int key, el_keymap_func_t function);
extern const char *el_next_hist(void);
extern const char *el_prev_hist(void);
extern char *rl_complete(char *token, int *match);
extern int rl_list_possib(char *token, char ***av);
extern char **rl_completion_matches(const char *token, rl_compentry_func_t *generator);
extern char *rl_filename_completion_function(const char *text, int state);
/* For compatibility with FSF readline. */
extern int rl_point;
extern int rl_mark;
extern int rl_end;
extern int rl_inhibit_complete;
extern char *rl_line_buffer;
extern const char *rl_readline_name;
extern FILE *rl_instream; /* The stdio stream from which input is read. Defaults to stdin if NULL - Not supported yet! */
extern FILE *rl_outstream; /* The stdio stream to which output is flushed. Defaults to stdout if NULL - Not supported yet! */
extern int el_no_echo; /* E.g under emacs, don't echo except prompt */
extern int el_no_hist; /* Disable auto-save of and access to history -- e.g. for password prompts or wizards */
extern int el_hist_size; /* size of history scrollback buffer, default: 15 */
extern void rl_initialize (void);
extern void rl_reset_terminal (const char *terminal_name);
extern void rl_uninitialize (void);
extern void rl_save_prompt (void);
extern void rl_restore_prompt (void);
extern void rl_set_prompt (const char *prompt);
extern void rl_clear_message (void);
extern void rl_forced_update_display(void);
extern void rl_prep_terminal (int meta_flag);
extern void rl_deprep_terminal (void);
extern int rl_getc(void);
extern int rl_insert_text (const char *text);
extern int rl_refresh_line (int ignore1, int ignore2);
extern char *readline (const char *prompt);
extern void add_history (const char *line);
extern int read_history (const char *filename);
extern int write_history (const char *filename);
extern rl_getc_func_t *rl_set_getc_func(rl_getc_func_t *func);
extern rl_completion_func_t *rl_attempted_completion_function;
extern rl_complete_func_t *rl_set_complete_func (rl_complete_func_t *func);
extern rl_list_possib_func_t *rl_set_list_possib_func (rl_list_possib_func_t *func);
/* Alternate interface to plain readline(), for event loops */
extern void rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *lhandler);
extern void rl_callback_read_char (void);
extern void rl_callback_handler_remove (void);
#ifdef __cplusplus
}
#endif
#endif /* EDITLINE_H_ */

View File

@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: @PACKAGE@
Description: A small line editing library without termcap/curses
Version: @VERSION@
Requires:
Libs: -L${libdir} -leditline
Cflags: -I${includedir}

8388
dep/editline-1.17.1/m4/libtool.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

437
dep/editline-1.17.1/m4/ltoptions.m4 vendored Normal file
View File

@ -0,0 +1,437 @@
# Helper functions for option handling. -*- Autoconf -*-
#
# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 8 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
# ------------------------------------------
m4_define([_LT_MANGLE_OPTION],
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
# ---------------------------------------
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
# saved as a flag.
m4_define([_LT_SET_OPTION],
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]),
[m4_warning([Unknown $1 option '$2'])])[]dnl
])
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
# ------------------------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
m4_define([_LT_IF_OPTION],
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
# -------------------------------------------------------
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
# are set.
m4_define([_LT_UNLESS_OPTIONS],
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
[m4_define([$0_found])])])[]dnl
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
])[]dnl
])
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
# ----------------------------------------
# OPTION-LIST is a space-separated list of Libtool options associated
# with MACRO-NAME. If any OPTION has a matching handler declared with
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
# the unknown option and exit.
m4_defun([_LT_SET_OPTIONS],
[# Set options
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[_LT_SET_OPTION([$1], _LT_Option)])
m4_if([$1],[LT_INIT],[
dnl
dnl Simply set some default values (i.e off) if boolean options were not
dnl specified:
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
])
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
])
dnl
dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither
dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
[_LT_ENABLE_FAST_INSTALL])
_LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
[_LT_WITH_AIX_SONAME([aix])])
])
])# _LT_SET_OPTIONS
## --------------------------------- ##
## Macros to handle LT_INIT options. ##
## --------------------------------- ##
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
# -----------------------------------------
m4_define([_LT_MANGLE_DEFUN],
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
# -----------------------------------------------
m4_define([LT_OPTION_DEFINE],
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
])# LT_OPTION_DEFINE
# dlopen
# ------
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
])
AU_DEFUN([AC_LIBTOOL_DLOPEN],
[_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'dlopen' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
# win32-dll
# ---------
# Declare package support for building win32 dll's.
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
;;
esac
test -z "$AS" && AS=as
_LT_DECL([], [AS], [1], [Assembler program])dnl
test -z "$DLLTOOL" && DLLTOOL=dlltool
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
test -z "$OBJDUMP" && OBJDUMP=objdump
_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
])# win32-dll
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
_LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'win32-dll' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
# _LT_ENABLE_SHARED([DEFAULT])
# ----------------------------
# implement the --enable-shared flag, and supports the 'shared' and
# 'disable-shared' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared],
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_shared=yes ;;
no) enable_shared=no ;;
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
_LT_DECL([build_libtool_libs], [enable_shared], [0],
[Whether or not to build shared libraries])
])# _LT_ENABLE_SHARED
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
# Old names:
AC_DEFUN([AC_ENABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
])
AC_DEFUN([AC_DISABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], [disable-shared])
])
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
# _LT_ENABLE_STATIC([DEFAULT])
# ----------------------------
# implement the --enable-static flag, and support the 'static' and
# 'disable-static' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static],
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_static=yes ;;
no) enable_static=no ;;
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
_LT_DECL([build_old_libs], [enable_static], [0],
[Whether or not to build static libraries])
])# _LT_ENABLE_STATIC
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
# Old names:
AC_DEFUN([AC_ENABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
])
AC_DEFUN([AC_DISABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], [disable-static])
])
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ----------------------------------
# implement the --enable-fast-install flag, and support the 'fast-install'
# and 'disable-fast-install' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install],
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_fast_install=yes ;;
no) enable_fast_install=no ;;
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
_LT_DECL([fast_install], [enable_fast_install], [0],
[Whether or not to optimize for fast installation])dnl
])# _LT_ENABLE_FAST_INSTALL
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
# Old names:
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the 'fast-install' option into LT_INIT's first parameter.])
])
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the 'disable-fast-install' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_AIX_SONAME([DEFAULT])
# ----------------------------------
# implement the --with-aix-soname flag, and support the `aix-soname=aix'
# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
m4_define([_LT_WITH_AIX_SONAME],
[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
shared_archive_member_spec=
case $host,$enable_shared in
power*-*-aix[[5-9]]*,yes)
AC_MSG_CHECKING([which variant of shared library versioning to provide])
AC_ARG_WITH([aix-soname],
[AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
[shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
[case $withval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
;;
esac
lt_cv_with_aix_soname=$with_aix_soname],
[AC_CACHE_VAL([lt_cv_with_aix_soname],
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
with_aix_soname=$lt_cv_with_aix_soname])
AC_MSG_RESULT([$with_aix_soname])
if test aix != "$with_aix_soname"; then
# For the AIX way of multilib, we name the shared archive member
# based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
# and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
# Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
# the AIX toolchain works better with OBJECT_MODE set (default 32).
if test 64 = "${OBJECT_MODE-32}"; then
shared_archive_member_spec=shr_64
else
shared_archive_member_spec=shr
fi
fi
;;
*)
with_aix_soname=aix
;;
esac
_LT_DECL([], [shared_archive_member_spec], [0],
[Shared archive member basename, for filename based shared library versioning on AIX])dnl
])# _LT_WITH_AIX_SONAME
LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
# _LT_WITH_PIC([MODE])
# --------------------
# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
# LT_INIT options.
# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
[lt_p=${PACKAGE-default}
case $withval in
yes|no) pic_mode=$withval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $withval; do
IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[pic_mode=m4_default([$1], [default])])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
# Old name:
AU_DEFUN([AC_LIBTOOL_PICMODE],
[_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'pic-only' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
## ----------------- ##
## LTDL_INIT Options ##
## ----------------- ##
m4_define([_LTDL_MODE], [])
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
[m4_define([_LTDL_MODE], [nonrecursive])])
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
[m4_define([_LTDL_MODE], [recursive])])
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
[m4_define([_LTDL_MODE], [subproject])])
m4_define([_LTDL_TYPE], [])
LT_OPTION_DEFINE([LTDL_INIT], [installable],
[m4_define([_LTDL_TYPE], [installable])])
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
[m4_define([_LTDL_TYPE], [convenience])])

124
dep/editline-1.17.1/m4/ltsugar.m4 vendored Normal file
View File

@ -0,0 +1,124 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 6 ltsugar.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
# lt_join(SEP, ARG1, [ARG2...])
# -----------------------------
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
# associated separator.
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
# versions in m4sugar had bugs.
m4_define([lt_join],
[m4_if([$#], [1], [],
[$#], [2], [[$2]],
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
m4_define([_lt_join],
[m4_if([$#$2], [2], [],
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
# lt_car(LIST)
# lt_cdr(LIST)
# ------------
# Manipulate m4 lists.
# These macros are necessary as long as will still need to support
# Autoconf-2.59, which quotes differently.
m4_define([lt_car], [[$1]])
m4_define([lt_cdr],
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
[$#], 1, [],
[m4_dquote(m4_shift($@))])])
m4_define([lt_unquote], $1)
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
# ------------------------------------------
# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
# Note that neither SEPARATOR nor STRING are expanded; they are appended
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
# than defined and empty).
#
# This macro is needed until we can rely on Autoconf 2.62, since earlier
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
m4_define([lt_append],
[m4_define([$1],
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
# ----------------------------------------------------------
# Produce a SEP delimited list of all paired combinations of elements of
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
# has the form PREFIXmINFIXSUFFIXn.
# Needed until we can rely on m4_combine added in Autoconf 2.62.
m4_define([lt_combine],
[m4_if(m4_eval([$# > 3]), [1],
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
[[m4_foreach([_Lt_prefix], [$2],
[m4_foreach([_Lt_suffix],
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
# -----------------------------------------------------------------------
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
m4_define([lt_if_append_uniq],
[m4_ifdef([$1],
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
[lt_append([$1], [$2], [$3])$4],
[$5])],
[lt_append([$1], [$2], [$3])$4])])
# lt_dict_add(DICT, KEY, VALUE)
# -----------------------------
m4_define([lt_dict_add],
[m4_define([$1($2)], [$3])])
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
# --------------------------------------------
m4_define([lt_dict_add_subkey],
[m4_define([$1($2:$3)], [$4])])
# lt_dict_fetch(DICT, KEY, [SUBKEY])
# ----------------------------------
m4_define([lt_dict_fetch],
[m4_ifval([$3],
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
# -----------------------------------------------------------------
m4_define([lt_if_dict_fetch],
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
[$5],
[$6])])
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
# --------------------------------------------------------------
m4_define([lt_dict_filter],
[m4_if([$5], [], [],
[lt_join(m4_quote(m4_default([$4], [[, ]])),
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
])

23
dep/editline-1.17.1/m4/ltversion.m4 vendored Normal file
View File

@ -0,0 +1,23 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# @configure_input@
# serial 4179 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.4.6])
m4_define([LT_PACKAGE_REVISION], [2.4.6])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.4.6'
macro_revision='2.4.6'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])

99
dep/editline-1.17.1/m4/lt~obsolete.m4 vendored Normal file
View File

@ -0,0 +1,99 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
# Foundation, Inc.
# Written by Scott James Remnant, 2004.
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 5 lt~obsolete.m4
# These exist entirely to fool aclocal when bootstrapping libtool.
#
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
# which have later been changed to m4_define as they aren't part of the
# exported API, or moved to Autoconf or Automake where they belong.
#
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
# using a macro with the same name in our local m4/libtool.m4 it'll
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
# and doesn't know about Autoconf macros at all.)
#
# So we provide this file, which has a silly filename so it's always
# included after everything else. This provides aclocal with the
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
# because those macros already exist, or will be overwritten later.
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
#
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
# Yes, that means every name once taken will need to remain here until
# we give up compatibility with versions before 1.7, at which point
# we need to keep only those names which we still refer to.
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])

View File

@ -0,0 +1,3 @@
AUTOMAKE_OPTIONS = foreign
dist_man_MANS = editline.3

View File

@ -0,0 +1,520 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = man
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
man3dir = $(mandir)/man3
am__installdirs = "$(DESTDIR)$(man3dir)"
NROFF = nroff
MANS = $(dist_man_MANS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
dist_man_MANS = editline.3
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign man/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-man3: $(dist_man_MANS)
@$(NORMAL_INSTALL)
@list1=''; \
list2='$(dist_man_MANS)'; \
test -n "$(man3dir)" \
&& test -n "`echo $$list1$$list2`" \
|| exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.3[a-z]*$$/p'; \
fi; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
done | \
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
sed 'N;N;s,\n, ,g' | { \
list=; while read file base inst; do \
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \
fi; \
done; \
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
while read files; do \
test -z "$$files" || { \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \
done; }
uninstall-man3:
@$(NORMAL_UNINSTALL)
@list=''; test -n "$(man3dir)" || exit 0; \
files=`{ for i in $$list; do echo "$$i"; done; \
l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
sed -n '/\.3[a-z]*$$/p'; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir)
tags TAGS:
ctags CTAGS:
cscope cscopelist:
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(MANS)
installdirs:
for dir in "$(DESTDIR)$(man3dir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-man
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man: install-man3
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-man
uninstall-man: uninstall-man3
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
cscopelist-am ctags-am distclean distclean-generic \
distclean-libtool distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-man3 install-pdf install-pdf-am install-ps \
install-ps-am install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am tags-am uninstall uninstall-am uninstall-man \
uninstall-man3
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,286 @@
.Dd February 23, 2020
.Dt EDITLINE 3
.Os
.Sh NAME
.Nm editline
.Nd command-line editing library with history
.Sh LIBRARY
.Lb libeditline
.Sh SYNOPSIS
.In editline.h
.Ft char *
.Fo readline
.Fa const char *prompt
.Fc
.Ft void
.Fo add_history
.Fa const char *line
.Fc
.Ft int
.Fo read_history
.Fa const char *filename
.Fc
.Ft int
.Fo write_history
.Fa const char *filename
.Fc
.Sh DESCRIPTION
.Nm
is a library that provides n line-editing interface with history. It
is intended to be functionally equivalent with the
.Nm readline
library provided by the Free Software Foundation, but much smaller. The
bulk of this manual page describes the basic user interface. More APIs,
both native and for
.Nm readline
compatibility ,
are also available. See the
.Cm editline.h
header file for details.
.Pp
The
.Fn readline
function displays the given
.Fa prompt
on stdout, waits for user input on stdin and then returns a line of text
with the trailing newline removed. The data is returned in a buffer
allocated with
.Xr malloc 3 ,
so the space should be released with
.Xr free 3
when the calling program is done with it.
.Pp
Each line returned is automatically saved in the internal history list,
unless it happens to be equal to the previous line. This is
configurable if you are building editline from source, i.e. if you would
rather like to call
.Fn add_history
manually.
.Pp
The
.Fn read_history
and
.Fn write_history
functions can be used to load and store the history of your application.
.Em Note:
these APIs do not do any tilde or environment variable expansion of the
given filename.
.Ss User Interface
A program that uses this library provides a simple emacs-like editing
interface to its users. A line may be edited before it is sent to the
calling program by typing either control characters or escape sequences.
A control character, shown as a caret followed by a letter, is typed by
holding down the control key while the letter is typed. For example,
.Cm ^A
is a control-A. An escape sequence is entered by typing the escape key
followed by one or more characters. The escape key is abbreviated as
.Cm ESC .
Note that unlike control keys, case matters in escape sequences;
.Cm ESC F
is not the same as
.Cm ESC f .
.Pp
An editing command may be typed anywhere on the line, not just at the
beginning. In addition, a return may also be typed anywhere on the
line, not just at the end.
.Pp
Most editing commands may be given a repeat count,
.Ar n ,
where
.Ar n
is a number. To enter a repeat count, type the escape key, the number,
and then the command to execute. For example,
.Cm ESC 4 ^f
moves forward four characters. If a command may be given a repeat count
then the text
.Cm [n]
is given at the end of its description.
.Pp
The following control characters are accepted:
.Pp
.Bl -tag -width "ESC DEL " -compact
.It ^A
Move to the beginning of the line
.It ^B
Move left (backwards) [n]
.It ^D
Delete character [n]
.It ^E
Move to end of line
.It ^F
Move right (forwards) [n]
.It ^G
Ring the bell
.It ^H
Delete character before cursor (backspace key) [n]
.It ^I
Complete filename (tab key); see below
.It ^J
Done with line (return key)
.It ^K
Kill to end of line (or column [n])
.It ^L
Redisplay line
.It ^M
Done with line (alternate return key)
.It ^N
Get next line from history [n]
.It ^P
Get previous line from history [n]
.It ^R
Search backward (forward if [n]) through history for text; prefixing the
string with a caret (^) forces it to match only at the beginning of a
history line
.It ^T
Transpose characters
.It ^V
Insert next character, even if it is an edit command
.It ^W
Wipe to the mark
.It ^X^X
Exchange current location and mark
.It ^Y
Yank back last killed text
.It ^[
Start an escape sequence (escape key)
.It ^]c
Move forward to next character
.Cm c
.It ^?
Delete character before cursor (delete key) [n]
.El
.Pp
The following escape sequences are provided:
.Pp
.Bl -tag -width "ESC DEL " -compact
.It ESC ^H
Delete previous word (backspace key) [n]
.It ESC DEL
Delete previous word (delete key) [n]
.It ESC SP
Set the mark (space key); see ^X^X and ^Y above
.It ESC\ .
Get the last (or [n]'th) word from previous line
.It ESC\ ?
Show possible completions; see below
.It ESC <
Move to start of history
.It ESC >
Move to end of history
.It ESC b
Move backward a word [n]
.It ESC d
Delete word under cursor [n]
.It ESC f
Move forward a word [n]
.It ESC l
Make word lowercase [n]
.It ESC m
Toggle if 8bit chars display normally or with an
.Ar M-
prefix
.It ESC u
Make word uppercase [n]
.It ESC y
Yank back last killed text
.It ESC v
Show library version
.It ESC w
Make area up to mark yankable
.It ESC nn
Set repeat count to the number nn
.It ESC C
Read from environment variable
.Ar $C ,
where
.Ar C
is an uppercase letter
.El
.Pp
The
.Nm
library has a small macro facility. If you type the escape key followed
by an uppercase letter,
.Ar C ,
then the contents of the environment variable
.Ar $C
are read in as if you had typed them at the keyboard. For example, if
the variable
.Ar $L
contains the following:
.Pp
.Dl ^A^Kecho '^V^[[H^V^[[2J'^M
.Pp
Then typing
.Cm ESC L
will move to the beginning of the line, kill the entire line, enter the
echo command needed to clear the terminal (if your terminal is like a
VT-100), and send the line back to the shell.
.Pp
The
.Nm
library also does filename completion. Suppose the root directory has
the following files in it:
.Pp
.Dl bin vmunix
.Dl core vmunix.old
.Pp
If you type
.Cm rm /v
and then the tab key,
.Nm
will then finish off as much of the name as possible by adding
.Ar munix .
Because the name is not unique, it will then beep. If you type the
escape key and a question mark, it will display the two choices. If you
then type a period and a tab, the library will finish off the filename
for you:
.Pp
.Bd -ragged -offset indent
rm /v[TAB]
.Em munix
\&.[TAB]
.Em old
.Ed
.Pp
The tab key is shown by [TAB] and the automatically-entered text
is shown in italics, or underline.
.Sh USAGE
To include
.Nm
in your program, call it as you do any other function and link your
program with
.Ar -leditline .
.Ss Example
The following brief example lets you enter a line and edit it, then displays it.
.Pp
.Bd -literal -offset indent
#include <stdio.h>
#include <stdlib.h>
#include <editline.h>
int main(void)
{
char *p;
while ((p = readline("CLI> "))) {
puts(p);
free(p);
}
return 0;
}
.El
.Sh AUTHORS
The original editline library was posted to comp.sources.unix newsgroup
by created by Simmule R. Turner and Rich Salz in 1992. It now exists in
several forks: Debian, Minix, Heimdal, Festival speech tools, Mozilla,
Google Gadgets for Linux, and many other places. The original manual
page was made by David W. Sanderson.
.Pp
This version was originally based on the Minix 2 sources, but has since
evolved to include patches from all relevant forks. It is currently
maintained by Joachim Nilsson at GitHub,
.Aq http://github.com/troglobit/editline
.Sh BUGS
Does not handle multiple lines or unicode characters well.

View File

@ -0,0 +1,6 @@
lib_LTLIBRARIES = libeditline.la
libeditline_la_SOURCES = editline.c editline.h complete.c sysunix.c unix.h
libeditline_la_CFLAGS = -std=gnu99
libeditline_la_CFLAGS += -W -Wall -Wextra -Wundef -Wunused -Wstrict-prototypes
libeditline_la_CFLAGS += -Werror-implicit-function-declaration -Wshadow -Wcast-qual
libeditline_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:2:0

View File

@ -0,0 +1,686 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
libeditline_la_LIBADD =
am_libeditline_la_OBJECTS = libeditline_la-editline.lo \
libeditline_la-complete.lo libeditline_la-sysunix.lo
libeditline_la_OBJECTS = $(am_libeditline_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
libeditline_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
$(libeditline_la_CFLAGS) $(CFLAGS) $(libeditline_la_LDFLAGS) \
$(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/aux/depcomp
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/libeditline_la-complete.Plo \
./$(DEPDIR)/libeditline_la-editline.Plo \
./$(DEPDIR)/libeditline_la-sysunix.Plo
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libeditline_la_SOURCES)
DIST_SOURCES = $(libeditline_la_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/aux/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
lib_LTLIBRARIES = libeditline.la
libeditline_la_SOURCES = editline.c editline.h complete.c sysunix.c unix.h
libeditline_la_CFLAGS = -std=gnu99 -W -Wall -Wextra -Wundef -Wunused \
-Wstrict-prototypes -Werror-implicit-function-declaration \
-Wshadow -Wcast-qual
libeditline_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:2:0
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign src/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
list2="$$list2 $$p"; \
else :; fi; \
done; \
test -z "$$list2" || { \
echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
}
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
libeditline.la: $(libeditline_la_OBJECTS) $(libeditline_la_DEPENDENCIES) $(EXTRA_libeditline_la_DEPENDENCIES)
$(AM_V_CCLD)$(libeditline_la_LINK) -rpath $(libdir) $(libeditline_la_OBJECTS) $(libeditline_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeditline_la-complete.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeditline_la-editline.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeditline_la-sysunix.Plo@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
am--depfiles: $(am__depfiles_remade)
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
libeditline_la-editline.lo: editline.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeditline_la_CFLAGS) $(CFLAGS) -MT libeditline_la-editline.lo -MD -MP -MF $(DEPDIR)/libeditline_la-editline.Tpo -c -o libeditline_la-editline.lo `test -f 'editline.c' || echo '$(srcdir)/'`editline.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeditline_la-editline.Tpo $(DEPDIR)/libeditline_la-editline.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='editline.c' object='libeditline_la-editline.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeditline_la_CFLAGS) $(CFLAGS) -c -o libeditline_la-editline.lo `test -f 'editline.c' || echo '$(srcdir)/'`editline.c
libeditline_la-complete.lo: complete.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeditline_la_CFLAGS) $(CFLAGS) -MT libeditline_la-complete.lo -MD -MP -MF $(DEPDIR)/libeditline_la-complete.Tpo -c -o libeditline_la-complete.lo `test -f 'complete.c' || echo '$(srcdir)/'`complete.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeditline_la-complete.Tpo $(DEPDIR)/libeditline_la-complete.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='complete.c' object='libeditline_la-complete.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeditline_la_CFLAGS) $(CFLAGS) -c -o libeditline_la-complete.lo `test -f 'complete.c' || echo '$(srcdir)/'`complete.c
libeditline_la-sysunix.lo: sysunix.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeditline_la_CFLAGS) $(CFLAGS) -MT libeditline_la-sysunix.lo -MD -MP -MF $(DEPDIR)/libeditline_la-sysunix.Tpo -c -o libeditline_la-sysunix.lo `test -f 'sysunix.c' || echo '$(srcdir)/'`sysunix.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeditline_la-sysunix.Tpo $(DEPDIR)/libeditline_la-sysunix.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sysunix.c' object='libeditline_la-sysunix.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeditline_la_CFLAGS) $(CFLAGS) -c -o libeditline_la-sysunix.lo `test -f 'sysunix.c' || echo '$(srcdir)/'`sysunix.c
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES)
installdirs:
for dir in "$(DESTDIR)$(libdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-am
-rm -f ./$(DEPDIR)/libeditline_la-complete.Plo
-rm -f ./$(DEPDIR)/libeditline_la-editline.Plo
-rm -f ./$(DEPDIR)/libeditline_la-sysunix.Plo
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-libLTLIBRARIES
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/libeditline_la-complete.Plo
-rm -f ./$(DEPDIR)/libeditline_la-editline.Plo
-rm -f ./$(DEPDIR)/libeditline_la-sysunix.Plo
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-libLTLIBRARIES
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-generic clean-libLTLIBRARIES clean-libtool cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-libLTLIBRARIES install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,442 @@
/* History and file completion functions for editline library.
*
* Copyright (c) 1992, 1993 Simmule Turner and Rich Salz
* All rights reserved.
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
* 1. The authors are not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
* 4. This notice may not be removed or altered.
*/
#include <ctype.h>
#include "editline.h"
#define MAX_TOTAL_MATCHES (256 << sizeof(char *))
int rl_attempted_completion_over = 0;
rl_completion_func_t *rl_attempted_completion_function = NULL;
rl_compentry_func_t *rl_completion_entry_function = NULL;
/* Wrap strcmp() for qsort() -- weird construct to pass -Wcast-qual */
static int compare(const void *p1, const void *p2)
{
char *const *v1 = (char *const *)p1;
char *const *v2 = (char *const *)p2;
return strcmp(*v1, *v2);
}
/* Fill in *avp with an array of names that match file, up to its length.
* Ignore . and .. . */
static int FindMatches(char *dir, char *file, char ***avp)
{
char **av;
char **word;
char *p;
DIR *dp;
DIRENTRY *ep;
size_t ac;
size_t len;
size_t choices;
size_t total;
if ((dp = opendir(dir)) == NULL)
return 0;
av = NULL;
ac = 0;
len = strlen(file);
choices = 0;
total = 0;
while ((ep = readdir(dp)) != NULL) {
p = ep->d_name;
if (p[0] == '.' && (p[1] == '\0' || (p[1] == '.' && p[2] == '\0')))
continue;
if (len && strncmp(p, file, len) != 0)
continue;
choices++;
if ((total += strlen(p)) > MAX_TOTAL_MATCHES) {
/* This is a bit too much. */
while (ac > 0) free(av[--ac]);
continue;
}
if ((ac % MEM_INC) == 0) {
word = malloc(sizeof(char *) * (ac + MEM_INC));
if (!word) {
total = 0;
break;
}
if (ac) {
memcpy(word, av, ac * sizeof(char *));
free(av);
}
*avp = av = word;
}
if ((av[ac] = strdup(p)) == NULL) {
if (ac == 0)
free(av);
total = 0;
break;
}
ac++;
}
/* Clean up and return. */
closedir(dp);
if (total > MAX_TOTAL_MATCHES) {
char many[sizeof(total) * 3];
p = many + sizeof(many);
*--p = '\0';
while (choices > 0) {
*--p = '0' + choices % 10;
choices /= 10;
}
while (p > many + sizeof(many) - 8)
*--p = ' ';
if ((p = strdup(p)) != NULL)
av[ac++] = p;
if ((p = strdup("choices")) != NULL)
av[ac++] = p;
} else {
if (ac)
qsort(av, ac, sizeof(char *), compare);
}
return ac;
}
/* Split a pathname into allocated directory and trailing filename parts. */
static int SplitPath(const char *path, char **dirpart, char **filepart)
{
static char DOT[] = ".";
char *dpart;
char *fpart;
if ((fpart = strrchr(path, '/')) == NULL) {
if ((dpart = strdup(DOT)) == NULL)
return -1;
if ((fpart = strdup(path)) == NULL) {
free(dpart);
return -1;
}
} else {
if ((dpart = strdup(path)) == NULL)
return -1;
dpart[fpart - path + 1] = '\0';
if ((fpart = strdup(fpart + 1)) == NULL) {
free(dpart);
return -1;
}
}
*dirpart = dpart;
*filepart = fpart;
return 0;
}
static rl_complete_func_t *el_complete_func = NULL;
/* For compatibility with the Heimdal project. */
rl_complete_func_t *rl_set_complete_func(rl_complete_func_t *func)
{
rl_complete_func_t *old = el_complete_func;
el_complete_func = func;
return old;
}
/* Attempt to complete the pathname, returning an allocated copy.
* Fill in *match if we completed it, or set it to 0 if ambiguous. */
char *el_filename_complete(char *pathname, int *match)
{
char **av;
char *dir;
char *file;
char *path;
char *p;
size_t ac;
size_t end;
size_t i;
size_t j;
size_t len;
if (SplitPath((const char *)pathname, &dir, &file) < 0)
return NULL;
if ((ac = FindMatches(dir, file, &av)) == 0) {
free(dir);
free(file);
return NULL;
}
p = NULL;
len = strlen(file);
if (ac == 1) {
/* Exactly one match -- finish it off. */
*match = 1;
j = strlen(av[0]) - len + 2;
p = malloc(sizeof(char) * (j + 1));
if (p) {
memcpy(p, av[0] + len, j);
len = strlen(dir) + strlen(av[0]) + 2;
path = malloc(sizeof(char) * len);
if (path) {
snprintf(path, len, "%s/%s", dir, av[0]);
rl_add_slash(path, p);
free(path);
}
}
} else {
*match = 0;
if (len) {
/* Find largest matching substring. */
for (i = len, end = strlen(av[0]); i < end; i++) {
for (j = 1; j < ac; j++) {
if (av[0][i] != av[j][i])
goto breakout;
}
}
breakout:
if (i > len) {
j = i - len + 1;
p = malloc(sizeof(char) * j);
if (p) {
memcpy(p, av[0] + len, j);
p[j - 1] = '\0';
}
}
}
}
/* Clean up and return. */
free(dir);
free(file);
for (i = 0; i < ac; i++)
free(av[i]);
free(av);
return p;
}
char *rl_filename_completion_function(const char *text, int state)
{
char *dir;
char *file;
static char **av;
static size_t i, ac;
if (!state) {
if (SplitPath(text, &dir, &file) < 0)
return NULL;
ac = FindMatches(dir, file, &av);
free(dir);
free(file);
if (!ac)
return NULL;
i = 0;
}
if (i < ac)
return av[i++];
do {
free(av[--i]);
} while (i > 0);
return NULL;
}
/* Similar to el_find_word(), but used by GNU Readline API */
static char *rl_find_token(size_t *len)
{
char *ptr;
int pos;
for (pos = rl_point; pos < rl_end; pos++) {
if (isspace(rl_line_buffer[pos])) {
if (pos > 0)
pos--;
break;
}
}
ptr = &rl_line_buffer[pos];
while (pos >= 0 && !isspace(rl_line_buffer[pos])) {
if (pos == 0)
break;
pos--;
}
if (ptr != &rl_line_buffer[pos]) {
*len = (size_t)(ptr - &rl_line_buffer[pos]);
return &rl_line_buffer[pos];
}
return NULL;
}
/*
* "uses an application-supplied generator function to generate the list
* of possible matches, and then returns the array of these matches. The
* caller should place the address of its generator function in
* rl_completion_entry_function"
*/
char **rl_completion_matches(const char *token, rl_compentry_func_t *generator)
{
int state = 0, num = 0;
char **array, *entry;
if (!generator) {
generator = rl_completion_entry_function;
if (!generator)
generator = rl_filename_completion_function;
}
if (!generator)
return NULL;
array = malloc(512 * sizeof(char *));
if (!array)
return NULL;
while (num < 511 && (entry = generator(token, state))) {
state = 1;
array[num++] = entry;
}
array[num] = NULL;
if (!num) {
free(array);
return NULL;
}
return array;
}
static char *complete(char *token, int *match)
{
size_t len = 0;
char *word, **words = NULL;
int start, end;
word = rl_find_token(&len);
if (!word)
goto fallback;
start = word - rl_line_buffer;
end = start + len;
word = strndup(word, len);
if (!word)
goto fallback;
rl_attempted_completion_over = 0;
words = rl_attempted_completion_function(word, start, end);
if (!rl_attempted_completion_over && !words)
words = rl_completion_matches(word, NULL);
if (words) {
int i = 0;
free(word);
word = NULL;
if (words[0])
word = strdup(words[0] + len);
while (words[i])
free(words[i++]);
free(words);
if (word)
return word;
}
fallback:
return el_filename_complete(token, match);
}
/*
* First check for editline specific custom completion function, then
* for any GNU Readline compat, then fallback to filename completion.
*/
char *rl_complete(char *token, int *match)
{
if (el_complete_func)
return el_complete_func(token, match);
if (rl_attempted_completion_function)
return complete(token, match);
return el_filename_complete(token, match);
}
static rl_list_possib_func_t *el_list_possib_func = NULL;
/* For compatibility with the Heimdal project. */
rl_list_possib_func_t *rl_set_list_possib_func(rl_list_possib_func_t *func)
{
rl_list_possib_func_t *old = el_list_possib_func;
el_list_possib_func = func;
return old;
}
/* Default possible completions. */
int el_filename_list_possib(char *pathname, char ***av)
{
char *dir;
char *file;
int ac;
if (SplitPath(pathname, &dir, &file) < 0)
return 0;
ac = FindMatches(dir, file, av);
free(dir);
free(file);
return ac;
}
/* Return all possible completions. */
int rl_list_possib(char *token, char ***av)
{
if (el_list_possib_func)
return el_list_possib_func(token, av);
return el_filename_list_possib(token, av);
}
/**
* Local Variables:
* c-file-style: "k&r"
* c-basic-offset: 4
* End:
*/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,101 @@
/* Internal header file for editline library.
*
* Copyright (c) 1992, 1993 Simmule Turner and Rich Salz
* All rights reserved.
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
* 1. The authors are not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
* 4. This notice may not be removed or altered.
*/
#ifndef EDITLINE_PRIVATE_H_
#define EDITLINE_PRIVATE_H_
#include <config.h>
#include <stdio.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef SYS_UNIX
#include "unix.h"
#endif
#ifdef SYS_OS9
#include "os9.h"
#endif
/* The following two are for TIOCGWINSZ */
#ifdef HAVE_TERMIOS_H
# include <termios.h>
#endif
#ifdef GWINSZ_IN_SYS_IOCTL
# include <sys/ioctl.h>
#endif
#define MEM_INC 64
#define SCREEN_INC 256
/* From The Practice of Programming, by Kernighan and Pike */
#ifndef NELEMS
#define NELEMS(array) (sizeof(array) / sizeof(array[0]))
#endif
/*
** Variables and routines internal to this package.
*/
extern int rl_eof;
extern int rl_erase;
extern int rl_intr;
extern int rl_kill;
extern int rl_quit;
#ifdef CONFIG_SIGSTOP
extern int rl_susp;
#endif
void rl_ttyset(int Reset);
void rl_add_slash(char *path, char *p);
char *rl_complete(char *token, int *match);
int rl_list_possib(char *token, char ***av);
#ifndef HAVE_STDLIB_H
extern char *getenv(const char *name);
extern char *malloc(size_t size);
extern char *realloc(void *ptr, size_t size);
extern char *memcpy(void *dest, const void *src, size_t n);
extern char *strcat(char *dest, const char *src);
extern char *strchr(const char *s, int c);
extern char *strrchr(const char *s, int c);
extern char *strcpy(char *dest, const char *src);
extern char *strdup(const char *s);
extern int strcmp(const char *s1, const char *s2);
extern int strlen(const char *s);
extern int strncmp(const char *s1, const char *s2, size_t n);
#endif/* !HAVE_STDLIB_H */
#ifndef HAVE_STRDUP
extern char *strdup(const char *s);
#endif
#include "../include/editline.h"
#endif /* EDITLINE_PRIVATE_H_ */

View File

@ -0,0 +1,251 @@
/* Unix system-dependant routines for editline library.
*
* Copyright (c) 1992, 1993 Simmule Turner and Rich Salz
* All rights reserved.
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
* 1. The authors are not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
* 4. This notice may not be removed or altered.
*/
#include <errno.h>
#include "editline.h"
#ifndef HAVE_TCGETATTR
/* Wrapper for ioctl syscalls to restart on signal */
static int ioctl_wrap(int fd, int req, void *arg)
{
int result, retries = 3;
while (-1 == (result = ioctl(fd, req, arg)) && retries > 0) {
retries--;
if (EINTR == errno)
continue;
break;
}
return result;
}
#endif
/* Prefer termios over the others since it is likely the most portable. */
#if defined(HAVE_TCGETATTR)
#include <termios.h>
/* Wrapper for tcgetattr */
static int getattr(int fd, struct termios *arg)
{
int result, retries = 3;
while (-1 == (result = tcgetattr(fd, arg)) && retries > 0) {
retries--;
if (EINTR == errno)
continue;
break;
}
return result;
}
/* Wrapper for tcgetattr */
static int setattr(int fd, int opt, const struct termios *arg)
{
int result, retries = 3;
while (-1 == (result = tcsetattr(fd, opt, arg)) && retries > 0) {
retries--;
if (EINTR == errno)
continue;
break;
}
return result;
}
void rl_ttyset(int Reset)
{
static struct termios old;
struct termios new;
if (!Reset) {
if (-1 == getattr(0, &old))
perror("Failed tcgetattr()");
rl_erase = old.c_cc[VERASE];
rl_kill = old.c_cc[VKILL];
rl_eof = old.c_cc[VEOF];
rl_intr = old.c_cc[VINTR];
rl_quit = old.c_cc[VQUIT];
#ifdef CONFIG_SIGSTOP
rl_susp = old.c_cc[VSUSP];
#endif
new = old;
new.c_lflag &= ~(ECHO | ICANON | ISIG);
new.c_iflag &= ~INPCK;
if (rl_meta_chars)
new.c_iflag |= ISTRIP;
else
new.c_iflag &= ~ISTRIP;
new.c_cc[VMIN] = 1;
new.c_cc[VTIME] = 0;
if (-1 == setattr(0, TCSADRAIN, &new))
perror("Failed tcsetattr(TCSADRAIN)");
} else {
if (-1 == setattr(0, TCSADRAIN, &old))
perror("Failed tcsetattr(TCSADRAIN)");
}
}
#elif defined(HAVE_TERMIO_H)
#include <termio.h>
void rl_ttyset(int Reset)
{
static struct termio old;
struct termio new;
if (!Reset) {
if (-1 == ioctl_wrap(0, TCGETA, &old))
perror("Failed ioctl(TCGETA)");
rl_erase = old.c_cc[VERASE];
rl_kill = old.c_cc[VKILL];
rl_eof = old.c_cc[VEOF];
rl_intr = old.c_cc[VINTR];
rl_quit = old.c_cc[VQUIT];
#ifdef CONFIG_SIGSTOP
rl_susp = old.c_cc[VSUSP];
#endif
new = old;
new.c_lflag &= ~(ECHO | ICANON | ISIG);
new.c_iflag &= ~INPCK;
if (rl_meta_chars)
new.c_iflag |= ISTRIP;
else
new.c_iflag &= ~ISTRIP;
new.c_cc[VMIN] = 1;
new.c_cc[VTIME] = 0;
if (-1 == ioctl_wrap(0, TCSETAW, &new))
perror("Failed ioctl(TCSETAW)");
} else {
if (-1 == ioctl_wrap(0, TCSETAW, &old))
perror("Failed ioctl(TCSETAW)");
}
}
#elif defined(HAVE_SGTTY_H)
#include <sgtty.h>
void rl_ttyset(int Reset)
{
static struct sgttyb old_sgttyb;
static struct tchars old_tchars;
struct sgttyb new_sgttyb;
struct tchars new_tchars;
#ifdef CONFIG_SIGSTOP
struct ltchars old_ltchars;
#endif
if (!Reset) {
if (-1 == ioctl_wrap(0, TIOCGETP, &old_sgttyb))
perror("Failed TIOCGETP");
rl_erase = old_sgttyb.sg_erase;
rl_kill = old_sgttyb.sg_kill;
if (-1 == ioctl_wrap(0, TIOCGETC, &old_tchars))
perror("Failed TIOCGETC");
rl_eof = old_tchars.t_eofc;
rl_intr = old_tchars.t_intrc;
rl_quit = old_tchars.t_quitc;
#ifdef CONFIG_SIGSTOP
if (-1 == ioctl_wrap(0, TIOCGLTC, &old_ltchars))
perror("Failed TIOCGLTC");
rl_susp = old_ltchars.t_suspc;
#endif
new_sgttyb = old_sgttyb;
new_sgttyb.sg_flags &= ~ECHO;
new_sgttyb.sg_flags |= RAW;
if (rl_meta_chars)
new_sgttyb.sg_flags &= ~PASS8;
else
new_sgttyb.sg_flags |= PASS8;
if (-1 == ioctl_wrap(0, TIOCSETP, &new_sgttyb))
perror("Failed TIOCSETP");
new_tchars = old_tchars;
new_tchars.t_intrc = -1;
new_tchars.t_quitc = -1;
if (-1 == ioctl_wrap(0, TIOCSETC, &new_tchars))
perror("Failed TIOCSETC");
} else {
if (-1 == ioctl_wrap(0, TIOCSETP, &old_sgttyb))
perror("Failed TIOCSETP");
if (-1 == ioctl_wrap(0, TIOCSETC, &old_tchars))
perror("Failed TIOCSETC");
}
}
#else /* Neither HAVE_SGTTY_H, HAVE_TERMIO_H or HAVE_TCGETATTR */
#error Unsupported platform, missing tcgetattr(), termio.h and sgtty.h
#endif /* Neither HAVE_SGTTY_H, HAVE_TERMIO_H or HAVE_TCGETATTR */
#ifndef HAVE_STRDUP
/* Return an allocated copy of a string. */
char *strdup(const char *s)
{
size_t len;
char *ptr;
if (!s)
return NULL;
len = strlen(s) + 1;
ptr = malloc(len);
if (ptr)
return memcpy(ptr, s, len);
return NULL;
}
#endif
void rl_add_slash(char *path, char *p)
{
struct stat Sb;
if (stat(path, &Sb) >= 0)
strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ");
}
/**
* Local Variables:
* c-file-style: "k&r"
* c-basic-offset: 4
* End:
*/

View File

@ -0,0 +1,36 @@
/* Editline system header file for Unix.
*
* Copyright (c) 1992, 1993 Simmule Turner and Rich Salz
* All rights reserved.
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
* 1. The authors are not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
* 4. This notice may not be removed or altered.
*/
#ifndef EDITLINE_UNIX_H_
#define EDITLINE_UNIX_H_
#define CRLF "\r\n"
#define FORWARD STATIC
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
typedef struct dirent DIRENTRY;
#endif /* EDITLINE_UNIX_H_ */

View File

@ -0,0 +1,26 @@
set(TOOL_NAME dsviewer)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
find_package(PkgConfig)
pkg_search_module(EDITLINE REQUIRED libeditline)
include_directories(${EDITLINE_INCLUDE_DIRS})
link_directories(${EDITLINE_LIBRARY_DIRS})
aux_source_directory(. TOOL_SRC)
add_executable(${TOOL_NAME} ${TOOL_SRC})
set_target_properties(${TOOL_NAME} PROPERTIES INSTALL_RPATH /usr/local/lib)
set_target_properties(${TOOL_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
target_link_libraries(${TOOL_NAME} PRIVATE gctl)
target_link_libraries(${TOOL_NAME} PRIVATE ${EDITLINE_LIBRARIES})
install(TARGETS ${TOOL_NAME} RUNTIME DESTINATION sbin)
file(GLOB HELP_DOC *.md)
install(FILES ${HELP_DOC} DESTINATION sbin/share)

614
dsviewer/dsviewer.cpp Normal file
View File

@ -0,0 +1,614 @@
/********************************************************
*
*
*
*
*
*
* Geophysical Computational Tools & Library (GCTL)
*
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
*
* GCTL is distributed under a dual licensing scheme. You can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 2
* of the License, or (at your option) any later version. You should have
* received a copy of the GNU Lesser General Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>.
*
* If the terms and conditions of the LGPL v.2. would prevent you from using
* the GCTL, please consider the option to obtain a commercial license for a
* fee. These licenses are offered by the GCTL's original author. As a rule,
* licenses are provided "as-is", unlimited in time for a one time fee. Please
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
* to include some description of your company and the realm of its activities.
* Also add information on how to contact you by electronic and paper mail.
******************************************************/
#include "dsviewer.h"
// We use the editline library to handle all inputs
#include "editline.h"
// install configuration
#include "../gctl_toolkits_config.h"
cmd_pair curr_cmd; // Executing command
gctl::dsv_io tc; // Grid object
extern "C" {
/*
* Strip whitespace from the start and end of STRING. Return a pointer
* into STRING.
*/
char *stripwhite(char *string)
{
char *s, *t;
for (s = string; isspace(*s); s++) ;
if (*s == 0)
return s;
t = s + strlen(s) - 1;
while (t > s && isspace(*t))
t--;
*++t = '\0';
return s;
}
/* Generator function for command completion. STATE lets us
know whether to start from scratch; without any state
(i.e. STATE == 0), then we start at the top of the list. */
char *command_generator(const char *text, int state)
{
static int list_index, len;
/* If this is a new word to complete, initialize now. This
includes saving the length of TEXT for efficiency, and
initializing the index variable to 0. */
if (!state)
{
list_index = 0;
len = strlen(text);
}
/* Return the next name which partially matches from the command list. */
while (list_index < CMD_NUM)
{
if (std::string(text) == commands[list_index].name.substr(0, len))
{
//const char* name = commands[list_index].name.data();
return strdup(commands[list_index].name.data());
}
else list_index++;
}
/* If no names matched, then return NULL. */
return nullptr;
}
/*
* Attempt to complete on the contents of TEXT. START and END
* bound the region of rl_line_buffer that contains the word to
* complete. TEXT is the word to complete. We can use the entire
* contents of rl_line_buffer in case we want to do some simple
* parsing. Return the array of matches, or NULL if there aren't any.
*/
char **dsviewer_completion(const char *text, int start, int end)
{
char **matches = nullptr;
/* If this word is at the start of the line, then it is a command
to complete. Otherwise it is the name of a file in the current
directory. */
if (start == 0) matches = rl_completion_matches(text, command_generator);
return matches;
}
void initialize_readline(void)
{
/* Allow conditional parsing of the ~/.inputrc file. */
rl_readline_name = "dsviewer";
/* Tell the completer that we want a crack first. */
rl_attempted_completion_function = dsviewer_completion;
}
} // End C section
void display_cmds()
{
std::clog << "Command:\n";
for (size_t i = 0; i < CMD_NUM - 1; i++)
{
std::clog << std::setw(12) << commands[i].name << ":\t" << commands[i].brief << "\n";
}
std::clog << "\nEnter \"<command>?\" to see detailed instructions.\n";
std::clog << "\nCmdFile:\n";
std::clog << "Each line of the input file(s) will be parsed as a command.\nEmpty lines and lines start with '#' will be skipped.\n";
std::clog << "\nHereDoc:\n";
std::clog << "You can use HereDoc to input commands. A simple example is:\n";
std::clog << "dsviewer << EOF\n";
std::clog << "open file1.csv\n";
std::clog << "info\n";
std::clog << "EOF\n";
return;
}
void display_help(std::string input_cmd)
{
std::string install_dir = GCTL_TOOLKITS_INSTALL_PREFIX;
std::ifstream helpin;
open_infile(helpin, install_dir + "/sbin/share/dsviewer", ".md");
std::string tmp_l, tmp_help;
std::vector<std::string> cmds;
std::vector<std::string> helps;
while (getline(helpin, tmp_l))
{
if (tmp_l.substr(0, 4) == "####")
{
cmds.push_back(tmp_l.substr(5));
tmp_help = "";
while (getline(helpin, tmp_l))
{
if (tmp_l == "") break;
else tmp_help += tmp_l + "\n";
}
helps.push_back(tmp_help);
}
}
helpin.close();
std::string cmd_str;
for (size_t j = 0; j < cmds.size(); j++)
{
parse_string_to_value(cmds[j], ' ', true, cmd_str);
if (input_cmd == cmd_str)
{
replace_all(tmp_l, cmds[j], "\\", "");
std::cout << GCTL_BOLDGREEN << tmp_l << GCTL_RESET << "\n";
std::cout << helps[j] << "\n";
break;
}
}
return;
}
void exec_cmd(std::string cmd)
{
std::string cmd_name;
parse_string_to_value(cmd, ' ', true, cmd_name);
// show instruction if there is a question mark at end of the command
if (cmd_name.back() == '?')
{
cmd_name = cmd_name.substr(0, cmd_name.length() - 1);
display_help(cmd_name);
return;
}
// set default command to null
curr_cmd = commands[CMD_NUM - 1];
for (size_t i = 0; i < CMD_NUM - 1; i++)
{
if (cmd_name == commands[i].name)
{
curr_cmd = commands[i]; break;
}
}
if (curr_cmd.func_p == nullptr) throw gctl::runtime_error("Invalid command: " + cmd_name);
std::vector<std::string> cmd_units;
parse_string_with_quotes(cmd, cmd_units);
return curr_cmd.func_p(cmd_units);
}
// This function is defined to avoid potential breakdown while running in script mode.
void quit(const std::vector<std::string> &cmd_units)
{
return;
}
void info(const std::vector<std::string> &cmd_units)
{
std::smatch ret;
std::regex pata("att"), patt("tag"), patc("col"), patr("row"), path("hdr");
// info [att|tag|hdr|col|row]
int info_code = 0;
if (cmd_units.size() > 1)
{
if (regex_search(cmd_units[1], ret, pata)) info_code = AttInfo;
if (regex_search(cmd_units[1], ret, patt)) info_code = info_code|TagInfo;
if (regex_search(cmd_units[1], ret, patc)) info_code = info_code|ColInfo;
if (regex_search(cmd_units[1], ret, patr)) info_code = info_code|RowInfo;
if (regex_search(cmd_units[1], ret, path)) info_code = info_code|HeadInfo;
tc.info(info_code);
}
else tc.info(ColInfo);
return;
}
void head(const std::vector<std::string> &cmd_units)
{
// head [number]
int h = 10;
if (cmd_units.size() > 1) h = atoi(cmd_units[1].c_str());
if (h <= 0) throw std::runtime_error("head: invalid number.");
_1s_vector cnames = tc.column_names();
display_vector(cnames, std::cout, tc.delimeter());
_1s_array line;
for (size_t i = 1; i <= h; i++)
{
tc.get_row(line, i);
line.show(std::cout, tc.delimeter());
}
return;
}
void tail(const std::vector<std::string> &cmd_units)
{
// tail [number]
int h = 10;
if (cmd_units.size() > 1) h = atoi(cmd_units[1].c_str());
if (h <= 0) throw std::runtime_error("tail: invalid number.");
_1s_vector cnames = tc.column_names();
display_vector(cnames, std::cout, tc.delimeter());
_1s_array line;
for (size_t i = tc.row_number() - h + 1; i <= tc.row_number(); i++)
{
tc.get_row(line, i);
line.show(std::cout, tc.delimeter());
}
return;
}
void set_enable(const std::vector<std::string> &cmd_units)
{
// enable table|column|row [<name1>,<name2>...]
if (cmd_units.size() < 2) throw std::runtime_error("enable: insufficient parameters.");
if (cmd_units[1] == "table") tc.table_output(Enable);
else if (cmd_units[1] == "column")
{
for (size_t i = 2; i < cmd_units.size(); i++)
{
tc.column_output(cmd_units[i], Enable);
}
}
else if (cmd_units[1] == "row")
{
for (size_t i = 2; i < cmd_units.size(); i++)
{
tc.row_output(cmd_units[i], Enable);
}
}
else throw std::runtime_error("enable: invalid parameters.");
return;
}
void set_disable(const std::vector<std::string> &cmd_units)
{
// disable table|column|row [<name1>,<name2>...]
if (cmd_units.size() < 2) throw std::runtime_error("disable: insufficient parameters.");
if (cmd_units[1] == "table") tc.table_output(Disable);
else if (cmd_units[1] == "column")
{
for (size_t i = 2; i < cmd_units.size(); i++)
{
tc.column_output(cmd_units[i], Disable);
}
}
else if (cmd_units[1] == "row")
{
for (size_t i = 2; i < cmd_units.size(); i++)
{
tc.row_output(cmd_units[i], Disable);
}
}
else throw std::runtime_error("disable: invalid parameters.");
return;
}
void load_file(const std::vector<std::string> &cmd_units)
{
// load <file> [nohead|column|row|both] [head_num] [<delimeter>] [att_sym] [tag_sym]
if (cmd_units.size() < 2) throw std::runtime_error("open: insufficient parameters.");
gctl::array<std::string> copy_str(5, "null");
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 5); i++)
{
copy_str[i] = cmd_units[i + 2];
}
int ht = NoHead;
if (copy_str[0] == "nohead") ht = NoHead;
else if (copy_str[0] == "column") ht = ColHead;
else if (copy_str[0] == "row") ht = RowHead;
else if (copy_str[0] == "both") ht = RowHead|ColHead;
int hnum = 0;
if (copy_str[1] != "null") hnum = atoi(copy_str[1].c_str());
if (hnum != 0) tc.head_number(hnum);
if (copy_str[2] != "null") tc.delimeter(copy_str[2][0]);
if (copy_str[3] != "null") tc.annotation_symbol(copy_str[3][0]);
if (copy_str[4] != "null") tc.tag_symbol(copy_str[4][0]);
std::string naked_name, exten_name;
parse_filename(cmd_units[1], naked_name, exten_name);
if (exten_name == ".csv") tc.load_csv(naked_name);
else tc.load_text(naked_name, exten_name, ht);
return;
}
void save_file(const std::vector<std::string> &cmd_units)
{
// save <file> [<delimeter>] [att_sym] [tag_sym]
if (cmd_units.size() < 2) throw std::runtime_error("save: insufficient parameters.");
gctl::array<std::string> copy_str(3, "null");
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 3); i++)
{
copy_str[i] = cmd_units[i + 2];
}
if (copy_str[0] != "null") tc.delimeter(copy_str[0][0]);
if (copy_str[1] != "null") tc.annotation_symbol(copy_str[1][0]);
if (copy_str[2] != "null") tc.tag_symbol(copy_str[2][0]);
std::string naked_name, exten_name;
parse_filename(cmd_units[1], naked_name, exten_name);
if (exten_name == ".csv") tc.save_csv(naked_name);
else tc.save_text(naked_name, exten_name);
return;
}
void statistic(const std::vector<std::string> &cmd_units)
{
// stats <column> <column>...
if (cmd_units.size() < 2) throw std::runtime_error("stats: insufficient parameters.");
_1d_array data;
for (size_t i = 1; i < cmd_units.size(); i++)
{
tc.get_column(data, cmd_units[i]);
std::clog << "column: " << cmd_units[i]
<< " | " << data.min() << "/" << data.mean() << "/" << data.max()
<< " | STD: " << data.std() << "\n";
}
return;
}
void set_type(const std::vector<std::string> &cmd_units)
{
// type row|col int|float|string <name>
if (cmd_units.size() < 4) throw std::runtime_error("type: insufficient parameters.");
if (cmd_units[1] == "row")
{
if (cmd_units[2] == "int") tc.row_type(Int, cmd_units[3]);
else if (cmd_units[2] == "float") tc.row_type(Float, cmd_units[3]);
else if (cmd_units[2] == "string") tc.row_type(String, cmd_units[3]);
else throw std::runtime_error("type: invalid parameters.");
}
else if (cmd_units[1] == "col")
{
if (cmd_units[2] == "int") tc.column_type(Int, cmd_units[3]);
else if (cmd_units[2] == "float") tc.column_type(Float, cmd_units[3]);
else if (cmd_units[2] == "string") tc.column_type(String, cmd_units[3]);
else throw std::runtime_error("type: invalid parameters.");
}
else throw std::runtime_error("type: invalid parameters.");
return;
}
void set_titles(const std::vector<std::string> &cmd_units)
{
// title <row|col> <t1>,<t2>,<t3>,... [<id1>,<id2>,<id3>,...]
if (cmd_units.size() < 3) throw std::runtime_error("title: insufficient parameters.");
if (cmd_units[1] == "row")
{
std::vector<std::string> row_titles;
std::vector<int> row_ids;
parse_string_to_vector(cmd_units[2], ',', row_titles);
if (cmd_units.size() >= 4)
{
parse_string_to_vector(cmd_units[3], ',', row_ids);
if (row_titles.size() != row_ids.size()) throw std::runtime_error("title: invalid parameters.");
tc.row_names(row_titles, row_ids);
}
else tc.row_names(row_titles);
}
else if (cmd_units[1] == "col")
{
std::vector<std::string> col_titles;
std::vector<int> col_ids;
parse_string_to_vector(cmd_units[2], ',', col_titles);
if (cmd_units.size() >= 4)
{
parse_string_to_vector(cmd_units[3], ',', col_ids);
if (col_titles.size()!= col_ids.size()) throw std::runtime_error("title: invalid parameters.");
tc.column_names(col_titles, col_ids);
}
else tc.column_names(col_titles);
}
else throw std::runtime_error("title: invalid parameters.");
return;
}
void math_func(const std::vector<std::string> &cmd_units)
{
// math <func> <col1>,<col2>,<col3>...
if (cmd_units.size() < 3) throw std::runtime_error("math: insufficient parameters.");
std::vector<std::string> col_names;
parse_string_to_vector(cmd_units[2], ',', col_names);
tc.cal_column(cmd_units[1], col_names, 12);
return;
}
void rand_data(const std::vector<std::string> &cmd_units)
{
// random normal|uniform <p1> <p2> [<colname>]
if (cmd_units.size() < 4) throw std::runtime_error("random: insufficient parameters.");
random_type_e rd_type = RdNormal;
if (cmd_units[1] == "normal") rd_type = RdNormal;
else if (cmd_units[1] == "uniform") rd_type = RdUniform;
else throw std::runtime_error("random: invalid parameters.");
double p1 = atof(cmd_units[2].c_str());
double p2 = atof(cmd_units[3].c_str());
array<double> rd_data(tc.row_number());
rd_data.random_float(p1, p2, rd_type);
if (cmd_units.size() >= 5) tc.fill_column(rd_data, cmd_units[4], 12);
else
{
std::string col_name = "RdData";
tc.add_column(col_name);
tc.fill_column(rd_data, col_name, 12);
}
return;
}
void filt_data(const std::vector<std::string> &cmd_units)
{
// filter row|col regex|math <expression> <name1>,<name2>,<name3>...
if (cmd_units.size() < 5) throw std::runtime_error("filter: insufficient parameters.");
std::vector<std::string> tar_names;
parse_string_to_vector(cmd_units[4], ',', tar_names);
table_headtype_e thead;
if (cmd_units[1] == "row") thead = RowHead;
else if (cmd_units[1] == "col") thead = ColHead;
else throw std::runtime_error("filter: invalid parameters.");
if (cmd_units[2] == "regex") tc.filter(cmd_units[3], tar_names[0], thead);
else if (cmd_units[2] == "math") tc.filter(cmd_units[3], tar_names, thead);
else throw std::runtime_error("filter: invalid parameters.");
return;
}
void insert_data(const std::vector<std::string> &cmd_units)
{
// insert row|col [<new-name>] [<insert-name>]
if (cmd_units.size() < 2) throw std::runtime_error("insert: insufficient parameters.");
if (cmd_units[1] == "row")
{
if (cmd_units.size() == 2) tc.add_row();
else if (cmd_units.size() == 3) tc.add_row(cmd_units[2]);
else if (cmd_units.size() == 4) tc.add_row(cmd_units[2], cmd_units[3]);
}
else if (cmd_units[1] == "col")
{
if (cmd_units.size() == 2) tc.add_column();
else if (cmd_units.size() == 3) tc.add_column(cmd_units[2]);
else if (cmd_units.size() == 4) tc.add_column(cmd_units[2], cmd_units[3]);
}
else throw std::runtime_error("insert: invalid parameters.");
return;
}
void set_data(const std::vector<std::string> &cmd_units)
{
// set row|col \<name\> \<value\>
if (cmd_units.size() < 4) throw std::runtime_error("set: insufficient parameters.");
if (cmd_units[1] == "row")
{
_1s_array row_data(tc.row_number(), cmd_units[3]);
tc.fill_row(row_data, cmd_units[2]);
}
else if (cmd_units[1] == "col")
{
_1s_array col_data(tc.col_number(), cmd_units[3]);
tc.fill_column(col_data, cmd_units[2]);
}
else throw std::runtime_error("set: invalid parameters.");
return;
}
void display_table(const std::vector<std::string> &cmd_units)
{
// view
tc.display();
return;
}
int main(int argc, char *argv[])
{
if (argc >= 2)
{
std::string tmp_l;
std::ifstream cmdin;
// Run commands from files. Each line is a command.
// You can give more than one file
for (size_t i = 1; i < argc; i++) try
{
open_infile(cmdin, argv[i]);
while (getline(cmdin, tmp_l) && tmp_l != "" && tmp_l[0] != '#')
{
exec_cmd(tmp_l);
}
cmdin.close();
}
catch(std::exception& e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, "run dsviewer in the interactive mode for instructions.", 0);
}
}
else
{
setlocale(LC_CTYPE, "");
initialize_readline(); /* Bind our completer. */
display_logo();
std::clog << "dsviewer - read, manipulate and write dsv/csv files.\n";
std::clog << "Usage: dsviewer [<cmdfile1> <cmdfile2>...]\n";
std::clog << "Enter '?' to see all available commands.\n";
std::string cmd_str;
char *c_line = (char *)NULL;
char *c_line_s = (char *)NULL;
bool quit = false;
while (!quit) try
{
c_line = readline(">> ");
if (!c_line) break;
c_line_s = stripwhite(c_line);
cmd_str = c_line_s;
if (cmd_str == "quit") quit = true;
else if (cmd_str == "?") display_cmds();
else exec_cmd(cmd_str);
free(c_line);
}
catch(std::exception& e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, "Enter 'help' for instructions.", 0);
}
}
return 0;
}

86
dsviewer/dsviewer.h Normal file
View File

@ -0,0 +1,86 @@
/********************************************************
*
*
*
*
*
*
* Geophysical Computational Tools & Library (GCTL)
*
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
*
* GCTL is distributed under a dual licensing scheme. You can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 2
* of the License, or (at your option) any later version. You should have
* received a copy of the GNU Lesser General Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>.
*
* If the terms and conditions of the LGPL v.2. would prevent you from using
* the GCTL, please consider the option to obtain a commercial license for a
* fee. These licenses are offered by the GCTL's original author. As a rule,
* licenses are provided "as-is", unlimited in time for a one time fee. Please
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
* to include some description of your company and the realm of its activities.
* Also add information on how to contact you by electronic and paper mail.
******************************************************/
#ifndef GCTL_DSVIEWER_H
#define GCTL_DSVIEWER_H
#include <regex>
#include "gctl/io.h"
using namespace gctl;
// Function pointer for commands
typedef void (*cmd_func_ptr)(const std::vector<std::string> &cmd_units);
struct cmd_pair
{
std::string name;
cmd_func_ptr func_p;
std::string brief;
};
void quit(const std::vector<std::string> &cmd_units);
void info(const std::vector<std::string> &cmd_units);
void head(const std::vector<std::string> &cmd_units);
void tail(const std::vector<std::string> &cmd_units);
void load_file(const std::vector<std::string> &cmd_units);
void save_file(const std::vector<std::string> &cmd_units);
void statistic(const std::vector<std::string> &cmd_units);
void set_enable(const std::vector<std::string> &cmd_units);
void set_disable(const std::vector<std::string> &cmd_units);
void set_type(const std::vector<std::string> &cmd_units);
void set_titles(const std::vector<std::string> &cmd_units);
void math_func(const std::vector<std::string> &cmd_units);
void rand_data(const std::vector<std::string> &cmd_units);
void filt_data(const std::vector<std::string> &cmd_units);
void insert_data(const std::vector<std::string> &cmd_units);
void set_data(const std::vector<std::string> &cmd_units);
void display_table(const std::vector<std::string> &cmd_units);
#define CMD_NUM 18
const cmd_pair commands[CMD_NUM] = {
{"quit", quit, "Quit the program."},
{"view", display_table, "Display valid cells."},
{"info", info, "Show the table information."},
{"head", head, "Show head line(s) of the table."},
{"tail", tail, "Show tail line(s) of the table."},
{"open", load_file, "Open a dsv/csv file."},
{"save", save_file, "Save the table to a file."},
{"stats", statistic, "Calculate statistics of the selected columns."},
{"enable", set_enable, "Enable column/row outputs by name or index."},
{"disable", set_disable, "Disable column/row outputs by name or index."},
{"insert", insert_data, "Insert a new column/row data."},
{"set", set_data, "Set a column/row data."},
{"type", set_type, "Set column/row data types."},
{"title", set_titles, "Set row and column titles."},
{"math", math_func, "Preform mathematic operations of column data."},
{"random", rand_data, "Generate random column data."},
{"filter", filt_data, "Filter row and column data using regex and mathematic expressions."},
{"null", nullptr, "null"}
};
#endif // GCTL_DSVIEWER_H

47
dsviewer/dsviewer.md Normal file
View File

@ -0,0 +1,47 @@
#### quit
Does what it says.
#### info [att|tag|hdr|col|row]
Show the table information. 'att' shows the annotations, 'tag' shows the tag lines, 'hdr' shows the head lines, 'col' shows the columns' summary, and 'row' shows the rows' summary. Use '|' to separate multiple options.
#### head
Show the first `n` (the default is 10) rows of the table.
#### tail
Show the last `n` (the default is 10) rows of the table.
#### open \<file\> [nohead|column|row|both] [\<head_num\>] [\<deli-sym\>] [\<att-sym\>] [\<tag-sym\>]
Open a dsv/csv file. The default setups are 'nohead', space for delimeter, '#' for annotations, and '!' for tags. If the file name ends with '.csv', the default delimeter is ','.
#### save \<file\> [\<delimeter\>] [\<att-sym\>] [\<tag-sym\>]
Save table to a dsv/csv file. The default setups are space for delimeter, '#' for annotations, and '!' for tags. If the file name ends with '.csv', the default delimeter is ','.
#### stats \<colname1\> \<colname2\> ...
Show statistics of a data column or columns. If the input file has no column names, use inbuilt names `C<id>` to select the columns.
#### enable table|column|row [\<name1\> \<name2\> ...]
Enable table outputs. If the input file has no row or column names, use inbuilt names `R<id>` and `C<id>` to select the rows and columns.
#### disable table|column|row [\<name1\> \<name2\> ...]
Disable table outputs. If the input file has no row or column names, use inbuilt names `R<id>` and `C<id>` to select the rows and columns.
#### insert row|col [\<new-name\>] [\<insert-name\>]
Insert a new row or column. The new row or column will be attached to the end of the table by default. A `new-name` can be provided if the user wants to rename the new row or column. Provide the `insert-name` to insert the new row or column at the specified row or column. The remaining columns or rows will be moved one step right or down accordingly. If the input file has no row or column names, use inbuilt names `R<id>` and `C<id>` to select the rows and columns.
#### set row|col \<name\> \<value\>
Set a row or column's value to the given one. If the input file has no row or column names, use inbuilt names `R<id>` and `C<id>` to select the rows and columns.
#### type row|col int|float|string \<name\>
Set the data type of a row or column. If the input file has no row or column names, use inbuilt names `R<id>` and `C<id>` to select the rows and columns.
#### title row|col \<t1\>,\<t2\>,\<t3\>,... [\<id1\>,\<id2\>,\<id3\>,...]
Set row and column titles. The titles will be assigned sequentially if no index is specified.
#### math \<func\> \<col1\>,\<col2\>,\<col3\>...
Preform mathematic operations of column data. The user needs to write a mathematical expression using the column names as variables. Then provide the column names as the arguments, in which the resultant column's name must be placed at the beginning. For example, to calculate the sum of column `C1` and `C2`, and store the result in column `C3`, the command is: `math C3=C1+C2 C3,C1,C2`.
#### random normal|uniform \<p1\> \<p2\> [\<colname\>]
Generate random data using normal or uniform distribution. The first parameter is the mean or the lower bound, and the second parameter is the standard deviation or the upper bound. If no column name is provided, a new column will be created (titled "RdData").
#### filter row|col regex|math \<expression\> \<name1\>,\<name2\>,\<name3\>...
Filter row and column data using regex and mathematic expressions. The first parameter is the expression, and the following parameters are the column names. For example, to filter rows whose column `C1` is greater than 0, the command is: `filter col math C1>0 C1`. Regex expression can be used to filter rows whose column `C1` contains the string "abc", the command is: `filter col regex abc C1`.

11
dsviewer/example.csv Normal file
View File

@ -0,0 +1,11 @@
Name,Age,Gender,Occupation,City,Phone Number,Email,Annual Income,Company,Position
John Doe,28,Male,Engineer,New York,123-456-7890,john.doe@example.com,$75000,ABC Tech,Senior Software Engineer
Jane Smith,34,Female,Teacher,Los Angeles,234-567-8901,jane.smith@example.com,$55000,XYZ School,Math Teacher
Michael Brown,22,Male,Student,Toronto,345-678-9012,michael.brown@example.com,$18000,University of Toronto,Undergraduate Student
Emily Davis,45,Female,Doctor,Chicago,456-789-0123,emily.davis@example.com,$180000,Chicago Medical Center,Cardiologist
David Wilson,30,Male,Designer,San Francisco,567-890-1234,david.wilson@example.com,$90000,DesignWorks,Senior Graphic Designer
Sarah Johnson,29,Female,Marketing Specialist,Seattle,678-901-2345,sarah.johnson@example.com,$85000,MarketingPro,Marketing Manager
Robert Lee,36,Male,Software Developer,Boston,789-012-3456,robert.lee@example.com,$120000,SoftDev Solutions,Lead Developer
Laura Miller,25,Female,Graphic Designer,Denver,890-123-4567,laura.miller@example.com,$60000,Creative Arts,Junior Designer
William Clark,40,Male,Consultant,Atlanta,901-234-5678,william.clark@example.com,$110000,ConsultPro,Business Consultant
Olivia Turner,33,Female,Researcher,Phoenix,012-345-6789,olivia.turner@example.com,$70000,ResearchInnovate,Research Scientist
1 Name Age Gender Occupation City Phone Number Email Annual Income Company Position
2 John Doe 28 Male Engineer New York 123-456-7890 john.doe@example.com $75000 ABC Tech Senior Software Engineer
3 Jane Smith 34 Female Teacher Los Angeles 234-567-8901 jane.smith@example.com $55000 XYZ School Math Teacher
4 Michael Brown 22 Male Student Toronto 345-678-9012 michael.brown@example.com $18000 University of Toronto Undergraduate Student
5 Emily Davis 45 Female Doctor Chicago 456-789-0123 emily.davis@example.com $180000 Chicago Medical Center Cardiologist
6 David Wilson 30 Male Designer San Francisco 567-890-1234 david.wilson@example.com $90000 DesignWorks Senior Graphic Designer
7 Sarah Johnson 29 Female Marketing Specialist Seattle 678-901-2345 sarah.johnson@example.com $85000 MarketingPro Marketing Manager
8 Robert Lee 36 Male Software Developer Boston 789-012-3456 robert.lee@example.com $120000 SoftDev Solutions Lead Developer
9 Laura Miller 25 Female Graphic Designer Denver 890-123-4567 laura.miller@example.com $60000 Creative Arts Junior Designer
10 William Clark 40 Male Consultant Atlanta 901-234-5678 william.clark@example.com $110000 ConsultPro Business Consultant
11 Olivia Turner 33 Female Researcher Phoenix 012-345-6789 olivia.turner@example.com $70000 ResearchInnovate Research Scientist

View File

@ -45,8 +45,8 @@
#include "gctl/core.h"
#include "gctl/utility.h"
#include "gctl/geometry.h"
#include "gctl/algorithms.h"
#include "gctl/poly.h"
#include "gctl/math.h"
using namespace std;

1
gctl_toolkits_config.h Normal file
View File

@ -0,0 +1 @@
#define GCTL_TOOLKITS_INSTALL_PREFIX "/opt/stow/gctl_toolkits"

View File

@ -0,0 +1,25 @@
set(TOOL_NAME gridmanager-potential)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
find_package(PkgConfig)
pkg_search_module(EDITLINE REQUIRED libeditline)
include_directories(${EDITLINE_INCLUDE_DIRS})
link_directories(${EDITLINE_LIBRARY_DIRS})
aux_source_directory(. TOOL_SRC)
add_executable(${TOOL_NAME} ${TOOL_SRC})
set_target_properties(${TOOL_NAME} PROPERTIES INSTALL_RPATH /usr/local/lib)
set_target_properties(${TOOL_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
target_link_libraries(${TOOL_NAME} PUBLIC ${GCTL_LIB})
target_link_libraries(${TOOL_NAME} PUBLIC gctl_potential)
target_link_libraries(${TOOL_NAME} PUBLIC ${EDITLINE_LIBRARIES})
install(TARGETS ${TOOL_NAME} RUNTIME DESTINATION sbin)
file(GLOB HELP_DOC *.md)
install(FILES ${HELP_DOC} DESTINATION sbin/share)

View File

@ -0,0 +1,881 @@
/********************************************************
*
*
*
*
*
*
* Geophysical Computational Tools & Library (GCTL)
*
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
*
* GCTL is distributed under a dual licensing scheme. You can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 2
* of the License, or (at your option) any later version. You should have
* received a copy of the GNU Lesser General Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>.
*
* If the terms and conditions of the LGPL v.2. would prevent you from using
* the GCTL, please consider the option to obtain a commercial license for a
* fee. These licenses are offered by the GCTL's original author. As a rule,
* licenses are provided "as-is", unlimited in time for a one time fee. Please
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
* to include some description of your company and the realm of its activities.
* Also add information on how to contact you by electronic and paper mail.
******************************************************/
#include "gridmanager-potential.h"
// We use the editline library to handle all inputs
#include "editline.h"
// install configuration
#include "../gctl_toolkits_config.h"
cmd_pair curr_cmd; // Executing command
gctl::gm_regular_grid rg; // Grid object
extern "C" {
/*
* Strip whitespace from the start and end of STRING. Return a pointer
* into STRING.
*/
char *stripwhite(char *string)
{
char *s, *t;
for (s = string; isspace(*s); s++) ;
if (*s == 0)
return s;
t = s + strlen(s) - 1;
while (t > s && isspace(*t))
t--;
*++t = '\0';
return s;
}
/* Generator function for command completion. STATE lets us
know whether to start from scratch; without any state
(i.e. STATE == 0), then we start at the top of the list. */
char *command_generator(const char *text, int state)
{
static int list_index, len;
/* If this is a new word to complete, initialize now. This
includes saving the length of TEXT for efficiency, and
initializing the index variable to 0. */
if (!state)
{
list_index = 0;
len = strlen(text);
}
/* Return the next name which partially matches from the command list. */
while (list_index < CMD_NUM)
{
if (std::string(text) == commands[list_index].name.substr(0, len))
{
//const char* name = commands[list_index].name.data();
return strdup(commands[list_index].name.data());
}
else list_index++;
}
/* If no names matched, then return NULL. */
return nullptr;
}
/*
* Attempt to complete on the contents of TEXT. START and END
* bound the region of rl_line_buffer that contains the word to
* complete. TEXT is the word to complete. We can use the entire
* contents of rl_line_buffer in case we want to do some simple
* parsing. Return the array of matches, or NULL if there aren't any.
*/
char **gridmanager_completion(const char *text, int start, int end)
{
char **matches = nullptr;
/* If this word is at the start of the line, then it is a command
to complete. Otherwise it is the name of a file in the current
directory. */
if (start == 0) matches = rl_completion_matches(text, command_generator);
return matches;
}
void initialize_readline(void)
{
/* Allow conditional parsing of the ~/.inputrc file. */
rl_readline_name = "gridmanager";
/* Tell the completer that we want a crack first. */
rl_attempted_completion_function = gridmanager_completion;
}
} // End C section
void display_cmds()
{
std::clog << "Command:\n";
for (size_t i = 0; i < CMD_NUM - 1; i++)
{
std::clog << std::setw(12) << commands[i].name << ":\t" << commands[i].brief << "\n";
}
std::clog << "\nEnter \"<command>?\" to see detailed instructions.\n\n";
std::clog << "Keywords:\n";
for (size_t i = 0; i < KEY_NUM; i++)
{
std::clog << std::setw(12) << keywords[i].name << ":\t" << keywords[i].brief << "\n";
}
return;
}
void display_help(std::string input_cmd)
{
std::string install_dir = GCTL_TOOLKITS_INSTALL_PREFIX;
std::ifstream helpin;
open_infile(helpin, install_dir + "/sbin/share/readme_gridmanager_potential", ".md");
std::string tmp_l, tmp_help;
std::vector<std::string> cmds;
std::vector<std::string> helps;
while (getline(helpin, tmp_l))
{
if (tmp_l.substr(0, 4) == "####")
{
cmds.push_back(tmp_l.substr(5));
tmp_help = "";
while (getline(helpin, tmp_l))
{
if (tmp_l == "") break;
else tmp_help += tmp_l + "\n";
}
helps.push_back(tmp_help);
}
}
helpin.close();
std::string cmd_str;
for (size_t j = 0; j < cmds.size(); j++)
{
parse_string_to_value(cmds[j], ' ', true, cmd_str);
if (input_cmd == cmd_str)
{
replace_all(tmp_l, cmds[j], "\\", "");
std::cout << tmp_l << "\n";
std::cout << helps[j] << "\n";
break;
}
}
return;
}
void exec_cmd(std::string cmd)
{
std::string cmd_name;
parse_string_to_value(cmd, ' ', true, cmd_name);
// show instruction if there is a question mark at end of the command
if (cmd_name.back() == '?')
{
cmd_name = cmd_name.substr(0, cmd_name.length() - 1);
display_help(cmd_name);
return;
}
// set default command to null
curr_cmd = commands[CMD_NUM - 1];
for (size_t i = 0; i < CMD_NUM - 1; i++)
{
if (cmd_name == commands[i].name)
{
curr_cmd = commands[i]; break;
}
}
if (curr_cmd.func_p == nullptr) throw gctl::runtime_error("Invalid command: " + cmd_name);
std::vector<std::string> cmd_units;
parse_string_with_quotes(cmd, cmd_units);
return curr_cmd.func_p(cmd_units);
}
// This function is defined to avoid potential breakdown while running in script mode.
void quit(const std::vector<std::string> &cmd_units)
{
return;
}
void mesh_info(const std::vector<std::string> &cmd_units)
{
// info [\<new-grid-name\>] [\<new-info\>]
if (cmd_units.size() == 1)
{
rg.show_info();
return;
}
gctl::array<std::string> copy_str(2, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 2); i++)
{
copy_str[i - 1] = cmd_units[i];
}
if (copy_str[0] != "null") rg.set_meshname(copy_str[0]);
if (copy_str[1] != "null") rg.set_meshinfo(copy_str[1]);
return;
}
#ifdef GCTL_MESH_EXPRTK
inline double expr2double(std::string s)
{
exprtk::symbol_table<double> sym_tab;
exprtk::expression<double> expr;
exprtk::parser<double> p;
sym_tab.add_constants();
expr.register_symbol_table(sym_tab);
p.compile(s, expr);
return expr.value();
}
#endif // GCTL_MESH_EXPRTK
void new_grid(const std::vector<std::string> &cmd_units)
{
// new \<new-file\> \<xnum\> \<ynum\> \<xmin\> \<ymin\> \<dx\> \<dy\> [\<info\>]
if (cmd_units.size() < 8) throw std::runtime_error("new-grid: insufficient parameters.");
gctl::array<std::string> copy_str(8, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 8); i++)
{
copy_str[i - 1] = cmd_units[i];
}
if (rg.initiated()) rg.clear_regular_grid();
double xmin, ymin, dx, dy;
#ifdef GCTL_MESH_EXPRTK
xmin = expr2double(copy_str[3]);
ymin = expr2double(copy_str[4]);
dx = expr2double(copy_str[5]);
dy = expr2double(copy_str[6]);
#else
xmin = atof(copy_str[3].c_str());
ymin = atof(copy_str[4].c_str());
dx = atof(copy_str[5].c_str());
dy = atof(copy_str[6].c_str());
#endif // GCTL_MESH_EXPRTK
rg.init(copy_str[0], copy_str[7], atoi(copy_str[1].c_str()),
atoi(copy_str[2].c_str()), xmin, ymin, dx, dy);
return;
}
void open_grid(const std::vector<std::string> &cmd_units)
{
// open binary <file>
// open netcdf <file> [<x-name> <y-name>] [<data-name>] [node|cell]
// open surfer <file> <new-data-name> [surfer6-text|surfer6-binary|surfer7] [node|cell]
if (cmd_units.size() < 3) throw std::runtime_error("open: insufficient parameters.");
if (cmd_units[1] == "binary") open_binary(cmd_units);
else if (cmd_units[1] == "netcdf") open_netcdf(cmd_units);
else if (cmd_units[1] == "surfer") open_surfer(cmd_units);
else throw std::runtime_error("open: unknown file format.");
return;
}
void save_grid(const std::vector<std::string> &cmd_units)
{
// save binary <file>
// save netcdf <file> [<data-name>|node|cell]
// save surfer <file> <data-name> [surfer6-text|surfer6-binary|surfer7]
// save gmsh <file>
// save text <file> <data-name> [<data-name>]...
if (cmd_units.size() < 3) throw std::runtime_error("save: insufficient parameters.");
if (cmd_units[1] == "binary") save_binary(cmd_units);
else if (cmd_units[1] == "netcdf") save_netcdf(cmd_units);
else if (cmd_units[1] == "surfer") save_surfer(cmd_units);
else if (cmd_units[1] == "gmsh") save_gmsh(cmd_units);
else if (cmd_units[1] == "text") save_text(cmd_units);
else throw std::runtime_error("save: unknown file format.");
return;
}
void open_binary(const std::vector<std::string> &cmd_units)
{
// open binary <file>
rg.load_binary(cmd_units[2]);
return;
}
void save_binary(const std::vector<std::string> &cmd_units)
{
// save binary <file>
rg.save_binary(cmd_units[2]);
return;
}
void open_netcdf(const std::vector<std::string> &cmd_units)
{
// open netcdf <file> [<x-name> <y-name>] [<data-name>] [node|cell]
if (cmd_units.size() < 3) throw std::runtime_error("open: insufficient parameters.");
gctl::array<std::string> copy_str(5, "null");
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 5); i++)
{
copy_str[i] = cmd_units[i + 2];
}
mesh_data_type_e d_type = NodeData;
if (copy_str[4] == "cell") d_type = ElemData;
else if (copy_str[4] == "node") d_type = NodeData;
if (copy_str[1] == "null") copy_str[1] = "x";
if (copy_str[2] == "null") copy_str[2] = "y";
if (copy_str[3] == "null") rg.load_netcdf_grid(copy_str[0], d_type, copy_str[1], copy_str[2]);
else rg.load_netcdf_grid(copy_str[0], d_type, copy_str[1], copy_str[2], copy_str[3]);
return;
}
void save_netcdf(const std::vector<std::string> &cmd_units)
{
// save netcdf <file> [<data-name>|node|cell]
if (cmd_units.size() < 3) throw std::runtime_error("save: insufficient parameters.");
gctl::array<std::string> copy_str(2, "null");
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 2); i++)
{
copy_str[i] = cmd_units[i + 2];
}
if (copy_str[1] == "null") rg.save_netcdf_grid(copy_str[0], NodeData);
else if (copy_str[1] == "cell") rg.save_netcdf_grid(copy_str[0], ElemData);
else rg.save_netcdf_grid(copy_str[0], copy_str[1]);
return;
}
void save_gmsh(const std::vector<std::string> &cmd_units)
{
// save gmsh <file>
if (cmd_units.size() < 3) throw std::runtime_error("save: insufficient parameters.");
rg.save_gmsh(cmd_units[2], NotPacked);
return;
}
void open_surfer(const std::vector<std::string> &cmd_units)
{
// open surfer <file> [<new-data-name>] [surfer6-text|surfer6-binary|surfer7] [node|cell]
if (cmd_units.size() < 4) throw std::runtime_error("open: insufficient parameters.");
gctl::array<std::string> copy_str(4, "null");
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 4); i++)
{
copy_str[i] = cmd_units[i + 2];
}
surfer_file_type_e st = Surfer6Text;
if (copy_str[2] == "surfer6-text") st = Surfer6Text;
else if (copy_str[2] == "surfer6-binary") st = Surfer6Binary;
else if (copy_str[2] == "surfer7") st = Surfer7Grid;
mesh_data_type_e d_type = NodeData;
if (copy_str[3] == "node") d_type = NodeData;
else if (copy_str[3] == "cell") d_type = ElemData;
if (copy_str[1] == "null") rg.load_surfer_grid(copy_str[0], "Untitled", d_type, st);
else rg.load_surfer_grid(copy_str[0], copy_str[3], d_type, st);
return;
}
void save_surfer(const std::vector<std::string> &cmd_units)
{
// save surfer <file> <data-name> [surfer6-text|surfer6-binary|surfer7]
if (cmd_units.size() < 4) throw std::runtime_error("save: insufficient parameters.");
gctl::array<std::string> copy_str(3, "null");
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 3); i++)
{
copy_str[i] = cmd_units[i + 2];
}
surfer_file_type_e st = Surfer6Text;
if (copy_str[2] == "surfer6-text") st = Surfer6Text;
else if (copy_str[2] == "surfer6-binary") st = Surfer6Binary;
else if (copy_str[2] == "surfer7") st = Surfer7Grid;
rg.save_surfer_grid(copy_str[0], copy_str[1] ,st);
return;
}
void save_text(const std::vector<std::string> &cmd_units)
{
// save text <file> <data-name>
if (cmd_units.size() < 4) throw std::runtime_error("save: insufficient parameters.");
gctl::array<std::string> copy_str(cmd_units.size() - 3, "null");
for (size_t i = 0; i < cmd_units.size() - 3; i++)
{
copy_str[i] = cmd_units[i + 3];
}
rg.save_text(cmd_units[2], copy_str);
return;
}
void data_cloud(const std::vector<std::string> &cmd_units)
{
// data-cloud \<new-data-name\> node|cell \<data-could-file\> \<search-x\> \<search-y\> \<search-deg\>
if (cmd_units.size() < 7) throw std::runtime_error("data-cloud: insufficient parameters.");
gctl::array<std::string> copy_str(7, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 7); i++)
{
copy_str[i - 1] = cmd_units[i];
}
mesh_data_type_e d_type = NodeData;
if (copy_str[1] == "node") d_type = NodeData;
else if (copy_str[1] == "cell") d_type = ElemData;
else throw std::runtime_error("open-surfer: invalid grid data type.");
geodsv_io text_in;
text_in.load_text(copy_str[2]);
array<point2dc> posi_arr;
_1d_array data_vec;
text_in.get_column_point2dc(posi_arr, 0, 1);
text_in.get_column(data_vec, 2);
rg.load_data_cloud(posi_arr, data_vec, atof(copy_str[3].c_str()), atof(copy_str[4].c_str()), atof(copy_str[5].c_str()), copy_str[0], d_type);
return;
}
void gradient(const std::vector<std::string> &cmd_units)
{
// gradient <data-name> <new-data-name> dx|dy <order>
if (cmd_units.size() < 4) throw std::runtime_error("gradient: insufficient parameters.");
gctl::array<std::string> copy_str(4, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 4); i++)
{
copy_str[i - 1] = cmd_units[i];
}
gradient_type_e g_type;
if (copy_str[2] == "dx") g_type = Dx;
else if (copy_str[2] == "dy") g_type = Dy;
else throw std::runtime_error("gradient: invalid gradient type.");
int order = 1;
if (copy_str[3] != "null") order = atoi(copy_str[3].c_str());
rg.regular_grid::gradient(copy_str[0], copy_str[1], g_type, order);
return;
}
void wavelet(const std::vector<std::string> &cmd_units)
{
// wavelet \<data-name\> \<wavelet-name\> \<order\> [\<show-summary\>]
if (cmd_units.size() < 4) throw std::runtime_error("wavelet: insufficient parameters.");
gctl::array<std::string> copy_str(4, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 4); i++)
{
copy_str[i - 1] = cmd_units[i];
}
int order = order = atoi(copy_str[2].c_str());
if (copy_str[3] == "yes") rg.wavelet(copy_str[0], copy_str[1], order, true);
else rg.wavelet(copy_str[0], copy_str[1], order, false);
return;
}
void sum_data(const std::vector<std::string> &cmd_units)
{
// sum-data \<new-data-name\> \<data-name1\> \<data-name2\>
if (cmd_units.size() < 4) throw std::runtime_error("sum: insufficient parameters.");
gctl::array<std::string> copy_str(3, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 3); i++)
{
copy_str[i - 1] = cmd_units[i];
}
rg.sum(copy_str[0], copy_str[1], copy_str[2]);
return;
}
void diff_data(const std::vector<std::string> &cmd_units)
{
// sum-data \<new-data-name\> \<data-name1\> \<data-name2\>
if (cmd_units.size() < 4) throw std::runtime_error("diff: insufficient parameters.");
gctl::array<std::string> copy_str(3, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 3); i++)
{
copy_str[i - 1] = cmd_units[i];
}
rg.diff(copy_str[0], copy_str[1], copy_str[2]);
return;
}
void bool_data(const std::vector<std::string> &cmd_units)
{
// bool \<new-data-name\> \<data-name1> \<bool-data\> [reverse]
if (cmd_units.size() < 4) throw std::runtime_error("bool: insufficient parameters.");
gctl::array<std::string> copy_str(4, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 4); i++)
{
copy_str[i - 1] = cmd_units[i];
}
if (copy_str[3] == "reverse") rg.boolean(copy_str[0], copy_str[1], copy_str[2], true);
else rg.boolean(copy_str[0], copy_str[1], copy_str[2]);
return;
}
void func_data(const std::vector<std::string> &cmd_units)
{
// function \<expression\> \<new-data-name\>
if (cmd_units.size() < 3) throw std::runtime_error("function: insufficient parameters.");
gctl::array<std::string> copy_str(3, "null");
for (size_t i = 0; i <= GCTL_MIN(cmd_units.size() - 1, 3); i++)
{
copy_str[i] = cmd_units[i + 1];
}
rg.function(copy_str[0], copy_str[1]);
return;
}
void calculator(const std::vector<std::string> &cmd_units)
{
// calculator \<expression\> \<var1,data-name1\> \<var2,data-name2\>...
if (cmd_units.size() < 4) throw std::runtime_error("calculator: insufficient parameters.");
gctl::array<std::string> copy_str(cmd_units.size() - 1, "null");
for (size_t i = 1; i <= cmd_units.size() - 1; i++)
{
copy_str[i - 1] = cmd_units[i];
}
array<std::string> var_list(copy_str.size() - 1), data_list(copy_str.size() - 1);
for (size_t i = 0; i < var_list.size(); i++)
{
parse_string_to_value(copy_str[i + 1], ',', true, var_list[i], data_list[i]);
}
rg.calculator(copy_str[0], var_list, data_list);
return;
}
void data_output(const std::vector<std::string> &cmd_units)
{
// data-output enable|disable \<data-name1\> \<data-name2\>...
if (cmd_units.size() < 3) throw std::runtime_error("data-output: insufficient parameters.");
gctl::array<std::string> copy_str(cmd_units.size() - 1, "null");
for (size_t i = 1; i <= cmd_units.size() - 1; i++)
{
copy_str[i - 1] = cmd_units[i];
}
meshdata* data_ptr;
if (copy_str[0] == "enable")
{
for (size_t i = 1; i < copy_str.size(); i++)
{
data_ptr = rg.get_data_ptr(copy_str[i]);
data_ptr->output_ok_ = true;
}
}
else if (copy_str[0] == "disable")
{
for (size_t i = 1; i < copy_str.size(); i++)
{
data_ptr = rg.get_data_ptr(copy_str[i]);
data_ptr->output_ok_ = false;
}
}
else throw std::runtime_error("data-output: invalid operation type.");
return;
}
void data_rename(const std::vector<std::string> &cmd_units)
{
// data-rename [\<old-name\>] [\<new-name\>]
if (cmd_units.size() < 3) throw std::runtime_error("rename: insufficient parameters.");
gctl::array<std::string> copy_str(2, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 2); i++)
{
copy_str[i - 1] = cmd_units[i];
}
meshdata &data = rg.get_data(copy_str[0]);
data.name_ = copy_str[1];
return;
}
void data_view(const std::vector<std::string> &cmd_units)
{
// plot [\<data-name\>]...
if (cmd_units.size() < 2) throw std::runtime_error("view: insufficient parameters.");
for (size_t i = 1; i < cmd_units.size(); i++)
{
rg.view(cmd_units[i]);
}
return;
}
void data_plot(const std::vector<std::string> &cmd_units)
{
// plot [\<data-name\>]...
if (cmd_units.size() < 2) throw std::runtime_error("plot: insufficient parameters.");
for (size_t i = 1; i < cmd_units.size(); i++)
{
rg.plot(cmd_units[i]);
}
return;
}
void get_stats(const std::vector<std::string> &cmd_units)
{
// statistic \<data-name1\> \<data-name2\>...
if (cmd_units.size() < 2) throw std::runtime_error("statistic: insufficient parameters.");
gctl::array<std::string> copy_str(cmd_units.size() - 1, "null");
for (size_t i = 1; i <= cmd_units.size() - 1; i++)
{
copy_str[i - 1] = cmd_units[i];
}
meshdata *data_ptr;
std::vector<double> stats;
for (size_t i = 0; i < copy_str.size(); i++)
{
data_ptr = rg.get_data_ptr(copy_str[i]);
data_ptr->show_info();
data_ptr->show_stats();
}
return;
}
void get_profile(const std::vector<std::string> &cmd_units)
{
// profile \<data-name\> \<out-file\> {\<x\>,\<y\> \<x\>,\<y\> \<num\>}|{\<xy-file\> [\<file-format\>]}
if (cmd_units.size() < 4) throw std::runtime_error("profile: insufficient parameters.");
gctl::array<std::string> copy_str(5, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 5); i++)
{
copy_str[i - 1] = cmd_units[i];
}
array<point2dc> xys;
array<double> p_data;
if (access(copy_str[2].c_str(), R_OK))
{
point2dc st_p, ed_p;
gctl::parse_string_to_value(copy_str[2], ',', true, st_p.x, st_p.y);
gctl::parse_string_to_value(copy_str[3], ',', true, ed_p.x, ed_p.y);
rg.extract_profile(copy_str[0], st_p, ed_p, atoi(copy_str[4].c_str()), xys, p_data);
}
else // File exist
{
geodsv_io fio;
fio.load_text(copy_str[2]);
fio.get_column_point2dc(xys, 0, 1);
rg.extract_points(copy_str[0], xys, p_data);
}
std::ofstream ofile;
open_outfile(ofile, copy_str[1], ".txt");
ofile << "# x y d val\n";
for (size_t i = 0; i < xys.size(); i++)
{
ofile << xys[i].x << " " << xys[i].y << " " << distance(xys[0], xys[i]) << " " << p_data[i] << "\n";
}
ofile.close();
return;
}
void potential_gradient(const std::vector<std::string> &cmd_units)
{
// potential-gradient <data-name> <new-data-name> Tzx|Tzy|Tzz <order>
if (cmd_units.size() < 4) throw std::runtime_error("potential-gradient: insufficient parameters.");
gctl::array<std::string> copy_str(4, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 4); i++)
{
copy_str[i - 1] = cmd_units[i];
}
gravitational_field_type_e g_type;
if (copy_str[2] == "Tzx") g_type = Tzx;
else if (copy_str[2] == "Tzy") g_type = Tzy;
else if (copy_str[2] == "Tzz") g_type = Tzz;
else throw std::runtime_error("potential-gradient: invalid gradient type.");
int order = 1;
if (copy_str[3] != "null") order = atoi(copy_str[3].c_str());
rg.gm_regular_grid::gradient(copy_str[0], copy_str[1], g_type, order);
return;
}
void rtp(const std::vector<std::string> &cmd_units)
{
// rtp <data-name> <rtp-name> inclination declination
if (cmd_units.size() < 5) throw std::runtime_error("rtp: insufficient parameters.");
gctl::array<std::string> copy_str(4, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 4); i++)
{
copy_str[i - 1] = cmd_units[i];
}
rg.rtp(copy_str[0], copy_str[1], atof(copy_str[2].c_str()), atof(copy_str[3].c_str()));
return;
}
void drtp(const std::vector<std::string> &cmd_units)
{
// drtp <data-name> <rtp-name> <inclination-name> <declination-name> [<order>]
if (cmd_units.size() < 5) throw std::runtime_error("drtp: insufficient parameters.");
gctl::array<std::string> copy_str(5, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 5); i++)
{
copy_str[i - 1] = cmd_units[i];
}
int order = 1;
if (copy_str[4] != "null") order = atoi(copy_str[4].c_str());
if (order < 1) throw std::runtime_error("drtp: invalid differential order.");
rg.drtp(copy_str[0], copy_str[1], copy_str[2], copy_str[3], order);
return;
}
void continuation(const std::vector<std::string> &cmd_units)
{
// continuation <data-name> <out-name> <height>
if (cmd_units.size() < 4) throw std::runtime_error("continuation: insufficient parameters.");
gctl::array<std::string> copy_str(3, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 3); i++)
{
copy_str[i - 1] = cmd_units[i];
}
double height = atof(copy_str[2].c_str());
std::cout << height << "\n";
rg.conti(copy_str[0], copy_str[1], height);
return;
}
void trend(const std::vector<std::string> &cmd_units)
{
// trend <data-name> <reg-name> <res-name> <wx-size> <wy-size> <x-order> <y-order>
if (cmd_units.size() < 8) throw std::runtime_error("trend: insufficient parameters.");
gctl::array<std::string> copy_str(7, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 7); i++)
{
copy_str[i - 1] = cmd_units[i];
}
int wx_s = atoi(copy_str[3].c_str());
int wy_s = atoi(copy_str[4].c_str());
int x_od = atoi(copy_str[5].c_str());
int y_od = atoi(copy_str[6].c_str());
if (wx_s < 3 || wy_s < 3 || x_od < 1 || y_od < 1) throw std::runtime_error("trend: invalid trending parameters.");
rg.trend(copy_str[0], copy_str[1], copy_str[2], wx_s, wy_s, x_od, y_od);
return;
}
int main(int argc, char *argv[])
{
if (argc >= 2)
{
std::string tmp_l;
std::ifstream cmdin;
// Run commands from files. Each line is a command.
// You can give more than one file
for (size_t i = 1; i < argc; i++) try
{
open_infile(cmdin, argv[i]);
while (getline(cmdin, tmp_l) && tmp_l != "" && tmp_l[0] != '#')
{
exec_cmd(tmp_l);
}
cmdin.close();
}
catch(std::exception& e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, "run gridmanager-potential in the interactive mode for instructions.", 0);
}
}
else
{
setlocale(LC_CTYPE, "");
initialize_readline(); /* Bind our completer. */
display_logo();
std::clog << "gridmanager - conversion, compuatation and manipulation of the grid data.\n";
std::clog << "gridmanager-potential - processing grided potential field data.\n";
std::clog << "Enter '?' to see all available commands.\n";
std::string cmd_str;
char *c_line = (char *)NULL;
char *c_line_s = (char *)NULL;
bool quit = false;
while (!quit) try
{
c_line = readline(">> ");
if (!c_line) break;
c_line_s = stripwhite(c_line);
cmd_str = c_line_s;
if (cmd_str == "quit") quit = true;
else if (cmd_str == "?") display_cmds();
else exec_cmd(cmd_str);
free(c_line);
}
catch(std::exception& e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, "Enter 'help' for instructions.", 0);
}
}
return 0;
}

View File

@ -0,0 +1,119 @@
/********************************************************
*
*
*
*
*
*
* Geophysical Computational Tools & Library (GCTL)
*
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
*
* GCTL is distributed under a dual licensing scheme. You can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 2
* of the License, or (at your option) any later version. You should have
* received a copy of the GNU Lesser General Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>.
*
* If the terms and conditions of the LGPL v.2. would prevent you from using
* the GCTL, please consider the option to obtain a commercial license for a
* fee. These licenses are offered by the GCTL's original author. As a rule,
* licenses are provided "as-is", unlimited in time for a one time fee. Please
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
* to include some description of your company and the realm of its activities.
* Also add information on how to contact you by electronic and paper mail.
******************************************************/
#ifndef GCTL_GRIDMANAGER_POTENTIAL_H
#define GCTL_GRIDMANAGER_POTENTIAL_H
#include "gctl/potential/gm_regular_grid.h"
using namespace gctl;
// Function pointer for commands
typedef void (*cmd_func_ptr)(const std::vector<std::string> &cmd_units);
struct cmd_pair
{
std::string name;
cmd_func_ptr func_p;
std::string brief;
};
void quit(const std::vector<std::string> &cmd_units);
void mesh_info(const std::vector<std::string> &cmd_units);
void new_grid(const std::vector<std::string> &cmd_units);
void data_cloud(const std::vector<std::string> &cmd_units);
void gradient(const std::vector<std::string> &cmd_units);
void wavelet(const std::vector<std::string> &cmd_units);
void sum_data(const std::vector<std::string> &cmd_units);
void diff_data(const std::vector<std::string> &cmd_units);
void bool_data(const std::vector<std::string> &cmd_units);
void func_data(const std::vector<std::string> &cmd_units);
void calculator(const std::vector<std::string> &cmd_units);
void data_output(const std::vector<std::string> &cmd_units);
void data_rename(const std::vector<std::string> &cmd_units);
void data_view(const std::vector<std::string> &cmd_units);
void data_plot(const std::vector<std::string> &cmd_units);
void get_stats(const std::vector<std::string> &cmd_units);
void get_profile(const std::vector<std::string> &cmd_units);
void open_grid(const std::vector<std::string> &cmd_units);
void save_grid(const std::vector<std::string> &cmd_units);
void open_binary(const std::vector<std::string> &cmd_units);
void save_binary(const std::vector<std::string> &cmd_units);
void open_netcdf(const std::vector<std::string> &cmd_units);
void save_netcdf(const std::vector<std::string> &cmd_units);
void save_gmsh(const std::vector<std::string> &cmd_units);
void open_surfer(const std::vector<std::string> &cmd_units);
void save_surfer(const std::vector<std::string> &cmd_units);
void save_text(const std::vector<std::string> &cmd_units);
void potential_gradient(const std::vector<std::string> &cmd_units);
void rtp(const std::vector<std::string> &cmd_units);
void drtp(const std::vector<std::string> &cmd_units);
void continuation(const std::vector<std::string> &cmd_units);
void trend(const std::vector<std::string> &cmd_units);
#define CMD_NUM 25
const cmd_pair commands[CMD_NUM] = {
{"info", mesh_info, "Show mesh's information."},
{"init", new_grid, "Initialize a new grid framework."},
{"open", open_grid, "Open a grid file."},
{"save", save_grid, "Save grid data to a file."},
{"cloud", data_cloud, "Import grid data from data cloud."},
{"gradient", gradient, "Calculate directional gradients."},
{"wavelet", wavelet, "Decompose grid data using the wavelet algorithm."},
{"sum", sum_data, "Calculate the sum of two grid data."},
{"diff", diff_data, "Calculate the difference of two grid data."},
{"bool", bool_data, "Preform the boolean operation of grid data."},
{"function", func_data, "Generate grid data from a mathematic expression."},
{"calculator", calculator, "Preform the mathematic operation of grid data."},
{"output", data_output, "Set output properites of grid data."},
{"rename", data_rename, "Rename a grid data."},
{"view", data_view, "Display a grid data using the exprtk library."},
{"plot", data_plot, "Plot a grid data using the GMT library."},
{"statistic", get_stats, "Show statistics of grid data."},
{"profile", get_profile, "Extract profile data of a grid data."},
{"gravgradient", potential_gradient, "Calculate gravitational gradients."},
{"rtp", rtp, "Preform the Reduce to Pole (RTP) process."},
{"drtp", drtp, "Preform the Differential Reduce to Pole (DRTP) process"},
{"continuation", continuation, "Preform the upward or downward continuation process."},
{"trend", trend, "Preform the separation process for the potential field data."},
{"quit", quit, "Quit the program."},
{"null", nullptr, "null"}
};
#define KEY_NUM 6
const cmd_pair keywords[KEY_NUM] = {
{"netcdf", nullptr, "netCDF format."},
{"surfer", nullptr, "Surfer format."},
{"binary", nullptr, "GCTL native format."},
{"gmsh", nullptr, "Gmsh format."},
{"node", nullptr, "Node registered data."},
{"cell", nullptr, "Cell registered data."}
};
#endif // GCTL_GRIDMANAGER_POTENTIAL_H

View File

@ -0,0 +1,75 @@
#### quit
Does what it says.
#### info [\<new-grid-name\>] [\<new-info\>]
Show and/or edit information of the grid. This option could be used to assign new name and information to the grid. If the input name or information contain spaces, enclose them with quotes.
#### init \<new-file\> \<xnum\> \<ynum\> \<xmin\> \<ymin\> \<dx\> \<dy\> [\<info\>]
(Re)create a new grid. 'xnum' and 'ynum' are point numbers on the x and y directions.
'xmin' and 'ymin' are the minimal values of the grid's coordinates. 'dx' and
'dy' are the grid spacings. Extra 'info' about the new grid could be added here.
Mathematic expresstions could be used to specify the grid ranges.
#### open binary|netcdf|surfer \<file\>
1. `open binary <file>` Open a grid stored in the GCTL native binary format (.2m file).
2. `open netcdf <file> [<x-name> <y-name>] [<data-name>] [node|cell]` Open a grid stored in the netCDF format. 'node' (default) or 'cell' indicates whether the input grid data should be node or cell registed. names of the input grid's x-axial and y-axial should be given id they are not 'x' and 'y'. A \<data-name\> could be given to read the specficed data. Otherwise all grid data will be readed.
3. `open surfer <file> [<new-data-name>] [surfer6-text|surfer6-binary|surfer7] [node|cell]` Open a grid stored in the Surfer formats. 'node' (default) or 'cell' indicates whether the input grid data should be node or cell registed. 'surfer6-text' (default), 'surfer6-binary' and 'surfer7' are the expected grid format. Since no data name is stored in the Surfer grid, a new data name could be given.
#### save binary|netcdf|surfer|gmsh \<file\>
1. `save binary <file>` Save the grid using the GCTL native binary format (.2m file).
2. `save netcdf <file> [<data-name>|node|cell]` Save grid data using the netCDF format. A \<data-name\> could be given to write the specficed data. Use 'node' (default) or 'cell' to write all node or cell registed data, respectively.
3. `save surfer <file> <data-name> [surfer6-text|surfer6-binary|surfer7]` Save grid data using the Surfer format. A \<data-name\> must be given to write the specficed data. 'surfer6-text', 'surfer6-binary' and 'surfer7' are the outputing grid format.
4. `save gmsh <file>` Save the grid using the Gmsh legacy format. This command will write all data that are allowed for outputing.
5. `save text <file>` Save the grid data to text file.
#### cloud \<new-data-name\> node|cell \<data-could-file\> \<search-x\> \<search-y\> \<search-deg\>
Import a randomly distributed data could (namely a xyz data). Note that a grid must exist before the use this command. 'node' or 'cell' indicates whether the input could data should be node or cell registed. \<data-could-file\> is the input data file. \<search-x\>,\<search-y\> and \<search-deg\> defines an oval of which the command is used to interpolate the could data to grid points.
#### gradient \<data-name\> \<new-data-name\> dx|dy \<order\>
Calculate directional gradient(s) of the selected data. The new gradient data will have the same
data type of the used data. 'dx' and 'dy' give the calculation directions. higher orders of the gradient could be specified by given them at the end of the command.
#### wavelet \<data-name\> \<wavelet-name\> \<order\> [\<show-summary\>]
Using a wavelet \<wavelet-name\> to decompose the selecte data. Avaiable wavelets include 'bd2'... .The order of decomposition could be set using \<order\>. And set \<show-summary\> to yes to see the summary.
#### sum \<new-data-name\> \<data-name1\> \<data-name2\>
Calculate the sum of the two data. The arguments' format should be clear enough.
#### diff \<new-data-name\> \<data-name1\> \<data-name2\>
Calculate the difference of the two data. The arguments' format should be clear enough.
#### bool \<new-data-name\> \<data-name1> \<bool-data\> [reverse]
Preform the bool operation on the slected data set. Put 'reverse' to for a reversed calculation.
#### calculator \<expression\> \<var1,data-name1\> \<var2,data-name2\>...
Preform mathematic calculation using stored data. \<expression\> is a string that describles the expected calculation. For example, 'c := a + b' represents a summation between two data 'a' and 'b'. And the sum is stored in data 'c'. Note that 'a', 'b' and 'c' are algebraic symbols. So they must be tided to actual data using \<var,data-name\>, in which \<var\> is the algebraic symbol, \<data-name>\ is the data name. Remeber to put the output data name at the first place and if the input expression contain spaces, enclose them with quotes.
#### function \<expression\> \<new-data-name\>
Create a new grid data named \<new-data-name\> from a mathematic expression. Default algebraic symbols 'f', 'x' and 'y' are defined for the resultent data, x-coordinate and y-coordinate, respectively. For example, 'f := x + y' represents a summation of the grid coordinates.
#### output enable|disable \<data-name1\> \<data-name2\>...
Enable or disable output of the given data.
#### rename [\<old-name\>] [\<new-name\>]
Change data name.
#### statistic \<data-name1\> \<data-name2\>...
Show statistics of the selected data.
#### profile \<data-name\> \<out-file\> {\<x\>,\<y\> \<x\>,\<y\> \<num\>}|\<xy-file\>
Extract a profile from the selected data and output to a text file.
#### gravgradient \<data-name\> \<new-data-name\> Tzx|Tzy|Tzz [\<order\>]
Calculate directional gradient(s) of the selected potential field data using the frequency domain method. The new gradient data will have the same data type of the used data. 'Tzx', 'Tzy' and 'Tzz' give the calculation directions. higher orders of the gradient could be specified by given them at the end of the command.
#### rtp \<data-name\> \<rtp-name\> \<inclination\> \<declination>\
Preforms the Reduce to Pole (RTP) process for the total intense magnetic field data.
#### drtp \<data-name\> \<rtp-name\> \<inclination-name\> \<declination-name\> [\<order\>]
Preforms the Differential Reduce to Pole (DRTP) process for the total intense magnetic field data.
#### continuation \<data-name\> \<out-name\> \<height\>
Preforms the upward or downward continuation process for the potential field data.
#### trend \<data-name\> \<reg-name\> \<res-name\> \<wx-size\> \<wy-size\> \<x-order\> \<y-order\>
Preforms the separation process for the potential field data using the polynomial trending method.

View File

@ -0,0 +1,27 @@
set(TOOL_NAME gridmanager)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
find_package(PkgConfig)
pkg_search_module(EDITLINE REQUIRED libeditline)
include_directories(${EDITLINE_INCLUDE_DIRS})
link_directories(${EDITLINE_LIBRARY_DIRS})
aux_source_directory(. TOOL_SRC)
add_executable(${TOOL_NAME} ${TOOL_SRC})
set_target_properties(${TOOL_NAME} PROPERTIES INSTALL_RPATH /usr/local/lib)
set_target_properties(${TOOL_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
target_link_libraries(${TOOL_NAME} PRIVATE ${GCTL_LIB})
target_link_libraries(${TOOL_NAME} PRIVATE ${GCTL_GRAPHIC_LIB})
target_link_libraries(${TOOL_NAME} PRIVATE gctl_mesh)
target_link_libraries(${TOOL_NAME} PRIVATE ${WaveLib_LIB})
target_link_libraries(${TOOL_NAME} PRIVATE ${EDITLINE_LIBRARIES})
install(TARGETS ${TOOL_NAME} RUNTIME DESTINATION sbin)
file(GLOB HELP_DOC *.md)
install(FILES ${HELP_DOC} DESTINATION sbin/share)

776
gridmanager/gridmanager.cpp Normal file
View File

@ -0,0 +1,776 @@
/********************************************************
*
*
*
*
*
*
* Geophysical Computational Tools & Library (GCTL)
*
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
*
* GCTL is distributed under a dual licensing scheme. You can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 2
* of the License, or (at your option) any later version. You should have
* received a copy of the GNU Lesser General Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>.
*
* If the terms and conditions of the LGPL v.2. would prevent you from using
* the GCTL, please consider the option to obtain a commercial license for a
* fee. These licenses are offered by the GCTL's original author. As a rule,
* licenses are provided "as-is", unlimited in time for a one time fee. Please
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
* to include some description of your company and the realm of its activities.
* Also add information on how to contact you by electronic and paper mail.
******************************************************/
#include "gridmanager.h"
// We use the editline library to handle all inputs
#include "editline.h"
// install configuration
#include "../gctl_toolkits_config.h"
cmd_pair curr_cmd; // Executing command
gctl::regular_grid rg; // Grid object
extern "C" {
/*
* Strip whitespace from the start and end of STRING. Return a pointer
* into STRING.
*/
char *stripwhite(char *string)
{
char *s, *t;
for (s = string; isspace(*s); s++) ;
if (*s == 0)
return s;
t = s + strlen(s) - 1;
while (t > s && isspace(*t))
t--;
*++t = '\0';
return s;
}
/* Generator function for command completion. STATE lets us
know whether to start from scratch; without any state
(i.e. STATE == 0), then we start at the top of the list. */
char *command_generator(const char *text, int state)
{
static int list_index, len;
/* If this is a new word to complete, initialize now. This
includes saving the length of TEXT for efficiency, and
initializing the index variable to 0. */
if (!state)
{
list_index = 0;
len = strlen(text);
}
/* Return the next name which partially matches from the command list. */
while (list_index < CMD_NUM)
{
if (std::string(text) == commands[list_index].name.substr(0, len))
{
//const char* name = commands[list_index].name.data();
return strdup(commands[list_index].name.data());
}
else list_index++;
}
/* If no names matched, then return NULL. */
return nullptr;
}
/*
* Attempt to complete on the contents of TEXT. START and END
* bound the region of rl_line_buffer that contains the word to
* complete. TEXT is the word to complete. We can use the entire
* contents of rl_line_buffer in case we want to do some simple
* parsing. Return the array of matches, or NULL if there aren't any.
*/
char **gridmanager_completion(const char *text, int start, int end)
{
char **matches = nullptr;
/* If this word is at the start of the line, then it is a command
to complete. Otherwise it is the name of a file in the current
directory. */
if (start == 0) matches = rl_completion_matches(text, command_generator);
return matches;
}
void initialize_readline(void)
{
/* Allow conditional parsing of the ~/.inputrc file. */
rl_readline_name = "gridmanager";
/* Tell the completer that we want a crack first. */
rl_attempted_completion_function = gridmanager_completion;
}
} // End C section
void display_cmds()
{
std::clog << "Command:\n";
for (size_t i = 0; i < CMD_NUM - 1; i++)
{
std::clog << std::setw(12) << commands[i].name << ":\t" << commands[i].brief << "\n";
}
std::clog << "\nEnter \"<command>?\" to see detailed instructions.\n\n";
std::clog << "Keywords:\n";
for (size_t i = 0; i < KEY_NUM; i++)
{
std::clog << std::setw(12) << keywords[i].name << ":\t" << keywords[i].brief << "\n";
}
return;
}
void display_help(std::string input_cmd)
{
std::string install_dir = GCTL_TOOLKITS_INSTALL_PREFIX;
std::ifstream helpin;
open_infile(helpin, install_dir + "/sbin/share/readme_gridmanager", ".md");
std::string tmp_l, tmp_help;
std::vector<std::string> cmds;
std::vector<std::string> helps;
while (getline(helpin, tmp_l))
{
if (tmp_l.substr(0, 4) == "####")
{
cmds.push_back(tmp_l.substr(5));
tmp_help = "";
while (getline(helpin, tmp_l))
{
if (tmp_l == "") break;
else tmp_help += tmp_l + "\n";
}
helps.push_back(tmp_help);
}
}
helpin.close();
std::string cmd_str;
for (size_t j = 0; j < cmds.size(); j++)
{
parse_string_to_value(cmds[j], ' ', true, cmd_str);
if (input_cmd == cmd_str)
{
replace_all(tmp_l, cmds[j], "\\", "");
std::cout << GCTL_BOLDGREEN << tmp_l << GCTL_RESET << "\n";
std::cout << helps[j] << "\n";
break;
}
}
return;
}
void exec_cmd(std::string cmd)
{
std::string cmd_name;
parse_string_to_value(cmd, ' ', true, cmd_name);
// show instruction if there is a question mark at end of the command
if (cmd_name.back() == '?')
{
cmd_name = cmd_name.substr(0, cmd_name.length() - 1);
display_help(cmd_name);
return;
}
// set default command to null
curr_cmd = commands[CMD_NUM - 1];
for (size_t i = 0; i < CMD_NUM - 1; i++)
{
if (cmd_name == commands[i].name)
{
curr_cmd = commands[i]; break;
}
}
if (curr_cmd.func_p == nullptr) throw gctl::runtime_error("Invalid command: " + cmd_name);
std::vector<std::string> cmd_units;
parse_string_with_quotes(cmd, cmd_units);
return curr_cmd.func_p(cmd_units);
}
// This function is defined to avoid potential breakdown while running in script mode.
void quit(const std::vector<std::string> &cmd_units)
{
return;
}
void mesh_info(const std::vector<std::string> &cmd_units)
{
// info [\<new-grid-name\>] [\<new-info\>]
if (cmd_units.size() == 1)
{
rg.show_info();
return;
}
gctl::array<std::string> copy_str(2, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 2); i++)
{
copy_str[i - 1] = cmd_units[i];
}
if (copy_str[0] != "null") rg.set_meshname(copy_str[0]);
if (copy_str[1] != "null") rg.set_meshinfo(copy_str[1]);
return;
}
#ifdef GCTL_MESH_EXPRTK
inline double expr2double(std::string s)
{
exprtk::symbol_table<double> sym_tab;
exprtk::expression<double> expr;
exprtk::parser<double> p;
sym_tab.add_constants();
expr.register_symbol_table(sym_tab);
p.compile(s, expr);
return expr.value();
}
#endif // GCTL_MESH_EXPRTK
void new_grid(const std::vector<std::string> &cmd_units)
{
// new \<new-file\> \<xnum\> \<ynum\> \<xmin\> \<ymin\> \<dx\> \<dy\> [\<info\>]
if (cmd_units.size() < 8) throw std::runtime_error("new-grid: insufficient parameters.");
gctl::array<std::string> copy_str(8, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 8); i++)
{
copy_str[i - 1] = cmd_units[i];
}
if (rg.initiated()) rg.clear_regular_grid();
double xmin, ymin, dx, dy;
#ifdef GCTL_MESH_EXPRTK
xmin = expr2double(copy_str[3]);
ymin = expr2double(copy_str[4]);
dx = expr2double(copy_str[5]);
dy = expr2double(copy_str[6]);
#else
xmin = atof(copy_str[3].c_str());
ymin = atof(copy_str[4].c_str());
dx = atof(copy_str[5].c_str());
dy = atof(copy_str[6].c_str());
#endif // GCTL_MESH_EXPRTK
rg.init(copy_str[0], copy_str[7], atoi(copy_str[1].c_str()),
atoi(copy_str[2].c_str()), xmin, ymin, dx, dy);
return;
}
void open_grid(const std::vector<std::string> &cmd_units)
{
// open binary <file>
// open netcdf <file> [<x-name> <y-name>] [<data-name>] [node|cell]
// open surfer <file> <new-data-name> [surfer6-text|surfer6-binary|surfer7] [node|cell]
if (cmd_units.size() < 3) throw std::runtime_error("open: insufficient parameters.");
if (cmd_units[1] == "binary") open_binary(cmd_units);
else if (cmd_units[1] == "netcdf") open_netcdf(cmd_units);
else if (cmd_units[1] == "surfer") open_surfer(cmd_units);
else throw std::runtime_error("open: unknown file format.");
return;
}
void save_grid(const std::vector<std::string> &cmd_units)
{
// save binary <file>
// save netcdf <file> [<data-name>|node|cell]
// save surfer <file> <data-name> [surfer6-text|surfer6-binary|surfer7]
// save gmsh <file>
// save text <file> <data-name> [<data-name>]...
if (cmd_units.size() < 3) throw std::runtime_error("save: insufficient parameters.");
if (cmd_units[1] == "binary") save_binary(cmd_units);
else if (cmd_units[1] == "netcdf") save_netcdf(cmd_units);
else if (cmd_units[1] == "surfer") save_surfer(cmd_units);
else if (cmd_units[1] == "gmsh") save_gmsh(cmd_units);
else if (cmd_units[1] == "text") save_text(cmd_units);
else throw std::runtime_error("save: unknown file format.");
return;
}
void open_binary(const std::vector<std::string> &cmd_units)
{
// open binary <file>
rg.load_binary(cmd_units[2]);
return;
}
void save_binary(const std::vector<std::string> &cmd_units)
{
// save binary <file>
rg.save_binary(cmd_units[2]);
return;
}
void open_netcdf(const std::vector<std::string> &cmd_units)
{
// open netcdf <file> [<x-name> <y-name>] [<data-name>] [node|cell]
if (cmd_units.size() < 3) throw std::runtime_error("open: insufficient parameters.");
gctl::array<std::string> copy_str(5, "null");
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 5); i++)
{
copy_str[i] = cmd_units[i + 2];
}
mesh_data_type_e d_type = NodeData;
if (copy_str[4] == "cell") d_type = ElemData;
else if (copy_str[4] == "node") d_type = NodeData;
if (copy_str[1] == "null") copy_str[1] = "x";
if (copy_str[2] == "null") copy_str[2] = "y";
if (copy_str[3] == "null") rg.load_netcdf_grid(copy_str[0], d_type, copy_str[1], copy_str[2]);
else rg.load_netcdf_grid(copy_str[0], d_type, copy_str[1], copy_str[2], copy_str[3]);
return;
}
void save_netcdf(const std::vector<std::string> &cmd_units)
{
// save netcdf <file> [<data-name>|node|cell] [xname] [yname]
if (cmd_units.size() < 3) throw std::runtime_error("save: insufficient parameters.");
gctl::array<std::string> copy_str(4, "null");
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 4); i++)
{
copy_str[i] = cmd_units[i + 2];
}
std::string xname = "x", yname = "y";
if (copy_str[2] != "null") xname = copy_str[2];
if (copy_str[3] != "null") yname = copy_str[3];
if (copy_str[1] == "null") rg.save_netcdf_grid(copy_str[0], NodeData, xname, yname);
else if (copy_str[1] == "node") rg.save_netcdf_grid(copy_str[0], NodeData, xname, yname);
else if (copy_str[1] == "cell") rg.save_netcdf_grid(copy_str[0], ElemData, xname, yname);
else rg.save_netcdf_grid(copy_str[0], copy_str[1], xname, yname);
return;
}
void save_gmsh(const std::vector<std::string> &cmd_units)
{
// save gmsh <file>
if (cmd_units.size() < 3) throw std::runtime_error("save: insufficient parameters.");
rg.save_gmsh_withdata(cmd_units[2], OverWrite, NotPacked);
return;
}
void open_surfer(const std::vector<std::string> &cmd_units)
{
// open surfer <file> [<new-data-name>] [surfer6-text|surfer6-binary|surfer7] [node|cell]
if (cmd_units.size() < 4) throw std::runtime_error("open: insufficient parameters.");
gctl::array<std::string> copy_str(4, "null");
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 4); i++)
{
copy_str[i] = cmd_units[i + 2];
}
surfer_file_type_e st = Surfer6Text;
if (copy_str[2] == "surfer6-text") st = Surfer6Text;
else if (copy_str[2] == "surfer6-binary") st = Surfer6Binary;
else if (copy_str[2] == "surfer7") st = Surfer7Grid;
mesh_data_type_e d_type = NodeData;
if (copy_str[3] == "node") d_type = NodeData;
else if (copy_str[3] == "cell") d_type = ElemData;
if (copy_str[1] == "null") rg.load_surfer_grid(copy_str[0], "Untitled", d_type, st);
else rg.load_surfer_grid(copy_str[0], copy_str[3], d_type, st);
return;
}
void save_surfer(const std::vector<std::string> &cmd_units)
{
// save surfer <file> <data-name> [surfer6-text|surfer6-binary|surfer7]
if (cmd_units.size() < 4) throw std::runtime_error("save: insufficient parameters.");
gctl::array<std::string> copy_str(3, "null");
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 3); i++)
{
copy_str[i] = cmd_units[i + 2];
}
surfer_file_type_e st = Surfer6Text;
if (copy_str[2] == "surfer6-text") st = Surfer6Text;
else if (copy_str[2] == "surfer6-binary") st = Surfer6Binary;
else if (copy_str[2] == "surfer7") st = Surfer7Grid;
rg.save_surfer_grid(copy_str[0], copy_str[1] ,st);
return;
}
void save_text(const std::vector<std::string> &cmd_units)
{
// save text <file> <data-name>
if (cmd_units.size() < 4) throw std::runtime_error("save: insufficient parameters.");
gctl::array<std::string> copy_str(cmd_units.size() - 3, "null");
for (size_t i = 0; i < cmd_units.size() - 3; i++)
{
copy_str[i] = cmd_units[i + 3];
}
rg.save_text(cmd_units[2], copy_str);
return;
}
void data_cloud(const std::vector<std::string> &cmd_units)
{
// data-cloud \<new-data-name\> node|cell \<data-could-file\> \<search-x\> \<search-y\> \<search-deg\>
if (cmd_units.size() < 7) throw std::runtime_error("data-cloud: insufficient parameters.");
gctl::array<std::string> copy_str(7, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 7); i++)
{
copy_str[i - 1] = cmd_units[i];
}
mesh_data_type_e d_type = NodeData;
if (copy_str[1] == "node") d_type = NodeData;
else if (copy_str[1] == "cell") d_type = ElemData;
else throw std::runtime_error("open-surfer: invalid grid data type.");
geodsv_io text_in;
text_in.load_text(copy_str[2]);
array<point2dc> posi_arr;
_1d_array data_vec;
text_in.get_column_point2dc(posi_arr, 0, 1);
text_in.get_column(data_vec, 2);
rg.load_data_cloud(posi_arr, data_vec, atof(copy_str[3].c_str()), atof(copy_str[4].c_str()), atof(copy_str[5].c_str()), copy_str[0], d_type);
return;
}
void gradient(const std::vector<std::string> &cmd_units)
{
// gradient <data-name> <new-data-name> dx|dy <order>
if (cmd_units.size() < 4) throw std::runtime_error("gradient: insufficient parameters.");
gctl::array<std::string> copy_str(4, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 4); i++)
{
copy_str[i - 1] = cmd_units[i];
}
gradient_type_e g_type;
if (copy_str[2] == "dx") g_type = Dx;
else if (copy_str[2] == "dy") g_type = Dy;
else throw std::runtime_error("gradient: invalid gradient type.");
int order = 1;
if (copy_str[3] != "null") order = atoi(copy_str[3].c_str());
rg.gradient(copy_str[0], copy_str[1], g_type, order);
return;
}
void wavelet(const std::vector<std::string> &cmd_units)
{
// wavelet \<data-name\> \<wavelet-name\> \<order\> [\<show-summary\>]
if (cmd_units.size() < 4) throw std::runtime_error("wavelet: insufficient parameters.");
gctl::array<std::string> copy_str(4, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 4); i++)
{
copy_str[i - 1] = cmd_units[i];
}
int order = order = atoi(copy_str[2].c_str());
if (copy_str[3] == "yes") rg.wavelet(copy_str[0], copy_str[1], order, true);
else rg.wavelet(copy_str[0], copy_str[1], order, false);
return;
}
void sum_data(const std::vector<std::string> &cmd_units)
{
// sum-data \<new-data\> \<data1\> \<data2\>
if (cmd_units.size() < 4) throw std::runtime_error("sum: insufficient parameters.");
rg.sum(cmd_units[1], cmd_units[2], cmd_units[3]);
return;
}
void diff_data(const std::vector<std::string> &cmd_units)
{
// diff \<new-data\> \<data1\> \<data2\>
if (cmd_units.size() < 4) throw std::runtime_error("diff: insufficient parameters.");
rg.diff(cmd_units[1], cmd_units[2], cmd_units[3]);
return;
}
void bool_data(const std::vector<std::string> &cmd_units)
{
// bool \<new-data-name\> \<data-name1> \<bool-data\> [reverse]
if (cmd_units.size() < 4) throw std::runtime_error("bool: insufficient parameters.");
gctl::array<std::string> copy_str(4, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 4); i++)
{
copy_str[i - 1] = cmd_units[i];
}
if (copy_str[3] == "reverse") rg.boolean(copy_str[0], copy_str[1], copy_str[2], true);
else rg.boolean(copy_str[0], copy_str[1], copy_str[2]);
return;
}
void func_data(const std::vector<std::string> &cmd_units)
{
// function \<expression\> \<new-data-name\>
if (cmd_units.size() < 3) throw std::runtime_error("function: insufficient parameters.");
gctl::array<std::string> copy_str(3, "null");
for (size_t i = 0; i <= GCTL_MIN(cmd_units.size() - 1, 3); i++)
{
copy_str[i] = cmd_units[i + 1];
}
rg.function(copy_str[0], copy_str[1]);
return;
}
void calculator(const std::vector<std::string> &cmd_units)
{
// calculator \<expression\> \<var1,data-name1\> \<var2,data-name2\>...
if (cmd_units.size() < 4) throw std::runtime_error("calculator: insufficient parameters.");
gctl::array<std::string> copy_str(cmd_units.size() - 1, "null");
for (size_t i = 1; i <= cmd_units.size() - 1; i++)
{
copy_str[i - 1] = cmd_units[i];
}
array<std::string> var_list(copy_str.size() - 1), data_list(copy_str.size() - 1);
for (size_t i = 0; i < var_list.size(); i++)
{
parse_string_to_value(copy_str[i + 1], ',', true, var_list[i], data_list[i]);
}
rg.calculator(copy_str[0], var_list, data_list);
return;
}
void data_output(const std::vector<std::string> &cmd_units)
{
// data-output enable|disable \<data-name1\> \<data-name2\>...
if (cmd_units.size() < 3) throw std::runtime_error("data-output: insufficient parameters.");
gctl::array<std::string> copy_str(cmd_units.size() - 1, "null");
for (size_t i = 1; i <= cmd_units.size() - 1; i++)
{
copy_str[i - 1] = cmd_units[i];
}
meshdata *data_ptr;
if (copy_str[0] == "enable")
{
for (size_t i = 1; i < copy_str.size(); i++)
{
data_ptr = rg.get_data_ptr(copy_str[i]);
data_ptr->output_ok_ = true;
}
}
else if (copy_str[0] == "disable")
{
for (size_t i = 1; i < copy_str.size(); i++)
{
data_ptr = rg.get_data_ptr(copy_str[i]);
data_ptr->output_ok_ = false;
}
}
else throw std::runtime_error("data-output: invalid operation type.");
return;
}
void data_rename(const std::vector<std::string> &cmd_units)
{
// data-rename [\<old-name\>] [\<new-name\>]
if (cmd_units.size() < 3) throw std::runtime_error("rename: insufficient parameters.");
gctl::array<std::string> copy_str(2, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 2); i++)
{
copy_str[i - 1] = cmd_units[i];
}
meshdata &curr_data = rg.get_data(copy_str[0]);
curr_data.name_ = copy_str[1];
return;
}
void data_view(const std::vector<std::string> &cmd_units)
{
// plot [\<data-name\>]...
if (cmd_units.size() < 2) throw std::runtime_error("view: insufficient parameters.");
for (size_t i = 1; i < cmd_units.size(); i++)
{
rg.view(cmd_units[i]);
}
return;
}
void data_plot(const std::vector<std::string> &cmd_units)
{
// plot [\<data-name\>]...
if (cmd_units.size() < 2) throw std::runtime_error("plot: insufficient parameters.");
for (size_t i = 1; i < cmd_units.size(); i++)
{
rg.plot(cmd_units[i]);
}
return;
}
void get_stats(const std::vector<std::string> &cmd_units)
{
// statistic \<data-name1\> \<data-name2\>...
if (cmd_units.size() < 2) throw std::runtime_error("statistic: insufficient parameters.");
gctl::array<std::string> copy_str(cmd_units.size() - 1, "null");
for (size_t i = 1; i <= cmd_units.size() - 1; i++)
{
copy_str[i - 1] = cmd_units[i];
}
meshdata *data_ptr;
std::vector<double> stats;
for (size_t i = 0; i < copy_str.size(); i++)
{
data_ptr = rg.get_data_ptr(copy_str[i]);
data_ptr->show_info();
data_ptr->show_stats();
}
return;
}
void get_profile(const std::vector<std::string> &cmd_units)
{
// profile \<data-name\> \<out-file\> {\<x\>,\<y\> \<x\>,\<y\> \<num\>}|{\<xy-file\>}
if (cmd_units.size() < 4) throw std::runtime_error("profile: insufficient parameters.");
gctl::array<std::string> copy_str(5, "null");
for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 5); i++)
{
copy_str[i - 1] = cmd_units[i];
}
array<point2dc> xys;
array<double> p_data;
if (access(copy_str[2].c_str(), R_OK))
{
point2dc st_p, ed_p;
gctl::parse_string_to_value(copy_str[2], ',', true, st_p.x, st_p.y);
gctl::parse_string_to_value(copy_str[3], ',', true, ed_p.x, ed_p.y);
rg.extract_profile(copy_str[0], st_p, ed_p, atoi(copy_str[4].c_str()), xys, p_data);
}
else // File exist
{
geodsv_io fio;
fio.load_text(copy_str[2]);
fio.get_column_point2dc(xys, 0, 1);
rg.extract_points(copy_str[0], xys, p_data);
}
std::ofstream ofile;
open_outfile(ofile, copy_str[1], ".txt");
ofile << "# x y d val\n";
for (size_t i = 0; i < xys.size(); i++)
{
ofile << xys[i].x << " " << xys[i].y << " " << distance(xys[0], xys[i]) << " " << p_data[i] << "\n";
}
ofile.close();
return;
}
int main(int argc, char *argv[])
{
if (argc >= 2)
{
std::string tmp_l;
std::ifstream cmdin;
// Run commands from files. Each line is a command.
// You can give more than one file
for (size_t i = 1; i < argc; i++) try
{
open_infile(cmdin, argv[i]);
while (getline(cmdin, tmp_l) && tmp_l != "" && tmp_l[0] != '#')
{
exec_cmd(tmp_l);
}
cmdin.close();
}
catch(std::exception& e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, "run gridmanager in the interactive mode for instructions.", 0);
}
}
else
{
setlocale(LC_CTYPE, "");
initialize_readline(); /* Bind our completer. */
display_logo();
std::clog << "gridmanager - conversion, compuatation and manipulation of the grid data.\n";
std::clog << "Enter '?' to see all available commands.\n";
std::string cmd_str;
char *c_line = (char *)NULL;
char *c_line_s = (char *)NULL;
bool quit = false;
while (!quit) try
{
c_line = readline(">> ");
if (!c_line) break;
c_line_s = stripwhite(c_line);
cmd_str = c_line_s;
if (cmd_str == "quit") quit = true;
else if (cmd_str == "?") display_cmds();
else exec_cmd(cmd_str);
free(c_line);
}
catch(std::exception& e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, "Enter 'help' for instructions.", 0);
}
}
return 0;
}

110
gridmanager/gridmanager.h Normal file
View File

@ -0,0 +1,110 @@
/********************************************************
*
*
*
*
*
*
* Geophysical Computational Tools & Library (GCTL)
*
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
*
* GCTL is distributed under a dual licensing scheme. You can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 2
* of the License, or (at your option) any later version. You should have
* received a copy of the GNU Lesser General Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>.
*
* If the terms and conditions of the LGPL v.2. would prevent you from using
* the GCTL, please consider the option to obtain a commercial license for a
* fee. These licenses are offered by the GCTL's original author. As a rule,
* licenses are provided "as-is", unlimited in time for a one time fee. Please
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
* to include some description of your company and the realm of its activities.
* Also add information on how to contact you by electronic and paper mail.
******************************************************/
#ifndef GCTL_MESH_GRIDMANAGER_H
#define GCTL_MESH_GRIDMANAGER_H
#include "gctl/io/term_io.h"
#include "gctl/io/dsv_io.h"
#include "gctl/mesh/regular_grid.h"
using namespace gctl;
// Function pointer for commands
typedef void (*cmd_func_ptr)(const std::vector<std::string> &cmd_units);
struct cmd_pair
{
std::string name;
cmd_func_ptr func_p;
std::string brief;
};
void quit(const std::vector<std::string> &cmd_units);
void mesh_info(const std::vector<std::string> &cmd_units);
void new_grid(const std::vector<std::string> &cmd_units);
void data_cloud(const std::vector<std::string> &cmd_units);
void gradient(const std::vector<std::string> &cmd_units);
void wavelet(const std::vector<std::string> &cmd_units);
void sum_data(const std::vector<std::string> &cmd_units);
void diff_data(const std::vector<std::string> &cmd_units);
void bool_data(const std::vector<std::string> &cmd_units);
void func_data(const std::vector<std::string> &cmd_units);
void calculator(const std::vector<std::string> &cmd_units);
void data_output(const std::vector<std::string> &cmd_units);
void data_rename(const std::vector<std::string> &cmd_units);
void data_view(const std::vector<std::string> &cmd_units);
void data_plot(const std::vector<std::string> &cmd_units);
void get_stats(const std::vector<std::string> &cmd_units);
void get_profile(const std::vector<std::string> &cmd_units);
void open_grid(const std::vector<std::string> &cmd_units);
void save_grid(const std::vector<std::string> &cmd_units);
void open_binary(const std::vector<std::string> &cmd_units);
void save_binary(const std::vector<std::string> &cmd_units);
void open_netcdf(const std::vector<std::string> &cmd_units);
void save_netcdf(const std::vector<std::string> &cmd_units);
void save_gmsh(const std::vector<std::string> &cmd_units);
void open_surfer(const std::vector<std::string> &cmd_units);
void save_surfer(const std::vector<std::string> &cmd_units);
void save_text(const std::vector<std::string> &cmd_units);
#define CMD_NUM 20
const cmd_pair commands[CMD_NUM] = {
{"info", mesh_info, "Show mesh's information."},
{"init", new_grid, "Initialize a new grid framework."},
{"open", open_grid, "Open a grid file."},
{"save", save_grid, "Save grid data to a file."},
{"cloud", data_cloud, "Import grid data from data cloud."},
{"gradient", gradient, "Calculate directional gradients."},
{"wavelet", wavelet, "Decompose grid data using the wavelet algorithm."},
{"sum", sum_data, "Calculate the sum of two grid data."},
{"diff", diff_data, "Calculate the difference of two grid data."},
{"bool", bool_data, "Preform the boolean operation of grid data."},
{"function", func_data, "Generate grid data from a mathematic expression."},
{"calculator", calculator, "Preform the mathematic operation of grid data."},
{"output", data_output, "Set output properites of grid data."},
{"rename", data_rename, "Rename a grid data."},
{"view", data_view, "Display a grid data using the exprtk library."},
{"plot", data_plot, "Plot a grid data using the GMT library."},
{"statistic", get_stats, "Show statistics of grid data."},
{"profile", get_profile, "Extract profile data of a grid data."},
{"quit", quit, "Quit the program."},
{"null", nullptr, "null"}
};
#define KEY_NUM 6
const cmd_pair keywords[KEY_NUM] = {
{"netcdf", nullptr, "netCDF format."},
{"surfer", nullptr, "Surfer format."},
{"binary", nullptr, "GCTL native format."},
{"gmsh", nullptr, "Gmsh format."},
{"node", nullptr, "Node registered data."},
{"cell", nullptr, "Cell registered data."}
};
#endif // GCTL_MESH_GRIDMANAGER_H

View File

@ -0,0 +1,60 @@
#### quit
Does what it says.
#### info [\<new-grid-name\>] [\<new-info\>]
Show and/or edit information of the grid. This option could be used to assign new name and information to the grid. If the input name or information contain spaces, enclose them with quotes.
#### init \<new-file\> \<xnum\> \<ynum\> \<xmin\> \<ymin\> \<dx\> \<dy\> [\<info\>]
(Re)create a new grid. 'xnum' and 'ynum' are point numbers on the x and y directions.
'xmin' and 'ymin' are the minimal values of the grid's coordinates. 'dx' and
'dy' are the grid spacings. Extra 'info' about the new grid could be added here.
Mathematic expresstions could be used to specify the grid ranges.
#### open binary|netcdf|surfer \<file\>
1. `open binary <file>` Open a grid stored in the GCTL native binary format (.2m file).
2. `open netcdf <file> [<x-name> <y-name>] [<data-name>] [node|cell]` Open a grid stored in the netCDF format. 'node' (default) or 'cell' indicates whether the input grid data should be node or cell registed. names of the input grid's x-axial and y-axial should be given id they are not 'x' and 'y'. A \<data-name\> could be given to read the specficed data. Otherwise all grid data will be readed.
3. `open surfer <file> [<new-data-name>] [surfer6-text|surfer6-binary|surfer7] [node|cell]` Open a grid stored in the Surfer formats. 'node' (default) or 'cell' indicates whether the input grid data should be node or cell registed. 'surfer6-text' (default), 'surfer6-binary' and 'surfer7' are the expected grid format. Since no data name is stored in the Surfer grid, a new data name could be given.
#### save binary|netcdf|surfer|gmsh \<file\>
1. `save binary <file>` Save the grid using the GCTL native binary format (.2m file).
2. `save netcdf <file> [<data-name>|node|cell] [xname] [yname]` Save grid data using the netCDF format. A \<data-name\> could be given to write the specficed data. Use 'node' (default) or 'cell' to write all node or cell registed data, respectively.
3. `save surfer <file> <data-name> [surfer6-text|surfer6-binary|surfer7]` Save grid data using the Surfer format. A \<data-name\> must be given to write the specficed data. 'surfer6-text', 'surfer6-binary' and 'surfer7' are the outputing grid format.
4. `save gmsh <file>` Save the grid using the Gmsh legacy format. This command will write all data that are allowed for outputing.
5. `save text <file>` Save the grid data to text file.
#### cloud \<new-data-name\> node|cell \<data-could-file\> \<search-x\> \<search-y\> \<search-deg\>
Import a randomly distributed data could (namely a xyz data). Note that a grid must exist before the use this command. 'node' or 'cell' indicates whether the input could data should be node or cell registed. \<data-could-file\> is the input data file. \<search-x\>,\<search-y\> and \<search-deg\> defines an oval of which the command is used to interpolate the could data to grid points.
#### gradient \<data-name\> \<new-data-name\> dx|dy \<order\>
Calculate directional gradient(s) of the selected data. The new gradient data will have the same
data type of the used data. 'dx' and 'dy' give the calculation directions. higher orders of the gradient could be specified by given them at the end of the command.
#### wavelet \<data-name\> \<wavelet-name\> \<order\> [\<show-summary\>]
Using a wavelet \<wavelet-name\> to decompose the selecte data. Avaiable wavelets include 'bd2'... .The order of decomposition could be set using \<order\>. And set \<show-summary\> to yes to see the summary.
#### sum \<new-data\> \<data1\> \<data2\>
Calculate the sum of the two data. The arguments' format should be clear enough.
#### diff \<new-data\> \<data1\> \<data2\>
Calculate the difference of the two data. The arguments' format should be clear enough.
#### bool \<new-data-name\> \<data-name1> \<bool-data\> [reverse]
Preform the bool operation on the slected data set. Put 'reverse' to for a reversed calculation.
#### calculator \<expression\> \<var1,data-name1\> \<var2,data-name2\>...
Preform mathematic calculation using stored data. \<expression\> is a string that describles the expected calculation. For example, 'c := a + b' represents a summation between two data 'a' and 'b'. And the sum is stored in data 'c'. Note that 'a', 'b' and 'c' are algebraic symbols. So they must be tided to actual data using \<var,data-name\>, in which \<var\> is the algebraic symbol, \<data-name>\ is the data name. Remeber to put the output data name at the first place and if the input expression contain spaces, enclose them with quotes.
#### function \<expression\> \<new-data-name\>
Create a new grid data named \<new-data-name\> from a mathematic expression. Default algebraic symbols 'f', 'x' and 'y' are defined for the resultent data, x-coordinate and y-coordinate, respectively. For example, 'f := x + y' represents a summation of the grid coordinates.
#### output enable|disable \<data-name1\> \<data-name2\>...
Enable or disable output of the given data.
#### rename [\<old-name\>] [\<new-name\>]
Change data name.
#### statistic \<data-name1\> \<data-name2\>...
Show statistics of the selected data.
#### profile \<data-name\> \<out-file\> {\<x\>,\<y\> \<x\>,\<y\> \<num\>}|\<xy-file\>
Extract a profile from the selected data and output to a text file.

View File

@ -26,9 +26,10 @@
******************************************************/
#include "gctl/core.h"
#include "gctl/geometry.h"
#include "gctl/poly.h"
#include "gctl/io.h"
#include "gctl/utility.h"
#include "gctl/math/geometry3d.h"
class HandyMan
{
@ -353,7 +354,7 @@ void HandyMan::SR_GeoAngle()
std::cin >> c[i].lon >> c[i].lat;
}
std::cout << "The geo-centric angle is: " << gctl::geometry3d::angle(c[0].s2c(), c[1].s2c())*180.0/M_PI << " deg.\n";
std::cout << "The geo-centric angle is: " << gctl::geometry3d::angle(s2c(c[0]), s2c(c[1]))*180.0/M_PI << " deg.\n";
return;
}

View File

@ -29,9 +29,10 @@
//#include "lcg/solver.h"
// GCTL library
#include "gctl/core.h"
#include "gctl/geometry.h"
#include "gctl/poly.h"
#include "gctl/io.h"
#include "gctl/utility.h"
#include "gctl/math/boxsort2d.h"
#include "gctl/optimization.h"
#if defined _WINDOWS || __WIN32__

View File

@ -0,0 +1,16 @@
set(TOOL_NAME levy_planner)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
aux_source_directory(. TOOL_SRC)
add_executable(${TOOL_NAME} ${TOOL_SRC})
set_target_properties(${TOOL_NAME} PROPERTIES INSTALL_RPATH /usr/local/lib)
set_target_properties(${TOOL_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
target_link_libraries(${TOOL_NAME} PRIVATE ${GCTL_LIB})
target_link_libraries(${TOOL_NAME} PRIVATE gctl_optimization)
install(TARGETS ${TOOL_NAME} RUNTIME DESTINATION sbin)

View File

@ -0,0 +1,84 @@
/********************************************************
*
*
*
*
*
*
* Geophysical Computational Tools & Library (GCTL)
*
* Copyright (c) 2022 Yi Zhang (yizhang-geo@zju.edu.cn)
*
* GCTL is distributed under a dual licensing scheme. You can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 2
* of the License, or (at your option) any later version. You should have
* received a copy of the GNU Lesser General Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>.
*
* If the terms and conditions of the LGPL v.2. would prevent you from using
* the GCTL, please consider the option to obtain a commercial license for a
* fee. These licenses are offered by the GCTL's original author. As a rule,
* licenses are provided "as-is", unlimited in time for a one time fee. Please
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
* to include some description of your company and the realm of its activities.
* Also add information on how to contact you by electronic and paper mail.
******************************************************/
#include "gctl/optimization/lgd.h"
class levy_planner : public gctl::lgd_solver
{
public:
levy_planner(){}
virtual ~levy_planner(){}
virtual double LGD_Evaluate(const gctl::array<double> &x, gctl::array<double> &g){return 0;}
};
int main(int argc, char *argv[]) try
{
gctl::display_logo();
levy_planner p;
gctl::lgd_para my_para = p.default_lgd_para();
double alpha, beta;
std::cout << "Input alpha (> 0) and beta (1.0 ~ 2.0): ";
std::cin >> alpha >> beta;
if (alpha <= 0 || beta <= 1.0 || beta >= 2.0)
{
std::cout << "Invalid inputs\n";
return 0;
}
my_para.flight_times = 100000;
my_para.beta = beta;
p.set_lgd_para(my_para);
gctl::array<double> dist;
p.get_levy_distribution(dist);
for (size_t i = 0; i < dist.size(); i++)
{
dist[i] *= alpha;
}
double mean = dist.mean();
double std = dist.std();
double cnt = 0.0;
for (size_t i = 0; i < dist.size(); i++)
{
if (fabs(dist[i] - mean) > 3.0*std) cnt += 1.0;
}
std::cout << "Step Avg. = " << mean << "\n";
std::cout << "Step STD = " << std << "\n";
std::cout << "Large Ones = " << cnt/1000.0 << "%\n";
return 0;
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}

1
lib/gctl_config.h Normal file
View File

@ -0,0 +1 @@
#define GCTL_TOOLKITS_INSTALL_PREFIX "/opt/stow/gctl_toolkits"

View File

@ -29,10 +29,11 @@
//#include "lcg/solver.h"
// GCTL library
#include "gctl/core.h"
#include "gctl/algorithms.h"
#include "gctl/geometry.h"
#include "gctl/poly.h"
#include "gctl/io.h"
#include "gctl/utility.h"
#include "gctl/math/boxsort2d.h"
#include "gctl/math/variogram.h"
#include "gctl/optimization.h"
#if defined _WINDOWS || __WIN32__

View File

@ -6,7 +6,7 @@ if [[ $# == 0 || ${1} == "help" ]]; then
echo "School of Earth Sciences, Zhejiang University"
echo "Yi Zhang (yizhang-geo@zju.edu.cn)"
echo ""
echo "Usage: ./installer [option] [Cmake options]"
echo "Usage: ./manager.sh [option] [Cmake options]"
echo ""
echo "Options:"
echo "(1) configure: Configure Cmake project(s). This option could take extra Cmake options as in <option>=<value>."

View File

@ -65,7 +65,7 @@ Please see instructions or contact the author for more information.");
gctl::read_netcdf_axis(in_name, out_x, x_name);
gctl::read_netcdf_axis(in_name, out_y, y_name);
gctl::read_netcdf_grid(in_name, out_data, x_name, y_name, data_name);
gctl::save_netcdf_grid(out_name, out_data, out_x, out_y, x_name, y_name, data_name, zmin, zmax);
gctl::save_netcdf_grid(out_name, out_data, out_x, out_y, gctl::BtmLeft, x_name, y_name, data_name, zmin, zmax);
return 0;
}
catch(std::exception &e)

View File

@ -31,7 +31,8 @@
// add gctl head files
#include "gctl/core.h"
#include "gctl/utility.h"
#include "gctl/algorithms.h"
#include "gctl/math/legendre.h"
#include "gctl/math/interpolate.h"
#include "gctl/io.h"
#define NORMAL_GRAVITY 9.80665 // m/s^2

View File

@ -29,9 +29,11 @@
//#include "lcg/solver.h"
// GCTL library
#include "gctl/core.h"
#include "gctl/geometry.h"
#include "gctl/poly.h"
#include "gctl/io.h"
#include "gctl/utility.h"
#include "gctl/math/boxsort2d.h"
#include "gctl/math/boxsort_sph.h"
#include "gctl/optimization.h"
#if defined _WINDOWS || __WIN32__

View File

@ -28,6 +28,7 @@
#include "gctl/core.h"
#include "gctl/io.h"
#include "gctl/utility.h"
#include "gctl/math/refellipsoid.h"
int main(int argc, char *argv[]) try
{

View File

@ -47,8 +47,8 @@
#include "gctl/core.h"
#include "gctl/utility.h"
#include "gctl/algorithms.h"
#include "gctl/io.h"
#include "gctl/math/interpolate.h"
using namespace std;

View File

@ -266,7 +266,7 @@ Please see instructions or contact the author for more information.");
}
gctl::save_netcdf_grid(grid_name, out_data, xnum, ynum, xmin, dx, ymin, dy,
label_index[0], label_index[1], label_index[2]);
gctl::BtmLeft, label_index[0], label_index[1], label_index[2]);
std::string save_dataname;
if (col_index.size() > 1)
@ -302,7 +302,7 @@ Please see instructions or contact the author for more information.");
}
gctl::save_netcdf_grid(grid_name, out_data, xnum, ynum, xmin, dx, ymin, dy,
label_index[0], label_index[1], label_index[2]);
gctl::BtmLeft, label_index[0], label_index[1], label_index[2]);
std::string save_dataname;
if (col_index.size() > 3)

View File

@ -28,6 +28,7 @@
#include "gctl/core.h"
#include "gctl/io.h"
#include "gctl/utility.h"
#include "gctl/math/gmath.h"
int main(int argc, char *argv[]) try
{
@ -134,11 +135,11 @@ The inputting continues until encounter a blank line or 'EOF'. Any lines start w
throw err_str;
}
ps = pc.c2s();
ps = c2s(pc);
if (ref_str != "NULL")
{
ps.rad = gctl::ellipse_radius_2d(ref_R, ref_r, ps.lat*GCTL_Pi/180.0);
pc = ps.s2c();
pc = s2c(ps);
}
if (verbose) std::cout << std::setprecision(pre_int) << pc.x << "," << pc.y << "," << pc.z << ",";
@ -163,7 +164,7 @@ The inputting continues until encounter a blank line or 'EOF'. Any lines start w
{
ps.rad = gctl::ellipse_radius_2d(ref_R, ref_r, ps.lat*GCTL_Pi/180.0);
}
pc = ps.s2c();
pc = s2c(ps);
if (verbose) std::cout << std::setprecision(pre_int) << ps.rad << "," << ps.lon << "," << ps.lat << ",";
std::cout << std::setprecision(pre_int) << pc.x << "," << pc.y << "," << pc.z << std::endl;