import 0.12.7

This commit is contained in:
liubo01 2024-06-07 15:37:42 +08:00
parent 5aa428472c
commit d0fbf5f25b
22 changed files with 300 additions and 721 deletions

View File

@ -1,12 +0,0 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

View File

@ -1,73 +0,0 @@
name: CI_build
on: [push, pull_request]
jobs:
build_windows:
runs-on: windows-2022
strategy:
max-parallel: 6
matrix:
build_configuration: [Release, Debug]
build_platform: [x64, arm64, x86]
build_vsver: [17]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Download PCRE2 sources
run: ./init.ps1 -pcre "10.40"
- name: Build and install PCRE2
run: ./build.ps1 -proj pcre2 -config ${{ matrix.build_configuration }} -arch ${{ matrix.build_platform }} -vsver ${{ matrix.build_vsver }} -init -install
- name: Build and install editorconfig-core-c
run: ./build.ps1 -proj core -config ${{ matrix.build_configuration }} -arch ${{ matrix.build_platform }} -vsver ${{ matrix.build_vsver }} -init -install
- name: Run the core tests
if: matrix.build_platform == 'x86' || matrix.build_platform == 'x64'
run: ./test.ps1 -proj core -config ${{ matrix.build_configuration }} -arch ${{ matrix.build_platform }}
build_linux:
runs-on: ubuntu-22.04
strategy:
max-parallel: 4
matrix:
compiler:
- { compiler: GNU, CC: gcc-11, CXX: g++-11 }
- { compiler: LLVM, CC: clang-14, CXX: clang++-14 }
build_configuration: [Release, Debug]
build_platform: ["Unix Makefiles"]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install packages via apt
run: |
sudo apt-get -qq update
sudo apt-get -qq install -y libpcre2-dev cmake doxygen graphviz
- name: generate cmake
env:
CC: ${{ matrix.compiler.CC }}
CXX: ${{ matrix.compiler.CXX }}
run: |
mkdir _build
cd _build
cmake -G "${{ matrix.build_platform }}" -DCMAKE_INSTALL_PREFIX=../_install ..
- name: build cmake
run: |
cd _build
cmake --build . --config ${{ matrix.build_configuration }} --target install
- name: run tests
run: |
cd _build
ctest -VV --output-on-failure .

36
.travis.yml Normal file
View File

@ -0,0 +1,36 @@
language: c
compiler:
- gcc
- clang
dist: xenial
addons:
apt:
packages:
- libpcre2-dev
# Settings to try
env:
- OPTIONS="-DCMAKE_BUILD_TYPE=Release -DBUILD_STATICALLY_LINKED_EXE=ON"
- OPTIONS="-DCMAKE_BUILD_TYPE=Release -DBUILD_STATICALLY_LINKED_EXE=OFF"
- OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DBUILD_STATICALLY_LINKED_EXE=ON"
- OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DBUILD_STATICALLY_LINKED_EXE=OFF"
# Run the Build script
script:
- mkdir _build
- cd _build
- cmake .. -DCMAKE_INSTALL_PREFIX=../_install $OPTIONS
- VERBOSE=1 cmake --build . --target install
# Run Tests
after_script:
- ctest -VV --output-on-failure .
# Notify the mailing list
notifications:
email:
on_success: change
on_failure: always

View File

@ -1,22 +1,3 @@
v0.12.7
- Fix pointer overflow in STRING_CAT.
- Fix a few more stack buffer overflows.
- Add license for FindPcre2 from LuaDist.
- Document and CI fixes.
v0.12.6
- Update property key, value length limits per spec change.
- Fix potential buffer overflow in ec_glob.
- CI fixes.
- Fix paths in pkg-config file with absolute CMAKE_INSTALL_*.
- Fix cross compiling for Windows.
v0.12.5
- Fix memory leak in editorconfig_parse() which would occur if no .editorconfig is found.
v0.12.4
- Add Windows build scripts.

View File

