diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml deleted file mode 100644 index 45e6142..0000000 --- a/.github/workflows/cmake.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: CMake - -on: - push: - branches: [ develop ] - pull_request: - branches: [ develop ] - -jobs: - build: - name: ${{ matrix.config.name }} - runs-on: ${{ matrix.config.os }} - strategy: - fail-fast: false - matrix: - config: - - { - name: "Ubuntu", - os: ubuntu-latest, - build_type: RelWithDebInfo, - build_testing: "On", - gtk_tsm: "On" - } - - { - name: "macOS", - os: macos-latest, - build_type: RelWithDebInfo, - build_testing: "Off", - gtk_tsm: "Off" - } - - steps: - - uses: actions/checkout@v2 - - - name: Print env - run: | - echo github.event.action: ${{ github.event.action }} - echo github.event_name: ${{ github.event_name }} - - - name: Install dependencies on Ubuntu - if: startsWith(matrix.config.name, 'Ubuntu') - run: sudo apt-get install -y check valgrind libgtk-3-dev libpango1.0-dev pkg-config - - - name: Install dependencies on macOS - if: startsWith(matrix.config.name, 'macOS') - run: brew install check - - - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ./build -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DBUILD_TESTING=${{ matrix.config.build_testing}} -DBUILD_GTKTSM=${{ matrix.config.gtk_tsm }} - - - name: Build - # Build your program with the given configuration - run: cmake --build ./build --config ${{ matrix.config.build_type }} - - - name: Test - working-directory: ./build - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C ${{ matrix.config.build_type }} - diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml new file mode 100644 index 0000000..33c29f7 --- /dev/null +++ b/.github/workflows/meson.yml @@ -0,0 +1,55 @@ +name: Meson + +on: + push: + branches: [ develop ] + pull_request: + branches: [ develop ] + +jobs: + build: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: + - { + name: "Ubuntu", + os: ubuntu-latest, + tests: "true", + gtk_tsm: "true" + } + - { + name: "macOS", + os: macos-latest, + tests: "true", + gtk_tsm: "false" + } + + steps: + - uses: actions/checkout@v3 + - name: Print env + run: | + echo github.event.action: ${{ github.event.action }} + echo github.event_name: ${{ github.event_name }} + + - name: Install dependencies on Ubuntu + if: startsWith(matrix.config.name, 'Ubuntu') + run: sudo apt-get update && sudo apt-get install -y meson check valgrind libgtk-3-dev libpango1.0-dev pkg-config + + - name: Install dependencies on macOS + if: startsWith(matrix.config.name, 'macOS') + run: brew install check meson ninja + + - name: Configure Meson + run: meson setup -Dtests=${{matrix.config.tests}} -Dgtktsm=${{matrix.config.gtk_tsm}} -Dextra_debug=true build + + - name: Build + working-directory: ./build + run: meson compile + + - name: Test + working-directory: ./build + run: meson test + diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index c53cdeb..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,184 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -project(libtsm - LANGUAGES C - VERSION 4.1.0 -) - -# Some meta data -## TODO: merge into project above after we require cmake 3.12 -set(PROJECT_HOMEPAGE_URL "https://github.com/Aetf/libtsm") -## TODO: merge into project above after we require cmake 3.10 -set(PROJECT_DESCRIPTION "terminal-emulator state machine") - -#--------------------------------------------------------------------------------------- -# Initial setups -#--------------------------------------------------------------------------------------- -# Ensure out-of-source build -if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) - message(FATAL_ERROR "Usage: mkdir build; cmake ..") -endif() - -# Include utilities -include(cmake/Utilities.cmake) -include(cmake/JoinPaths.cmake) -# For feature_summary -include(FeatureSummary) - -# Extra build types -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() -include(cmake/BuildTypes.cmake) - -#--------------------------------------------------------------------------------------- -# Options -#--------------------------------------------------------------------------------------- -option(BUILD_SHARED_LIBS "Build as shared libraries" ON) -add_feature_info(BUILD_SHARED_LIBS BUILD_SHARED_LIBS "build as shared libraries") - -option(BUILD_TESTING "Whether to build test suite in default target" OFF) -add_feature_info(BUILD_TESTING BUILD_TESTING "build unit tests") - -# We enable a lot of debug options by default, so this option is really only for -# extended developer debug modes. -option(ENABLE_EXTRA_DEBUG "Whether to enable several non-standard debug options." OFF) -add_feature_info(ENABLE_EXTRA_DEBUG ENABLE_EXTRA_DEBUG "enable additional non-standard debug options") - -# Whether to our gtktsm example. This is linux-only as it uses epoll and friends. -# Therefore, it's disabled by default. -option(BUILD_GTKTSM "Whether to build the gtktsm example" OFF) -add_feature_info(BUILD_GTKTSM BUILD_GTKTSM "build the gtktsm example, it requires gtk+-3 and friends and is linux-only.") - -#--------------------------------------------------------------------------------------- -# Find packages -#--------------------------------------------------------------------------------------- -# Additional find modules -list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules) - -# GNU filesystem layout -include(GNUInstallDirs) - -# We need xkbcommon for keysym definitions. If it's not found, we use our own -# private copy of xkbcommon-keysyms.h. -find_package(XKBCommon COMPONENTS KeySyms) -set_package_properties(XKBCommon PROPERTIES - TYPE OPTIONAL - PURPOSE "Needed for keysym definitions. Will use private copy if not found." -) - -# Optionally, look for gtk+-3 and friends for gtktsm -if(BUILD_GTKTSM) - find_package(GTK3) - set_package_properties(GTK3 PROPERTIES - TYPE REQUIRED - PURPOSE "For gtktsm example" - ) - - find_package(Cairo) - set_package_properties(Cairo PROPERTIES - TYPE REQUIRED - PURPOSE "For gtktsm example" - ) - - find_package(Pango) - set_package_properties(Pango PROPERTIES - TYPE REQUIRED - PURPOSE "For gtktsm example" - ) - - find_package(PangoCairo) - set_package_properties(PangoCairo PROPERTIES - TYPE REQUIRED - PURPOSE "For gtktsm example" - ) - - find_package(XKBCommon COMPONENTS XKBCommon) - set_package_properties(XKBCommon PROPERTIES - TYPE REQUIRED - PURPOSE "For gtktsm example" - ) -endif() - -if(BUILD_TESTING) - enable_testing() - find_package(Check) - set_package_properties(Check PROPERTIES - TYPE REQUIRED - PURPOSE "For testing" - ) -endif() - -feature_summary(INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES WHAT ALL) - -#--------------------------------------------------------------------------------------- -# Set compiler options and features -#--------------------------------------------------------------------------------------- -# Only set compile options after any inclusion of third party code -include(cmake/CompileOptions.cmake) - -# Pass infomation to config header -if(XKBCommon_KeySyms_FOUND) - set(BUILD_HAVE_XKBCOMMON ON) -endif() -if(ENABLE_EXTRA_DEBUG) - set(BUILD_ENABLE_DEBUG ON) -endif(ENABLE_EXTRA_DEBUG) -configure_file(src/config.h.in ${CMAKE_BINARY_DIR}/config.h) -include_directories(${CMAKE_BINARY_DIR}) - -#--------------------------------------------------------------------------------------- -# Put code together -#--------------------------------------------------------------------------------------- -# Venderoized external code -add_subdirectory(external) - -add_subdirectory(src) - -if(BUILD_TESTING) - add_subdirectory(test) -endif(BUILD_TESTING) - -#--------------------------------------------------------------------------------------- -# Installation of other files -#--------------------------------------------------------------------------------------- -# pkgconfig file for backward compatibility -join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}") -join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") -configure_file(etc/libtsm.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libtsm.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtsm.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - -#Export the targets to a script -set(INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/libtsm) -install(EXPORT tsm-targets - FILE - libtsm-targets.cmake - NAMESPACE - libtsm:: - DESTINATION - ${INSTALL_CMAKEDIR} -) - -#Create a ConfigVersion.cmake file -include(CMakePackageConfigHelpers) -write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/libtsm-config-version.cmake - COMPATIBILITY SameMajorVersion -) - -configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/etc/libtsm-config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/libtsm-config.cmake - PATH_VARS - INSTALL_CMAKEDIR - INSTALL_DESTINATION - ${INSTALL_CMAKEDIR} - NO_CHECK_REQUIRED_COMPONENTS_MACRO -) - -#Install the config, configversion and custom find modules -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/libtsm-config-version.cmake - ${CMAKE_CURRENT_BINARY_DIR}/libtsm-config.cmake - DESTINATION ${INSTALL_CMAKEDIR} -) diff --git a/README.md b/README.md index f2ba0a4..b6230cf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # TSM - Terminal Emulator State Machine -[![Build Status](https://travis-ci.com/Aetf/libtsm.svg?branch=master)](https://travis-ci.com/Aetf/libtsm) +![Build Status](https://github.com/aetf/libtsm/actions/workflows/meson.yml/badge.svg?branch=develop) TSM is a state machine for DEC VT100-VT520 compatible terminal emulators. It tries to support all common standards while keeping compatibility to existing @@ -19,44 +19,40 @@ This is a personal modified version. For more information, please refer to its o + Support Ctrl + Arrow keys + Support custom title using OSC + Bug fixes: - * [Repsonse to 'CSI c' contains random bytes][91335] + * [Response to 'CSI c' contains random bytes][91335] * [Fix invalid cpr values](https://github.com/Aetf/libtsm/pull/2) [91335]: https://bugs.freedesktop.org/show_bug.cgi?id=91335 ## Build ```bash -mkdir build && cd build -cmake .. -make -make install +meson setup build +cd build +meson compile +meson install ``` ### Build options -Options may be supplied when configuring cmake: +Options may be supplied when configuring meson: ```bash -cmake -DOPTION1=VALUE1 -DOPTION2=VALUE2 .. +meson -Dtests=true -Dextra_debug=true -Dgtktsm=true ``` The following options are available: |Name | Description | Default | |:---:|:---|:---:| -| BUILD_SHARED_LIBS | Whether to build as a shared library | ON | -| BUILD_TESTING | Whether to build test suits | OFF | -| ENABLE_EXTRA_DEBUG | Whether to enable several non-standard debug options. | OFF | -| BUILD_GTKTSM | Whether to build the gtktsm example. This is linux-only as it uses epoll and friends. Therefore is disabled by default. | OFF | - -### Dependencies - -- [cmake](https://cmake.org) >= 3.5 +| tests | Whether build the test suite | ON | +| extra_debug | Whether to enable several non-standard debug options | OFF | +| gtktsm | Whether to build the gtktsm example. This is linux-only as it uses epoll and friends. Therefor is disabled by default. | OFF | + +## Dependencies +### Required +- [meson](https://mesonbuild.com) >= 3.5 +### Optional - `xkbcommon-keysyms.h` from xkbcommon (Optional. Will use private copy if not found.) - -The test suits needs: - -- [check](https://libcheck.github.io/check/) >= 0.9.10 - -The gtktsm example needs: - +## Test suite +- [check](https://libcheck.github.io/check/) >= 0.9.10 (For the test suite) +## Gtktsm - gtk3 - cairo - pango diff --git a/ci.ctest b/ci.ctest deleted file mode 100644 index 3c1177c..0000000 --- a/ci.ctest +++ /dev/null @@ -1,63 +0,0 @@ -set(CTEST_PROJECT_NAME libtsm) - -set(CTEST_SOURCE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) -set(CTEST_BINARY_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/build/ctest") - -set(CTEST_CMAKE_GENERATOR "Unix Makefiles") - -set(ENV{CK_FORK} "no") -find_program(VALGRIND valgrind) -if(NOT VALGRIND) - message(FATAL_ERROR "valgrind is required for memcheck") -endif() -set(CTEST_MEMORYCHECK_COMMAND "${VALGRIND}") -string(CONCAT CTEST_MEMORYCHECK_COMMAND_OPTIONS - " --tool=memcheck" - " --leak-check=yes" - " --show-reachable=yes" - " --leak-resolution=high" - " --error-exitcode=1" -) -set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "${CTEST_SOURCE_DIRECTORY}/etc/test.supp") - -function(print_section name) - message(STATUS "********************") - message(STATUS "${name}") - message(STATUS "********************") -endfunction() - -# -# Start the tests -# -ctest_start("Continuous") - -print_section("Configuring project") -ctest_configure(OPTIONS "-DBUILD_TESTING=ON;-DBUILD_GTKTSM=ON" RETURN_VALUE ret) -if(NOT ${ret} EQUAL 0) - message(FATAL_ERROR "Configure step failed with ${ret}") -endif() - -print_section("Building project") -ctest_build(RETURN_VALUE ret) -if(NOT ${ret} EQUAL 0) - message(FATAL_ERROR "Build step failed with ${ret}") -endif() - -print_section("Running tests") -ctest_test(RETURN_VALUE ret) -if(NOT ${ret} EQUAL 0) - message(FATAL_ERROR "Tests step failed with ${ret}") -endif() - -# First make sure valgrind works -print_section("Making sure valgrind works") -ctest_memcheck(INCLUDE_LABEL "memcheck-xfail" RETURN_VALUE ret) -if(${ret} EQUAL 0) - message(FATAL_ERROR "Valgrind may not work correctly. Expected failed test got passed.") -endif() - -print_section("Running memcheck") -ctest_memcheck(EXCLUDE_LABEL "memcheck-xfail" RETURN_VALUE ret) -if(NOT ${ret} EQUAL 0) - message(FATAL_ERROR "Memcheck step failed with ${ret}") -endif() diff --git a/cmake/BuildTypes.cmake b/cmake/BuildTypes.cmake deleted file mode 100644 index e90d8f8..0000000 --- a/cmake/BuildTypes.cmake +++ /dev/null @@ -1,64 +0,0 @@ -# Add new build types for sanitizer and profiler -# Address sanitizer and undefined beheavior sanitizer -set(CMAKE_CXX_FLAGS_ASAN "-g -O1 -fno-omit-frame-pointer -fsanitize=address" - CACHE STRING "Flags used by the C++ compiler during ASan builds." FORCE) - -set(CMAKE_C_FLAGS_ASAN "${CMAKE_CXX_FLAGS_ASAN}" - CACHE STRING "Flags used by the C compiler during ASan builds." FORCE) - -set(CMAKE_EXE_LINKER_FLAGS_ASAN "-fsanitize=address" - CACHE STRING "Flags used for linking binaries during ASan builds." FORCE) - -set(CMAKE_SHARED_LINKER_FLAGS_ASAN "-fsanitize=address" - CACHE STRING "Flags used by the shared libraries linker during ASan builds." FORCE) - -# Thread sanitizer -set(CMAKE_CXX_FLAGS_TSAN "-DNDEBUG -g -O0 -fno-omit-frame-pointer -fsanitize=thread" - CACHE STRING "Flags used by the C++ compiler during TSan builds." FORCE) - -set(CMAKE_C_FLAGS_TSAN "${CMAKE_CXX_FLAGS_TSAN}" - CACHE STRING "Flags used by the C compiler during TSan builds." FORCE) - -set(CMAKE_EXE_LINKER_FLAGS_TSAN "-fsanitize=thread" - CACHE STRING "Flags used for linking binaries during TSan builds." FORCE) - -set(CMAKE_SHARED_LINKER_FLAGS_TSAN "-fsanitize=thread" - CACHE STRING "Flags used by the shared libraries linker during TSan builds." FORCE) - -# Memory sanitizer -set(CMAKE_CXX_FLAGS_MSAN "-DNDEBUG -g -O1 -fno-omit-frame-pointer -fsanitize=memory" - CACHE STRING "Flags used by the C++ compiler during MSan builds." FORCE) - -set(CMAKE_C_FLAGS_MSAN "${CMAKE_CXX_FLAGS_MSAN}" - CACHE STRING "Flags used by the C compiler during MSan builds." FORCE) - -set(CMAKE_EXE_LINKER_FLAGS_MSAN "-fsanitize=memory" - CACHE STRING "Flags used for linking binaries during MSan builds." FORCE) - -set(CMAKE_SHARED_LINKER_FLAGS_MSAN "-fsanitize=memory" - CACHE STRING "Flags used by the shared libraries linker during MSan builds." FORCE) - -set(KNOWN_BUILD_TYPES "") -foreach(build IN ITEMS ASan TSan MSan) - string(TOUPPER ${build} build_upper) - mark_as_advanced( - CMAKE_CXX_FLAGS_${build_upper} - CMAKE_C_FLAGS_${build_upper} - CMAKE_EXE_LINKER_FLAGS_${build_upper} - CMAKE_SHARED_LINKER_FLAGS_${build_upper} - ) - list(APPEND KNOWN_BUILD_TYPES ${build}) -endforeach() -list(APPEND KNOWN_BUILD_TYPES Debug Release RelWithDebInfo MinSizeRel) - -if (NOT CMAKE_BUILD_TYPE IN_LIST KNOWN_BUILD_TYPES) - message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}. Choices are ${KNOWN_BUILD_TYPES}") -endif() - -# Update the documentation string of CMAKE_BUILD_TYPE for GUIs -set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" - CACHE STRING - "Choose the type of build, options are: None;${KNOWN_BUILD_TYPES}." - FORCE) - -message(STATUS "Using build type: ${CMAKE_BUILD_TYPE}") diff --git a/cmake/CompileOptions.cmake b/cmake/CompileOptions.cmake deleted file mode 100644 index 8c2d2ad..0000000 --- a/cmake/CompileOptions.cmake +++ /dev/null @@ -1,92 +0,0 @@ -# Set compiler flags -set(CMAKE_C_STANDARD 99) -set(CMAKE_C_STANDARD_REQUIRED ON) - -# analogous to AC_USE_SYSTEM_EXTENSIONS in configure.ac -add_definitions(-D_POSIX_C_SOURCE=199309L -D_GNU_SOURCE) - -# copied from Autoconf's AC_SYS_LARGEFILE -if(NOT WIN32) - add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE) -endif(NOT WIN32) - -if(APPLE) - add_compile_definitions(_DARWIN_C_SOURCE) - link_directories("/usr/local/lib") - include_directories("external") -endif() - -# Set compiler flags for warnings -if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - # using Clang or AppleClang - - # reasonable and standard - add_compile_options_with_check(-Weverything) - add_compile_options_with_check(-Werror) - add_compile_options_with_check(-Wfatal-errors) - - add_compile_options_with_check(-Wold-style-cast) - # helps catch hard to track down memory errors - add_compile_options_with_check(-Wnon-virtual-dtor) - # warn for potential performance problem casts - add_compile_options_with_check(-Wcast-align) - # warn if you overload (not override) a virtual function - add_compile_options_with_check(-Woverloaded-virtual) -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - # using GCC - - # reasonable and standard - add_compile_options_with_check(-Wall) - add_compile_options_with_check(-Wextra) - add_compile_options_with_check(-pedantic) - add_compile_options_with_check(-Werror) - #add_compile_options_with_check(-Wfatal-errors) - - add_compile_options_with_check(-Wold-style-cast) - # helps catch hard to track down memory errors - add_compile_options_with_check(-Wnon-virtual-dtor) - # warn for potential performance problem casts - add_compile_options_with_check(-Wcast-align) - # warn if you overload (not override) a virtual function - add_compile_options_with_check(-Woverloaded-virtual) -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") - # using Intel C++ - message(WARNING "Using of Intel C++ is not supported, you are on your own.") -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # using Visual Studio C++ - - # all reasonable warnings - add_compile_options_with_check(/W4) - # treat warnings as errors - add_compile_options_with_check(/Wx) - # enable warning on thread un-safe static member initialization - add_compile_options_with_check(/W44640) -endif() - -# Other flags are not added directly globally, but using a function -# so later when defining targets, it can be set per target -function(add_libtsm_compile_options target) - # Make all files include "config.h" by default. This shouldn't cause any - # problems and we cannot forget to include it anymore. - target_compile_options(${target} PRIVATE - -include ${CMAKE_BINARY_DIR}/config.h - -pipe - -fno-common - -ffast-math - -fno-strict-aliasing - -ffunction-sections - -fdata-sections - ) - - # Linker flags - ## Make the linker discard all unused symbols. - if(APPLE) - set(LDFLAGS "-Wl,-dead_strip -Wl,-dead_strip_dylibs -Wl") - elseif(UNIX) - set(LDFLAGS "-Wl,--as-needed -Wl,--gc-sections -Wl,-z,relro -Wl,-z,now") - else() - message("Unsupported platform, you are on your own.") - endif() - - set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS " ${LDFLAGS}") -endfunction() diff --git a/cmake/JoinPaths.cmake b/cmake/JoinPaths.cmake deleted file mode 100644 index c68d91b..0000000 --- a/cmake/JoinPaths.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# This module provides function for joining paths -# known from most languages -# -# SPDX-License-Identifier: (MIT OR CC0-1.0) -# Copyright 2020 Jan Tojnar -# https://github.com/jtojnar/cmake-snips -# -# Modelled after Python’s os.path.join -# https://docs.python.org/3.7/library/os.path.html#os.path.join -# Windows not supported -function(join_paths joined_path first_path_segment) - set(temp_path "${first_path_segment}") - foreach(current_segment IN LISTS ARGN) - if(NOT ("${current_segment}" STREQUAL "")) - if(IS_ABSOLUTE "${current_segment}") - set(temp_path "${current_segment}") - else() - set(temp_path "${temp_path}/${current_segment}") - endif() - endif() - endforeach() - set(${joined_path} "${temp_path}" PARENT_SCOPE) -endfunction() diff --git a/cmake/Utilities.cmake b/cmake/Utilities.cmake deleted file mode 100644 index 42c68a9..0000000 --- a/cmake/Utilities.cmake +++ /dev/null @@ -1,287 +0,0 @@ -include(CheckCCompilerFlag) - -# -# Check compiler flag support with cached support. -# Shadows the internal check_c_compiler_flag -# -macro(libtsm_check_c_compiler_flag flag retvar) - string(REPLACE "-" "_" cache_name "COMPILER_SUPPORT_${flag}") - check_c_compiler_flag(${flag} ${cache_name}) - set(${retvar} ${cache_name}) -endmacro() - -# Add a global default compile option -function(add_compile_options_with_check flag) - libtsm_check_c_compiler_flag(${flag} ret) - if(${ret}) - add_compile_options(${flag}) - endif() -endfunction() - -# Add a new private compile option to a target -function(target_compile_options_with_check target flag) - libtsm_check_c_compiler_flag(${flag} ret) - if(${ret}) - target_compile_options(${target} PRIVATE ${flag}) - endif() -endfunction() - -# Add compile option to a build type with check -function(build_type_add_compile_option_with_check buildtype flag) - libtsm_check_c_compiler_flag(${flag} ret) - if(${ret}) - set(CMAKE_CXX_FLAGS_${buildtype} "${CMAKE_CXX_FLAGS_${buildtype}}" ${flag}) - endif() -endfunction() - -# Print all properties for a target -# From https://stackoverflow.com/questions/32183975/how-to-print-all-the-properties-of-a-target-in-cmake -# -# Get all propreties that cmake supports -execute_process(COMMAND cmake --help-property-list OUTPUT_VARIABLE CMAKE_PROPERTY_LIST) -# Convert command output into a CMake list -string(REGEX REPLACE ";" "\\\\;" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}") -string(REGEX REPLACE "\n" ";" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}") -list(REMOVE_DUPLICATES CMAKE_PROPERTY_LIST) - -function(print_properties) - message ("CMAKE_PROPERTY_LIST = ${CMAKE_PROPERTY_LIST}") -endfunction(print_properties) - -function(print_target_properties tgt) - if(NOT TARGET ${tgt}) - message("There is no target named '${tgt}'") - return() - endif() - - foreach (prop ${CMAKE_PROPERTY_LIST}) - string(REPLACE "" "${CMAKE_BUILD_TYPE}" prop ${prop}) - # Fix https://stackoverflow.com/questions/32197663/how-can-i-remove-the-the-location-property-may-not-be-read-from-target-error-i - if(prop STREQUAL "LOCATION" OR prop MATCHES "^LOCATION_" OR prop MATCHES "_LOCATION$") - continue() - endif() - # message ("Checking ${prop}") - get_property(propval TARGET ${tgt} PROPERTY ${prop} SET) - if (propval) - get_target_property(propval ${tgt} ${prop}) - message ("${tgt} ${prop} = ${propval}") - endif() - endforeach(prop) -endfunction(print_target_properties) - -# A simpler version to parse package components -# Copied from extra-cmake-modules -macro(find_package_parse_components module_name) - set(fppc_options) - set(fppc_oneValueArgs RESULT_VAR) - set(fppc_multiValueArgs KNOWN_COMPONENTS DEFAULT_COMPONENTS) - cmake_parse_arguments(FPPC "${fppc_options}" "${fppc_oneValueArgs}" "${fppc_multiValueArgs}" ${ARGN}) - - if(FPPC_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unexpected arguments to find_package_parse_components: ${FPPC_UNPARSED_ARGUMENTS}") - endif() - if(NOT FPPC_RESULT_VAR) - message(FATAL_ERROR "Missing RESULT_VAR argument to find_package_parse_components") - endif() - if(NOT FPPC_KNOWN_COMPONENTS) - message(FATAL_ERROR "Missing KNOWN_COMPONENTS argument to find_package_parse_components") - endif() - if(NOT FPPC_DEFAULT_COMPONENTS) - set(FPPC_DEFAULT_COMPONENTS ${FPPC_KNOWN_COMPONENTS}) - endif() - - if(${module_name}_FIND_COMPONENTS) - set(fppc_requestedComps ${${module_name}_FIND_COMPONENTS}) - - list(REMOVE_DUPLICATES fppc_requestedComps) - - # This makes sure components are listed in the same order as - # KNOWN_COMPONENTS (potentially important for inter-dependencies) - set(${FPPC_RESULT_VAR}) - foreach(fppc_comp ${FPPC_KNOWN_COMPONENTS}) - list(FIND fppc_requestedComps "${fppc_comp}" fppc_index) - if(NOT "${fppc_index}" STREQUAL "-1") - list(APPEND ${FPPC_RESULT_VAR} "${fppc_comp}") - list(REMOVE_AT fppc_requestedComps ${fppc_index}) - endif() - endforeach() - # if there are any left, they are unknown components - if(fppc_requestedComps) - set(fppc_msgType STATUS) - if(${module_name}_FIND_REQUIRED) - set(fppc_msgType FATAL_ERROR) - endif() - if(NOT ${module_name}_FIND_QUIETLY) - message(${fppc_msgType} "${module_name}: requested unknown components ${fppc_requestedComps}") - endif() - return() - endif() - else() - set(${FPPC_RESULT_VAR} ${FPPC_DEFAULT_COMPONENTS}) - endif() -endmacro() - -# -# Creates an imported library target for each component. See ECM's documentation for usage. -# -# This version addtionally treats empty __lib variable as an indication for interface only library -# -# The following additionall keyword arguments are accepted: -# NAMESPACE - The namespace to use for the imported target, default to -# -macro(find_package_handle_library_components module_name) - set(fphlc_options SKIP_PKG_CONFIG SKIP_DEPENDENCY_HANDLING) - set(fphlc_oneValueArgs NAMESPACE) - set(fphlc_multiValueArgs COMPONENTS) - cmake_parse_arguments(FPHLC "${fphlc_options}" "${fphlc_oneValueArgs}" "${fphlc_multiValueArgs}" ${ARGN}) - - if(FPHLC_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unexpected arguments to find_package_handle_components: ${FPHLC_UNPARSED_ARGUMENTS}") - endif() - if(NOT FPHLC_COMPONENTS) - message(FATAL_ERROR "Missing COMPONENTS argument to find_package_handle_components") - endif() - - if(NOT FPHLC_NAMESPACE) - set(FPHLC_NAMESPACE ${module_name}) - endif() - - include(FindPackageHandleStandardArgs) - find_package(PkgConfig QUIET) - foreach(fphlc_comp ${FPHLC_COMPONENTS}) - set(fphlc_dep_vars) - set(fphlc_dep_targets) - if(NOT SKIP_DEPENDENCY_HANDLING) - foreach(fphlc_dep ${${module_name}_${fphlc_comp}_component_deps}) - list(APPEND fphlc_dep_vars "${module_name}_${fphlc_dep}_FOUND") - list(APPEND fphlc_dep_targets "${FPHLC_NAMESPACE}::${fphlc_dep}") - endforeach() - endif() - - if(NOT FPHLC_SKIP_PKG_CONFIG AND ${module_name}_${fphlc_comp}_pkg_config) - pkg_check_modules(PKG_${module_name}_${fphlc_comp} QUIET - ${${module_name}_${fphlc_comp}_pkg_config}) - endif() - - if("${${module_name}_${fphlc_comp}_lib}" STREQUAL "") - set(fphlc_library_type INTERFACE) - set(fphlc_required_vars "${module_name}_${fphlc_comp}_INCLUDE_DIR") - else() - set(fphlc_library_type UNKNOWN) - set(fphlc_required_vars "${module_name}_${fphlc_comp}_LIBRARY;${module_name}_${fphlc_comp}_INCLUDE_DIR") - endif() - - find_path(${module_name}_${fphlc_comp}_INCLUDE_DIR - NAMES ${${module_name}_${fphlc_comp}_header} - HINTS ${PKG_${module_name}_${fphlc_comp}_INCLUDE_DIRS} - PATH_SUFFIXES ${${module_name}_${fphlc_comp}_header_subdir} - ) - find_library(${module_name}_${fphlc_comp}_LIBRARY - NAMES ${${module_name}_${fphlc_comp}_lib} - HINTS ${PKG_${module_name}_${fphlc_comp}_LIBRARY_DIRS} - ) - - set(${module_name}_${fphlc_comp}_VERSION "${PKG_${module_name}_${fphlc_comp}_VERSION}") - if(NOT ${module_name}_VERSION) - set(${module_name}_VERSION ${${module_name}_${fphlc_comp}_VERSION}) - endif() - - find_package_handle_standard_args(${module_name}_${fphlc_comp} - FOUND_VAR - ${module_name}_${fphlc_comp}_FOUND - REQUIRED_VARS - ${fphlc_required_vars} - ${fphlc_dep_vars} - VERSION_VAR - ${module_name}_${fphlc_comp}_VERSION - ) - - mark_as_advanced( - ${module_name}_${fphlc_comp}_LIBRARY - ${module_name}_${fphlc_comp}_INCLUDE_DIR - ) - - if(${module_name}_${fphlc_comp}_FOUND) - if("${fphlc_library_type}" STREQUAL "UNKNOWN") - list(APPEND ${module_name}_LIBRARIES - "${${module_name}_${fphlc_comp}_LIBRARY}") - endif() - list(APPEND ${module_name}_INCLUDE_DIRS - "${${module_name}_${fphlc_comp}_INCLUDE_DIR}") - set(${module_name}_DEFINITIONS - ${${module_name}_DEFINITIONS} - ${PKG_${module_name}_${fphlc_comp}_DEFINITIONS}) - if(NOT TARGET ${FPHLC_NAMESPACE}::${fphlc_comp}) - add_library(${FPHLC_NAMESPACE}::${fphlc_comp} ${fphlc_library_type} IMPORTED) - set_target_properties(${FPHLC_NAMESPACE}::${fphlc_comp} PROPERTIES - INTERFACE_COMPILE_OPTIONS "${PKG_${module_name}_${fphlc_comp}_DEFINITIONS}" - INTERFACE_INCLUDE_DIRECTORIES "${${module_name}_${fphlc_comp}_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${fphlc_dep_targets}" - ) - if("${fphlc_library_type}" STREQUAL "UNKNOWN") - set_target_properties(${FPHLC_NAMESPACE}::${fphlc_comp} PROPERTIES - IMPORTED_LOCATION "${${module_name}_${fphlc_comp}_LIBRARY}" - ) - endif() - endif() - list(APPEND ${module_name}_TARGETS - "${FPHLC_NAMESPACE}::${fphlc_comp}") - endif() - endforeach() - if(${module_name}_LIBRARIES) - list(REMOVE_DUPLICATES ${module_name}_LIBRARIES) - endif() - if(${module_name}_INCLUDE_DIRS) - list(REMOVE_DUPLICATES ${module_name}_INCLUDE_DIRS) - endif() - if(${module_name}_DEFINITIONS) - list(REMOVE_DUPLICATES ${module_name}_DEFINITIONS) - endif() - if(${module_name}_TARGETS) - list(REMOVE_DUPLICATES ${module_name}_TARGETS) - endif() -endmacro() - -# -# Helper to link to an object library. -# -# The advantage of using this over target_link_library directly -# is that when used privately, it will not pollute target exports, -# See: https://gitlab.kitware.com/cmake/cmake/issues/17357 -# -# This is done by not involving target_link_libraries but directly set -# properties. -# -function(target_link_object_libraries target) - set(tlol_options) - set(tlol_oneValueArgs) - set(tlol_multiValueArgs PRIVATE INTERFACE PUBLIC) - cmake_parse_arguments(TLOL "${tlol_options}" "${tlol_oneValueArgs}" "${tlol_multiValueArgs}" ${ARGN}) - - if(TLOL_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unexpected arguments to target_link_object_libraries: ${TLOL_UNPARSED_ARGUMENTS}") - endif() - - if(NOT TLOL_PRIVATE AND NOT TLOL_INTERFACE AND NOT TLOL_PUBLIC) - message(FATAL_ERROR "Missing PRIVATE|INTERFACE|PUBLIC argument to target_link_object_libraries") - endif() - - foreach(lib IN LISTS TLOL_PRIVATE) - target_sources(${target} PRIVATE $ $) - target_include_directories(${target} PRIVATE $) - target_compile_options(${target} PRIVATE $) - # This is not supported, as it will make exporting ${target} also needs exporting ${lib} even in PRIVATE mode - #target_link_libraries(${target} PRIVATE $) - endforeach() - foreach(lib IN LISTS TLOL_INTERFACE) - target_sources(${target} INTERFACE $ $) - target_include_directories(${target} INTERFACE $) - target_compile_options(${target} INTERFACE $) - target_link_libraries(${target} INTERFACE $) - endforeach() - foreach(lib IN LISTS TLOL_PUBLIC) - target_sources(${target} PUBLIC $ $) - target_include_directories(${target} PUBLIC $) - target_compile_options(${target} PUBLIC $) - endforeach() -endfunction() diff --git a/cmake/modules/FindCairo.cmake b/cmake/modules/FindCairo.cmake deleted file mode 100644 index ea68828..0000000 --- a/cmake/modules/FindCairo.cmake +++ /dev/null @@ -1,2 +0,0 @@ -find_package(PkgConfig QUIET) -pkg_check_modules(Cairo ${Cairo_FIND_REQUIRED} ${Cairo_FIND_QUITELY} cairo IMPORTED_TARGET) diff --git a/cmake/modules/FindCheck.cmake b/cmake/modules/FindCheck.cmake deleted file mode 100644 index 49316e7..0000000 --- a/cmake/modules/FindCheck.cmake +++ /dev/null @@ -1,96 +0,0 @@ -# Try to find libcheck -# -# This will define: -# -# Check_FOUND - True if libcheck is available -# Check_LIBRARIES - Found libraries for libcheck -# Check_INCLUDE_DIRS - Include directory for libcheck -# Check_CFLAGS - Other compiler flags for using libcheck -# Check_VERSION - Version of the found libcheck -# -# Additionally, the following imported targets will be defined: -# -# check::check -# -include(FindPackageHandleStandardArgs) - -set(module_name Check) - -# We rely on pkg-config to provide dependency info. -find_package(PkgConfig REQUIRED QUIET) - -pkg_check_modules(PKG_${module_name} QUIET check) - -find_path(${module_name}_INCLUDE_DIR - NAMES check.h - HINTS ${PKG_${module_name}_INCLUDE_DIRS} -) -find_library(${module_name}_LIBRARY - NAMES check_pic check - HINTS ${PKG_${module_name}_LIBRARY_DIRS} -) - -set(${module_name}_VERSION "${PKG_${module_name}_VERSION}") -if(NOT ${module_name}_VERSION) - set(${module_name}_VERSION ${${module_name}_VERSION}) - - if(${module_name}_INCLUDE_DIR) - file(STRINGS "${${module_name}_INCLUDE_DIR}/check.h" ${module_name}_MAJOR_VERSION REGEX "^#define CHECK_MAJOR_VERSION +\\(?([0-9]+)\\)?$") - string(REGEX REPLACE "^#define CHECK_MAJOR_VERSION \\(?([0-9]+)\\)?" "\\1" ${module_name}_MAJOR_VERSION "${${module_name}_MAJOR_VERSION}") - file(STRINGS "${${module_name}_INCLUDE_DIR}/check.h" ${module_name}_MINOR_VERSION REGEX "^#define CHECK_MINOR_VERSION +\\(?([0-9]+)\\)?$") - string(REGEX REPLACE "^#define CHECK_MINOR_VERSION \\(?([0-9]+)\\)?" "\\1" ${module_name}_MINOR_VERSION "${${module_name}_MINOR_VERSION}") - file(STRINGS "${${module_name}_INCLUDE_DIR}/check.h" ${module_name}_MICRO_VERSION REGEX "^#define CHECK_MICRO_VERSION +\\(?([0-9]+)\\)?$") - string(REGEX REPLACE "^#define CHECK_MICRO_VERSION \\(?([0-9]+)\\)?" "\\1" ${module_name}_MICRO_VERSION "${${module_name}_MICRO_VERSION}") - set(${module_name}_VERSION "${${module_name}_MAJOR_VERSION}.${${module_name}_MINOR_VERSION}.${${module_name}_MICRO_VERSION}") - unset(${module_name}_MAJOR_VERSION) - unset(${module_name}_MINOR_VERSION) - unset(${module_name}_MICRO_VERSION) - endif() -endif() - -find_package_handle_standard_args(${module_name} - FOUND_VAR - ${module_name}_FOUND - REQUIRED_VARS - ${module_name}_LIBRARY - ${module_name}_INCLUDE_DIR - VERSION_VAR - ${module_name}_VERSION -) - -mark_as_advanced( - ${module_name}_LIBRARY - ${module_name}_INCLUDE_DIR -) - -if(${module_name}_FOUND) - list(APPEND ${module_name}_LIBRARIES "${PKG_${module_name}_LIBRARIES}") - list(APPEND ${module_name}_CFLAGS "${PKG_${module_name}_CFLAGS_OTHER}") - list(APPEND ${module_name}_LDFLAGS "${PKG_${module_name}_LDFLAGS_OTHER}") - - message("PKG_${module_name}_LDFLAGS_OTHER = ${PKG_${module_name}_LDFLAGS_OTHER}") - - if("-pthread" IN_LIST ${module_name}_LDFLAGS) - include(CMakeFindDependencyMacro) - find_dependency(Threads REQUIRED) - list(APPEND ${module_name}_LIBRARIES Threads::Threads) - endif() - - list(APPEND ${module_name}_INCLUDE_DIRS "${${module_name}_INCLUDE_DIR}") - if(NOT TARGET check::check) - add_library(check::check INTERFACE IMPORTED) - set_target_properties(check::check PROPERTIES - INTERFACE_COMPILE_OPTIONS "${${module_name}_CFLAGS}" - INTERFACE_INCLUDE_DIRECTORIES "${${module_name}_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${${module_name}_LIBRARIES}" - ) - endif() -endif() - -include(FeatureSummary) -set_package_properties(${module_name} PROPERTIES - URL "https://libcheck.github.io/check/" - DESCRIPTION "A unit testing framework for C" -) - -unset(module_name) diff --git a/cmake/modules/FindGTK3.cmake b/cmake/modules/FindGTK3.cmake deleted file mode 100644 index 3da766d..0000000 --- a/cmake/modules/FindGTK3.cmake +++ /dev/null @@ -1,2 +0,0 @@ -find_package(PkgConfig QUIET) -pkg_check_modules(GTK3 ${GTK3_FIND_REQUIRED} ${GTK3_FIND_QUIETLY} gtk+-3.0 IMPORTED_TARGET) diff --git a/cmake/modules/FindPango.cmake b/cmake/modules/FindPango.cmake deleted file mode 100644 index 2e946d5..0000000 --- a/cmake/modules/FindPango.cmake +++ /dev/null @@ -1,2 +0,0 @@ -find_package(PkgConfig QUIET) -pkg_check_modules(Pango ${Pango_FIND_REQUIRED} ${Pango_FIND_QUIETLY} pango IMPORTED_TARGET) diff --git a/cmake/modules/FindPangoCairo.cmake b/cmake/modules/FindPangoCairo.cmake deleted file mode 100644 index e8ceb48..0000000 --- a/cmake/modules/FindPangoCairo.cmake +++ /dev/null @@ -1,6 +0,0 @@ -# FindPangoCairo.cmake -# -# CMake support for PangoCairo. -# -find_package(PkgConfig QUIET) -pkg_check_modules(PangoCairo ${PangoCairo_FIND_REQUIRED} ${PangoCairo_FIND_QUIETLY} pangocairo IMPORTED_TARGET) diff --git a/cmake/modules/FindXKBCommon.cmake b/cmake/modules/FindXKBCommon.cmake deleted file mode 100644 index 08d5e4f..0000000 --- a/cmake/modules/FindXKBCommon.cmake +++ /dev/null @@ -1,72 +0,0 @@ -# Try to find xkbcommon -# -# Available components: -# XKBCommon - The whole xkbcommon library -# KeySyms - The interface library containing only xkbcommon-keysyms.h -# -# This will define: -# -# XKBCommon_FOUND - True if xkbcommon is available -# XKBCommon_LIBRARIES - Found libraries for xkbcommon -# XKBCommon_INCLUDE_DIRS - Include directory for xkbcommon -# XKBCommon_DEFINITIONS - Compiler flags for using xkbcommon -# -# Additionally, the following imported targets will be defined: -# -# XKB::XKBCommon -# XKB::KeySyms -# -include(FindPackageHandleStandardArgs) - -# Note that this list needs to be ordered such that any component appears after its dependencies -set(XKBCommon_known_components - XKBCommon - KeySyms -) - -set(XKBCommon_XKBCommon_component_deps) -set(XKBCommon_XKBCommon_pkg_config "xkbcommon") -set(XKBCommon_XKBCommon_lib "xkbcommon") -set(XKBCommon_XKBCommon_header "xkbcommon/xkbcommon.h") - -set(XKBCommon_KeySyms_component_deps) -set(XKBCommon_KeySyms_pkg_config "xkbcommon") -set(XKBCommon_KeySyms_lib) -set(XKBCommon_KeySyms_header "xkbcommon/xkbcommon-keysyms.h") - -# Parse components -find_package_parse_components(XKBCommon - RESULT_VAR XKBCommon_components - KNOWN_COMPONENTS ${XKBCommon_known_components} -) - -# Find each component -# use our private version of find_package_handle_library_components -# that also handles interface library -find_package_handle_library_components(XKBCommon - NAMESPACE XKB - COMPONENTS ${XKBCommon_components} -) - -set(XKBCommon_component_FOUND_VARS) -foreach(comp ${XKBCommon_components}) - list(APPEND XKBCommon_component_FOUND_VARS "XKBCommon_${comp}_FOUND") -endforeach(comp) - -find_package_handle_standard_args(XKBCommon - FOUND_VAR - XKBCommon_FOUND - REQUIRED_VARS - ${XKBCommon_component_FOUND_VARS} - VERSION_VAR - XKBCommon_VERSION - HANDLE_COMPONENTS -) - -unset(XKBCommon_component_FOUND_VARS) - -include(FeatureSummary) -set_package_properties(XKBCommon PROPERTIES - URL "http://xkbcommon.org" - DESCRIPTION "Keyboard handling library using XKB data" -) diff --git a/etc/libtsm-config.cmake.in b/etc/libtsm-config.cmake.in deleted file mode 100644 index 8044bbb..0000000 --- a/etc/libtsm-config.cmake.in +++ /dev/null @@ -1,13 +0,0 @@ -# -# libtsm -# ------ -# -# The following imported targets are created: -# libtsm::libtsm -# - -@PACKAGE_INIT@ - -if(NOT TARGET libtsm::tsm) - include("${CMAKE_CURRENT_LIST_DIR}/libtsm-targets.cmake") -endif() diff --git a/etc/libtsm.pc.in b/etc/libtsm.pc.in deleted file mode 100644 index 158aea5..0000000 --- a/etc/libtsm.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=@libdir_for_pc_file@ -includedir=@includedir_for_pc_file@ - -Name: @PROJECT_NAME@ -Description: @PROJECT_DESCRIPTION@ -URL: @PROJECT_HOMEPAGE_URL@ -Version: @PROJECT_VERSION@ -Libs: -L${libdir} -ltsm -Cflags: -I${includedir} diff --git a/etc/test.supp b/etc/test.supp deleted file mode 100644 index a61a1f7..0000000 --- a/etc/test.supp +++ /dev/null @@ -1,15 +0,0 @@ -# -# Some suppression rules for our test-suite to work correctly. -# libcheck has some weird errors, so lets ignore them. -# - -{ - libcheck timer_create warnings - Memcheck:Param - timer_create(evp) - fun:timer_create - obj:/usr/lib/libcheck.so.0.0.0 - obj:/usr/lib/libcheck.so.0.0.0 - fun:srunner_run - fun:main -} diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt deleted file mode 100644 index dd69c7b..0000000 --- a/external/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# -# External vendorized code -# build everything into a object library for ease of use internally -# -add_library(external OBJECT - wcwidth/wcwidth.c -) - -target_include_directories(external - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/wcwidth -) -set_target_properties(external PROPERTIES - C_VISIBILITY_PRESET hidden - POSITION_INDEPENDENT_CODE ON -) -add_libtsm_compile_options(external) diff --git a/external/meson.build b/external/meson.build new file mode 100644 index 0000000..3f14075 --- /dev/null +++ b/external/meson.build @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: MIT + +subdir('wcwidth') diff --git a/external/wcwidth/meson.build b/external/wcwidth/meson.build new file mode 100644 index 0000000..87bbe99 --- /dev/null +++ b/external/wcwidth/meson.build @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: MIT + +incdirs = include_directories('.') +wcwidth = static_library('wcwidth', 'wcwidth.c', include_directories: incdirs) + +wcwidth_dep = declare_dependency( + include_directories: incdirs, + link_with: wcwidth, + sources: ['wcwidth.c'], +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..ae7a05a --- /dev/null +++ b/meson.build @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: MIT + +project( + 'libtsm', + 'c', + version: '4.1.0', + license: 'MIT', + meson_version: '>=1.1', + default_options: [ + 'warning_level=1', + 'werror=true', + 'buildtype=debugoptimized', + 'c_std=gnu99', + ], +) + +add_project_arguments( + '-ffast-math', + '-fno-strict-aliasing', + '-ffunction-sections', + '-fdata-sections', + '-D_GNU_SOURCE', + '-D_POSIX_C_SOURCE=200809L', + language: 'c', +) + +# +# Optional xkbcommon dependency, otherwise use the provided xbkcommon-keysyms.h +# +xkbcommon_dep = dependency('xkbcommon', version: '>=0.5.0', required: false) +if not xkbcommon_dep.found() + xkbcommon_dep = declare_dependency( + include_directories: include_directories('external'), + ) +endif + +# +# Add a config.h which can define BUILD_ENABLE_DEBUG for extra debugging +# +config = configuration_data() +config.set('BUILD_ENABLE_DEBUG', get_option('extra_debug')) +config_h = configure_file(configuration: config, output: 'config.h') +abs_config_h = meson.current_build_dir() / '@0@'.format('config.h') +add_project_arguments('-include', abs_config_h, language: 'c') + +subdir('external') +subdir('src') + +if get_option('tests') + subdir('test') +endif diff --git a/meson.options b/meson.options new file mode 100644 index 0000000..ea0d1ba --- /dev/null +++ b/meson.options @@ -0,0 +1,7 @@ + +option('extra_debug', type: 'boolean', value: false, + description: 'Enable non-standard debug option') +option('tests', type: 'boolean', value: true, + description: 'Build unit tests') +option('gtktsm', type: 'boolean', value: false, + description: 'tests using gtktsm') \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index adab1a4..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -add_subdirectory(shared) -add_subdirectory(tsm) - -if(BUILD_GTKTSM) - add_subdirectory(gtktsm) -endif() diff --git a/src/config.h.in b/src/config.h.in deleted file mode 100644 index 635deeb..0000000 --- a/src/config.h.in +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef LIBTSM_CONFIG_H -#define LIBTSM_CONFIG_H - -/* Enable debug mode */ -#cmakedefine BUILD_ENABLE_DEBUG - -/* Have xkbcommon library */ -#cmakedefine BUILD_HAVE_XKBCOMMON - -#endif // LIBTSM_CONFIG_H diff --git a/src/gtktsm/CMakeLists.txt b/src/gtktsm/CMakeLists.txt deleted file mode 100644 index d3f5947..0000000 --- a/src/gtktsm/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# -# GtkTsm - Example -# -add_executable(gtktsm - gtktsm.c - gtktsm-app.c - gtktsm-terminal.c - gtktsm-win.c -) -target_link_libraries(gtktsm - PRIVATE - tsm - - m - PkgConfig::GTK3 - PkgConfig::Cairo - PkgConfig::Pango - PkgConfig::PangoCairo - XKB::XKBCommon -) -target_link_object_libraries(gtktsm - PRIVATE - shl -) -add_libtsm_compile_options(gtktsm) - -install(TARGETS gtktsm - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" -) diff --git a/src/gtktsm/gtktsm-win.c b/src/gtktsm/gtktsm-win.c index 52377de..3ce24cd 100644 --- a/src/gtktsm/gtktsm-win.c +++ b/src/gtktsm/gtktsm-win.c @@ -51,18 +51,7 @@ G_DEFINE_TYPE_WITH_PRIVATE(GtkTsmWin, gtktsm_win, GTK_TYPE_WINDOW); static void win_realize(GtkWidget *widget) { - GtkTsmWin *win = GTKTSM_WIN(widget); - GdkWindow *w; - GdkRGBA col; - GTK_WIDGET_CLASS(gtktsm_win_parent_class)->realize(widget); - - w = gtk_widget_get_window(GTK_WIDGET(win)); - col.red = 0.0; - col.green = 0.0; - col.blue = 0.0; - col.alpha = 1.0; - gdk_window_set_background_rgba(w, &col); } static gboolean win_title_fn(GtkTsmTerminal *term, gchar *title, gpointer data) diff --git a/src/gtktsm/meson.build b/src/gtktsm/meson.build new file mode 100644 index 0000000..8c9e66d --- /dev/null +++ b/src/gtktsm/meson.build @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: MIT + +gtktsm_src = ['gtktsm.c', 'gtktsm-app.c', 'gtktsm-terminal.c', 'gtktsm-win.c'] + +gtk_dep = dependency('gtk+-3.0') +cairo_dep = dependency('cairo') + +gtktsm_deps = [ + wcwidth_dep, + shl_dep, + libtsm_dep, + gtk_dep, + cairo_dep, + xkbcommon_dep, +] + +executable('gtktsm', gtktsm_src, dependencies: gtktsm_deps) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..40660a0 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: MIT + +subdir('shared') +subdir('tsm') + +if get_option('gtktsm') + subdir('gtktsm') +endif diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt deleted file mode 100644 index d876f77..0000000 --- a/src/shared/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# -# SHL - Static Helper Library -# The SHL subsystem contains several small code pieces used all over libtsm and -# other applications. -# -add_library(shl OBJECT - shl-htable.c -) - -if (BUILD_GTKTSM) - target_sources(shl PRIVATE shl-pty.c shl-ring.c) -endif() - -target_include_directories(shl - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} -) -set_target_properties(shl PROPERTIES - C_VISIBILITY_PRESET hidden - POSITION_INDEPENDENT_CODE ON -) -add_libtsm_compile_options(shl) diff --git a/src/shared/meson.build b/src/shared/meson.build new file mode 100644 index 0000000..dcdc172 --- /dev/null +++ b/src/shared/meson.build @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: MIT + +shl_inc = include_directories('.') +shl_src = ['shl-htable.c'] + +if get_option('gtktsm') + shl_src += ['shl-pty.c', 'shl-ring.c'] +endif + +shl = static_library('shl', shl_src, include_directories: shl_inc) + +shl_dep = declare_dependency( + include_directories: shl_inc, + link_with: shl, + sources: shl_src, +) diff --git a/src/tsm/CMakeLists.txt b/src/tsm/CMakeLists.txt deleted file mode 100644 index 317be10..0000000 --- a/src/tsm/CMakeLists.txt +++ /dev/null @@ -1,101 +0,0 @@ -# -# libtsm -# Main library build instructions -# - -# -# Use a separate object library that is shared between tsm and tsm_test -# -add_library(tsm_obj OBJECT - tsm-render.c - tsm-screen.c - tsm-selection.c - tsm-unicode.c - tsm-vte.c - tsm-vte-charsets.c -) -set_target_properties(tsm_obj PROPERTIES - POSITION_INDEPENDENT_CODE ON - C_VISIBILITY_PRESET hidden -) - -# Fix include path for tsm_obj because it can't directly link to -# external and shl. TODO: remove after we require 3.12 -foreach(lib IN ITEMS external shl) - target_include_directories(tsm_obj PRIVATE $) -endforeach() - -# Other non-compilation properties shared between tsm and tsm_test -function(apply_properties target) - # TODO: set this on tsm_obj after we require 3.12 - # Link to dependencies - target_link_object_libraries(${target} - PRIVATE - external - shl - ) - if(XKBCommon_KeySyms_FOUND) - target_link_libraries(${target} - PRIVATE - XKB::KeySyms - ) - endif() - target_include_directories(${target} - INTERFACE - $ - $ - ) - set_target_properties(${target} PROPERTIES - POSITION_INDEPENDENT_CODE ON - C_VISIBILITY_PRESET hidden - VERSION "${PROJECT_VERSION}" - SOVERSION "${PROJECT_VERSION_MAJOR}" - PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/libtsm.h" - ) - add_libtsm_compile_options(${target}) -endfunction() - -# -# Main production library -# -add_library(tsm) -target_link_object_libraries(tsm PRIVATE tsm_obj) -apply_properties(tsm) -# The production library additionally use version script -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -set_property(TARGET tsm APPEND_STRING - PROPERTY - LINK_FLAGS " -Wl,--version-script=\"${CMAKE_CURRENT_SOURCE_DIR}/libtsm.sym\"" -) -set_property(TARGET tsm APPEND - PROPERTY - LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libtsm.sym" -) -endif() - -# Add an alias so that library can be used inside the build tree -add_library(libtsm::tsm ALIAS tsm) - -# -# Add an additional static library for testing -# -if(BUILD_TESTING) - # Must be static to avoid visibility=hidden - add_library(tsm_test STATIC) - target_link_object_libraries(tsm_test PRIVATE tsm_obj) - apply_properties(tsm_test) - # Additionally expose internal private header path - target_include_directories(tsm_test - INTERFACE - $ - ) -endif() - -# -# Installation -# -install(TARGETS tsm EXPORT tsm-targets - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" -) diff --git a/src/tsm/meson.build b/src/tsm/meson.build new file mode 100644 index 0000000..ea3f92d --- /dev/null +++ b/src/tsm/meson.build @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: MIT + +libtsm_srcs = [ + 'tsm-render.c', + 'tsm-screen.c', + 'tsm-selection.c', + 'tsm-unicode.c', + 'tsm-vte-charsets.c', + 'tsm-vte.c', +] + +version=meson.project_version() +major=version.split('.')[0] + +libtsm = shared_library( + 'tsm', + libtsm_srcs, + dependencies: [wcwidth_dep, shl_dep, xkbcommon_dep], + install: true, + version: version, + soversion: major, +) + +libtsm_dep = declare_dependency( + include_directories: '.', + link_with: libtsm, + sources: libtsm_srcs, +) + +install_headers('libtsm.h') + +pkg = import('pkgconfig') +pkg.generate( + libtsm, + name: 'libtsm', + url: 'https://github.com/Aetf/libtsm', + description: 'terminal-emulator state machine', +) diff --git a/src/tsm/tsm-selection.c b/src/tsm/tsm-selection.c index 7821f03..57b07cd 100644 --- a/src/tsm/tsm-selection.c +++ b/src/tsm/tsm-selection.c @@ -191,7 +191,6 @@ static void swap_selections(struct selection_pos **a, struct selection_pos **b) static void norm_selection(struct tsm_screen *con, struct selection_pos **start, struct selection_pos **end) { struct line *iter; - struct selection_pos *buffer; if ((*end)->line == NULL && (*end)->y == SELECTION_TOP) { swap_selections(start, end); diff --git a/src/tsm/tsm-unicode.c b/src/tsm/tsm-unicode.c index bc1609a..6216ebd 100644 --- a/src/tsm/tsm-unicode.c +++ b/src/tsm/tsm-unicode.c @@ -57,7 +57,7 @@ #include #include #include -#include "wcwidth/wcwidth.h" +#include "wcwidth.h" #include "libtsm.h" #include "libtsm-int.h" #include "shl-array.h" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 9ec5aa7..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,69 +0,0 @@ -# -# Tests -# These tests are included in a separate "test" target that can be run manually via `make test' -# But a more useful way to run the tests is using ctest, which runs valgrind on all tests. -# This is also the setup using in our CI. -# Note that ctest fails if _any_ leak is detected by valgrind. Thus, you -# need to have valgrind installed and libcheck running properly (without leaks) -# to make the tests succeed. - -function(libtsm_add_test name) - set(options) - set(oneValueArgs) - set(multiValueArgs LINK_LIBRARIES) - cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - add_executable(${name} ${name}) - if(ARG_LINK_LIBRARIES) - target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBRARIES}) - endif() - add_test(NAME ${name} COMMAND ${name}) -endfunction() - -libtsm_add_test(test_htable - LINK_LIBRARIES - check::check -) -target_link_object_libraries(test_htable - PRIVATE - shl -) - -libtsm_add_test(test_symbol - LINK_LIBRARIES - tsm_test - check::check -) - -libtsm_add_test(test_screen - LINK_LIBRARIES - tsm_test - check::check -) - -libtsm_add_test(test_selection - LINK_LIBRARIES - tsm_test - check::check -) - -libtsm_add_test(test_vte - LINK_LIBRARIES - tsm_test - check::check -) - -libtsm_add_test(test_vte_mouse - LINK_LIBRARIES - tsm_test - check::check -) - -# This is only a quick sanity check that verifies the -# valgrind tests work properly. -libtsm_add_test(test_valgrind - LINK_LIBRARIES - check::check -) -# mark the test as will fail in memcheck -set_tests_properties(test_valgrind PROPERTIES LABELS memcheck-xfail) diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000..f689b12 --- /dev/null +++ b/test/meson.build @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: MIT + +check_dep = dependency('check') + +# For tests that depends on libtsm and all dependencies +test_deps = [shl_dep, check_dep, libtsm_dep, xkbcommon_dep, wcwidth_dep] + +test_htable = executable( + 'test_htable', + 'test_htable.c', + dependencies: [shl_dep, check_dep], +) +test_screen = executable('test_screen', 'test_screen.c', dependencies: test_deps) +test_selection = executable( + 'test_selection', + 'test_selection.c', + dependencies: test_deps, +) +test_symbol = executable('test_symbol', 'test_symbol.c', dependencies: test_deps) +test_valgrind = executable( + 'test_valgrind', + 'test_valgrind.c', + dependencies: [check_dep], +) +test_vte_mouse = executable( + 'test_vte_mouse', + 'test_vte_mouse.c', + dependencies: test_deps, +) +test_vte = executable('test_vte', 'test_vte.c', dependencies: test_deps) + +test('htable', test_htable) +test('screen', test_screen) +test('selection', test_selection) +test('symbol', test_symbol) +test('valgrind', test_valgrind) +test('vte_mouse', test_vte_mouse) +test('vte', test_vte) + diff --git a/test/test_screen.c b/test/test_screen.c index 0608ab2..f1ac141 100644 --- a/test/test_screen.c +++ b/test/test_screen.c @@ -152,7 +152,7 @@ START_TEST(test_screen_resize_alt_colors) tsm_screen_set_flags(screen, TSM_SCREEN_ALTERNATE); /* change background color to red */ - bzero(&new_attr, sizeof(new_attr)); + memset(&new_attr, 0, sizeof(new_attr)); new_attr.br = 255; new_attr.bg = 0; new_attr.bb = 0; diff --git a/test/test_selection.c b/test/test_selection.c index 5c151f1..1ee6ab0 100644 --- a/test/test_selection.c +++ b/test/test_selection.c @@ -33,7 +33,7 @@ static void write_string(struct tsm_screen *screen, const char *str) struct tsm_screen_attr attr; int i; - bzero(&attr, sizeof(attr)); + memset(&attr, 0, sizeof(attr)); attr.fccode = 37; /* white */ attr.bccode = 40; /* black */ @@ -192,7 +192,7 @@ START_TEST(test_screen_copy_line_scrolled) r = tsm_screen_resize(screen, 80, 40); ck_assert_int_eq(r, 0); - for (int i = 0; i < 39; i++) { + for (i = 0; i < 39; i++) { tsm_screen_newline(screen); } @@ -305,7 +305,7 @@ START_TEST(test_screen_copy_lines_scrolled) r = tsm_screen_resize(screen, 80, 40); ck_assert_int_eq(r, 0); - for (int i = 0; i < 37; i++) { + for (i = 0; i < 37; i++) { tsm_screen_newline(screen); } tsm_screen_newline(screen); @@ -439,7 +439,7 @@ END_TEST START_TEST(test_screen_copy_line_sb_scrolled) { struct tsm_screen *screen; - int r, i; + int r; char *str = NULL; r = tsm_screen_new(&screen, NULL, NULL); @@ -554,7 +554,7 @@ START_TEST(test_screen_copy_line_sb_scrolled_invalid) ck_assert_int_eq(screen->sel_end.y, 0); /* force the selected text to scroll up */ - for (int i = 0; i < 40; i++) { + for (i = 0; i < 40; i++) { tsm_screen_newline(screen); } @@ -724,7 +724,7 @@ START_TEST(test_screen_copy_lines_sb_scrolled) ck_assert_int_eq(screen->sel_end.y, 2); /* force the selected text to scroll into the sb */ - for (int i = 0; i < 40; i++) { + for (i = 0; i < 40; i++) { tsm_screen_newline(screen); } @@ -815,7 +815,7 @@ START_TEST(test_screen_copy_lines_sb_scrolled_cut_off) ck_assert_int_eq(screen->sel_end.y, 2); /* force the selected text to scroll up */ - for (int i = 0; i < 39; i++) { + for (i = 0; i < 39; i++) { tsm_screen_newline(screen); } diff --git a/test/test_vte.c b/test/test_vte.c index 5de07b4..a109f13 100644 --- a/test/test_vte.c +++ b/test/test_vte.c @@ -293,7 +293,7 @@ START_TEST(test_vte_csi_cursor_up_down) struct tsm_screen *screen; struct tsm_vte *vte; int r; - int h, w; + int h; char csi_cmd[64]; r = tsm_screen_new(&screen, log_cb, NULL); @@ -314,7 +314,6 @@ START_TEST(test_vte_csi_cursor_up_down) assert_tsm_screen_cursor_pos(screen, 0, 1); h = tsm_screen_get_height(screen); - w = tsm_screen_get_width(screen); // move cursor up out of screen, should at first line sprintf(csi_cmd, "\033[%dF", h + 10); diff --git a/test/test_vte_mouse.c b/test/test_vte_mouse.c index b228ffb..6c717bb 100644 --- a/test/test_vte_mouse.c +++ b/test/test_vte_mouse.c @@ -68,7 +68,7 @@ void setup() mouse_track_mode = 0; mouse_track_pixels = false; - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); } void teardown() @@ -111,21 +111,21 @@ START_TEST(test_mouse_x10) ck_assert_int_eq(r, 0); /* right click on (0, 0) */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer,0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 0, 0, 0, 0, 2, TSM_MOUSE_EVENT_PRESSED, 0); expected = "\e[M\"!!"; r = memcmp(&write_buffer, expected, strlen(expected)); ck_assert_int_eq(r, 0); /* middle click on (0, 0) */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer,0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 0, 0, 0, 0, 1, TSM_MOUSE_EVENT_PRESSED, 0); expected = "\e[M!!!"; r = memcmp(&write_buffer, expected, strlen(expected)); ck_assert_int_eq(r, 0); /* left click out of range (299, 279) */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer,0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 299, 279, 0, 0, 0, TSM_MOUSE_EVENT_PRESSED, 0); expected = "\e[M \xff\xff"; r = memcmp(&write_buffer, expected, strlen(expected)); @@ -150,7 +150,7 @@ START_TEST(test_mouse_cb_sgr) mouse_track_pixels = false; /* Set Button Events */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); msg = "\e[?1002h"; tsm_vte_input(vte, msg, strlen(msg)); @@ -177,42 +177,42 @@ START_TEST(test_mouse_sgr) ck_assert_int_eq(r, 0); /* button release event for (1, 1) */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 0, 0, 0, 0, 0, TSM_MOUSE_EVENT_RELEASED, 0); expected = "\e[<0;1;1m"; r = memcmp(&write_buffer, expected, strlen(expected)); ck_assert_int_eq(r, 0); /* button 1 (middle mouse button) */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 0, 0, 0, 0, 1, TSM_MOUSE_EVENT_PRESSED, 0); expected = "\e[<1;1;1M"; r = memcmp(&write_buffer, expected, strlen(expected)); ck_assert_int_eq(r, 0); /* button 2 (right mouse button) */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 0, 0, 0, 0, 2, TSM_MOUSE_EVENT_PRESSED, 0); expected = "\e[<2;1;1M"; r = memcmp(&write_buffer, expected, strlen(expected)); ck_assert_int_eq(r, 0); /* button 4 (mouse wheel up scroll) */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 0, 0, 0, 0, 4, TSM_MOUSE_EVENT_PRESSED, 0); expected = "\e[<64;1;1M"; r = memcmp(&write_buffer, expected, strlen(expected)); ck_assert_int_eq(r, 0); /* button 5 (mouse wheel down scroll) */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 0, 0, 0, 0, 5, TSM_MOUSE_EVENT_PRESSED, 0); expected = "\e[<65;1;1M"; r = memcmp(&write_buffer, expected, strlen(expected)); ck_assert_int_eq(r, 0); /* check for (50, 120) */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 49, 119, 0, 0, 0, TSM_MOUSE_EVENT_PRESSED, 0); expected = "\e[<0;50;120M"; r = memcmp(&write_buffer, expected, strlen(expected)); @@ -237,19 +237,19 @@ START_TEST(test_mouse_sgr_cell_change) ck_assert_int_eq(r, 0); /* repeated reportings of the same cell should be ignored */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 0, 0, 0, 0, 0, TSM_MOUSE_EVENT_MOVED, 0); ck_assert_int_eq(write_buffer[0], 0); /* different cells must be reported */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 1, 1, 0, 0, 0, TSM_MOUSE_EVENT_MOVED, 0); expected = "\e[<35;2;2M"; r = memcmp(&write_buffer, expected, strlen(expected)); ck_assert_int_eq(r, 0); /* a click must be reported in all cases */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 1, 1, 0, 0, 0, TSM_MOUSE_EVENT_PRESSED, 0); expected = "\e[<0;2;2M"; r = memcmp(&write_buffer, expected, strlen(expected)); @@ -274,7 +274,7 @@ START_TEST(test_mouse_cb_pixels) mouse_track_pixels = false; /* Set Button Events */ - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); msg = "\e[?1003h"; tsm_vte_input(vte, msg, strlen(msg)); @@ -299,13 +299,13 @@ START_TEST(test_mouse_pixels) r = memcmp(&write_buffer, expected, strlen(expected)); ck_assert_int_eq(r, 0); - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 0, 0, 236, 120, 0, TSM_MOUSE_EVENT_PRESSED, 0); expected = "\e[<0;236;120M"; r = memcmp(&write_buffer, expected, strlen(expected)); ck_assert_int_eq(r, 0); - bzero(&write_buffer, sizeof(write_buffer)); + memset(&write_buffer, 0, sizeof(write_buffer)); tsm_vte_handle_mouse(vte, 0, 0, 236, 120, 0, TSM_MOUSE_EVENT_RELEASED, 0); expected = "\e[<0;236;120m"; r = memcmp(&write_buffer, expected, strlen(expected));