@ -29,7 +29,7 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_policy(VERSION 3.5.1)
project(editorconfig VERSION "0.12.7" LANGUAGES C)
project(editorconfig VERSION "0.12.5" LANGUAGES C)
set(PROJECT_VERSION_SUFFIX "")
@ -52,7 +52,7 @@ add_custom_target(uninstall
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# package target
set(HOME_URL "https://editorconfig.org")
set(HOME_URL "http://editorconfig.org")
set(MAILING_LIST "editorconfig@googlegroups.com")
set(CPACK_PACKAGE_VENDOR "EditorConfig Team")

View File

@ -20,8 +20,8 @@
FIND_PATH(PCRE2_INCLUDE_DIR NAMES pcre2.h)
# Look for the library.
FIND_LIBRARY(PCRE2_LIBRARY_RELEASE NAMES pcre2-8 pcre2-8-static)
FIND_LIBRARY(PCRE2_LIBRARY_DEBUG NAMES pcre2-8d pcre2-8-staticd)
FIND_LIBRARY(PCRE2_LIBRARY_RELEASE NAMES pcre2-8)
FIND_LIBRARY(PCRE2_LIBRARY_DEBUG NAMES pcre2-8d)
# Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)

View File

@ -1,6 +1,5 @@
Contributors to EditorConfig C Core:
Hong Xu
Ralf Habacker
Trey Hunner
William Swanson

View File

@ -14,8 +14,6 @@ Debian (Jessie and later): `apt-get install editorconfig`
ArchLinux: `pacman -S editorconfig-core-c`
Fedora: `dnf install editorconfig`
Mac OS X users can `brew install editorconfig` with [Homebrew](http://brew.sh).
Generally Linux users can also install with [LinuxBrew](https://github.com/Homebrew/linuxbrew)
by `brew install editorconfig`.
@ -99,7 +97,7 @@ these libraries could be executed properly.
Automated Build on Windows
==========================
Requirements on Windows are [Visual Studio] 2015, 2017, 2019 or 2022, [cmake] 2.8.12 or higher and Powershell 3 or higher. For Visual Studio the community edition is sufficient, but the [C++ workload](https://docs.microsoft.com/en-us/cpp/build/vscpp-step-0-installation?view=vs-2017) is required.
Requirements on Windows are [Visual Studio] 2013, 2015 or 2017, [cmake] 2.8.12 or higher and Powershell 3 or higher. For Visual Studio the community edition is sufficient, but the [C++ workload](https://docs.microsoft.com/en-us/cpp/build/vscpp-step-0-installation?view=vs-2017) is required.
Non-static build is currently not supported.
@ -109,7 +107,7 @@ Download pcre2
You have to download and extract the pcre2 sources after checkout.
```powershell
~> ./init.ps1 [-pcre "10.40"]
~> ./init.ps1 [-pcre 10.32]
```
Arguments:
@ -130,7 +128,7 @@ The `-install` argument will put the binaries to a location (`bin/$(ARCH)-static
For the other arguments please see below.
```powershell
~> ./build.ps1 [-proj all | core | pcre2] [-init] [-install] [-vsver 17 | 16 | 15 | 14 ] [-arch x64 | x86 | arm64] [-config Release | Debug]
~> ./build.ps1 [-proj all | core | pcre2] [-init] [-install] [-vsver 15 | 14 | 12] [-arch x64 | x86] [-config Release | Debug]
```
Arguments:
@ -159,7 +157,7 @@ Arguments:
On Windows the test `utf_8_char` is disabled.
```powershell
~> ./test.ps1 [-arch x64 | x86 | arm64] [-config Release | Debug]
~> ./test.ps1 [-arch x64 | x86] [-config Release | Debug]
```
Arguments:

40
LICENSE
View File

@ -28,43 +28,3 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Third Party
===========
CMake_Modules/FindPCRE2.cmake
LuaDist License
---------------
LuaDist is licensed under the terms of the MIT license reproduced below.
This means that LuaDist is free software and can be used for both academic
and commercial purposes at absolutely no cost.
Modules and Lua bindings contained in "dist" packages have their
individual copyright.
===============================================================================
Copyright (C) 2007-2010 LuaDist.
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
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================================================

View File

@ -1,8 +1,7 @@
[EditorConfig][]
================
[![GitHub release](https://img.shields.io/github/release/editorconfig/editorconfig-core-c.svg)](../../releases/latest)
[![Build Status](https://github.com/editorconfig/editorconfig-core-c/actions/workflows/CI_build.yml/badge.svg)](https://github.com/editorconfig/editorconfig-core-c/actions/workflows/CI_build.yml)
[![Build Status](https://secure.travis-ci.org/editorconfig/editorconfig-core-c.svg?branch=master)](http://travis-ci.org/editorconfig/editorconfig-core-c)
[![Build status](https://ci.appveyor.com/api/projects/status/u9t8m4uech5kejoi/branch/master?svg=true)](https://ci.appveyor.com/project/xuhdev/editorconfig-core-c/branch/master)
EditorConfig makes it easy to maintain the correct coding style when switching

View File

@ -1,19 +1,18 @@
image:
- Visual Studio 2022
- Visual Studio 2017
environment:
CONFIG: Release
VSVER: 17
VSVER: 15
matrix:
- ARCH: x86
- ARCH: x64
#- ARCH: arm64
install:
- cmake --version
- git submodule update --init
# Download PCRE2 sources
- ps: ./init.ps1 -pcre "10.40"
- ps: ./init.ps1 -pcre 10.32
# Build and install PCRE2
- ps: ./build.ps1 -proj pcre2 -config $env:CONFIG -arch $env:ARCH -vsver $env:VSVER -init -install
@ -27,5 +26,4 @@ test_script:
on_failure:
- echo. && echo. && echo. && echo "Tests for editorconfig-core-c failed. Here is their detailed output:" && echo. && echo. && echo.
- cd .\bin\%ARCH%-static\core\Testing\Temporary\
- type LastTest.log
- type .\bin\x64-static\core\Testing\Temporary\LastTest.log

View File

@ -12,11 +12,11 @@ param(
[ValidateSet("Debug","Release")]
[string] $config = "Release",
[ValidateSet("x86","x64","arm64")]
[ValidateSet("x86","x64")]
[string] $arch = "x64",
[ValidateSet("17","16","15","14")]
[ValidateSet("15","14","12")]
[int] $vsver = 15
)
@ -48,8 +48,8 @@ function exec
}
if ($proj -eq "all"){
.\build.ps1 -proj pcre2 -init:$init -install:$install -vsver $vsver -arch $arch -config $config -static $static
.\build.ps1 -proj core -init:$init -install:$install -vsver $vsver -arch $arch -config $config -static $static
.\build.ps1 -proj pcre2 -init:$init -install:$install -arch $arch -config $config -static $static
.\build.ps1 -proj core -init:$init -install:$install -arch $arch -config $config -static $static
return
}
@ -75,12 +75,6 @@ if ($init) {
$gen = "Visual Studio "
switch ($vsver) {
17 {
$gen += "17 2022"
}
16 {
$gen += "16 2019"
}
15 {
$gen += "15 2017"
}
@ -95,15 +89,8 @@ if ($init) {
}
}
$cmake_arch=""
if($arch -eq "x64"){
$cmake_arch += "x64"
}
elseif($arch -eq "x86"){
$cmake_arch += "Win32"
}
elseif($arch -eq "arm64"){
$cmake_arch += "ARM64"
$gen += " Win64"
}
mkdir $dest -ErrorAction SilentlyContinue | Out-Null
@ -113,14 +100,14 @@ if ($init) {
pcre2 {
$BUILD_SHARED_LIBS = "ON"
if ($static -eq "ON"){ $BUILD_SHARED_LIBS = "OFF"}
exec { cmake -G "$gen" -A $cmake_arch -DCMAKE_INSTALL_PREFIX="$PREFIX" -DPCRE2_STATIC_RUNTIME="$static" `
exec { cmake -G "$gen" -DCMAKE_INSTALL_PREFIX="$PREFIX" -DPCRE2_STATIC_RUNTIME="$static" `
-DBUILD_SHARED_LIBS="$BUILD_SHARED_LIBS" -DPCRE2_BUILD_PCRE2GREP="OFF" -DPCRE2_BUILD_TESTS="OFF" `
"../../pcre2" }
}
core {
$MSVC_MD = "ON"
if ($static -eq "ON"){ $MSVC_MD = "OFF"}
exec { cmake -G "$gen" -A $cmake_arch -DCMAKE_INSTALL_PREFIX="$PREFIX" -DMSVC_MD="$MSVC_MD" -DPCRE2_STATIC="$static" `
exec { cmake -G "$gen" -DCMAKE_INSTALL_PREFIX="$PREFIX" -DMSVC_MD="$MSVC_MD" -DPCRE2_STATIC="$static" `
"../../../." }
}
}

View File

@ -125,7 +125,7 @@ if(BUILD_DOCUMENTATION)
if(INSTALL_HTML_DOC)
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html"
DESTINATION "${CMAKE_INSTALL_DOCDIR}")
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/editorconfig")
endif(INSTALL_HTML_DOC)
else(DOXYGEN_FOUND)

File diff suppressed because it is too large Load Diff

View File

@ -72,13 +72,13 @@
* @endhtmlonly
* @manonly
*
* \-f Specify conf filename other than ".editorconfig".
* -f Specify conf filename other than ".editorconfig".
*
* \-b Specify version (used by devs to test compatibility).
* -b Specify version (used by devs to test compatibility).
*
* \-h OR \-\-help Print this help message.
* -h OR --help Print this help message.
*
* \-\-version Display version information.
* --version Display version information.
*
* @endmanonly
*
@ -181,7 +181,7 @@
* <li><strong>tab_width</strong>: a whole number defining the number of columns used to represent a tab character. This defaults to the value of <strong>indent_size</strong> and should not usually need to be specified.</li>
* <li><strong>end_of_line</strong>: set to "lf", "cr", or "crlf" to control how line breaks are represented. The values are case insensitive.</li>
* <li><strong>charset</strong>: set to "latin1", "utf-8", "utf-8-bom", "utf-16be" or "utf-16le" to control the character set. Use of "utf-8-bom" is discouraged.</li>
* <li><strong>trim_trailing_whitespace</strong>: set to "true" to remove any whitespace characters preceding newline characters and "false" to ensure it doesn't.</li>
* <li><strong>trim_trailing_whitespace</strong>: set to "true" to remove any whitespace characters preceeding newline characters and "false" to ensure it doesn't.</li>
* <li><strong>insert_final_newline</strong>: set to "true" ensure file ends with a newline when saving and "false" to ensure it doesn't.</li>
* <li><strong>root</strong>: special property that should be specified at the top of the file outside of any sections. Set to "true" to stop <code>.editorconfig</code> files search on current file. The value is case insensitive.</li>
* </ul>

View File

@ -1,5 +1,5 @@
param(
$pcre="10.40"
$pcre="10.32"
)
$ErrorActionPreference="Stop"
@ -14,7 +14,7 @@ New-Item $dest -ItemType Directory -ErrorAction SilentlyContinue | Out-Null
#####################################################################
# pcre
#####################################################################
$url = "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-$($pcre)/pcre2-$($pcre).zip"
$url = "https://ftp.pcre.org/pub/pcre/pcre2-$($pcre).zip"
$output = "$dest\pcre-$($pcre).zip"
"Downloading pcre2 v$pcre sources" | Write-Host -ForegroundColor DarkGreen

View File

@ -43,7 +43,7 @@ set_target_properties(editorconfig_shared PROPERTIES
# We need to link Shwapi since we use PathIsRelative
if(WIN32)
target_link_libraries(editorconfig_shared shlwapi)
target_link_libraries(editorconfig_shared Shlwapi)
endif()
target_link_libraries(editorconfig_shared ${PCRE2_LIBRARIES})
if (BUILD_STATICALLY_LINKED_EXE)
@ -62,7 +62,7 @@ set_target_properties(editorconfig_static PROPERTIES
# We need to link Shwapi since we use PathIsRelative
if(WIN32)
target_link_libraries(editorconfig_static shlwapi)
target_link_libraries(editorconfig_static Shlwapi)
endif()
target_link_libraries(editorconfig_static ${PCRE2_LIBRARIES})
@ -90,16 +90,6 @@ if(NOT BUILD_STATICALLY_LINKED_EXE)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
set(libdir_for_pc_file "${CMAKE_INSTALL_LIBDIR}")
else()
set(libdir_for_pc_file "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
endif()
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
set(includedir_for_pc_file "${CMAKE_INSTALL_INCLUDEDIR}")
else()
set(includedir_for_pc_file "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/editorconfig.pc.in
${CMAKE_CURRENT_BINARY_DIR}/editorconfig.pc

View File

@ -27,7 +27,6 @@
#include "global.h"
#include <assert.h>
#include <ctype.h>
#include <string.h>
#include <pcre2.h>
@ -52,20 +51,12 @@ static const UT_icd ut_int_pair_icd = {sizeof(int_pair),NULL,NULL,NULL};
/* concatenate the string then move the pointer to the end */
#define STRING_CAT(p, string, end) do { \
size_t string_len = strlen(string); \
assert(end > p); \
if (string_len >= (size_t)(end - p)) \
if (p + string_len >= end) \
return -1; \
strcat(p, string); \
p += string_len; \
} while(0)
/* safely add a char to a string then move the pointer to the end */
#define ADD_CHAR(string, new_chr, end) do { \
if (string + 1 >= end) \
return -1; \
*(string ++) = new_chr; \
} while(0)
#define PATTERN_MAX 4097
/*
* Whether the string matches the given glob pattern. Return 0 if successful, return -1 if a PCRE
@ -140,8 +131,8 @@ int ec_glob(const char *pattern, const char *string)
case '\\': /* also skip the next one */
if (*(c+1) != '\0')
{
ADD_CHAR(p_pcre, *(c++), pcre_str_end);
ADD_CHAR(p_pcre, *c, pcre_str_end);
*(p_pcre ++) = *(c++);
*(p_pcre ++) = *c;
}
else
STRING_CAT(p_pcre, "\\\\", pcre_str_end);
@ -194,14 +185,10 @@ int ec_glob(const char *pattern, const char *string)
if (!right_bracket) /* The right bracket may not exist */
right_bracket = c + strlen(c);
STRING_CAT(p_pcre, "\\", pcre_str_end);
/* Boundary check for strncat below. */
if (pcre_str_end - p_pcre <= right_bracket - c) {
return -1;
}
strcat(p_pcre, "\\");
strncat(p_pcre, c, right_bracket - c);
if (*right_bracket) /* right_bracket is a bracket */
STRING_CAT(p_pcre, "\\]", pcre_str_end);
strcat(p_pcre, "\\]");
p_pcre += strlen(p_pcre);
c = right_bracket;
if (!*c)
@ -221,18 +208,18 @@ int ec_glob(const char *pattern, const char *string)
++ c;
}
else
STRING_CAT(p_pcre, "[", pcre_str_end);
*(p_pcre ++) = '[';
break;
case ']':
is_in_bracket = 0;
ADD_CHAR(p_pcre, *c, pcre_str_end);
*(p_pcre ++) = *c;
break;
case '-':
if (is_in_bracket) /* in brackets, - indicates range */
ADD_CHAR(p_pcre, *c, pcre_str_end);
*(p_pcre ++) = *c;
else
STRING_CAT(p_pcre, "\\-", pcre_str_end);
@ -315,12 +302,12 @@ int ec_glob(const char *pattern, const char *string)
}
-- brace_level;
STRING_CAT(p_pcre, ")", pcre_str_end);
*(p_pcre ++) = ')';
break;
case ',':
if (brace_level > 0) /* , inside {...} */
STRING_CAT(p_pcre, "|", pcre_str_end);
*(p_pcre ++) = '|';
else
STRING_CAT(p_pcre, "\\,", pcre_str_end);
break;
@ -339,13 +326,13 @@ int ec_glob(const char *pattern, const char *string)
default:
if (!isalnum(*c))
STRING_CAT(p_pcre, "\\", pcre_str_end);
*(p_pcre ++) = '\\';
ADD_CHAR(p_pcre, *c, pcre_str_end);
*(p_pcre ++) = *c;
}
}
ADD_CHAR(p_pcre, '$', pcre_str_end);
*(p_pcre ++) = '$';
pcre2_code_free(re); /* ^\\d+\\.\\.\\d+$ */

View File

@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=@libdir_for_pc_file@
includedir=@includedir_for_pc_file@
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: editorconfig
Description: Library handling EditorConfig files, a file format defining coding styles in projects.

View File

@ -78,8 +78,8 @@ int ini_parse_file(FILE* file,
#endif
#define MAX_SECTION_NAME 4096
#define MAX_PROPERTY_NAME 1024
#define MAX_PROPERTY_VALUE 4096
#define MAX_PROPERTY_NAME 50
#define MAX_PROPERTY_VALUE 255
/* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
the file. See http://code.google.com/p/inih/issues/detail?id=21 */

View File

@ -28,7 +28,7 @@
#include "misc.h"
#ifdef WIN32
# include <shlwapi.h>
# include <Shlwapi.h>
#endif
#if !defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP)

View File

@ -8,7 +8,7 @@ param(
[ValidateSet("Debug","Release")]
[string] $config = "Release",
[ValidateSet("x86","x64","arm64")]
[ValidateSet("x86","x64")]
[string] $arch = "x64"
)