1
0
mirror of https://github.com/adamyg/mcwin32.git synced 2025-04-18 01:17:37 +03:00
* build-231
 * 4.8.33 merge (#94)
 * internal tools front-ends, externalized (#78)
      o mcedit
      o mcdiff and mcbsddiff (diff backend)
      o mcview
 * upgrades/bugfixes
      o pcre2 10.45 (#106)
      o appupdater (#102)
      o glib 2.54.3 (#102)
      o zlib-1.3.1 (#102)
      o mbedtls-3.6.2 (#100)
      o improved UNC and extended prefix support, plus stat optimisations (#98)
      o libssh2-1.11.1 (#95)
      o enhanced utf8 support, directory plus username; non-ascii user name support (#97)
      o EXDEV, cross-device detection rename failure; allowing alt move logic (#85)
      o x64 installer path (#79)
This commit is contained in:
adamyg 2025-03-13 04:02:45 +08:00 committed by GitHub
parent 742f6662cb
commit c29dd79890
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
806 changed files with 34526 additions and 20845 deletions

View File

@ -104,7 +104,6 @@ jobs:
path: mcwin32/bin.${{ matrix.config.toolversion }}/release/*
- name: Installer
if: startsWith(matrix.config.name, 'Windows Latest MSVC') || startsWith(matrix.config.name, 'Windows Latest OWC')
shell: cmd
run: |
@set PERL=c:/Strawberry/perl/bin/perl
@ -114,7 +113,6 @@ jobs:
"%programfiles(x86)%\Inno Setup 5\ISCC" -DBUILD_INFO=1 -DBUILD_TYPE=release ".\releases\mc-inno-setup.iss"
- name: Release artifacts
if: startsWith(matrix.config.name, 'Windows Latest MSVC') || startsWith(matrix.config.name, 'Windows Latest OWC')
uses: softprops/action-gh-release@v1
with:
files: ./mcwin32/releases/mcwin32-build*-setup.exe

1
.gitignore vendored
View File

@ -5,6 +5,7 @@ mcmerge/
busybox/
mcwin32/bin/
inno/
ref/
directory.txt
gtk-source.txt
mcgtk-source.txt

View File

@ -0,0 +1,9 @@
Thank you for thinking about contributing to Midnight Commander, but we **ARE NOT** using pull requests to manage incoming patches!
Instead, please check out our Trac instance to see if the issue has already been reported, or submit a new ticket:
https://midnight-commander.org/wiki/NewTicket
If you chose to submit the pull request instead, keep in mind that we are not checking on them regularly, so it might take ages before we even get to it, if at all.
Unfortunately, GitHub does not allow us to disable the pull requests feature for this repository, so we have to warn you this way...

46
mcsrc/.github/workflows/ci-alpine.yml vendored Normal file
View File

@ -0,0 +1,46 @@
name: ci-alpine
on:
workflow_call:
jobs:
build-alpine:
runs-on: ubuntu-latest
container:
image: alpine:latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
apk add autoconf automake build-base libtool pkgconf sudo
apk add aspell-dev check-dev e2fsprogs-dev gettext-dev glib-dev gpm-dev libssh2-dev perl slang-dev
- name: Bootstrap build system
run: ./autogen.sh
- name: Build default configuration
run: |
adduser --home "$(pwd)" --no-create-home --disabled-password test
chown -R test "$(pwd)"
su - test -c ' \
./configure \
--prefix="$(pwd)/install-prefix" \
--enable-mclib \
--enable-aspell \
--enable-werror \
&& \
\
make -j$(nproc) && \
make check && \
make install \
'
- uses: actions/upload-artifact@v4
if: failure()
with:
name: test-suite-logs-alpine
path: ./**/test-suite.log

53
mcsrc/.github/workflows/ci-fedora.yml vendored Normal file
View File

@ -0,0 +1,53 @@
name: ci-fedora
on:
workflow_call:
jobs:
build-fedora:
runs-on: ubuntu-latest
container:
image: fedora:latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
dnf install -y autoconf automake gcc gettext-devel groff libtool make pkgconfig
dnf install -y aspell-devel check-devel gpm-devel libX11-devel "pkgconfig(ext2fs)" "pkgconfig(glib-2.0)" "pkgconfig(gmodule-2.0)" "pkgconfig(libssh2)" "pkgconfig(slang)"
# For tests
dnf install -y glibc-gconv-extra util-linux
- name: Lint documentation
working-directory: maint
run: ./doctest
- name: Bootstrap build system
run: ./autogen.sh
- name: Build default configuration
run: |
useradd --home "$(pwd)" test
chown -R test "$(pwd)"
su - test -c ' \
./configure \
--prefix="$(pwd)/install-prefix" \
--enable-mclib \
--enable-aspell \
--enable-werror \
&& \
\
make -j$(nproc) && \
make check && \
make install \
'
- uses: actions/upload-artifact@v4
if: failure()
with:
name: test-suite-logs-fedora
path: ./**/test-suite.log

54
mcsrc/.github/workflows/ci-freebsd.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: ci-freebsd
on:
workflow_call:
inputs:
CFLAGS:
description: 'Custom CFLAGS'
default: ''
required: false
type: string
jobs:
build-freebsd:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Build on FreeBSD
uses: vmactions/freebsd-vm@v1
with:
prepare: |
pkg install -y autoconf automake gettext libtool pkgconf
pkg install -y aspell check glib libssh2 libX11 python3
run: |
./autogen.sh
pw useradd test -d "$(pwd)"
chown -R test $(pwd)
su - test -c ' \
\
export CFLAGS="${{ inputs.CFLAGS }}" && \
\
./configure \
--prefix="$(pwd)/install-prefix" \
--with-screen=ncurses \
--enable-mclib \
--enable-aspell \
--enable-werror \
&& \
\
make && \
make check && \
make install \
'
- uses: actions/upload-artifact@v4
if: failure()
with:
name: test-suite-logs-freebsd
path: ./**/test-suite.log

47
mcsrc/.github/workflows/ci-macos.yml vendored Normal file
View File

@ -0,0 +1,47 @@
name: ci-macos
on:
workflow_call:
inputs:
CFLAGS:
description: 'Custom CFLAGS'
default: ''
required: false
type: string
jobs:
build-macos:
runs-on: macos-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
brew install autoconf automake gettext check gnu-indent libtool pkg-config
brew install aspell e2fsprogs glib libssh2 openssl s-lang
# unzip is part of the base system
- name: Bootstrap build system
run: ./autogen.sh
- name: Build default configuration
run: |
export CFLAGS="${{ inputs.CFLAGS }}"
./configure \
--prefix="$(pwd)/install-prefix" \
--enable-mclib \
--enable-aspell=/opt/homebrew
make -j$(sysctl -n hw.logicalcpu)
make check
make install
- uses: actions/upload-artifact@v4
if: failure()
with:
name: test-suite-logs-macos
path: ./**/test-suite.log

48
mcsrc/.github/workflows/ci-solaris.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: ci-solaris
on:
workflow_call:
jobs:
build-solaris:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Build on Solaris
uses: vmactions/solaris-vm@v1
with:
release: "11.4-gcc" # autoconf automake developer/gcc/gcc-c libtool pkg-config
prepare: |
pkg install --no-backup-be --no-refresh --accept -v \
aspell check glib2 libssh2 libx11
run: |
./autogen.sh
useradd -d "$(pwd)" test
chown -R test $(pwd)
su - test -c ' \
export PKG_CONFIG_PATH=/usr/lib/64/pkgconfig && \
\
./configure \
--prefix="$(pwd)/install-prefix" \
--with-screen=ncurses \
--enable-mclib \
--enable-aspell \
--enable-werror \
&& \
\
make && \
make check && \
make install \
'
- uses: actions/upload-artifact@v4
if: failure()
with:
name: test-suite-logs-solaris
path: ./**/test-suite.log

100
mcsrc/.github/workflows/ci-ubuntu.yml vendored Normal file
View File

@ -0,0 +1,100 @@
name: ci-ubuntu
on:
workflow_call:
jobs:
build-ubuntu:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get install -y autoconf autopoint check gettext indent libtool pkg-config
sudo apt-get install -y e2fslibs-dev libaspell-dev libglib2.0-dev libgpm-dev libncurses5-dev libpcre2-dev libslang2-dev libssh2-1-dev libx11-dev unzip
- name: Bootstrap build system
run: ./autogen.sh
- name: Build distribution archive
run: |
mkdir -p build-distrib && cd $_
../configure
make dist-bzip2
- name: Build full configuration
run: |
tar -xjf $(ls build-distrib/mc-*.tar.bz2) --one-top-level=build-full
cd build-full
../configure \
--prefix="$(pwd)/install" \
--enable-mclib \
--enable-aspell \
--enable-vfs-undelfs \
--enable-werror
make indent
# TODO: exit 1
git ls-files --modified
make -j$(nproc)
make check
make install
- name: Build ncurses & pcre2 configuration
run: |
tar -xjf $(ls build-distrib/mc-*.tar.bz2) --one-top-level=build-ncurses
cd build-ncurses
../configure \
--prefix="$(pwd)/install" \
--with-screen=ncurses \
--with-search-engine=pcre2 \
--enable-werror
make -j$(nproc)
make check
- name: Build minimal configuration
run: |
tar -xjf $(ls build-distrib/mc-*.tar.bz2) --one-top-level=build-minimal
cd build-minimal
../configure \
--prefix="$(pwd)/install" \
--disable-shared \
--disable-static \
--disable-maintainer-mode \
--disable-largefile \
--disable-nls \
--disable-rpath \
--disable-charset \
--disable-mclib \
--disable-assert \
--disable-aspell \
--disable-background \
--disable-vfs \
--disable-doxygen-doc \
--without-x \
--without-gpm-mouse \
--without-internal-edit \
--without-diff-viewer \
--without-subshell \
--enable-tests \
--enable-werror
make -j$(nproc)
make check
- uses: actions/upload-artifact@v4
if: failure()
with:
name: test-suite-logs-ubuntu
path: build-*/**/test-suite.log

30
mcsrc/.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: CI
on: [ push, pull_request ]
jobs:
call-build-ubuntu:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/ci-ubuntu.yml
call-build-fedora:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/ci-fedora.yml
call-build-alpine:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/ci-alpine.yml
call-build-macos:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/ci-macos.yml
call-build-solaris:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/ci-solaris.yml
call-build-freebsd:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/ci-freebsd.yml
with:
# https://github.com/GNUAspell/aspell/pull/651
CFLAGS: -Wno-strict-prototypes

32
mcsrc/.github/workflows/transifex.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: transifex
on:
push:
branches:
- master
jobs:
transifex-upload:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- name: Install gettext & po4a
run: sudo apt-get install -y gettext po4a
- name: Install modern Transifex client
run: |
mkdir -p $HOME/.local/bin && cd $HOME/.local/bin
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- run: ./maint/sync-transifex/po-to-transifex.py
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
- run: ./maint/sync-transifex/hints-to-transifex.py
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}

View File

@ -0,0 +1,48 @@
name: update-sources
on:
push:
branches:
- master
jobs:
update-sources:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install GNU Global
run: sudo apt-get install -y global exuberant-ctags python3-pygments
- name: Checkout source repo
uses: actions/checkout@v4
with:
repository: MidnightCommander/source
path: HTML
ref: gh-pages
ssh-key: ${{ secrets.SOURCE_DEPLOY_KEY }}
- name: Create sources index
run: |
pushd HTML
git rm -rf *
popd
gtags
htags --suggest -t "Welcome to the Midnight Commander source tour!"
./maint/htagsfix
- name: Deploy to GitHub
run: |
cd HTML
touch .nojekyll
echo "source.midnight-commander.org" > CNAME
git config user.name "GitHub Actions"
git config user.email "github@midnight-commander.org"
git add .
git commit -m "Deploy to GitHub Pages"
git push --force-with-lease

View File

@ -1,31 +0,0 @@
language: c
sudo: true
env:
- CFLAGS=-Wno-error=shadow
install:
- sudo apt-get update -qq
- sudo apt-get install -y autoconf gettext autopoint libtool check indent
- sudo apt-get install -y e2fslibs-dev libaspell-dev libglib2.0-dev libgpm-dev libncurses5-dev libslang2-dev libssh2-1-dev libx11-dev unzip
- sudo apt-get install -y wget exuberant-ctags python-pygments ruby
before_script:
- git fetch --tags
script:
- ./maint/utils/check-indent.sh
- ./autogen.sh
- ./maint/utils/travis-build.sh
after_success:
- openssl aes-256-cbc -K $encrypted_036881b9e9dd_key -iv $encrypted_036881b9e9dd_iv -in ./maint/utils/deploy-key.enc -out $HOME/.ssh/deploy-key -d
- chmod 600 $HOME/.ssh/deploy-key
- echo "Host github.com" >> $HOME/.ssh/config
- echo " IdentityFile ~/.ssh/deploy-key" >> $HOME/.ssh/config
deploy:
provider: script
script: ./maint/utils/travis-deploy.sh
on:
branch: master

View File

@ -1,5 +1,5 @@
## Process this file with automake to create Makefile.in.
AUTOMAKE_OPTIONS = 1.12
AUTOMAKE_OPTIONS = 1.14
SUBDIRS = po lib src doc contrib misc
@ -115,7 +115,7 @@ cppcheck-split-all: \
cppcheck-unusedFunction \
cppcheck-missingInclude
INDENT_CMD = indent \
INDENT_CMD = $(INDENT) \
--gnu-style \
--format-first-column-comments \
--indent-level4 \

View File

@ -1,3 +1,4 @@
m4_include([m4.include/gnulib/mc-gnulib-common.m4])
m4_include([m4.include/gnulib/mode_t.m4])
m4_include([m4.include/gnulib/stat-size.m4])
m4_include([m4.include/gnulib/fstypename.m4])
@ -13,6 +14,7 @@ m4_include([m4.include/ax_check_compile_flag.m4])
m4_include([m4.include/ax_append_flag.m4])
m4_include([m4.include/ax_append_compile_flags.m4])
m4_include([m4.include/mc-cflags.m4])
m4_include([m4.include/mc-stdckdint.m4])
m4_include([m4.include/ax_gcc_func_attribute.m4])
m4_include([m4.include/mc-check-search-type.m4])
m4_include([m4.include/mc-get-fs-info.m4])

View File

@ -2,23 +2,30 @@
set -e
srcdir="$(cd "$(dirname "$0")" && pwd)"
# Use backticks to support ksh on Solaris
basedir=`dirname "$0"`
srcdir=`cd "$basedir" && pwd`
cd "$srcdir"
${AUTORECONF:-autoreconf} --verbose --install --force -I m4 ${AUTORECONF_FLAGS}
# Customize the INSTALL file
rm -f INSTALL && ln -s doc/INSTALL
rm -f INSTALL && ln -s doc/INSTALL .
# Generate po/POTFILES.in
${XGETTEXT:-xgettext} --keyword=_ --keyword=N_ --keyword=Q_ --output=- \
if ! xgettext -h 2>&1 | grep -- '--keyword' >/dev/null ; then
echo "gettext is unable to extract translations, set XGETTEXT to GNU gettext!" >&2
touch po/POTFILES.in
else
${XGETTEXT:-xgettext} --keyword=_ --keyword=N_ --keyword=Q_ --output=- \
`find . -name '*.[ch]'` | ${SED-sed} -ne '/^#:/{s/#://;s/:[0-9]*/\
/g;s/ //g;p;}' | \
grep -v '^$' | sort | uniq >po/POTFILES.in
$srcdir/version.sh "$srcdir"
if test -x $srcdir/configure.mc; then
$srcdir/configure.mc "$@"
fi
"$srcdir/version.sh" "$srcdir"
if test -x "$srcdir/configure.mc"; then
"$srcdir/configure.mc" "$@"
fi

View File

@ -3,7 +3,7 @@ dnl Configure.in file for the Midnight Commander
dnl
dnl 2.64 is required at least for m4_esyscmd_s()
AC_PREREQ(2.64)
AC_PREREQ([2.64])
AC_INIT([GNU Midnight Commander], m4_esyscmd_s([./version.sh .]),
[https://www.midnight-commander.org/wiki/NewTicket], [mc],
@ -36,8 +36,16 @@ dnl ############################################################################
dnl Check for compiler
dnl ############################################################################
dnl This should be checked before toolchain macros, otherwise they will remember
dnl that ar cannot be found and linking via libtool will fail at a later stage
AC_CHECK_TOOLS([AR], [ar gar])
AC_PROG_CC
AM_PROG_CC_C_O
# AC_PROG_CC doesn't try enabling C99 in autoconf 2.69 and below, but
# AC_PROG_CC_C99 is deprecated in newer ones. In autoconf 2.70+ both
# will try enabling features up to C11.
m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_C99])
mc_CHECK_CFLAGS
@ -46,7 +54,7 @@ if test "x$CFLAGS" = "x"; then
CFLAGS_OPTS=" -O2 "
fi
if test x$USE_MAINTAINER_MODE = xyes; then
CFLAGS_OPTS="-g3 -O -ggdb"
CFLAGS_OPTS="-g3 -Og -ggdb"
AC_DEFINE(USE_MAINTAINER_MODE, 1, [Use maintainer mode])
fi
@ -61,6 +69,8 @@ dnl which causes attribute checks to fail
ax_gcc_func_attribute_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS=
AX_GCC_FUNC_ATTRIBUTE([fallthrough])
AX_GCC_FUNC_ATTRIBUTE([weak])
AX_GCC_FUNC_ATTRIBUTE([unused])
_AC_LANG_PREFIX[]FLAGS=$ax_gcc_func_attribute_save_flags
unset ax_gcc_func_attribute_save_flags
@ -87,9 +97,9 @@ if $HAVE_nroff; then
AC_CACHE_VAL(mc_cv_mandoc, [
nroff -mandoc < /dev/null > /dev/null 2>&1
if test $? = 0; then
mc_cv_mandoc=-mandoc
mc_cv_mandoc=-mandoc
else
mc_cv_mandoc=-man
mc_cv_mandoc=-man
fi
])
MANDOC=$mc_cv_mandoc
@ -99,9 +109,9 @@ if $HAVE_nroff; then
AC_CACHE_VAL(mc_cv_man_nocolor, [
nroff -c < /dev/null > /dev/null 2>&1
if test $? = 0; then
mc_cv_man_nocolor=-c
mc_cv_man_nocolor=-c
else
mc_cv_man_nocolor=
mc_cv_man_nocolor=
fi
])
MAN_FLAGS=$mc_cv_man_nocolor
@ -112,12 +122,12 @@ if $HAVE_nroff; then
mc_cv_nroff_tascii=
nroff -Tlatin1 < /dev/null > /dev/null 2>&1 /dev/null
if test $? = 0; then
mc_cv_nroff_tascii=-Tlatin1
mc_cv_nroff_tascii=-Tlatin1
else
nroff -Tascii < /dev/null > /dev/null 2>&1 /dev/null
if test $? = 0; then
mc_cv_nroff_tascii=-Tascii
fi
mc_cv_nroff_tascii=-Tascii
fi
fi
])
AC_MSG_RESULT([${mc_cv_nroff_tascii-no}])
@ -203,15 +213,12 @@ if $HAVE_FILECMD; then
fi
fi
dnl Only list browsers here that can be run in background (i.e. with `&')
AC_CHECK_PROGS(X11_WWW, [gnome-moz-remote mozilla firefox konqueror opera])
dnl ############################################################################
dnl Check for other tools
dnl ############################################################################
AC_CHECK_TOOL(AR, ar, ar)
AC_CHECK_TOOLS([INDENT], [gindent indent])
mc_UNIT_TESTS
@ -232,13 +239,15 @@ dnl Check for header files
dnl ############################################################################
AC_CHECK_HEADERS([string.h memory.h limits.h malloc.h \
utime.h sys/statfs.h sys/vfs.h \
sys/select.h sys/ioctl.h stropts.h arpa/inet.h \
sys/socket.h])
utime.h sys/statfs.h sys/vfs.h \
sys/select.h sys/ioctl.h stropts.h arpa/inet.h \
sys/socket.h])
dnl This macro is redefined in m4.include/gnulib/sys_types_h.m4
dnl to work around a buggy version in autoconf <= 2.69.
AC_HEADER_MAJOR
mc_CHECK_HEADER_STDCKDINT
dnl ############################################################################
dnl Check for types
@ -256,11 +265,17 @@ AC_TYPE_MODE_T
gl_PROMOTED_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_UID_T
AC_CHECK_TYPE([major_t], [], [AC_DEFINE([major_t], [int], [Type of major device numbers.])])
AC_CHECK_TYPE([minor_t], [], [AC_DEFINE([minor_t], [int], [Type of minor device numbers.])])
dnl Taken from GNU/Linux, and should be good enough on platforms lacking these types.
AC_CHECK_TYPE([dev_t], [unsigned long long int])
AC_CHECK_TYPE([ino_t], [unsigned long long int])
dnl Taken from GNU/Linux, and should be good enough on platforms lacking these types.
AC_CHECK_TYPE([major_t], [unsigned int])
AC_CHECK_TYPE([minor_t], [unsigned int])
AC_STRUCT_ST_BLOCKS
AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev, struct stat.st_mtim])
AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev, struct stat.st_mtim, struct stat.st_mtimespec, struct stat.st_mtimensec])
gl_STAT_SIZE
AH_TEMPLATE([sig_atomic_t],
@ -303,9 +318,9 @@ dnl Check for functions
dnl ############################################################################
AC_CHECK_FUNCS([\
strverscmp \
strncasecmp \
realpath
strverscmp \
strncasecmp \
realpath
])
dnl getpt is a GNU Extension (glibc 2.1.x)
@ -316,19 +331,6 @@ dnl replacing lstat with statlstat on sco makes it more portable between
dnl sco clones
AC_CHECK_FUNCS(statlstat)
dnl Overriding mmap support. This has to be before AC_FUNC_MMAP is used.
dnl We use only part of the functionality of mmap, so on AIX,
dnl it's possible to use mmap, even if it doesn't pass the autoconf test.
AC_ARG_WITH([mmap],
AS_HELP_STRING([--with-mmap], [Use the mmap call @<:@yes if found@:>@]))
if test x$with_mmap != xno; then
if test x$with_mmap = x; then
AC_FUNC_MMAP
else
AC_DEFINE(HAVE_MMAP, 1)
fi
fi
mc_GET_FS_INFO
@ -347,19 +349,14 @@ dnl ############################################################################
dnl OS specific stuff
dnl ############################################################################
case $host_os in
*os400)
AC_PATH_PROG([PERL], [perl], [/QOpenSys/pkgs/bin/perl])
AC_PATH_PROG([PERL_FOR_BUILD], [perl], [/QOpenSys/pkgs/bin/perl])
AC_PATH_PROG([PYTHON], [python], [/QOpenSys/pkgs/bin/python2])
AC_PATH_PROG([RUBY], [ruby], [/QOpenSys/pkgs/bin/ruby])
;;
*)
AC_PATH_PROG([PERL], [perl], [/usr/bin/perl])
AC_PATH_PROG([PERL_FOR_BUILD], [perl], [/usr/bin/perl])
AC_PATH_PROG([PYTHON], [python], [/usr/bin/python])
AC_PATH_PROG([RUBY], [ruby], [/usr/bin/ruby])
esac
AC_CHECK_DECLS([environ], , ,
[ #include <unistd.h>
#include <stdlib.h> ])
AC_PATH_PROG([PERL], [perl], [/usr/bin/env perl], [$PATH$PATH_SEPARATORQOpenSys/pkgs/bin])
AC_PATH_PROG([PERL_FOR_BUILD], [perl], [/usr/bin/env perl], [$PATH$PATH_SEPARATORQOpenSys/pkgs/bin])
AC_PATH_PROG([PYTHON], [python3], [/usr/bin/env python3], [$PATH$PATH_SEPARATORQOpenSys/pkgs/bin])
AC_PATH_PROG([RUBY], [ruby], [/usr/bin/env ruby], [$PATH$PATH_SEPARATORQOpenSys/pkgs/bin])
case $host_os in
aux*)
@ -369,7 +366,7 @@ aux*)
;;
esac
dnl If running under AIX, AC_AIX does not tell us that
dnl If running under AIX, AC_USE_SYSTEM_EXTENSIONS does not tell us that
AC_MSG_CHECKING([for AIX defines])
AC_EGREP_CPP([yes],
[
@ -386,14 +383,7 @@ AC_EGREP_CPP([yes],
])
dnl utimensat is supported since glibc 2.6 and specified in POSIX.1-2008
dnl utimensat() causes different timespec structures to cause failures on IBM i and AIX
case $host_os in
*os400 | aix*)
;;
*)
AC_CHECK_FUNCS([utimensat])
;;
esac
AC_CHECK_FUNCS([utimensat])
case $host_os in
*os400)
@ -421,17 +411,16 @@ AC_ARG_WITH([gpm-mouse],
case $host_os in
linux*)
if test x$with_gpm_mouse != xno; then
AC_CHECK_LIB(gpm, Gpm_Repeat,
[AC_DEFINE(HAVE_LIBGPM, 1,
[Define to enable gpm mouse support on Linux])
mouse_lib="gpm and xterm"
MCLIBS="$MCLIBS -lgpm"],
AC_CHECK_LIB(gpm, Gpm_Repeat,
[AC_DEFINE(HAVE_LIBGPM, 1, [Define to enable gpm mouse support on Linux])
mouse_lib="gpm and xterm"
MCLIBS="$MCLIBS -lgpm"],
if test "x$with_gpm_mouse" = "xyes"; then
[AC_MSG_ERROR([libgpm is missing or older than 0.18])]
else
[AC_MSG_WARN([libgpm is missing or older than 0.18])]
fi
)
)
fi
;;
esac
@ -478,12 +467,12 @@ AC_ARG_WITH([diff_viewer],
AS_HELP_STRING([--with-diff-viewer], [Compile with diff viewer @<:@yes@:>@]))
if test x$with_diff_viewer != xno; then
AC_DEFINE(USE_DIFF_VIEW, 1, [Define to enable diff viewer])
use_diff=yes
diff_msg="yes"
AC_MSG_NOTICE([using diff viewer])
AC_DEFINE(USE_DIFF_VIEW, 1, [Define to enable diff viewer])
use_diff=yes
diff_msg="yes"
AC_MSG_NOTICE([using diff viewer])
else
diff_msg="no"
diff_msg="no"
fi
mc_SUBSHELL
@ -502,12 +491,16 @@ test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
if test x${libexecdir} = x'${exec_prefix}/libexec'; then
EXTHELPERSDIR=${prefix}/libexec/${PACKAGE}/ext.d
EXTFSHELPERSDIR=${prefix}/libexec/${PACKAGE}/extfs.d
elif test x${libexecdir} = x'${exec_prefix}/lib'; then
EXTHELPERSDIR=${prefix}/lib/${PACKAGE}/ext.d
EXTFSHELPERSDIR=${prefix}/lib/${PACKAGE}/extfs.d
else
EXTHELPERSDIR=${libexecdir}/${PACKAGE}/ext.d
EXTFSHELPERSDIR=${libexecdir}/${PACKAGE}/extfs.d
fi
AC_SUBST(EXTHELPERSDIR)
AC_SUBST(EXTFSHELPERSDIR)
dnl ############################################################################
@ -523,9 +516,9 @@ ALL_DOC_LINGUAS="es hu it pl ru sr"
DOC_LINGUAS=
if test "x$USE_NLS" = xyes; then
if test -z "$LINGUAS"; then
langs="`grep -v '^#' $srcdir/po/LINGUAS`"
langs="`grep -v '^#' $srcdir/po/LINGUAS`"
else
langs="$LINGUAS"
langs="$LINGUAS"
fi
else
langs=
@ -533,10 +526,10 @@ fi
for h_lang in $ALL_DOC_LINGUAS; do
for lang in $langs; do
if test "$lang" = "$h_lang"; then
DOC_LINGUAS="$DOC_LINGUAS $lang"
break
fi
if test "$lang" = "$h_lang"; then
DOC_LINGUAS="$DOC_LINGUAS $lang"
break
fi
done
done
AC_SUBST(DOC_LINGUAS)
@ -606,7 +599,6 @@ misc/ext.d/Makefile
misc/ext.d/doc.sh
misc/ext.d/misc.sh
misc/ext.d/text.sh
misc/ext.d/web.sh
misc/macros.d/Makefile
misc/mc.ext.ini
@ -639,11 +631,13 @@ src/vfs/extfs/helpers/mailfs
src/vfs/extfs/helpers/patchfs
src/vfs/extfs/helpers/rpms+
src/vfs/extfs/helpers/s3+
src/vfs/extfs/helpers/torrent
src/vfs/extfs/helpers/uace
src/vfs/extfs/helpers/ualz
src/vfs/extfs/helpers/uar
src/vfs/extfs/helpers/uarc
src/vfs/extfs/helpers/uarj
src/vfs/extfs/helpers/uc1541
src/vfs/extfs/helpers/ucab
src/vfs/extfs/helpers/uha
src/vfs/extfs/helpers/ulha
@ -721,6 +715,7 @@ tests/lib/mcconfig/Makefile
tests/lib/search/Makefile
tests/lib/strutil/Makefile
tests/lib/vfs/Makefile
tests/lib/vfs/mc.charsets
tests/lib/widget/Makefile
tests/src/Makefile
tests/src/filemanager/Makefile

View File

@ -1,9 +1,9 @@
set MC_USER=`whoami`
if ($?TMPDIR) then
setenv MC_PWD_FILE $TMPDIR/mc-$MC_USER/mc.pwd.$$
if ($?MC_TMPDIR) then
setenv MC_PWD_FILE "`mktemp '$MC_TMPDIR/mc.pwd.XXXXXX'`"
else if ($?TMPDIR) then
setenv MC_PWD_FILE "`mktemp '$TMPDIR/mc.pwd.XXXXXX'`"
else
setenv MC_PWD_FILE /tmp/mc-$MC_USER/mc.pwd.$$
setenv MC_PWD_FILE "`mktemp '/tmp/mc.pwd.XXXXXX'`"
endif
@bindir@/mc -P "$MC_PWD_FILE" $*
@ -11,11 +11,10 @@ endif
if (-r "$MC_PWD_FILE") then
setenv MC_PWD "`cat '$MC_PWD_FILE'`"
if ("$MC_PWD" != "$cwd" && -d "$MC_PWD") then
cd "$MC_PWD"
cd "$MC_PWD" || true
endif
unsetenv MC_PWD
endif
rm -f "$MC_PWD_FILE"
unsetenv MC_PWD_FILE
unsetenv MC_USER

View File

@ -1,15 +1,20 @@
MC_USER=`whoami`
MC_PWD_FILE="${TMPDIR-/tmp}/mc-$MC_USER/mc.pwd.$$"
if test -n "$MC_TMPDIR"; then
MC_PWD_FILE="`mktemp "${MC_TMPDIR}/mc.pwd.XXXXXX"`"
elif test -n "$TMPDIR"; then
MC_PWD_FILE="`mktemp "${TMPDIR}/mc.pwd.XXXXXX"`"
else
MC_PWD_FILE="`mktemp "/tmp/mc.pwd.XXXXXX"`"
fi
@bindir@/mc -P "$MC_PWD_FILE" "$@"
if test -r "$MC_PWD_FILE"; then
MC_PWD="`cat "$MC_PWD_FILE"`"
if test -n "$MC_PWD" && test "$MC_PWD" != "$PWD" && test -d "$MC_PWD"; then
cd "$MC_PWD"
cd "$MC_PWD" || true
fi
unset MC_PWD
fi
rm -f "$MC_PWD_FILE"
unset MC_PWD_FILE
unset MC_USER

View File

@ -284,13 +284,14 @@ f2 Keyboard
2.7 What 'keys' are the "a1" and "c1" keys mentioned in the manual?
The "a1" key is the key which has the "a1" caption on it.
A1 is the "Home" key on the keypad (numpad 7 with Num Lock turned
off), which is decoded as a different key from the regular "Home".
Likewise C1 is keypad "End", A3 is keypad "Page Up", C3 is keypad
"Page Down", and B2 is documented to "center of keypad", i.e. the 5
key, though I don't know whether any keyboards actually use that.
They are documented for the curses library (search for "keypad"):
The "c1" key is the key which has the "c1" caption on it.
If you have to ask what these two keys are your keyboard hasn't
probably got them. Actually, I have never seen a keyboard which has
got them.
https://pubs.opengroup.org/onlinepubs/007908799/xcurses/curses.h.html
2.8 How do I change the key bindings?

View File

@ -13,16 +13,7 @@ lists.
Compiling from GIT
==================
To compile GNU Midnight commander from GIT, the following software is
required:
Autoconf 2.64 and above (latest is recommended)
Automake 1.12 and above (latest is recommended)
Gettext 0.18.2 and above
Glib 2.32 and above
Full list of requirements you can see at:
https://www.midnight-commander.org/wiki/doc/buildAndInstall/req
The full list of requirements is listed in the INSTALL file.
It is recommended that all those tools are installed with the same
prefix. Make sure that the tools with the right version are first in

View File

@ -1,31 +1,56 @@
This file contains:
- Build requirements for GNU Midnight Commander
- Installation instructions for GNU Midnight Commander
- Where to get more information on GNU Midnight Commander
- Notes about GNU Midnight Commander installation
- Obtaining related software
Build requirements for GNU Midnight Commander
----------------------------------------------------
---------------------------------------------
- glibc
- gcc
- glibc or uClibc or musl
- https://www.gnu.org/software/libc/
- https://uclibc.org
- https://www.musl-libc.org
- gcc or clang
- https://gcc.gnu.org
- https://clang.llvm.org
- make
- https://www.gnu.org/software/make/
- autoconf >= 2.64
- automake >= 1.12
- https://www.gnu.org/software/autoconf/
- automake >= 1.14
- https://www.gnu.org/software/automake/
- libtool
- https://www.gnu.org/software/libtool/
- pkg-config (optional)
- https://pkg-config.freedesktop.org/wiki/
- glib2 >= 2.32
- slang2 or ncurses
- https://www.gtk.org
- slang2 or ncurses screen library
- https://www.jedsoft.org/slang/
- https://invisible-island.net/ncurses/ncurses.html
- gettext >= 0.18.2
- libssh2 >= 1.2.8 is required only for sftp vfs
- libaspell to support spell checking in the internal editor
- ext2fs >= 1.42.4 to support ext{2,3,4}fs extended attributes
- https://www.gnu.org/software/gettext/
- pcre or pcre2 (as an alternative to glib-regexp)
- https://www.pcre.org
- gpm (general purpose mouse daemon as an alternative to xterm mouse)
- https://www.nico.schottelius.org/software/gpm/
- libssh2 >= 1.2.8 (required only for sftp vfs)
- https://libssh2.org
- libaspell (spell checking support in the internal editor)
- http://aspell.net
- ext2fs >= 1.42.4 (support for ext{2,3,4}fs extended attributes)
- https://e2fsprogs.sourceforge.net
Installation instructions for GNU Midnight Commander
----------------------------------------------------
Midnight Commander is written in a portable manner and uses GNU Autoconf
for configuration, so it is expected to compile without changes on many
other operating systems.
If you are installing from an official tarball, it already contains
pre-bootstrapped autotools build system (specifically the `configure'
script). In the case that you are installing from a version control
checkout, you need to bootstrap the build system yourself first using
the `autogen.sh' script. Note that to do this you would need to install
the autotools suite first and not only direct mc build dependencies.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation, and creates
the makefiles. It also creates a file `config.status' that you can run
@ -36,14 +61,7 @@ To compile this package:
1. Configure the package for your system.
Normally, you just `cd' to the directory containing the package's source
code and type `./configure'. If you're using `csh' on an old version of
SystemV, you might need to type `sh configure' instead to prevent `csh'
from trying to execute `configure' itself. Under AIX, you may need to
use ksh instead of sh.
Running `configure' takes a while. While it is running, it prints some
messages that tell what it is doing. If you don't want to see any
messages, run `configure' with the `--quiet' option.
code and type `./configure'.
To compile the package in a different directory than the one containing
the source code, you must use a version of `make' supporting the `VPATH'
@ -58,13 +76,6 @@ By default, `make install' will install the package's files in
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for architecture specific
files and architecture-independent files. If you give `configure' the
option `--exec-prefix=PATH', the package will use PATH as the prefix for
installing binary programs and libraries. Data files and documentation
will still use the regular prefix. Normally, all files are installed
using the same prefix.
If compiled on GNU/Linux, Midnight Commander detects if you have the gpm
library installed. If you installed the gpm mouse library in a
non-standard place, you will need to use the --with-gpm-mouse flag with
@ -89,9 +100,10 @@ incomplete, use `configure --help' to get the full list):
built-in file editor. The built-in editor is compiled in by
default.
`--enable-aspell'
This option adds spell check support in the internal editor using
libaspell. Disabled by default.
`--enable-aspell[=prefix]'
This option adds spell check support to the internal editor using
libaspell and optionally sets path to libaspell installation prefix
[default=/usr]. Disabled by default.
`--without-gpm-mouse'
Use this flag to disable gpm mouse support (e.g. if you want to
@ -102,12 +114,6 @@ incomplete, use `configure --help' to get the full list):
building binaries for distribution purposes and may not work on
some operating systems.
`--with-mmap', `--without-mmap'
Force using or not using the mmap function. It is currently used
in the internal viewer. `--with-mmap' may be useful on some
versions of AIX where the `configure' script decides that mmap is
broken, but it's actually suitable for the internal viewer.
`--with-subshell[=optional]', `--without-subshell'
The subshell support is by default turned on, you can disable
this by using the --without-subshell option. If you pass the
@ -219,9 +225,6 @@ ncurses):
Set path to ncurses library [default=/usr/lib]; make sense
only if --with-screen=ncurses is used.
Compiler options:
- - - - - - - - -
On systems that require unusual options for compilation or linking that
the package's `configure' script does not know about, you can give
`configure' initial values for variables by placing them in the command
@ -229,157 +232,17 @@ line:
./configure CC='gcc -traditional' LIBS=-lposix
Here are the variables that you might want to override when running
`configure'.
- Variable: CC
C compiler program. The default is `gcc' if found, otherwise `cc'.
- Variable: CFLAGS
The default flags used to build the program.
- Variable: INSTALL
Program to use to install files. The default is `install' if you
have it, `cp' otherwise.
For these variables, any value given in the command line is added to the
value that `configure' decides to use:
- Variable: LIBS
Libraries to link with, in the form `-lfoo -lbar...'.
- Variable: LDFLAGS
Linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
- Variable: CPPFLAGS
C/C++ preprocessor flags, e.g. -I<include dir> if you have
headers in a nonstandard directory <include dir>
If you need to do unusual things to compile the package, we encourage
you to figure out how `configure' could check whether to do them, and
mail diffs or instructions to the address given in the README so we can
include them in the next release.
2. Type `make' to compile the package.
3. Type `make install' to install programs, data files, and the
documentation. On GNU/Linux the console screen saver is installed as
well.
documentation.
4. You can remove the program binaries and object files from the source
directory by typing `make clean'. If you want to clean the source tree
completely, so that it contains only those files that should be packaged
in the archive, issue `make distclean'. If you've run configure in a
different directory than the source tree, distclean won't remove your
*.o and linked programs in that directory.
If you're on a GNU/Linux system, this will install the `cons.saver'
utility, which allows the Midnight Commander to save and restore the
console contents. This utility can be installed setuid root, but it's
only needed on systems where users cannot access /dev/vcsaN, where N is
the virtual console number, on which the uses is logged on.
5. GNU Midnight Commander allows you to stay in the last current
directory after exiting MC. This is done with a shell function, the man
page has more information about this.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need it if you want to regenerate
`configure' using a newer version of `autoconf'.
Where to get more information on GNU Midnight Commander
-------------------------------------------------------
There are two mailing lists for the program:
mc@lists.midnight-commander.org: Discussion on GNU Midnight Commander file manager.
mc-devel@lists.midnight-commander.org: Discussion between the developers of the program.
To subscribe to the mailing lists, visit their respective pages:
https://lists.midnight-commander.org/mailman/listinfo/mc/
https://lists.midnight-commander.org/mailman/listinfo/mc-devel/
Notes about GNU Midnight Commander installation
-----------------------------------------------
GNU Midnight Commander has been run in the following configurations:
i386-*-linux
sparc-*-linux
alpha-*-linux
powerpc-*-linux
mips-dec-{open,net}bsd1.0
mips-sgi-irix5.2
mips-sgi-irix5.3
powerpc-ibm-aix5.3.0.0 (IBM XL C, IBM XL C/C++)
sparc-sun-sunos4.1
sparc-sun-netbsd1.0
sparc-sun-solaris2.3
hppa-hp-hpux9
hppa-hp-hpux7
m68k-apple-aux
mc88110-aviion-dgux5.4
i386-*-bsdi2
i386-*-freebsd4.3
i386-*-openbsd2.9
Midnight Commander is written in a portable manner and uses GNU Autoconf
for configuration, so it is expected to compile without changes on many
other operating systems.
You will need an ANSI C Compiler (such as GCC) and glib library to
compile the source. GNU Midnight Commander now comes with the S-Lang
screen manager, a fast screen manager, but you may want to use the
already installed S-Lang or ncurses library.
If you insist on using ncurses, it's recommended to use ncurses 4.1 and
above, since the older versions don't support resizing in the xterm
window.
GNU Midnight Commander comes with the mouse support on xterms and in the
Linux console. In order to take advantage of the mouse support on the
Linux console you will need the gpm mouse server (see the section
"Obtaining related software" in this file).
Once you get gpm, compile it and install it, then you will have to
specify the `--with-gpm-mouse' flag to the configure program if you
installed it in a non-standard directory. If you installed the gpm
package under /usr or /usr/local, you don't need to specify this flag;
configure will find gpm for you. The support for mice on xterms is
always compiled in.
We are working on further enhancements to the program, but we're not
sure which ones must go first. If you would like to point us in the
Right Direction we will be glad to hear from you.
If you happen to find a feature that doesn't do what you expect, please
write to mc@lists.midnight-commander.org telling as much as you can
about the problem you're experiencing. Please don't send personal
messages to the maintainers.
Obtaining related software
--------------------------
glib
----
The only "hard" dependency of GNU Midnight Commander is glib. You can
get glib from
ftp://ftp.gnome.org/pub/gnome/sources/glib/
Minimal version of glib: 2.32.0
Recommended version: 2.32.x and higher.
Newer versions may work, but haven't been tested.
PCRE
----
Both PCRE and PCRE2 libraries are supported.
You can get PCRE from
http://www.pcre.org/
Terminal database
-----------------
@ -388,66 +251,23 @@ There are many incomplete terminal databases out there, however, a
complete terminfo is bundled with ncurses. (It is simple to generate
the termcap database using the infocmp utility in ncurses).
Some terminfo data are included with the mc distribution (lib/*.ti).
Particularly linux, xterm and vt100. Use e.g. ''tic linux.ti'' to use
them.
If you want to run mc on xterm/color_xterm/ansi_xterm (not rxvt), then
you might read lib/README.xterm for further information.
you might read contrib/README.xterm for further information.
Screen libraries
----------------
GNU Midnight Commander can use the included version of S-Lang, but you
can get the latest version here:
Porting
-------
http://www.s-lang.org/
Some less widespread UNIX systems like AIX or Solaris often come with their own
implementations of make and relevant parts of the toolchain necessary to build
mc. While autotools abstract a lot of platform specific issues, you might
encounter unresolved problems while using the native toolchain.
Alternatively, you can use ncurses:
Often, GNU tools are shipped as a part of an additional software collection
(/opt/freeware on AIX, or OpenCSW on Solaris). These tools are usually prefixed
with the letter `g', e.g. `gmake' instead of `make'. If you are not really
interested in building with the native toolchain, try to override tools causing
problems like this:
http://www.gnu.org/software/ncurses/ncurses.html
Mouse support
-------------
The general purpose mouse (gpm) daemon is available from
http://unix.schottelius.org/gpm/
Compiler
--------
If your C compiler is not powerful enough to compile GNU Midnight
Commander, you should report is as a bug to the GNU Midnight Commander
team. Sometimes there is no solution than upgrading to a modern and
free compiler - GCC (Compiler Collection):
http://gcc.gnu.org/
AIX
---
Currently you can not use gcc 4.2.4 (and probably other versions) on
AIX to compile the S-Lang version. Please use IBM XL C or IBM XL C/C++
instead.
If you compile a ncurses version you need to set TERM=dtterm to get
working color support. Furthermore it is important to specify the
--with-ncurses-includes/--with-ncurses-lib parameters because otherwise
mc will pick up term.h from AIX which does not work with the ncurses
library.
The AIX S-Lang build was tested with S-Lang 2.0.7. Later versions may
also work but are not tested yet.
Here is an example for S-Lang, it is assumed that the S-Lang library
is installed under /user/local and that you also want want to install
to /usr/local:
export CC=cc_r
export CXX=xlC_r
export CONFIG_SHELL=/usr/bin/bash (if installed)
export SHELL=/usr/bin/bash (if installed)
./configure \
--prefix=/usr/local \
--with-screen=slang
./configure MAKE=gmake AR=gar
gmake

View File

@ -1,51 +0,0 @@
Read the INSTALL file for the complete instructions.
GNU Midnight Commander requires glib2.
GNU Midnight Commander uses the S-Lang screen library by default. It
tries the S-Lang library installed on the system. If it's not found,
the included S-Lang sources are used. It is also possible to use
ncurses as the screen library.
1. Configure the package for your system.
Normally, you just `cd' to the package main directory and type
`./configure'.
The most often needed options to configure are following:
`--prefix=PATH'
By default, `make install' will install the package's files
in `/usr/local/bin', `/usr/local/man', etc. or to `/usr/bin',
`/usr/man', etc. depending on the location of an old mc binary.
If you have none in your system, default will be `/usr/local'.
You can specify an installation prefix other than default by
giving `configure' the option `--prefix=PATH'.
`--with-screen={slang|ncurses}'
Choose the library used to manage interaction with the terminal.
`slang' means S-Lang library already installed on the system,
`ncurses' means ncurses library already installed on the system.
The installed S-Lang library is used by default if found.
You may also want to specify CFLAGS for the compiler, even if it finds
itself some defaults by typing e.g.
./configure CFLAGS=-O3
2. Type `make' to compile the package.
3. Type `make install' to install programs, data files, and
documentation. You may need to run this command as root.
If you're on a GNU/Linux system, this will install the `cons.saver'
utility, which allows the Midnight Commander to save and restore the
screen contents. This utility can be installed setuid root, but it's
only needed on systems where users cannot access /dev/vcsaN, where N is
the virtual console number, on which the uses is logged on.
If you're making a mc binary distribution for other people and want to
package the whole installed tree, use `make install DESTDIR=PATH', which
will make PATH the root for installation.
4. Type `mc' and enjoy!

View File

@ -1 +0,0 @@
Email: mc-devel@lists.midnight-commander.org

View File

@ -1,10 +0,0 @@
This is a list of sites known to mirror the Midnight Commander release.
----------
The Midnight Commander distribution is placed at:
* http://ftp.osuosl.org/pub/midnightcommander/
* ftp://ftp.osuosl.org/pub/midnightcommander/
-----------

View File

@ -1,7 +1,7 @@
DIST_SUBDIRS = hints man hlp
SUBDIRS = hints man hlp
DOCS = FAQ HACKING INSTALL INSTALL.FAST MAINTAINERS README.QNX MIRRORS.txt
DOCS = FAQ HACKING INSTALL
EXTRA_DIST = $(DX_CONFIG) doxygen-include.am $(DOCS)
include doxygen-include.am

View File

@ -1,34 +1,140 @@
Version 4.8.33
Starting with this release, we will be using language features that require a C99 compiler to build.
- Core
* Minimal version of Automake is 1.14 (#4604)
* Upgrade C standard to C99 (#4604)
* Support ksh variants as subshell (#3748)
* Improve fish 4.0 shell support (#4597)
* Add support for bash PROMPT_COMMAND being an array (#4599)
* Don't override ENV variable for ash/dash subshell (#4605)
* Don't disable verbose mode if tty baudrate can't be reliably determined (#2452)
* New keymap for vim users (#4588)
- VFS
* extfs vfs: chmod/chown inside extfs (e.g. zip archive) silently fails (#4629)
* Add embedded torrent viewer/vfs (#3100)
- Misc
* Code cleanup (#4572, #4593, #4595, #4598)
* Adjust mc-wrappers to work with the new MC_TMPDIR creation logic (#4575)
* Prefer console players for sound, images and video in non-graphical sessions (#4479, #4596)
* Support `TERM=xterm-clear` for FreeBSD users (#2633)
* mc.ext.ini:
- Support for Rust crates file format (#4609)
- Support for OpenEmbedded ipk archives (#4626)
* ext.d: select browser at runtime (#4615)
* Move CI from Travis to GitHub Actions (#4170, #3738, #4602)
- Fixes
* Segfault if filter makes file panel empty (#4600)
* Segfault in built-in help when going to the previous topic (#4627)
* Incorrect handling of ext2 attributes of a directory (#4590)
* Failed copy/move operations make ETA inaccurate (#3205, #4613, #4623)
* Hotlist: use after free (#4621)
* mc.ext.ini: typo for apt view command line (#4583)
* mcedit: visual glitches if built with aspell, but libraries not installed (#4576)
* mcedit: segfault on new file creation (#4580)
* mcedit: PageDown skips lines in edit window (#4617)
* mcedit: cursor jumps during PageDown in edit window (#4618)
* mvciew: false-positive regex search of BOL (#4587)
* mcdiff: segmentation fault on empty files merge (#4608)
* tar vfs: double free (#4616)
* sftpfs vfs: use after free (#4620)
* tests: fix charset-related code on non-glibc platforms (Alpine, Illumos) (#3972, #4495)
* tests: use weak symbols instead of symbol duplication to support non-GNU linkers / macOS (#4584, #3542)
Version 4.8.32
- Core
* Tell the current directory to the terminal using OSC 7 sequence (so it can open new tabs there) (#3088)
* Preserve ext2fs attributes on copy/move operations (#4532)
* Change name of temporary directory: make it unique for each run (#4535)
* Hide password in file operation progress dialog (#4541)
* Support reget in file move operation (#4563)
* Implement nanosecond precision timestamps on non-Linux (macOS, BSD, AIX, Solaris) (#4563)
* Remove remaining mmap code to simplify maintenance (#3960)
- VFS
* extfs: support unrar-7 (#4518)
- Editor
* Improve syntax highlighting:
- C and C++ (MidnightCommander/mc#195, #4556)
- Diff viewer
* Add man page mcdiff.1 (#4224)
- Misc
* Code cleanup (#4524)
* New skins
- xoria256-thin, xoria256root-thin (#4530)
- modarcon16-defbg-thin, modarcon16-thin, modarcon16root-defbg-thin, modarcon16root-thin (#4530)
- modarin256-defbg-thin, modarin256-thin, modarin256root-defbg-thin, modarin256root-thin (#4530)
- julia256root (#4536)
* mc.ext.ini: clarify escaping of spaces and parenthesis (#4502)
- Fixes
* External editor does not work with arguments in $EDITOR (#4533)
* fish shell: strings " cd (printf '%b' ... " in history (#4521)
* Redundant back slashes for autocomplete (#4292)
* subshell: call execl with argv[0] that is not an actual path to Bash (#4549)
* mcedit: php.syntax: comment highlight from start of light only (#4519)
* mcedit: wrong replacement using regular expressions with begin or end of line (#4525, #4526)
* mcedit: losing column position when navigating up/down (MidnightCommander/mc#194)
* mcedit: macro deletes text (#4540)
* mcedit: macros are applied to the pasted text (#4562)
* extfs: iso9660: xorriso is slow to open an ISO image (#3570, #4567)
* extfs: u7z: wrong add of nested directories to archive (#4559)
* extfs: segfault on enter to deleted archive (#4560)
* tar: segfault on copy files from archive (#4561)
* man: typo (#4550)
Version 4.8.31
- Core
* Minimal version of GLib is 2.32.0.
* Minimal version of GLib is 2.32.0.
- VFS
* fish: drop support of native FISH server and protocol. Rename VFS to shell (#4232)
* extfs;
* uc1541 extfs: update up to 3.6 version (#4511)
* s3+: port to Python3 (#4324)
* Support for LZO/LZOP compression format (#4509)
* fish: drop support of native FISH server and protocol. Rename VFS to shell (#4232)
* extfs;
- uc1541 extfs: update up to 3.6 version (#4511)
- s3+: port to Python3 (#4324)
* Support for LZO/LZOP compression format (#4509)
- Misc
* Skins: add color for non-printable characters in editor (#4433)
* Code clean up (#4490)
* Skins: add color for non-printable characters in editor (#4433)
- Fixes
* FTBFS on FreeBSD with ext2fs attribute support (#4493)
* Broken stickchars (-a) mode (#4498)
* Wrong timestamp after resuming of file copy operation (#4499)
* Editor: wrong deletion of marked column (#3761)
* Diff viewer: segfault when display of line numbers is enabled (#4500)
* Tar VFS: broken handling of hard links (#4494)
* Sftp VFS: failure establishing SSH session due hashed host names in ~/.ssh/known_hosts (#4506)
* Shell VFS: incorrect file names with cyrillic or diacritic symbols (#4507)
* mc.ext.ini: incorrect description of of how multiple sections and keys with same names are processed (#4497)
* mc.ext.ini: unescaped backslash \ is treated as invalid escape sequence in glib-2.77.3 and glib-2.79 (#4502)
* mc.ext.ini: file "Makefile.zip" is handled as Makefile not as zip-arhive (#4419)
* FTBFS on FreeBSD with ext2fs attribute support (#4493)
* Broken stickchars (-a) mode (#4498)
* Wrong timestamp after resuming of file copy operation (#4499)
* Editor: wrong deletion of marked column (#3761)
* Diff viewer: segfault when display of line numbers is enabled (#4500)
* Tar VFS: broken handling of hard links (#4494)
* Sftp VFS: failure establishing SSH session due hashed host names in ~/.ssh/known_hosts (#4506)
* Shell VFS: incorrect file names with cyrillic or diacritic symbols (#4507)
* mc.ext.ini: incorrect description of of how multiple sections and keys with same names are processed (#4497)
* mc.ext.ini: unescaped backslash \ is treated as invalid escape sequence in glib-2.77.3 and glib-2.79 (#4502)
* mc.ext.ini: file "Makefile.zip" is handled as Makefile not as zip-arhive (#4419)
Version 4.8.30

View File

@ -1,12 +1,12 @@
Contents
--------
Introduction
Dependencies
Features
Mini-documentation
Where to get more information
Reporting problems
* Introduction
* Dependencies
* Features
* Mini-documentation
* Where to get more information
* Reporting problems
Introduction
@ -141,15 +141,19 @@ Where to get more information
There is a webpage for GNU Midnight Commander at
https://www.midnight-commander.org/
* https://www.midnight-commander.org
This page also has current information about mailing lists and some
useful advices how to report bugs.
You can download the latest version of GNU Midnight Commander from
https://www.midnight-commander.org/downloads/
* https://www.midnight-commander.org/downloads/
The Midnight Commander distribution is placed at:
* http://ftp.osuosl.org/pub/midnightcommander/
* ftp://ftp.osuosl.org/pub/midnightcommander/
Reporting problems
------------------
@ -168,8 +172,6 @@ There are two mailing lists:
Use mc-devel@ if you are prepared for a more technical discussion
with the developers of the package, otherwise use mc@.
Please don't sent HTML e-mail to either of those mailing lists.
Include the output of "mc --version", the operating system and the
distribution (if applicable) you are using, the compiler and the
configure flags used to compile the program (if you know them).

View File

@ -1,313 +0,0 @@
Midnight Commander for QNX (not QNX Neutrino)
---------------------------------------------
1. Compiling
2. Running 'mc' under QNX
3. List of modifications on mc-4.1.33
4. TODO
5. Contact information
1. Compiling
------------
1.1 Make utility
----------------
Use 'gmake'. (This is the default 'make' under QNX 4.23+). [The old 'qmake'
cannot handle the makefiles in the mc-source.]
1.2 Configuring
---------------
If you don't have an installed TCP/IP development kit, you have to 'hide'
the library file 'socket3r.lib' (can be installed by e.g. Watcom C 10.6)
in /usr/lib or /usr/watcom/10.6/usr/lib, because the existence of this file
will confuse 'configure': it will erroneously assume you have the complete
TCP/IP development kit (with headers) and will enable compiling of the
network-related VFS code (not only tarfs).
[A patch would be required in the configure-script to check the existence
of the TCP/IP-related headers also...]
Use '--disable-nls' option, if you don't have the binary utilities of
GNU 'gettext' package (e.g. 'msgfmt'). ['--with-included-gettext' doesn't
really work in 4.1.33, there are configuration/compiling problems...]
1.3 Compiler
------------
It is advised to use Watcom C 10.6+ to compile the source, because older
compilers (e.g. 9.52) do not support some convenient/required features.
[e.g. 'ar'-compatible 'wlib',...]
1.4 "No prototype found for '<function>'" warnings
--------------------------------------------------
It is advised to use high warning level (e.g. 'CFLAGS="-w4" ./configure'),
when compiling the source, because Watcom C uses a special parameter passing
convention for functions with fixed number of arguments only. So if the
compiler doesn't see the correct prototype of a function with variable
number of arguments (like printf()), it will produce a warning about the
missing prototype, but generates function call code according to the special
parameter passing convention, not the required CDECL convention (it is used
by default for functions with variable number of arguments). So the calling
convention of the function call code and the function code itself will not
match! So you MUST provide the correct prototype for function with variable
number of arguments! (Or you can force using the stack-based calling
convention as a default, if you have the stack-call-conv version of all of the
required libraries ('<name>3s.lib')...[Watcom C 10.6 required!])
[The latest release version (4.1.33/qnx) is checked against these types of
missing prototypes...]
1.5 Tested configuration
------------------------
QNX 4.24
Watcom C 10.6 (release version, no newer beta patches)
Photon 1.12
no TCP/IP development kit (-> VFS: tarfs only!)
mc-4.1.33, mc-4.1.34
2. Running 'mc' under QNX
-------------------------
Using 'qnx*' terminals:
You cannot use your keyboard correctly, if you disable the "Full 8 bits
input" feature in the 'Options|Display bits...' dialog.
On 'qnx*' terminals 'mc' will run in black and white mode by default,
because these types of terminals use non-ANSI-compatible color sequences.
Accessing remote nodes via the native QNX-network:
[The problem exists under the older versions of 'mc' only...]
If directory panels cannot handle '//<node-id>' prefix in directory names,
use directory links in order to access remote nodes on the native QNX
network:
mkdir /net
ln -sf //1/ /net/1
...
Extension and menu files:
Default 'tar' uses 'stderr' (and not 'stdout' as its 'normal' output with
'-t' option.
Default 'tar' is not a GNU 'tar', so does not understand '-z' option.
Special key-mappings:
Restrictions of the META-? as Alt-? functionality:
[META-? as ESC-? will always work!!!]
Alt-TAB -> Ctrl-TAB (Alt-TAB reserved in Photon [1.12+])
Alt-ENTER -> Ctrl-ENTER ('qnx*' terminals only)
Alt-<uppercase letter>: doesn't work
'qansi*' terminals:
Problem [QNX 4.23+ only]: screen corruption (strange line-drawing character
set handling) on 'qansi*' terminals, if linked with mc/Slang/terminfo
terminal management. (Older versions of QNX and Slang/termcap not affected.)
This problem is solved, see the comments in slang/sldisply.c about
SLTT_TRANSP_ACS_PATCH and QNX_QANSI_SLANG_COMPAT_ACS!
other terminals:
I have tested 'mc' under QNX on 'qnx*' and 'qansi*' terminals only.
toggle panels on/off (CTRL-o):
Currently not supported, but could be implemented later...
3. List of modifications on mc-4.1.33/mc-4.1.34
-----------------------------------------------
edit/
syntax.c: (4.1.33 only, fixed in 4.1.34)
line 100,191: WCC 10.6 doesn't like "<label>: }" construct ("no statement
after the label"), modified to "<label>: /*nop*/; }".
lib/
mc.menu:
'Z' on 'tar.Z' and 'tar.z' files: '%f' -> '$1'.
mc.ext.in.qnx.diff:
QNX: modified 'mc.ext.in'. [tar -t: output to stderr,...]
(No automatic install implemented: patch must be applied before
running 'configure' [->mc.ext.in.qnx.diff!]; this patch can be not
only QNX-specific...)
Makefile.in:
'mc.ext.in.qnx.diff' added to DISTLIB.
slang/
sldisply.c:
SLTT_TRANSP_ACS_PATCH dependent code:
The problem: some terminals (e.g. QNX/qansi*) map the whole upper half of
the ASCII table to the lower half, when alt-char-set is activated with
the smacs/as string-sequence. This means, that if 0 <= ch < 128 written
to the terminal, it will be translated to (ch+128) automatically by the
terminal: so not only the line-drawing characters can be written, when
the alt-char-set is activated. It implicitly means, that space, NL, CR,
etc. characters (exactly: anything besides the "standard" line drawing
characters) cannot be written directly to the terminal, when the
alt-char-set is activated, because writing these characters doesn't cause
an implicit/temporary switching-back to the standard char-set!
The original code in SLang assumes that space, NL, CR, etc. can be
printed when alt-char-set is activated. If SLTT_TRANSP_ACS_PATCH is
defined, the modified code will not use this assumption.
[Remark: the patch-code is not the most exact solution, but works...]
QNX_QANSI_SLANG_COMPAT_ACS_PATCH dependent code:
A more OS/terminal-specific solution for the problem mentioned above
(->SLTT_TRANSP_ACS_PATCH).
If QNX_QANSI_SLANG_COMPAT_ACS is defined, the default smacs/sa, rmacs/ae,
acsc/ac [and sgr/sa, if it would be used!] command sequences will be
replaced internally with the "old style" (pre-QNX 4.23) sequences in case
of QNX/qansi terminals. Using these optional command sequences the terminal
remains compatible with the original SLang code (without using the
workaround-code enabled by defining SLTT_TRANSP_ACS_PATCH).
Remark:
Currently SLTT_TRANSP_ACS_PATCH is not auto-configured by 'configure'.
(Must be manually defined...)
There is some (QNX-specific) auto-configuration hand-coded in the source:
#ifdef SLTT_TRANSP_ACS_PATCH
# if defined(__QNX__) && defined(QNX_QANSI_SLANG_COMPAT_ACS)
# undef SLTT_TRANSP_ACS_PATCH
# endif
#else
# if defined(__QNX__) && !defined(QNX_QANSI_SLANG_COMPAT_ACS)
# define QNX_QANSI_SLANG_COMPAT_ACS 1
# endif
#endif
slutty.c:
"newtty.c_iflag &= ~(ECHO | INLCR | ICRNL);"
ECHO(0x08) is a c_lflag bit, it means PARMRK(0x08) in c_iflag. (!?!)
src/
file.c:
'do_reget' can be extern if (ENABLE_VFS && USE_NETCODE), not if (ENABLE_VFS).
find.c:
search_content():
variable 'i' "must be" 'int', not 'char'. ["i == -1": (buggy?) WCC 10.6
doesn't convert automatically (int)(-1) to (char)(-1) (GCC does), so
"comparison result always 0" warning produced. It is cleaner to define
'i' as 'int', than cast '-1' to 'char', because 'read()' returns 'int'.]
key.c:
init_key():
Call load_xtra_key_defines() and clear 'use_8th_bit_as_meta' by default
under QNX, if a 'qnx*' terminal detected. (A saved config file (mc.ini)
can override it later...)
key.h:
Declare load_xtra_key_defines().
keyxdef.c:
Provides a method to define some platform-specific additional key
mappings. (e.g. QNX terminals can handle most of META-? combinations as
ALT-?...)
(Currently not listed in doc/FILES...)
layout.c:
TIOCGWINSZ must be available (<sys/ioctl.h> included), because window-
resizing code doesn't work, if not defined.
main.c:
print_usage(): reserved name in the QNX run-time library!
print_usage() -> print_mc_usage()
mouse.c:
QNX: ncurses 1.9.8a ported to QNX doesn't provide the 'SP' pointer as a
global symbol in the library, so the keyok() emulation currently cannot
be used under QNX (4.24 & Watcom C 10.6 release version).
slint.c:
QNX: 'qansi*' terminals added to the color_terminals[] list.
subshell.c:
utilunix.c:
QNX: include <unix.h> to get prototype for exec*()!!!
[See README.QNX/Section 1.4!]
Makefile.in:
'keyxdef' module added to SRCS and OBJS.
vfs/
<mc-src-root>/
README.QNX:
QNX-specific notes...
configure (line 3369):
configure.in (line 88):
(mc-4.1.34 only)
'test x$CCOPTS = x;' => 'test "x$CCOPTS" = x;'
Makefile.in:
README.QNX added to DISTMAIN.
4. TODO
-------
Because of limited time and resources now I can define a 'wish list' only:
(maybe somebody in the QNX community can help...)
subshell support with panel switch on/off ?
mouse under Photon (with qnxm, qansi-m terminals) ?
...
5. Contact information
----------------------
Please report QNX-specific bugs and comments via e-mail to: gt_cosy@usa.net
-------------
Tamasi Gyorgy
-------------

View File

@ -1,87 +1,87 @@
Падказка. «C-x t» перапісвае ў камандны радок назвы пазначаных файлаў.
Падказка: выкарыстоўвайце "C-x t", каб капіяваць у камандны радок назвы пазначаных файлаў.
Падказка. «C-x p» перапісвае у камандны радок дзейны шлях.
Падказка: выкарыстоўвайце "C-x p", каб капіяваць у камандны радок бягучы шлях.
Падказка. «M-Tab» ці «Esc+Tab» дапаўняе набранае. Каб убачыць сьпіс, націсьніце двойчы.
Падказка: выкарыстоўвайце "M-Tab" або "Esc+Tab" для дапаўнення. Каб убачыць спіс, націсніце двойчы.
Падказка. «M-p» і «M-n» дае доступ да гісторыі каманд.
Падказка: выкарыстоўвайце "M-p" і "M-n" для доступу да гісторыі каманд.
Падказка. Трэба ўставіць знак літаральна? Цісьніце «Control-q» і знак.
Падказка: каб уставіць знак у двукоссях, выкарыстоўвайце "Control-q" і знак.
Падказка. Стаміліся ад гэтах парадаў? Забараніце іх у мэню «Налады» → «Выгляд».
Падказка: калі стаміліся ад гэтах паведамленняў, то можаце адключыць іх у меню "Параметры" → "Макет".
Падказка. Каб пазначыць каталёґі, дадайце касую рысу ( / ) ў канец шаблёну.
Падказка: для пазначэння каталогаў дадайце касую рысу ( / ) у канец адпаведнага шаблона.
Падказка. Калі тэрмінал ня мае функцыянальных клявішаў, ужывайце «ESC+лічба».
Падказка: калі ў тэрмінала няма функцыянальных клавіш, выкарыстоўвайце "ESC+лічба".
Падказка. Сайт «Міднайт Камандэра» — https://www.midnight-commander.org.
Падказка: сайт GNU Midnight Commander — https://www.midnight-commander.org
Падказка. Пра хібы паведамляйце на mc-devel@lists.midnight-commander.org.
Падказка: пра хібы паведамляйце на mc-devel@lists.midnight-commander.org
Падказка. «Tab» пераключае дзейную панэль.
Падказка: клавішай "Tab" пераключаецца бягучая панэль.
Падказка. VFS — гэта зручна: націсьніце «Ўвод» на архіве, і ўбачыце яго зьмесьціва.
Падказка: VFS вельмі зручная - націсніце на архіве "Enter", і ўбачыце яго змесціва.
Падказка. У нас ёсьць даведка ў man.
Падказка: мы маем зручную даведку.
Намінка. Хочаце перасоўвацца, як у «Lynx»? Вызначце гэта ў «Настаўленьнях».
Падказка: калі хочаце навігацыю ў стылі Lynx, можаце абраць гэта ў канфігурацыі.
Падказка. Макрасы «%» працуюць нават у камандным радку.
Падказка: макрасы % працуюць нават у камандным радку.
Падказка. «M-!» дазваляе выконваць праґрамы, а вывад бачыць у праглядніку.
Падказка: з дапамогай "M-!" можна запускаць праграмы і глядзець вывад.
Падказка. Выгляд пераліку файлаў можна зьмяніць — глядзіце «man mc».
Падказка: фармат спіса файлаў можна змяніць — глядзіце "man mc".
Падказка. «%D» і «%T» выводзіць каталёґ насупраць і пазначаныя ў ім файлы.
Падказка: з дапамогай "%D" і "%T» насупраць выводзіцца каталог і пазначаныя ў ім файлы.
Падказка. Хочаце звычайную абалонку? Цісьніце «C-o», а каб вярнуцца — «C-o» яшчэ раз.
Падказка: калі хочаце звычайную абалонку, націсніце "C-o", а каб вярнуцца — "C-o" яшчэ раз.
Падказка. Каб хутчэй набіраць каманды «cd …», вызначце зьменную «CDPATH».
Падказка: каб хутчэй набіраць каманды "cd…", наладзьце зменную "CDPATH".
Падказка. Калі хочаце бачыць схаваныя файлы «.*», вызначце гэта ў «Настаўленьнях».
Падказка: калі хочаце бачыць схаваныя файлы ".*", наладзьце гэта ў канфігурацыі.
Падказка. Хочаце бачыць файлы адноўкі «*~»? Вызначце гэта ў «Настаўленьнях».
Падказка: калі хочаце бачыць файлы рэзервовых копій "*~", то наладзьце гэта ў канфігурацыі.
Падказка. Ва ўсіх радках уводу і дыялёґах можна дапаўняць: націсьніце «M-Tab».
Падказка: дапаўненне працуе ва ўсіх радках уводу і дыялогавых вокнах; проста націсніце "M-Tab".
Падказка. На павольных тэрміналах можа дапамагчы пазнака «-s».
Падказка: на павольных тэрміналах можа дапамагчы адзнака "-s".
Намінка. Шукаць файл: кнопка «На панэль» дазваляе працаваць са знойдзеным.
Падказка: вы можаце працаваць са знойдзенымі файламі з дапамогай кнопкі "На панэль".
Падказка. Калі патрэбны складаны пошук, ужывайце каманду «На вонкавую панэль».
Падказка: калі патрэбны складаны пошук, ужывайце вонкавую каманду "На панэль".
Падказка. Каб хутка зьмяніць каталёґ, калі набіраеце каманду, цісьніце «M-c».
Падказка: каб змяніць каталог падчас ўводу каманды, выкарыстоўвайце "M-c" (хуткая каманда cd).
Падказка: каманды абалонкі могуць не працаваць на немясцовых файлавых сыстэмах.
Падказка: каманды абалонкі могуць не працаваць на адлеглых файлавых сістэмах.
Падказка. «C-y» вяртае страчаны тэкст.
Падказка: "C-y" вяртае страчаны тэкст.
Падказка. Пэўныя клявішы не працуюць? Зірніце «Налады» → «Вывучыць клявішы».
Падказка: калі пэўныя клавішы не працуюць, зазірніце ў "Параметры" → "Вывучыць клавішы".
Падказка. Каб пабачыць вывад каманды ў праглядніку, цісьніце «M-!»
Падказка: каб убачыць вывад каманды ў выкарыстоўвайце "M-!"
Падказка. «F13» (або «Shift-F3») праглядае файл наўпрост.
Падказка: з дапамогай "F13" або "Shift-F3" можна праглядаць файлы ў зыходным выглядзе.
Падказка. Зьменная «EDITOR» вызначае рэдактар, які выклікаецца праз «F4».
Падказка: з дапамогай зменнай "EDITOR" вы можаце змяніць рэдактар, які выклікаецца з дапамогай клавішы "F4".
Падказка. Зьменныя «VIEWER» або «PAGER» вызначаюць вонкавы прагляднік.
Падказка: з дапамогай зменнай "VIEWER" або "PAGER" вы можаце прызначыць вонкавы сродак для прагляду.
Падказка. Забараніць спробы пацьвярджаць можна ў «Наладах» → «Пацьвярджаць».
Падказка: вы можаце адключыць запыты пацвярджэння ў "Параметры" → "Пацвярджэнне".
Падказка. Пераскокваць да каталёґаў, якія часта ўжываюцца, можна праз па «C-\».
Падказка: з дапамогай "C-\" можна пераходзіць да каталогаў, якія часта ўжываюцца.
Падказка. Можна ўвайсьці на FTP ананімна, набраўшы «cd ftp://machine.edu»
Падказка: на FTP можна ўвайсці ананімна, набраўшы "cd ftp://machine.edu"
Падказка. «Midnight Commander» мае ўбудаваны FTP — глядзіце «Панэль» → «Злучыцца праз FTP».
Падказка: Midnight Commander мае ўбудаваны FTP — глядзіце "Файл" → "FTP".
Падказка. «M-t» хутка зьмяняе выгляд пераліку ў панэлі.
Падказка: з дапамогай "M-t" можна хутка змяніць выгляд спіса файлаў на панэлі.
Падказка. На FTPS можна пазначаць імя карыстальніка: «cd ftp://user@machine.edu».
Падказка: на FTPS можна пазначаць імя карыстальніка з дапамогай "cd ftp://user@machine.edu"
Падказка. Можна зазірнуць у зьмесьціва архіву RPM, калі націснуць на ім «Увод».
Падказка: можна паглядзець змесціва архіва RPM, калі націснуць на ім "Enter".
Падказка. Каб у дыялёґу выбару пазначыць каталёґі, дадайце / .
Падказка: каб у дыялогавым акне выбару пазначыць каталогі, дадайце "/ ".
Падказка. Каб выразаць і ўстаўляць мышкаю, можа спатрэбіцца націснуць і трымаць «Shift».
Падказка: для выразання і ўстаўляння мышкаю можа спатрэбіцца націснуць і ўтрымліваць "Shift"
Падказка. Захавайце сайты FTP, якія часта наведваеце: націсьніце «C-\».
Падказка: захаваць сайты FTP, якія часта наведваеце можна з дапамогай "C-\".

View File

@ -4,7 +4,7 @@
Hint: Completion: use M-Tab (or Esc+Tab). Type it twice to get a list.
Hint: Use M-p and M-n to access the command history.
ヒントM-pとM-nを使用すると、コマンド履歴にアクセスできます。
Hint: Need to quote a character? Use Control-q and the character.
@ -34,7 +34,7 @@ Hint: The file listing format can be customized; do "man mc" for details.
Hint: %D/%T expands to the tagged files in the opposite directory.
Hint: Want your plain shell? Press C-o, and get back to MC with C-o again.
ヒントプレーンなシェルが必要な場合はC-oを押してください。もう一度押すことでMCに戻ることが出来ます。
Hint: Setting the CDPATH variable can save you keystrokes in cd commands.

View File

@ -16,11 +16,11 @@
Совет: Домашняя страница Midnight Commander: https://www.midnight-commander.org
Совет: Пожалуйста, шлите любые сообщения об ошибках на mc-devel@lists.midnight-commander.org
Совет: Пожалуйста, шлите любые отчёты об ошибках на mc-devel@lists.midnight-commander.org
Совет: Tab меняет текущую панель.
Совет: Удобство ВФС: нажать Enter на файле tar для получения его содержимого.
Совет: Удобство ВФС: нажмите Enter на файле tar для получения его содержимого.
Совет: У нас также имеется толковая страница руководства.
@ -38,7 +38,7 @@
Совет: Установив переменную CDPATH, вы сбережёте усилия при наборе команды cd.
Совет: Вы сможете видеть скрытые файлы .*, установив опцию в меню Конфигурация.
Совет: Вы можете показать скрытые файлы .*, используя настройку в меню Конфигурация.
Совет: Хотите видеть резервные файлы .~ ? Установите опцию в меню Конфигурация.

View File

@ -3,7 +3,15 @@ if USE_NLS
SUBDIRS = $(DOC_LINGUAS)
endif
man_MANS = mc.1 mcedit.1 mcview.1
man_MANS = mc.1 mcview.1
if USE_INTERNAL_EDIT
man_MANS += mcedit.1
endif
if USE_DIFF
man_MANS += mcdiff.1
endif
CLEANFILES = $(man_MANS)
@ -11,7 +19,8 @@ EXTRA_DIST = \
date-of-man-include.am \
mc.1.in \
mcedit.1.in \
mcview.1.in
mcview.1.in \
mcdiff.1.in
DATE_LANG=en_US.UTF-8
DATE_FORMAT=%B %Y

View File

@ -15,10 +15,18 @@ mc.1: $(srcdir)/mc.1.in
MAN_FILE='$(srcdir)/mc.1.in'; MAN_DATE=$$($(MAN_DATE_CMD)); \
$(SED) $(SED_PARAMETERS) '$(srcdir)/mc.1.in' > '$@'
mcedit.1: $(srcdir)/mcedit.1.in
MAN_FILE='$(srcdir)/mcedit.1.in'; MAN_DATE=$$($(MAN_DATE_CMD)); \
$(SED) $(SED_PARAMETERS) '$(srcdir)/mcedit.1.in' > '$@'
mcview.1: $(srcdir)/mcview.1.in
MAN_FILE='$(srcdir)/mcview.1.in'; MAN_DATE=$$($(MAN_DATE_CMD)); \
$(SED) $(SED_PARAMETERS) '$(srcdir)/mcview.1.in' > '$@'
if USE_INTERNAL_EDIT
mcedit.1: $(srcdir)/mcedit.1.in
MAN_FILE='$(srcdir)/mcedit.1.in'; MAN_DATE=$$($(MAN_DATE_CMD)); \
$(SED) $(SED_PARAMETERS) '$(srcdir)/mcedit.1.in' > '$@'
endif
if USE_DIFF
mcdiff.1: $(srcdir)/mcdiff.1.in
MAN_FILE='$(srcdir)/mcdiff.1.in'; MAN_DATE=$$($(MAN_DATE_CMD)); \
$(SED) $(SED_PARAMETERS) '$(srcdir)/mcdiff.1.in' > '$@'
endif

View File

@ -1283,8 +1283,7 @@ El comando Compara directorios (Ctrl\-x d) compara los paneles de directorio
uno con el otro. Podemos usar el comando Copiar (F5) para hacer ambos
paneles idénticos. Hay tres métodos de comparación. El método rápido
compara solo el tamaño de archivo y la fecha. El método completo realiza
una comparación completa octeto a octeto. El método completo no está disponible si
la máquina no soporta la llamada de sistema mmap(2). El método de comparación
una comparación completa octeto a octeto. El método de comparación
de solo tamaño solo compara los tamaños de archivo y no chequea los
contenidos o las fechas, solo chequea los tamaños de los archivos.
.PP
@ -2780,13 +2779,6 @@ pueden entremezclar como en:
.PP
Nótese que 012 es un número octal y \-1 se convierte en 0xFF.
.PP
Algunos detalles internos del visualizador: En sistemas con acceso a la llamada
del sistema mmap(2), el programa mapea el archivo en vez de cargarlo;
si el sistema no provee de la llamada al sistema mmap(2) o el archivo
realiza una acción que necesita de un filtro, entonces el visor usará
sus cachés de crecimiento, cargando solo las partes del archivo
a las que actualmente estamos accediendo (esto incluye a los archivos comprimidos).
.PP
He aquí una lista de las acciones asociadas a cada tecla que
Midnight Commander gestiona en el visor interno de archivos.
.PP
@ -3084,7 +3076,7 @@ o simplemente emplear la orden
como cuando cambiamos habitualmente de directorio, pero indicando
como ruta:
.PP
.I ftp://[!][usuario[:clave]@]maquina[:puerto][dir\-remoto]
.I ftp://[!][usuario[:clave]@]maquina[:puerto]/[dir\-remoto]
.PP
Los elementos
.IR usuario ,

View File

@ -1067,8 +1067,7 @@ A Könyvtár összehasonlítás (C\-x d) parancs összehasonlítja a könyvtár
paneleket egymással. Ilyenkor használható a Másol (F5) parancs a panelek
azonossá tételére. Ennek három formája van. A gyors változat csak a fájlok
méretét, és dátumát vizsgálja meg. Az alapos változat teljesen, byte\-ról
byte\-ra végzi el a vizsgálatot. Az alapos változat nem használható,
ha a gép nem támogatja az mmap(2) rendszerhívást. A 'Csak fájlhossz'
byte\-ra végzi el a vizsgálatot. A 'Csak fájlhossz'
szerinti változat csak a fájlméretet hasonlítja össze és nem ellenőrzi
le a dátumukat.
.PP
@ -2297,14 +2296,6 @@ Használhatsz kevert hivatkozást is ezen értékeknek megfelelően: "Szöveg"
0xFE 0xBB "további szöveg". A szöveg értékek közötti részt és a
hivatkozás szövegét nem veszi figyelembe.
.PP
Néhány belső részlet a fájlnézőről: Azokon a rendszereken, ahol létezik
az mmap(2) rendszerhívás, a fájl programtérképe olvasódik be ehelyett;
ha a rendszer nem tartalmazza az mmap(2) rendszerhívást, vagy a fájl
tartalmaz olyan műveletet, mint ami megfelel a szűrőnek, a fájlnéző egy
növekvő buffert fog használni, amely csak azokat a részeit tartalmazza a
fájlnak, amelyekhez jelenleg hozzáférsz (ez tömörített fájlokra is
vonatkozik).
.PP
Ez a lista tartalmazza azokat a gombokat, amelyekhez művelet kapcsolódik
a Midnight Commander belső fájlnézőjében.
.PP
@ -2538,7 +2529,7 @@ panel FTP kapcsolat... parancsát (elérhető a menüből), vagy
közvetlenül átválthatsz a jelenlegi könyvtárból a cd
parancs használatával, valahogy így:
.PP
.I ftp://[!][felhasználó[:jelszó]@]machine[:port][távoli\-könyvtár]
.I ftp://[!][felhasználó[:jelszó]@]machine[:port]/[távoli\-könyvtár]
.PP
A
.I felhasználó, port

View File

@ -1090,8 +1090,7 @@ pannelli directory uno con l'altro. E' poi possibile usare il comando
Copia (F5) per rendere i pannelli identici. Ci sono tre metodi di
confronto. Il metodo veloce confronta solo l'ampiezza e la data del
file. Il metodo completo fa un confronto byte\-per\-byte. Il metodo
completo non è disponibile se la macchina non supporta la chiamata di
sistema mmap(2). Il metodo solo dimensione confronta solo l'ampiezza dei
solo dimensione confronta solo l'ampiezza dei
file e non controlla il contenuto né la data del file.
.PP
Il comando cronologia comandi mostra un'elenco dei comandi battuti. Il
@ -2336,14 +2335,6 @@ mescolare testo protetto con costanti come nell'esempio:
.PP
Notare che 012 è un numero ottale. \-1 viene convertito in 0xFF.
.PP
Alcuni dettagli interni circa il visualizzatore: su sistemi che
forniscono la chiamata di sistema mmap(2), il programma mappa il
file invece di caricarlo; se il sistema non fornisce la chiamata di
sistema mmap(2) o il file corrisponde ad un'azione che richiede
un filtro, allora il visualizzatore userà i buffer di accrescimanto
(growing), caricando perciò solo le parti del file su cui vi si accede
(inclusi i file compressi).
.PP
Ecco un'elenco di azioni associate ad ogni tasto che il Midnight Commander
gestisce nel visualizzatore di file interno.
.PP
@ -2580,7 +2571,7 @@ la directory corrente con un comando
.I cd
verso un percorso simile al seguente:
.PP
.I ftp://[!][utente[:pass]@]macchina[:porta][dir\-remota]
.I ftp://[!][utente[:pass]@]macchina[:porta]/[dir\-remota]
.PP
Gli elementi
.IR utente ,

View File

@ -961,7 +961,7 @@ be filtered. When
.I Shell Patterns
checkbox is on, the regular expression is much like the filename globbing
in the shell (* standing for zero or more characters and ? standing
for one character). Otherwise, the matching of files/directoris is done
for one character). Otherwise, the matching of files/directories is done
with normal regular expressions (see ed(1)). When
.I Case sensitive
checkbox is on, the filtering will be case sensitive characters. Otherwise,
@ -1241,8 +1241,7 @@ The "Compare directories" command compares the directory
panels with each other. You can then use the Copy (F5) command to make
the panels identical. There are three compare methods. The quick method
compares only file size and file date. The thorough method makes a
full byte\-by\-byte compare. The thorough method is not available if the
machine does not support the mmap(2) system call. The size\-only
full byte\-by\-byte compare. The size\-only
compare method just compares the file sizes and does not check the
contents or the date times, it just checks the file size.
.PP
@ -2388,7 +2387,7 @@ is substituted.
.\"NODE " The subshell support"
.SH " The subshell support"
The subshell support is a compile time option, that works with the
shells: bash, ash (BusyBox and Debian), tcsh, zsh and fish.
shells: bash, ash (BusyBox and Debian), (o/m)ksh, tcsh, zsh and fish.
.PP
When the subshell support is active, Midnight Commander will
spawn a concurrent copy of your shell (the one defined in the
@ -2407,6 +2406,18 @@ and special keyboard maps in ~/.local/share/mc/inputrc (fallback ~/.inputrc).
.B ash/dash
users (BusyBox or Debian) may specify startup commands in ~/.local/share/mc/ashrc (fallback ~/.profile).
.PP
.B ksh/oksh
users (PD ksh variants) may specify startup commands in ~/.local/share/mc/kshrc
(fallback
.I ENV
or ~/.profile).
.PP
.B mksh
users (MirBSD ksh) may specify startup commands in ~/.local/share/mc/mkshrc
(fallback
.I ENV
or ~/.mkshrc).
.PP
.B zsh
users may specify startup commands in ~/.local/share/mc/.zshrc (fallback ~/.zshrc).
.PP
@ -2557,42 +2568,102 @@ cancel the Chattr command.
.SH "File Operations"
When you copy, move or delete files, Midnight Commander shows the
file operations dialog. It shows the files currently being processed
and uses up to three progress bars. The file bar indicates the
and uses up to two progress bars. The file bytes bar indicates the
percentage of the current file that has been processed so far. The
count bar shows how many of the tagged files have been handled. The
bytes bar indicates the percentage of the total size of the tagged files
that has been handled. If the verbose option is off, the file and bytes
bars are not shown.
total bytes bar indicates the percentage of the total size of the tagged
files that has been handled. Counters that show how many of the tagged
files have been handled are displayed. If the
.I Verbose
option is off, the file bytes bar and total bytes bar are not shown.
.PP
There are two buttons at the bottom of the dialog. Pressing the Skip
button will skip the rest of the current file. Pressing the Abort
button will abort the whole operation, the rest of the files are
skipped.
There are three buttons at the bottom of the dialog:
.TP
.B [Skip]
button to skip the rest of the current file.
.TP
.B [Suspend]
button to suspend the file operation and button transforms to the
.B [Continue]
one which continue the suspended operation.
.TP
.B [Abort]
button to abort the whole operation, the rest of the files are skipped.
.PP
There are three other dialogs which you can run into during the file
operations.
.PP
The error dialog informs about error conditions and has three choices.
Normally you select either the Skip button to skip the file or the Abort
button to abort the operation altogether. You can also select the Retry
button if you fixed the problem from another terminal.
The error dialog informs about error conditions and has four choices:
.TP
.B [Ignore]
button to ignore this error.
.TP
.B [Ignore all]
button to ignore this and all future errors.
.TP
.B [Abort]
button to abort the operation altogether.
.TP
.B [Retry]
button to continue if you fixed the problem from another terminal.
.PP
The replace dialog is shown when you attempt to copy or move a file on
the top of an existing file. The dialog shows the dates and sizes of
the both files. Press the Yes button to overwrite the file, the No
button to skip the file, the All button to overwrite all the files, the
None button to never overwrite and the Update button to overwrite if the
source file is newer than the target file. You can abort the whole
operation by pressing the Abort button.
the both files. There are the following buttons in this dialog:
.TP
.B [Yes]
button to overwrite the file.
.TP
.B [No]
button to skip the file.
.TP
.B [Append]
button to append the source file to the target one.
.TP
.B [Reget]
button to append the rest of the source file to the target one.
This button is displayed only if the size of the target file
is non-zero and less than the size of the source file.
.TP
.B [All]
button to overwrite all the files.
.TP
.B [Older]
button to overwrite if the source file is newer than the target file.
.TP
.B [None]
button to never overwrite files
.TP
.B [Smaller]
button to overwrite if the source file size is less than the target one.
.TP
.B [Size differs]
button to overwrite files with different sizes.
.TP
.B [Abort]
button to abort the whole operation.
.PP
If the
.B Don't overwrite with zero length file
checkbox is on, the zero\-sized source files don't overwrite the
non\-zero\-sized target files.
.PP
The recursive delete dialog is shown when you try to delete a directory
which is not empty. Press the Yes button to delete the directory
recursively, the No button to skip the directory, the All button to
delete all the directories and the None button to skip all the non\-empty
directories. You can abort the whole operation by pressing the Abort
button. If you selected the Yes or All button you will be asked for a
confirmation. Type "yes" only if you are really sure you want to do the
recursive delete.
which is not empty. There are the following buttons in this dialog:
.TP
.B [Yes]
button to delete the directory recursively.
.TP
.B [No]
button to skip the directory.
.TP
.B [All]
button to delete all the directories.
.TP
.B [None]
button to skip all the non\-empty directories.
.TP
.B [Abort]
button to abort the whole operation.
.PP
If you have tagged files and perform an operation on them only the files
on which the operation succeeded are untagged. Failed and skipped files
@ -2829,7 +2900,7 @@ Scroll one line backward.
Move one page up.
.TP
.B PageDown
Mves one page down.
Moves one page down.
.TP
.B Home, A1
Moves to the line beginning.
@ -3161,7 +3232,7 @@ item in the menu or directly change your current directory using the
.I cd
command to a path name that looks like this:
.PP
.I ftp://[!][user[:pass]@]machine[:port][remote\-dir]
.I ftp://[!][user[:pass]@]machine[:port]/[remote\-dir]
.PP
The
.IR user ,

97
mcsrc/doc/man/mcdiff.1.in Normal file
View File

@ -0,0 +1,97 @@
.TH MCDIFF 1 "%DATE_OF_MAN_PAGE%" "MC Version %MAN_VERSION%" "GNU Midnight Commander"
.SH NAME
mcdiff \- Internal diff viewer of GNU Midnight Commander.
.SH USAGE
.B mcdiff
[\-bcCdfhstVx?] file1 file2
.SH DESCRIPTION
.LP
mcdiff is a link to
.BR mc ,
the main GNU Midnight Commander executable. Executing GNU Midnight
Commander under this name requests starting the internal diff viewer
which compares
.I file1
and
.I file2
specified on the command line.
.SH OPTIONS
.TP
.I "\-b"
Force black and white display.
.TP
.I "\-c"
Force color mode on terminals where
.B mcdiff
defaults to black and white.
.TP
.I "\-C <keyword>=<fgcolor>,<bgcolor>,<attributes>:<keyword>= ..."
Specify a different color set. See the
.B Colors
section in mc(1) for more information.
.TP
.I "\-d"
Disable mouse support.
.TP
.I "\-f"
Display the compiled\-in search paths for Midnight Commander files.
.TP
.I "\-t"
Used only if the code was compiled with S\-Lang and terminfo: it makes
the Midnight Commander use the value of the
.B TERMCAP
variable for the terminal information instead of the information on
the system wide terminal database
.TP
.I "\-V"
Displays the version of the program.
.TP
.I "\-x"
Forces xterm mode. Used when running on xterm\-capable terminals (two
screen modes, and able to send mouse escape sequences).
.PP
.SH COLORS
The default colors may be changed by appending to the
.B MC_COLOR_TABLE
environment variable. Foreground and background colors pairs may be
specified for example with:
.PP
.nf
MC_COLOR_TABLE="$MC_COLOR_TABLE:\\
normal=lightgray,black:\\
selected=black,green"
.fi
.PP
.SH FILES
.I %pkgdatadir%/mc.hlp
.IP
The help file for the program.
.PP
.I %pkgdatadir%/mc.ini
.IP
The default system\-wide setup for GNU Midnight Commander, used only if
the user's own ~/.config/mc/ini file is missing.
.PP
.I %pkgdatadir%/mc.lib
.IP
Global settings for the Midnight Commander. Settings in this file
affect all users, whether they have ~/.config/mc/ini or not.
.PP
.I ~/.config/mc/ini
.IP
User's own setup. If this file is present, the setup is loaded from
here instead of the system\-wide startup file.
.PP
.SH LICENSE
This program is distributed under the terms of the GNU General Public
License as published by the Free Software Foundation. See the built\-in
help of the Midnight Commander for details on the License and the lack
of warranty.
.SH AVAILABILITY
The latest version of this program can be found at
http://ftp.midnight\-commander.org/.
.SH SEE ALSO
mc(1), mcedit(1), mcview(1)
.PP
.SH BUGS
Bugs should be reported to https://www.midnight\-commander.org/.

View File

@ -895,8 +895,7 @@ Komenda porównywania katalogów (Compare directories) (C\-x d) porównuje
zawartości panelu katalogowego z drugim. Możesz potem użyc Kopiuj (F5)
żeby stworzyć dwa dokładnie identyczne panele. Metoda "quick" porównuje
tylko i wyłącznie rozmiary plików i ich daty. Metoda "thorough" porównuje
pliki bajt po bajcie. Ta metoda działa tylko wtedy kiedy komputer obsługuje
wywołanie mmap(2). Metoda "size\-only" zwraca uwagę tylko na rozmiar plików.
pliki bajt po bajcie. Metoda "size\-only" zwraca uwagę tylko na rozmiar plików.
Nie ma dla niej żadnego znaczenia czy plik ma inną datę lub zawartość, liczy
się tylko rozmiar.
.PP
@ -1957,13 +1956,6 @@ Możesz mieszać ciągi znaków ze stałymi tak jak: "Ciąg" 0xFE 0xBB
"więcej tekstu". Ciąg pomiędzy stałymi i cudzysłowami jest po prostu
ignorowany.
.PP
Kilka wewnętrznych szczegółów na temat podglądu: Na systemach, które używają
wywołania systemowego mmap(2), program mapuje pliki zamiast je ładować;
jeśli system nie obsługuje mmap(2) lub plik pasuje do któregoś z wybranych
filtrów, podgląd użyje jego rozszerzalnych buforów, dzięki temu ładując tylko
te części, do których musisz mieć aktualnie dostęp (dotyczy również
plików skompresowanych).
.PP
Tu jest lista akcji powiązanych z każdym klawiszem, który Midnight Commander
obsługuje w wewnętrznym poglądzie.
.PP
@ -2186,7 +2178,7 @@ normalnego użytku, możesz próbować używać panelowych komend FTP i dowiąza
(dostępnych z linii menu) lub zmienić ścieżkę bezpośrednio za pomocą zwykłej
komendy cd wyglądającej tak jak poniżej:
.PP
.I ftp://[!][użytkownik[:hasło]@]komputer[:port][zdalny katalog]
.I ftp://[!][użytkownik[:hasło]@]komputer[:port]/[zdalny\-katalog]
.PP
Parametry
.IR użytkownik ,

View File

@ -1345,8 +1345,7 @@ Midnight Commander за счет добавления в личное меню
для того, чтобы сделать содержимое каталогов одинаковым. Существует
три метода сравнения. При быстром методе сравниваются только размер и
дата создания файлов с одинаковыми именами. При побайтном методе
сравнивается содержимое файлов (побайтно). Этот метод недоступен, если
машина не поддерживает системный вызов mmap(2). При сравнении по размеру
сравнивается содержимое файлов (побайтно). При сравнении по размеру
сравниваются только размеры соответствующих файлов, а дата создания не
проверяется.
.PP
@ -2344,8 +2343,8 @@ Commander, выделены цветом, определённым ключев
тестироваться. Вы можете перемещать подсветку по названиям, используя
клавишу
.B Tab
или клавиши, применяемые в редакторе vi ('h' влево, 'j' вниз, 'k' вверх,
'l' вправо). Если один раз нажать на клавиши со стрелками, после чего возле
или клавиши, применяемые в редакторе vi ('h' влево, 'j' вниз, 'k' вверх, 'l'
вправо). Если один раз нажать на клавиши со стрелками, после чего возле
их названий в таблице появится пометка
.IR OK ,
то их тоже можно будет использовать для управления перемещением.
@ -2902,56 +2901,66 @@ chattr \- команде изменения атрибутов файлов и
файлов, Midnight Commander отображает на экране диалоговое окно, в
котором показано, какой(ие) файл(ы) в данный момент обрабатывается и как
идет процесс обработки. Для отображения процесса обработки на экран
выводится до трёх диаграмм\-полосок (progress bars). Первая (file bar)
показывает, какая часть текущего файла обработана (например,
скопирована). Вторая (count bar) показывает, какая доля помеченных файлов
обработана на текущий момент. Третья (bytes bar) показывает долю
выполненных работ (в процентах от суммарного объема помеченных файлов).
Если выключена опция
выводится до двух диаграмм\-полосок (progress bars). Первая показывает,
какая часть текущего файла обработана (например, скопирована). Вторая
показывает долю выполненных работ (в процентах от суммарного объема
помеченных файлов). Если выключена опция
.I "Детали операций"
(см.
.\"LINK2"
Настройки/Конфигурация\&.
.\"Configuration"
), две последних диаграммы не отображаются.
), вторая диаграмма не отображаются.
.PP
В нижней части этого диалогового окна имеются две кнопки. Нажатие на
кнопку
В нижней части этого диалогового окна имеются три кнопки:
.TP
.B [Пропустить]
приведёт к тому, что будет пропущена обработка текущего файла. Нажатие
на кнопку
прерывает обработку текущего файла.
.TP
.B [Приостановить]
приостанавливает выполнение операции и при нажатии превращается в кнопку
.BR [Продолжить] ,
при нажатии на которую выполнение операции продолжится.
.TP
.B [Прервать]
прерывает выполнение заданной операции, все оставшиеся файлы будут пропущены.
.PP
В процессе выполнения файловых операций вы можете увидеть окна ещё трёх
видов.
.PP
Окно ошибок информирует об ошибке и предлагает три варианта продолжения.
Обычно вы выбираете либо вариант
.B [Пропустить]
для того, чтобы исключить из обработки файл, на котором споткнулась
программа, либо
.B [Прервать] ,
чтобы вообще отменить выполнение заданной операции. Третий вариант,
.B [Повторить] ,
выбирается тогда, когда вам удалось устранить причину сбоя (например,
воспользовавшись другим терминалом).
Окно ошибок информирует об ошибке и предлагает четыре варианта продолжения:
.TP
.B [Игнорировать]
проигнорировать текущую ошибку файловой операции.
.TP
.B [Игнорировать всё]
игнорировать эту и все последующие ошибки файловой операции.
.TP
.B [Прервать]
отменить выполнение заданной операции.
.TP
.B [Повторить]
продолжить выполнение операции, когда вам удалось устранить причину
сбоя (например, воспользовавшись другим терминалом).
.PP
Окно подтверждения перезаписи появляется тогда, когда вы пытаетесь
переписать существующий файл. В этом окне отображаются время создания и
размер файла\-источника и файла\-приёмника (то есть перезаписываемого
файла, который фактически будет уничтожен). Ниже выведены два вопроса.
На первый вопрос ("Переписать этот файл?") предлагается три варианта
ответа:
размеры файла\-источника и файла\-приёмника. Ннже находится вопрос "Переписать
этот файл?" и предлагается четыре варианта ответа:
.TP
.B ]
согласиться;
.B [Да]
переписать текущий файл.
.TP
.B [Нет]
отказаться, то есть пропустить перезапись текущего файла;
пропустить перезапись текущего файла.
.TP
.B [Дописать в конец]
дописать содержимое файла\-источника в конец файла\-приёмника.
.TP
.B [Докачать]
дописать оставшуюся часть файла\-источника в конец файла\-приёмника.
Эта кнопка появляется только в том случае, если размер файла\-приёмника
не нулевой и меньше размера файла\-источника.
.PP
Выбор одного из вариантов ответа на второй вопрос ("Переписать все
файлы?") позволяет принять одно решение по всем выбранным для обработки
@ -2959,41 +2968,49 @@ chattr \- команде изменения атрибутов файлов и
варианта решения:
.TP
.B [Все]
перезаписались без дополнительных вопросов все выбранные файлы;
перезаписать без дополнительных вопросов все выбранные файлы.
.TP
.B [Устаревшие]
перезапишутся (затрутся) только файлы, которые созданы раньше
файла\-источника;
.B [Старше]
перезапиcать (затереть) только те файлы, которые созданы раньше
файла\-источника.
.TP
.B [Ни одного]
не перезаписывать файлы (но если не существует файла\-приёмника, то
копирование источника будет произведено);
копирование источника будет произведено).
.TP
.B [Меньше]
перезапиcать (затереть) только те файлы, размеры которых меньше
размеров соответствующих файлов\-источников.
.TP
.B [Различающиеся по длине]
перезапиcать (затереть) только те файлы, размеры которых отличаются
от размеров соответствующих файлов\-источников.
.TP
.I [Различающиеся по длине]
Вы можете отказаться от выполнения операции, если нажмете кнопку
.B [Прервать]
в нижней части окна запроса. Выбор экранной кнопки производится
.B клавишами\-стрелками
или клавишей
.BR Tab .
прервать выполнение операции.
.PP
Если перекючатель
.B Не перезаписывать файлами нулевой длины
включен, то файлы\-источники с нулевыми размерами не будут перезаписывать
файлы\-приёмники с ненулевымы размерами.
.PP
Окно запроса на рекурсивное удаление появляется в том случае, если вы
пытаетесь удалить непустой каталог. По кнопке
пытаетесь удалить непустой каталог. В этом диалоге имеются следующие кнопки:
.TP
.B [Да]
каталог будет удален вместе со всеми файлами.
.TP
.B [Нет]
означает отказ от удаления каталога.
.B [Всё] надо выбирать, если вы отметили группу подкаталогов для удаления и
уверены в своём выборе,
.B [Ни одного]
\- чтобы пропустить все непустые каталоги из числа помеченных.
.B [Прервать]
означает отказ от выполнения операции удаления. Выбирайте
.B [Да]
или
отказ от удаления каталога.
.TP
.B [Всё]
только в том случае, если вы действительно уверены в том, что хотите удалить
каталог со всеми вложенными подкаталогами.
удалить все помеченные каталоги.
.TP
.B [Ни одного]
пропустить все непустые каталоги из числа помеченных.
.TP
.B [Прервать]
отказ от выполнения операции удаления.
.PP
Если вы пометили для обработки группу файлов, то после выполнения
операции будет снята отметка только с тех файлов, которые успешно
@ -3277,14 +3294,6 @@ ASCII и шестнадцатеричный (hex). Для переключени
можно просто ввести "BB". Число "012" интерпретируется не как
восьмеричное, а как 0x12.
.PP
Некоторые детали внутренней реализации программы просмотра: на системах,
которые предоставляют системный вызов mmap(2) программа отображает файл
в память вместо его загрузки; иначе, а также если при вызове mmap
возникает сбой или c файлом связано некоторое действие, которое требует
фильтр, программа использует динамически распределяемые буфера памяти,
загружая только те части файла, к которым вы обращаетесь (это относится
к архивированным файлам).
.PP
Ниже приводится перечень всех клавиш и их комбинаций, с которыми
ассоциированы некие действия встроенной программы просмотра.
.TP
@ -3621,7 +3630,7 @@ tar\-файлов;
сменить текущий каталог командой cd, задав путь к каталогу следующим
образом:
.PP
.I ftp://[!][user[:pass]@]machine[:port][remote\-dir]
.I ftp://[!][user[:pass]@]machine[:port]/[remote\-dir]
.PP
Элементы
.IR user ,

View File

@ -1050,8 +1050,7 @@ file may be preallocated relative to preallocate_space configure option.
једно са другим. Тада можете користити наредбу Копирај (F5) да бисте
изједначили окна. Постоје три начина упоређивања. Брзи начин упоређује
само величину и датум датотека. Темељни начин упоређује сваки бајт са
сваким бајтом датотека. Темељни начин није доступан ако машина не
подржава системски позив mmap(2). Начин упоређивања Само величина
сваким бајтом датотека. Начин упоређивања Само величина
упоређује само величине датотека, а не проверава садржаје или датуме
датотека.
.PP
@ -2305,13 +2304,6 @@ linux би вас одвело у /usr/src/linux).
.PP
Приметите да је 012 октални број. \-1 се претвара у 0xFF.
.PP
Ево још неких детаља о прегледачу: на системима који имају системски
позив mmap(2), програм мапира датотеку уместо да је учита; уколико
систем нема системски позив mmap(2) или датотека одговара радњи која
захтева филтар, онда ће прегледач користити растуће прихватнике, тиме
учитавајући само оне делове датотеке којима стварно приступате (овим
су обухваћене и компримоване датотеке).
.PP
Ево списка радњи које су придружене тастерима које Поноћни наредник
прихвата у уграђеном прегледачу.
.PP
@ -2560,7 +2552,7 @@ if the
.I cd (пром.дир.)
на путању која изгледа овако:
.PP
.I ftp://[!][корисник[:лозинка]@]машина[:порт][удаљени\-дир]
.I ftp://[!][корисник[:лозинка]@]машина[:порт]/[удаљени\-дир]
.PP
Елементи
.IR корисник ,

View File

@ -16,15 +16,17 @@ endif
SUBLIB_includes = \
event.h event-types.h \
filehighlight.h \
idx.h \
intprops-internal.h \
intprops.h \
mcconfig.h \
search.h \
skin.h \
strescape.h \
strutil.h \
widget.h
SRC_mc_utils = \
utilunix.c utilunix.h \
utilunix.c \
unixcompat.h \
util.c util.h
@ -53,6 +55,9 @@ if CHARSET
libmc_la_SOURCES += charsets.c charsets.h
endif
EXTRA_DIST = \
stdckdint.in.h
AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
libmc_la_LIBADD = \

View File

@ -1,7 +1,7 @@
/*
Text conversion from one charset to another.
Copyright (C) 2001-2024
Copyright (C) 2001-2025
Free Software Foundation, Inc.
Written by:
@ -94,7 +94,7 @@ free_codepage_desc (gpointer data)
/* returns display codepage */
static void
load_codepages_list_from_file (GPtrArray ** list, const char *fname)
load_codepages_list_from_file (GPtrArray **list, const char *fname)
{
FILE *f;
char buf[BUF_MEDIUM];
@ -135,8 +135,7 @@ load_codepages_list_from_file (GPtrArray ** list, const char *fname)
if (*list == NULL)
{
*list = g_ptr_array_sized_new (16);
g_ptr_array_set_free_func (*list, free_codepage_desc);
*list = g_ptr_array_new_full (16, free_codepage_desc);
g_ptr_array_add (*list, new_codepage_desc (id, p));
}
else
@ -268,17 +267,16 @@ get_codepage_index (const char *id)
gboolean
is_supported_encoding (const char *encoding)
{
gboolean result = FALSE;
guint t;
GIConv coder;
gboolean result;
for (t = 0; t < codepages->len; t++)
{
const char *id;
id = ((codepage_desc *) g_ptr_array_index (codepages, t))->id;
result |= (g_ascii_strncasecmp (encoding, id, strlen (id)) == 0);
}
if (encoding == NULL)
return FALSE;
coder = str_crt_conv_from (encoding);
result = coder != INVALID_CONV;
if (result)
str_close_conv (coder);
return result;
}
@ -290,7 +288,7 @@ init_translation_table (int cpsource, int cpdisplay)
int i;
GIConv cd;
/* Fill inpit <-> display tables */
/* Fill input <-> display tables */
if (cpsource < 0 || cpdisplay < 0 || cpsource == cpdisplay)
{
@ -365,6 +363,8 @@ str_nconvert_to_display (const char *str, int len)
return g_string_new (str);
conv = str_crt_conv_from (cp_source);
if (conv == INVALID_CONV)
return g_string_new (str);
buff = g_string_new ("");
str_nconvert (conv, str, len, buff);
@ -397,6 +397,8 @@ str_nconvert_to_input (const char *str, int len)
return g_string_new (str);
conv = str_crt_conv_to (cp_source);
if (conv == INVALID_CONV)
return g_string_new (str);
buff = g_string_new ("");
str_nconvert (conv, str, len, buff);

View File

@ -2,7 +2,7 @@
Handle events in application.
Interface functions: init/deinit; start/stop
Copyright (C) 2011-2024
Copyright (C) 2011-2025
Free Software Foundation, Inc.
Written by:
@ -48,7 +48,7 @@ GTree *mc_event_grouplist = NULL;
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_event_init (GError ** mcerror)
mc_event_init (GError **mcerror)
{
mc_return_val_if_error (mcerror, FALSE);
@ -74,7 +74,7 @@ mc_event_init (GError ** mcerror)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_event_deinit (GError ** mcerror)
mc_event_deinit (GError **mcerror)
{
mc_return_val_if_error (mcerror, FALSE);
@ -92,7 +92,7 @@ mc_event_deinit (GError ** mcerror)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_event_mass_add (const event_init_t * events, GError ** mcerror)
mc_event_mass_add (const event_init_t *events, GError **mcerror)
{
size_t array_index;
@ -113,7 +113,7 @@ mc_event_mass_add (const event_init_t * events, GError ** mcerror)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_event_present (const gchar * event_group_name, const gchar * event_name)
mc_event_present (const gchar *event_group_name, const gchar *event_name)
{
GTree *event_group;
GPtrArray *callbacks;

View File

@ -2,7 +2,7 @@
Handle any events in application.
Manage events: add, delete, destroy, search
Copyright (C) 2011-2024
Copyright (C) 2011-2025
Free Software Foundation, Inc.
Written by:
@ -57,8 +57,8 @@ mc_event_group_destroy_value (gpointer data)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_event_add (const gchar * event_group_name, const gchar * event_name,
mc_event_callback_func_t event_callback, gpointer event_init_data, GError ** mcerror)
mc_event_add (const gchar *event_group_name, const gchar *event_name,
mc_event_callback_func_t event_callback, gpointer event_init_data, GError **mcerror)
{
GTree *event_group;
GPtrArray *callbacks;
@ -95,7 +95,7 @@ mc_event_add (const gchar * event_group_name, const gchar * event_name,
/* --------------------------------------------------------------------------------------------- */
void
mc_event_del (const gchar * event_group_name, const gchar * event_name,
mc_event_del (const gchar *event_group_name, const gchar *event_name,
mc_event_callback_func_t event_callback, gpointer event_init_data)
{
GTree *event_group;
@ -122,7 +122,7 @@ mc_event_del (const gchar * event_group_name, const gchar * event_name,
/* --------------------------------------------------------------------------------------------- */
void
mc_event_destroy (const gchar * event_group_name, const gchar * event_name)
mc_event_destroy (const gchar *event_group_name, const gchar *event_name)
{
GTree *event_group;
@ -136,7 +136,7 @@ mc_event_destroy (const gchar * event_group_name, const gchar * event_name)
/* --------------------------------------------------------------------------------------------- */
void
mc_event_group_del (const gchar * event_group_name)
mc_event_group_del (const gchar *event_group_name)
{
if (mc_event_grouplist != NULL && event_group_name != NULL)
@ -146,8 +146,8 @@ mc_event_group_del (const gchar * event_group_name)
/* --------------------------------------------------------------------------------------------- */
GTree *
mc_event_get_event_group_by_name (const gchar * event_group_name, gboolean create_new,
GError ** mcerror)
mc_event_get_event_group_by_name (const gchar *event_group_name, gboolean create_new,
GError **mcerror)
{
GTree *event_group;
@ -175,8 +175,8 @@ mc_event_get_event_group_by_name (const gchar * event_group_name, gboolean creat
/* --------------------------------------------------------------------------------------------- */
GPtrArray *
mc_event_get_event_by_name (GTree * event_group, const gchar * event_name, gboolean create_new,
GError ** mcerror)
mc_event_get_event_by_name (GTree *event_group, const gchar *event_name, gboolean create_new,
GError **mcerror)
{
GPtrArray *callbacks;
@ -199,7 +199,7 @@ mc_event_get_event_by_name (GTree * event_group, const gchar * event_name, gbool
/* --------------------------------------------------------------------------------------------- */
mc_event_callback_t *
mc_event_is_callback_in_array (GPtrArray * callbacks, mc_event_callback_func_t event_callback,
mc_event_is_callback_in_array (GPtrArray *callbacks, mc_event_callback_func_t event_callback,
gpointer event_init_data)
{
guint array_index;

View File

@ -2,7 +2,7 @@
Handle any events in application.
Raise events.
Copyright (C) 2011-2024
Copyright (C) 2011-2025
Free Software Foundation, Inc.
Written by:
@ -46,7 +46,7 @@
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_event_raise (const gchar * event_group_name, const gchar * event_name, gpointer event_data)
mc_event_raise (const gchar *event_group_name, const gchar *event_name, gpointer event_data)
{
GTree *event_group;
GPtrArray *callbacks;

View File

@ -2,7 +2,7 @@
File highlight plugin.
Interface functions
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -63,7 +63,7 @@ mc_fhl_filter_free (gpointer data)
/* --------------------------------------------------------------------------------------------- */
void
mc_fhl_array_free (mc_fhl_t * fhl)
mc_fhl_array_free (mc_fhl_t *fhl)
{
if (fhl->filters != NULL)
{
@ -104,7 +104,7 @@ mc_fhl_new (gboolean need_auto_fill)
/* --------------------------------------------------------------------------------------------- */
void
mc_fhl_free (mc_fhl_t ** fhl)
mc_fhl_free (mc_fhl_t **fhl)
{
if (fhl == NULL || *fhl == NULL)
return;
@ -117,7 +117,7 @@ mc_fhl_free (mc_fhl_t ** fhl)
/* --------------------------------------------------------------------------------------------- */
void
mc_fhl_clear (mc_fhl_t * fhl)
mc_fhl_clear (mc_fhl_t *fhl)
{
if (fhl != NULL)
{

View File

@ -2,7 +2,7 @@
File highlight plugin.
Interface functions. get color pair index for highlighted file.
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -49,7 +49,7 @@
/*inline functions */
inline static gboolean
mc_fhl_is_file (const file_entry_t * fe)
mc_fhl_is_file (const file_entry_t *fe)
{
#if HAVE_S_ISREG == 0
(void) fe;
@ -60,7 +60,7 @@ mc_fhl_is_file (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_file_exec (const file_entry_t * fe)
mc_fhl_is_file_exec (const file_entry_t *fe)
{
return is_exe (fe->st.st_mode);
}
@ -68,7 +68,7 @@ mc_fhl_is_file_exec (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_dir (const file_entry_t * fe)
mc_fhl_is_dir (const file_entry_t *fe)
{
#if HAVE_S_ISDIR == 0
(void) fe;
@ -79,7 +79,7 @@ mc_fhl_is_dir (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_link (const file_entry_t * fe)
mc_fhl_is_link (const file_entry_t *fe)
{
#if HAVE_S_ISLNK == 0
(void) fe;
@ -90,7 +90,7 @@ mc_fhl_is_link (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_hlink (const file_entry_t * fe)
mc_fhl_is_hlink (const file_entry_t *fe)
{
return (fe->st.st_nlink > 1);
}
@ -98,7 +98,7 @@ mc_fhl_is_hlink (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_link_to_dir (const file_entry_t * fe)
mc_fhl_is_link_to_dir (const file_entry_t *fe)
{
return mc_fhl_is_link (fe) && fe->f.link_to_dir != 0;
}
@ -106,7 +106,7 @@ mc_fhl_is_link_to_dir (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_stale_link (const file_entry_t * fe)
mc_fhl_is_stale_link (const file_entry_t *fe)
{
return mc_fhl_is_link (fe) ? (fe->f.stale_link != 0) : !mc_fhl_is_file (fe);
}
@ -114,7 +114,7 @@ mc_fhl_is_stale_link (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_device_char (const file_entry_t * fe)
mc_fhl_is_device_char (const file_entry_t *fe)
{
#if HAVE_S_ISCHR == 0
(void) fe;
@ -125,7 +125,7 @@ mc_fhl_is_device_char (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_device_block (const file_entry_t * fe)
mc_fhl_is_device_block (const file_entry_t *fe)
{
#if HAVE_S_ISBLK == 0
(void) fe;
@ -136,7 +136,7 @@ mc_fhl_is_device_block (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_special_socket (const file_entry_t * fe)
mc_fhl_is_special_socket (const file_entry_t *fe)
{
#if HAVE_S_ISSOCK == 0
(void) fe;
@ -147,7 +147,7 @@ mc_fhl_is_special_socket (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_special_fifo (const file_entry_t * fe)
mc_fhl_is_special_fifo (const file_entry_t *fe)
{
#if HAVE_S_ISFIFO == 0
(void) fe;
@ -158,7 +158,7 @@ mc_fhl_is_special_fifo (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_special_door (const file_entry_t * fe)
mc_fhl_is_special_door (const file_entry_t *fe)
{
#if HAVE_S_ISDOOR == 0
(void) fe;
@ -169,7 +169,7 @@ mc_fhl_is_special_door (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
inline static gboolean
mc_fhl_is_special (const file_entry_t * fe)
mc_fhl_is_special (const file_entry_t *fe)
{
return
(mc_fhl_is_special_socket (fe) || mc_fhl_is_special_fifo (fe)
@ -179,8 +179,8 @@ mc_fhl_is_special (const file_entry_t * fe)
/* --------------------------------------------------------------------------------------------- */
static int
mc_fhl_get_color_filetype (const mc_fhl_filter_t * mc_filter, const mc_fhl_t * fhl,
const file_entry_t * fe)
mc_fhl_get_color_filetype (const mc_fhl_filter_t *mc_filter, const mc_fhl_t *fhl,
const file_entry_t *fe)
{
gboolean my_color = FALSE;
@ -258,8 +258,8 @@ mc_fhl_get_color_filetype (const mc_fhl_filter_t * mc_filter, const mc_fhl_t * f
/* --------------------------------------------------------------------------------------------- */
static int
mc_fhl_get_color_regexp (const mc_fhl_filter_t * mc_filter, const mc_fhl_t * fhl,
const file_entry_t * fe)
mc_fhl_get_color_regexp (const mc_fhl_filter_t *mc_filter, const mc_fhl_t *fhl,
const file_entry_t *fe)
{
(void) fhl;
@ -277,7 +277,7 @@ mc_fhl_get_color_regexp (const mc_fhl_filter_t * mc_filter, const mc_fhl_t * fhl
/* --------------------------------------------------------------------------------------------- */
int
mc_fhl_get_color (const mc_fhl_t * fhl, const file_entry_t * fe)
mc_fhl_get_color (const mc_fhl_t *fhl, const file_entry_t *fe)
{
guint i;
int ret;

View File

@ -2,7 +2,7 @@
File highlight plugin.
Reading and parse rules from ini-files
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -29,7 +29,7 @@
#include "lib/global.h"
#include "lib/fileloc.h"
#include "lib/strescape.h"
#include "lib/strutil.h"
#include "lib/skin.h"
#include "lib/util.h" /* exist_file() */
@ -52,7 +52,7 @@
/* --------------------------------------------------------------------------------------------- */
static void
mc_fhl_parse_fill_color_info (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_fill_color_info (mc_fhl_filter_t *mc_filter, mc_fhl_t *fhl, const gchar *group_name)
{
(void) fhl;
@ -62,7 +62,7 @@ mc_fhl_parse_fill_color_info (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, const
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_fhl_parse_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_get_file_type_id (mc_fhl_t *fhl, const gchar *group_name)
{
mc_fhl_filter_t *mc_filter;
@ -107,7 +107,7 @@ mc_fhl_parse_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name)
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_fhl_parse_get_regexp (mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_get_regexp (mc_fhl_t *fhl, const gchar *group_name)
{
mc_fhl_filter_t *mc_filter;
gchar *regexp;
@ -135,7 +135,7 @@ mc_fhl_parse_get_regexp (mc_fhl_t * fhl, const gchar * group_name)
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_fhl_parse_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_get_extensions (mc_fhl_t *fhl, const gchar *group_name)
{
mc_fhl_filter_t *mc_filter;
gchar **exts, **exts_orig;
@ -154,7 +154,7 @@ mc_fhl_parse_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
{
char *esc_ext;
esc_ext = strutils_regex_escape (*exts);
esc_ext = str_regex_escape (*exts);
if (buf->len != 0)
g_string_append_c (buf, '|');
g_string_append (buf, esc_ext);
@ -185,7 +185,7 @@ mc_fhl_parse_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_fhl_read_ini_file (mc_fhl_t * fhl, const gchar * filename)
mc_fhl_read_ini_file (mc_fhl_t *fhl, const gchar *filename)
{
if (fhl == NULL || filename == NULL || !exist_file (filename))
return FALSE;
@ -201,7 +201,7 @@ mc_fhl_read_ini_file (mc_fhl_t * fhl, const gchar * filename)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_fhl_init_from_standard_files (mc_fhl_t * fhl)
mc_fhl_init_from_standard_files (mc_fhl_t *fhl)
{
gchar *name;
gboolean ok;
@ -230,7 +230,7 @@ mc_fhl_init_from_standard_files (mc_fhl_t * fhl)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_fhl_parse_ini_file (mc_fhl_t * fhl)
mc_fhl_parse_ini_file (mc_fhl_t *fhl)
{
gchar **group_names, **orig_group_names;
gboolean ok;

View File

@ -53,6 +53,8 @@
#define MC_BASHRC_FILE "bashrc"
#define MC_ZSHRC_FILE ".zshrc"
#define MC_ASHRC_FILE "ashrc"
#define MC_KSHRC_FILE "kshrc"
#define MC_MKSHRC_FILE "mkshrc"
#define MC_INPUTRC_FILE "inputrc"
#define MC_CONFIG_FILE "ini"
#define MC_EXT_FILE "mc.ext.ini"

View File

@ -98,9 +98,6 @@
#define MC_MAXPATHLEN MAXPATHLEN
#endif
/* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */
#define NLENGTH(dirent) (strlen ((dirent)->d_name))
/* DragonFlyBSD doesn't provide MAXNAMLEN macro */
#ifndef MAXNAMLEN
#define MAXNAMLEN NAME_MAX

View File

@ -1,7 +1,7 @@
/*
GLIB - Library of useful routines for C programming
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -44,12 +44,63 @@
/*** file scope variables ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
#if ! GLIB_CHECK_VERSION (2, 54, 0)
/**
* g_ptr_array_find_with_equal_func: (skip)
* @haystack: pointer array to be searched
* @needle: pointer to look for
* @equal_func: (nullable): the function to call for each element, which should
* return %TRUE when the desired element is found; or %NULL to use pointer
* equality
* @index_: (optional) (out): return location for the index of
* the element, if found
*
* Checks whether @needle exists in @haystack, using the given @equal_func.
* If the element is found, %TRUE is returned and the element^A^A^As index is
* returned in @index_ (if non-%NULL). Otherwise, %FALSE is returned and @index_
* is undefined. If @needle exists multiple times in @haystack, the index of
* the first instance is returned.
*
* @equal_func is called with the element from the array as its first parameter,
* and @needle as its second parameter. If @equal_func is %NULL, pointer
* equality is used.
*
* Returns: %TRUE if @needle is one of the elements of @haystack
* Since: 2.54
*/
gboolean
g_ptr_array_find_with_equal_func (GPtrArray *haystack, gconstpointer needle, GEqualFunc equal_func,
guint *index_)
{
guint i;
g_return_val_if_fail (haystack != NULL, FALSE);
if (equal_func == NULL)
equal_func = g_direct_equal;
for (i = 0; i < haystack->len; i++)
if (equal_func (g_ptr_array_index (haystack, i), needle))
{
if (index_ != NULL)
*index_ = i;
return TRUE;
}
return FALSE;
}
#endif /* ! GLIB_CHECK_VERSION (2, 54, 0) */
/* --------------------------------------------------------------------------------------------- */
#if ! GLIB_CHECK_VERSION (2, 63, 3)
/**
* g_clear_slist: (skip)
@ -63,7 +114,7 @@
* Since: 2.64
*/
void
g_clear_slist (GSList ** slist_ptr, GDestroyNotify destroy)
g_clear_slist (GSList **slist_ptr, GDestroyNotify destroy)
{
GSList *slist;
@ -94,7 +145,7 @@ g_clear_slist (GSList ** slist_ptr, GDestroyNotify destroy)
* Since: 2.64
*/
void
g_clear_list (GList ** list_ptr, GDestroyNotify destroy)
g_clear_list (GList **list_ptr, GDestroyNotify destroy)
{
GList *list;
@ -127,7 +178,7 @@ g_clear_list (GList ** list_ptr, GDestroyNotify destroy)
* Since: 2.60
*/
void
g_queue_clear_full (GQueue * queue, GDestroyNotify free_func)
g_queue_clear_full (GQueue *queue, GDestroyNotify free_func)
{
g_return_if_fail (queue != NULL);
@ -188,7 +239,7 @@ g_string_new_take (char *init)
* There is no such API in GLib2.
*/
GString *
mc_g_string_copy (GString * dest, const GString * src)
mc_g_string_copy (GString *dest, const GString *src)
{
g_return_val_if_fail (src != NULL, NULL);
g_return_val_if_fail (dest != NULL, NULL);
@ -211,7 +262,7 @@ mc_g_string_copy (GString * dest, const GString * src)
* There is no such API in GLib2.
*/
GString *
mc_g_string_dup (const GString * s)
mc_g_string_dup (const GString *s)
{
GString *ret = NULL;
@ -222,3 +273,32 @@ mc_g_string_dup (const GString * s)
}
/* --------------------------------------------------------------------------------------------- */
/**
* mc_g_string_append_c_len:
* @s: (not nullable): the destination #GString.
* @c: the byte to append onto the end of @s
* @len: the number of bytes @c to append onto the end of @s
* @return: @s
*
* Adds @len bytes @c onto the end of @s.
*
* There is no such API in GLib2.
*/
GString *
mc_g_string_append_c_len (GString *s, gchar c, guint len)
{
g_return_val_if_fail (s != NULL, NULL);
if (len != 0)
{
guint s_len = s->len;
g_string_set_size (s, s->len + len);
memset (s->str + s_len, (unsigned char) c, len);
}
return s;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -16,6 +16,11 @@
/*** declarations of public functions ************************************************************/
#if ! GLIB_CHECK_VERSION (2, 54, 0)
gboolean g_ptr_array_find_with_equal_func (GPtrArray * haystack, gconstpointer needle,
GEqualFunc equal_func, guint * index_);
#endif /* ! GLIB_CHECK_VERSION (2, 54, 0) */
#if ! GLIB_CHECK_VERSION (2, 63, 3)
void g_clear_slist (GSList ** slist_ptr, GDestroyNotify destroy);
void g_clear_list (GList ** list_ptr, GDestroyNotify destroy);
@ -35,6 +40,9 @@ GString *mc_g_string_copy (GString * dest, const GString * src);
/* There is no such API in GLib2 */
GString *mc_g_string_dup (const GString * s);
/* There is no such API in GLib2 */
GString *mc_g_string_append_c_len (GString * s, gchar c, guint len);
/*** inline functions ****************************************************************************/
#endif /* MC_GLIBCOMPAT_H */

View File

@ -1,7 +1,7 @@
/*
Global structure for some library-related variables
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:

View File

@ -7,91 +7,23 @@
#ifndef MC_GLOBAL_H
#define MC_GLOBAL_H
#if defined(HAVE_STRING_H)
#include <string.h>
/* An ANSI string.h and pre-ANSI memory.h might conflict */
#elif defined(HAVE_MEMORY_H)
#include <memory.h>
#else
#include <strings.h>
/* memory and strings.h conflict on other systems */
#endif /* !STDC_HEADERS & !HAVE_STRING_H */
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
/* for O_* macros */
#include <fcntl.h>
/* for sig_atomic_t */
#include <signal.h>
#ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH
#define MC_FALLTHROUGH __attribute__((fallthrough))
#else
#define MC_FALLTHROUGH
#endif
/*** typedefs(not structures) and defined constants **********************************************/
/* Enable WIN32 tweaks */
#if defined(_WIN32) && !defined(WIN32)
#define WIN32 1
#endif
/* The O_BINARY definition was taken from gettext */
#if defined(__WATCOMC__) //WIN32/c11
#include <fcntl.h>
#include <inttypes.h>
#elif defined(_MSC_VER)
#if !defined O_BINARY && defined _O_BINARY
/* For MSC-compatible compilers. */
#define O_BINARY _O_BINARY
#endif
#endif
#ifdef __BEOS__
/* BeOS 5 has O_BINARY, but is has no effect. */
#undef O_BINARY
#endif
/* On reasonable systems, binary I/O is the default. */
#ifndef O_BINARY
#define O_BINARY 0
#endif
/* Replacement for O_NONBLOCK */
#ifndef O_NONBLOCK
#ifdef O_NDELAY /* SYSV */
#define O_NONBLOCK O_NDELAY
#else /* BSD */
#ifdef WIN32 //WIN32/APY
#define O_NONBLOCK 0
#else
#define O_NONBLOCK FNDELAY
#endif
#endif /* !O_NDELAY */
#endif /* !O_NONBLOCK */
#if defined(__QNX__) && !defined(__QNXNTO__)
/* exec*() from <process.h> */
#include <unix.h>
#endif
#include <glib.h>
#if defined(HAVE_FUNC_ATTRIBUTE_WEAK) && defined(HAVE_TESTS)
#define MC_MOCKABLE __attribute__((weak))
#else
#define MC_MOCKABLE
#endif
#include "glibcompat.h"
/* For SMB VFS only */
#ifndef __GNUC__
#define __attribute__(x)
#endif
#include "unixcompat.h"
/* Solaris9 doesn't have PRIXMAX */
#ifndef WIN32 //WIN32, fix
#ifndef PRIXMAX
#define PRIXMAX PRIxMAX
#endif
#endif
#include "fs.h"
#include "shell.h"
#include "mcconfig.h"
/*** typedefs(not structures) and defined constants **********************************************/
#ifdef ENABLE_NLS
#include <libintl.h>
@ -112,9 +44,17 @@
#define N_(String) (String)
#endif /* !ENABLE_NLS */
#include "fs.h"
#include "shell.h"
#include "mcconfig.h"
#ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH
#define MC_FALLTHROUGH __attribute__((fallthrough))
#else
#define MC_FALLTHROUGH
#endif
#ifdef HAVE_FUNC_ATTRIBUTE_UNUSED
#define MC_UNUSED __attribute__((unused))
#else
#define MC_UNUSED
#endif
#ifdef USE_MAINTAINER_MODE
#include "lib/logging.h"
@ -131,41 +71,8 @@
#define BUF_SMALL 128
#define BUF_TINY 64
/* ESC_CHAR is defined in /usr/include/langinfo.h in some systems */
#ifdef ESC_CHAR
#undef ESC_CHAR
#endif
/* AIX compiler doesn't understand '\e' */
#define ESC_CHAR '\033'
#define ESC_STR "\033"
/* OS specific defines */
#define PATH_SEP '/'
#define PATH_SEP_STR "/"
#if defined(WIN32) //WIN32, path
#define PATH_SEP2 '\\'
#define PATH_SEP_STR2 "\\"
#define IS_PATH_SEP(c) ((c) == PATH_SEP || (c) == PATH_SEP2)
#define PATH_ENV_SEP ';'
extern char *strrchr2(const char *s, int c1, int c2);
extern char *strchr2(const char *s, int c1, int c2);
#else
#define IS_PATH_SEP(c) ((c) == PATH_SEP)
#define PATH_ENV_SEP ':'
#endif
#define TMPDIR_DEFAULT "/tmp"
#define SCRIPT_SUFFIX ""
#define get_default_editor() "vi"
#define OS_SORT_CASE_SENSITIVE_DEFAULT TRUE
#define UTF8_CHAR_LEN 6
/* struct stat members */
#ifdef __APPLE__
#define st_atim st_atimespec
#define st_ctim st_ctimespec
#define st_mtim st_mtimespec
#endif
/* Used to distinguish between a normal MC termination and */
/* one caused by typing 'exit' or 'logout' in the subshell */
#define SUBSHELL_EXIT 128

View File

@ -4,7 +4,7 @@
Slavaz: Warning! this file is deprecated and should be replaced
by mcevents functional.
Copyright (C) 1994-2024
Copyright (C) 1994-2025
Free Software Foundation, Inc.
Written by:
@ -54,7 +54,7 @@
/* --------------------------------------------------------------------------------------------- */
void
add_hook (hook_t ** hook_list, void (*hook_fn) (void *), void *data)
add_hook (hook_t **hook_list, void (*hook_fn) (void *), void *data)
{
hook_t *new_hook = g_new (hook_t, 1);
@ -68,7 +68,7 @@ add_hook (hook_t ** hook_list, void (*hook_fn) (void *), void *data)
/* --------------------------------------------------------------------------------------------- */
void
execute_hooks (hook_t * hook_list)
execute_hooks (hook_t *hook_list)
{
hook_t *new_hook = NULL;
hook_t *p;
@ -101,7 +101,7 @@ execute_hooks (hook_t * hook_list)
/* --------------------------------------------------------------------------------------------- */
void
delete_hook (hook_t ** hook_list, void (*hook_fn) (void *))
delete_hook (hook_t **hook_list, void (*hook_fn) (void *))
{
hook_t *new_list = NULL;
hook_t *current, *next;
@ -120,7 +120,7 @@ delete_hook (hook_t ** hook_list, void (*hook_fn) (void *))
/* --------------------------------------------------------------------------------------------- */
gboolean
hook_present (hook_t * hook_list, void (*hook_fn) (void *))
hook_present (hook_t *hook_list, void (*hook_fn) (void *))
{
hook_t *p;

144
mcsrc/lib/idx.h Normal file
View File

@ -0,0 +1,144 @@
/* A type for indices and sizes.
Copyright (C) 2020-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C 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.
The GNU C 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 the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _IDX_H
#define _IDX_H
/* Get ptrdiff_t. */
#include <stddef.h>
/* Get PTRDIFF_MAX. */
#include <stdint.h>
/* The type 'idx_t' holds an (array) index or an (object) size.
Its implementation promotes to a signed integer type,
which can hold the values
0..2^63-1 (on 64-bit platforms) or
0..2^31-1 (on 32-bit platforms).
Why a signed integer type?
* Security: Signed types can be checked for overflow via
'-fsanitize=undefined', but unsigned types cannot.
* Comparisons without surprises: ISO C99 § 6.3.1.8 specifies a few
surprising results for comparisons, such as
(int) -3 < (unsigned long) 7 => false
(int) -3 < (unsigned int) 7 => false
and on 32-bit machines:
(long) -3 < (unsigned int) 7 => false
This is surprising because the natural comparison order is by
value in the realm of infinite-precision signed integers ().
The best way to get rid of such surprises is to use signed types
for numerical integer values, and use unsigned types only for
bit masks and enums.
Why not use 'size_t' directly?
* Because 'size_t' is an unsigned type, and a signed type is better.
See above.
Why not use 'ssize_t'?
* 'ptrdiff_t' is more portable; it is standardized by ISO C
whereas 'ssize_t' is standardized only by POSIX.
* 'ssize_t' is not required to be as wide as 'size_t', and some
now-obsolete POSIX platforms had 'size_t' wider than 'ssize_t'.
* Conversely, some now-obsolete platforms had 'ptrdiff_t' wider
than 'size_t', which can be a win and conforms to POSIX.
Won't this cause a problem with objects larger than PTRDIFF_MAX?
* Typical modern or large platforms do not allocate such objects,
so this is not much of a problem in practice; for example, you
can safely write 'idx_t len = strlen (s);'. To port to older
small platforms where allocations larger than PTRDIFF_MAX could
in theory be a problem, you can use Gnulib's ialloc module, or
functions like ximalloc in Gnulib's xalloc module.
Why not use 'ptrdiff_t' directly?
* Maintainability: When reading and modifying code, it helps to know that
a certain variable cannot have negative values. For example, when you
have a loop
int n = ...;
for (int i = 0; i < n; i++) ...
or
ptrdiff_t n = ...;
for (ptrdiff_t i = 0; i < n; i++) ...
you have to ask yourself "what if n < 0?". Whereas in
idx_t n = ...;
for (idx_t i = 0; i < n; i++) ...
you know that this case cannot happen.
Similarly, when a programmer writes
idx_t = ptr2 - ptr1;
there is an implied assertion that ptr1 and ptr2 point into the same
object and that ptr1 <= ptr2.
* Being future-proof: In the future, range types (integers which are
constrained to a certain range of values) may be added to C compilers
or to the C standard. Several programming languages (Ada, Haskell,
Common Lisp, Pascal) already have range types. Such range types may
help producing good code and good warnings. The type 'idx_t' could
then be typedef'ed to a range type that is signed after promotion. */
#ifdef __cplusplus
extern "C" {
#endif
/* In the future, idx_t could be typedef'ed to a signed range type.
The clang "extended integer types", supported in Clang 11 or newer
<https://clang.llvm.org/docs/LanguageExtensions.html#extended-integer-types>,
are a special case of range types. However, these types don't support binary
operators with plain integer types (e.g. expressions such as x > 1).
Therefore, they don't behave like signed types (and not like unsigned types
either). So, we cannot use them here. */
/* Use the signed type 'ptrdiff_t'. */
/* Note: ISO C does not mandate that 'size_t' and 'ptrdiff_t' have the same
size, but it is so on all platforms we have seen since 1990. */
typedef ptrdiff_t idx_t;
/* IDX_MAX is the maximum value of an idx_t. */
#define IDX_MAX PTRDIFF_MAX
/* So far no need has been found for an IDX_WIDTH macro.
Perhaps there should be another macro IDX_VALUE_BITS that does not
count the sign bit and is therefore one less than PTRDIFF_WIDTH. */
#ifdef __cplusplus
}
#endif
#endif /* _IDX_H */

View File

@ -0,0 +1,399 @@
/* intprops-internal.h -- properties of integer types not visible to users
Copyright (C) 2001-2024 Free Software Foundation, Inc.
This program 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 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_INTPROPS_INTERNAL_H
#define _GL_INTPROPS_INTERNAL_H
#include <limits.h>
/* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED. */
#if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
# pragma GCC diagnostic ignored "-Wtype-limits"
#endif
/* Return a value with the common real type of E and V and the value of V.
Do not evaluate E. */
#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
<https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v))
/* The extra casts in the following macros work around compiler bugs,
e.g., in Cray C 5.0.3.0. */
/* True if the real type T is signed. */
#define _GL_TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* Return 1 if the real expression E, after promotion, has a
signed or floating type. Do not evaluate E. */
#define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
/* Minimum and maximum values for integer types and expressions. */
/* The width in bits of the integer type or expression T.
Do not evaluate T. T must not be a bit-field expression.
Padding bits are not supported; this is checked at compile-time below. */
#define _GL_TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
/* The maximum and minimum values for the type of the expression E,
after integer promotion. E is not evaluated. */
#define _GL_INT_MINIMUM(e) \
(_GL_EXPR_SIGNED (e) \
? ~ _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_CONVERT (e, 0))
#define _GL_INT_MAXIMUM(e) \
(_GL_EXPR_SIGNED (e) \
? _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_NEGATE_CONVERT (e, 1))
#define _GL_SIGNED_INT_MAXIMUM(e) \
(((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1)
/* Work around OpenVMS incompatibility with C99. */
#if !defined LLONG_MAX && defined __INT64_MAX
# define LLONG_MAX __INT64_MAX
# define LLONG_MIN __INT64_MIN
#endif
/* This include file assumes that signed types are two's complement without
padding bits; the above macros have undefined behavior otherwise.
If this is a problem for you, please let us know how to fix it for your host.
This assumption is tested by the intprops-tests module. */
/* Does the __typeof__ keyword work? This could be done by
'configure', but for now it's easier to do it by hand. */
#if (2 <= __GNUC__ \
|| (4 <= __clang_major__) \
|| (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
|| (0x5110 <= __SUNPRO_C && !__STDC__))
# define _GL_HAVE___TYPEOF__ 1
#else
# define _GL_HAVE___TYPEOF__ 0
#endif
/* Return 1 if the integer type or expression T might be signed. Return 0
if it is definitely unsigned. T must not be a bit-field expression.
This macro does not evaluate its argument, and expands to an
integer constant expression. */
#if _GL_HAVE___TYPEOF__
# define _GL_SIGNED_TYPE_OR_EXPR(t) _GL_TYPE_SIGNED (__typeof__ (t))
#else
# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
#endif
/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
A should not have side effects, and A's type should be an
integer with minimum value MIN and maximum MAX. */
#define _GL_INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
((min) < 0 ? (a) < - (max) : 0 < (a))
/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
(A, B, P) work when P is non-null. */
#ifdef __EDG__
/* EDG-based compilers like nvc 22.1 cannot add 64-bit signed to unsigned
<https://bugs.gnu.org/53256>. */
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
#elif 7 <= __GNUC__
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
#else
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
#endif
/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
#if defined __clang_major__ && __clang_major__ < 14
/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
#else
# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
#endif
/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
__builtin_sub_overflow_p and __builtin_mul_overflow_p. */
#ifdef __EDG__
/* In EDG-based compilers like ICC 2021.3 and earlier,
__builtin_add_overflow_p etc. are not treated as integral constant
expressions even when all arguments are. */
# define _GL_HAS_BUILTIN_OVERFLOW_P 0
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p)
#else
# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
#endif
#if (!defined _GL_STDCKDINT_H && 202311 <= __STDC_VERSION__ \
&& ! (_GL_HAS_BUILTIN_ADD_OVERFLOW && _GL_HAS_BUILTIN_MUL_OVERFLOW))
# include <stdckdint.h>
#endif
/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
Return 1 if the result overflows. Arguments should not have side
effects and A, B and *R can be of any integer type other than char,
bool, a bit-precise integer type, or an enumeration type. */
#if _GL_HAS_BUILTIN_ADD_OVERFLOW
# define _GL_INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r)
# define _GL_INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r)
#elif defined ckd_add && defined ckd_sub && !defined _GL_STDCKDINT_H
# define _GL_INT_ADD_WRAPV(a, b, r) ckd_add (r, + (a), + (b))
# define _GL_INT_SUBTRACT_WRAPV(a, b, r) ckd_sub (r, + (a), + (b))
#else
# define _GL_INT_ADD_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW)
# define _GL_INT_SUBTRACT_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
#endif
#if _GL_HAS_BUILTIN_MUL_OVERFLOW
# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
|| (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
&& !defined __EDG__)
# define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
# else
/* Work around GCC bug 91450. */
# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \
&& _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, \
(__typeof__ (*(r))) 0, \
(__typeof__ (*(r))) -1)) \
? ((void) __builtin_mul_overflow (a, b, r), 1) \
: __builtin_mul_overflow (a, b, r))
# endif
#elif defined ckd_mul && !defined _GL_STDCKDINT_H
# define _GL_INT_MULTIPLY_WRAPV(a, b, r) ckd_mul (r, + (a), + (b))
#else
# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
#endif
/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
https://llvm.org/bugs/show_bug.cgi?id=25390
For now, assume GCC < 14 and all Clang versions generate bogus
warnings for _Generic. This matters only for compilers that
lack relevant builtins. */
#if (__GNUC__ && __GNUC__ < 14) || defined __clang__
# define _GL__GENERIC_BOGUS 1
#else
# define _GL__GENERIC_BOGUS 0
#endif
/* Store the low-order bits of A <op> B into *R, where OP specifies
the operation and OVERFLOW the overflow predicate. Return 1 if the
result overflows. Arguments should not have side effects,
and A, B and *R can be of any integer type other than char, bool, a
bit-precise integer type, or an enumeration type. */
#if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
(_Generic \
(*(r), \
signed char: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
signed char, SCHAR_MIN, SCHAR_MAX), \
unsigned char: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned char, 0, UCHAR_MAX), \
short int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
short int, SHRT_MIN, SHRT_MAX), \
unsigned short int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned short int, 0, USHRT_MAX), \
int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
int, INT_MIN, INT_MAX), \
unsigned int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned int, 0, UINT_MAX), \
long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX), \
unsigned long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
unsigned long int, 0, ULONG_MAX), \
long long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
long long int, LLONG_MIN, LLONG_MAX), \
unsigned long long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
unsigned long long int, 0, ULLONG_MAX)))
#else
/* Store the low-order bits of A <op> B into *R, where OP specifies
the operation and OVERFLOW the overflow predicate. If *R is
signed, its type is ST with bounds SMIN..SMAX; otherwise its type
is UT with bounds U..UMAX. ST and UT are narrower than int.
Return 1 if the result overflows. Arguments should not have side
effects, and A, B and *R can be of any integer type other than
char, bool, a bit-precise integer type, or an enumeration type. */
# if _GL_HAVE___TYPEOF__
# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
(_GL_TYPE_SIGNED (__typeof__ (*(r))) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax))
# else
# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
(overflow (a, b, smin, smax) \
? (overflow (a, b, 0, umax) \
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \
: (overflow (a, b, 0, umax) \
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0)))
# endif
# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
(sizeof *(r) == sizeof (signed char) \
? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
signed char, SCHAR_MIN, SCHAR_MAX, \
unsigned char, UCHAR_MAX) \
: sizeof *(r) == sizeof (short int) \
? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
short int, SHRT_MIN, SHRT_MAX, \
unsigned short int, USHRT_MAX) \
: sizeof *(r) == sizeof (int) \
? (_GL_EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
int, INT_MIN, INT_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned int, 0, UINT_MAX)) \
: _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
# ifdef LLONG_MAX
# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
(sizeof *(r) == sizeof (long int) \
? (_GL_EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
unsigned long int, 0, ULONG_MAX)) \
: (_GL_EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
long long int, LLONG_MIN, LLONG_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
unsigned long long int, 0, ULLONG_MAX)))
# else
# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
(_GL_EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
unsigned long int, 0, ULONG_MAX))
# endif
#endif
/* Store the low-order bits of A <op> B into *R, where the operation
is given by OP. Use the unsigned type UT for calculation to avoid
overflow problems. *R's type is T, with extrema TMIN and TMAX.
T can be any signed integer type other than char, bool, a
bit-precise integer type, or an enumeration type.
Return 1 if the result overflows. */
#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
(overflow (a, b, tmin, tmax) \
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
/* Return 1 if the integer expressions A - B and -A would overflow,
respectively. Arguments should not have side effects,
and can be any signed integer type other than char, bool, a
bit-precise integer type, or an enumeration type.
These macros are tuned for their last input argument being a constant. */
#if _GL_HAS_BUILTIN_OVERFLOW_P
# define _GL_INT_NEGATE_OVERFLOW(a) \
__builtin_sub_overflow_p (0, a, (__typeof__ (- (a))) 0)
#else
# define _GL_INT_NEGATE_OVERFLOW(a) \
_GL_INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
#endif
/* Return the low-order bits of A <op> B, where the operation is given
by OP. Use the unsigned type UT for calculation to avoid undefined
behavior on signed integer overflow, and convert the result to type T.
UT is at least as wide as T and is no narrower than unsigned int,
T is two's complement, and there is no padding or trap representations.
Assume that converting UT to T yields the low-order bits, as is
done in all known two's-complement C compilers. E.g., see:
https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
According to the C standard, converting UT to T yields an
implementation-defined result or signal for values outside T's
range. However, code that works around this theoretical problem
runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
As the compiler bug is real, don't try to work around the
theoretical problem. */
#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
((t) ((ut) (a) op (ut) (b)))
/* Return true if the numeric values A + B, A - B, A * B fall outside
the range TMIN..TMAX. Arguments should not have side effects
and can be any integer type other than char, bool,
a bit-precise integer type, or an enumeration type.
TMIN should be signed and nonpositive.
TMAX should be positive, and should be signed unless TMIN is zero. */
#define _GL_INT_ADD_RANGE_OVERFLOW(a, b, tmin, tmax) \
((b) < 0 \
? (((tmin) \
? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, (tmin) - (b))) || (b) < (tmin)) \
&& (a) < (tmin) - (b)) \
: (a) <= -1 - (b)) \
|| ((_GL_EXPR_SIGNED (a) ? 0 <= (a) : (tmax) < (a)) && (tmax) < (a) + (b))) \
: (a) < 0 \
? (((tmin) \
? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (b, (tmin) - (a))) || (a) < (tmin)) \
&& (b) < (tmin) - (a)) \
: (b) <= -1 - (a)) \
|| ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, b)) || (tmax) < (b)) \
&& (tmax) < (a) + (b))) \
: (tmax) < (b) || (tmax) - (b) < (a))
#define _GL_INT_SUBTRACT_RANGE_OVERFLOW(a, b, tmin, tmax) \
(((a) < 0) == ((b) < 0) \
? ((a) < (b) \
? !(tmin) || -1 - (tmin) < (b) - (a) - 1 \
: (tmax) < (a) - (b)) \
: (a) < 0 \
? ((!_GL_EXPR_SIGNED (_GL_INT_CONVERT ((a) - (tmin), b)) && (a) - (tmin) < 0) \
|| (a) - (tmin) < (b)) \
: ((! (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
&& _GL_EXPR_SIGNED (_GL_INT_CONVERT ((tmax) + (b), a))) \
&& (tmax) <= -1 - (b)) \
|| (tmax) + (b) < (a)))
#define _GL_INT_MULTIPLY_RANGE_OVERFLOW(a, b, tmin, tmax) \
((b) < 0 \
? ((a) < 0 \
? (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
? (a) < (tmax) / (b) \
: ((_GL_INT_NEGATE_OVERFLOW (b) \
? _GL_INT_CONVERT (b, tmax) >> (_GL_TYPE_WIDTH (+ (b)) - 1) \
: (tmax) / -(b)) \
<= -1 - (a))) \
: _GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \
? (_GL_EXPR_SIGNED (a) \
? 0 < (a) + (tmin) \
: 0 < (a) && -1 - (tmin) < (a) - 1) \
: (tmin) / (b) < (a)) \
: (b) == 0 \
? 0 \
: ((a) < 0 \
? (_GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (a, tmin)) && (a) == -1 \
? (_GL_EXPR_SIGNED (b) ? 0 < (b) + (tmin) : -1 - (tmin) < (b) - 1) \
: (tmin) / (a) < (b)) \
: (tmax) / (b) < (a)))
#endif /* _GL_INTPROPS_INTERNAL_H */

335
mcsrc/lib/intprops.h Normal file
View File

@ -0,0 +1,335 @@
/* intprops.h -- properties of integer types
Copyright (C) 2001-2024 Free Software Foundation, Inc.
This program 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 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_INTPROPS_H
#define _GL_INTPROPS_H
#include "intprops-internal.h"
/* The extra casts in the following macros work around compiler bugs,
e.g., in Cray C 5.0.3.0. */
/* True if the arithmetic type T is an integer type. bool counts as
an integer. */
#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
/* True if the real type T is signed. */
#define TYPE_SIGNED(t) _GL_TYPE_SIGNED (t)
/* Return 1 if the real expression E, after promotion, has a
signed or floating type. Do not evaluate E. */
#define EXPR_SIGNED(e) _GL_EXPR_SIGNED (e)
/* Minimum and maximum values for integer types and expressions. */
/* The width in bits of the integer type or expression T.
Do not evaluate T. T must not be a bit-field expression.
Padding bits are not supported; this is checked at compile-time below. */
#define TYPE_WIDTH(t) _GL_TYPE_WIDTH (t)
/* The maximum and minimum values for the integer type T. */
#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
#define TYPE_MAXIMUM(t) \
((t) (! TYPE_SIGNED (t) \
? (t) -1 \
: ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
/* Bound on length of the string representing an unsigned integer
value representable in B bits. log10 (2.0) < 146/485. The
smallest value of B where this bound is not tight is 2621. */
#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
/* Bound on length of the string representing an integer type or expression T.
T must not be a bit-field expression.
Subtract 1 for the sign bit if T is signed, and then add 1 more for
a minus sign if needed.
Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 1 when its argument is
unsigned, this macro may overestimate the true bound by one byte when
applied to unsigned types of size 2, 4, 16, ... bytes. */
#define INT_STRLEN_BOUND(t) \
(INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \
+ _GL_SIGNED_TYPE_OR_EXPR (t))
/* Bound on buffer size needed to represent an integer type or expression T,
including the terminating null. T must not be a bit-field expression. */
#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
/* Range overflow checks.
The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
operators overflow arithmetically when given the same arguments.
These macros do not rely on undefined or implementation-defined behavior.
Although their implementations are simple and straightforward,
they are harder to use and may be less efficient than the
INT_<op>_WRAPV, INT_<op>_OK, and INT_<op>_OVERFLOW macros described below.
Example usage:
long int i = ...;
long int j = ...;
if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX))
printf ("multiply would overflow");
else
printf ("product is %ld", i * j);
Restrictions on *_RANGE_OVERFLOW macros:
These macros do not check for all possible numerical problems or
undefined or unspecified behavior: they do not check for division
by zero, for bad shift counts, or for shifting negative numbers.
These macros may evaluate their arguments zero or multiple times,
so the arguments should not have side effects. The arithmetic
arguments (including the MIN and MAX arguments) must be of the same
integer type after the usual arithmetic conversions, and the type
must have minimum value MIN and maximum MAX. Unsigned types should
use a zero MIN of the proper type.
Because all arguments are subject to integer promotions, these
macros typically do not work on types narrower than 'int'.
These macros are tuned for constant MIN and MAX. For commutative
operations such as A + B, they are also tuned for constant B. */
/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. */
#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \
((b) < 0 \
? (a) < (min) - (b) \
: (max) - (b) < (a))
/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. */
#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \
((b) < 0 \
? (max) + (b) < (a) \
: (a) < (min) + (b))
/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
See above for restrictions. */
#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
_GL_INT_NEGATE_RANGE_OVERFLOW (a, min, max)
/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Avoid && and || as they tickle
bugs in Sun C 5.11 2010/08/13 and other compilers; see
<https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */
#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
((b) < 0 \
? ((a) < 0 \
? (a) < (max) / (b) \
: (b) == -1 \
? 0 \
: (min) / (b) < (a)) \
: (b) == 0 \
? 0 \
: ((a) < 0 \
? (a) < (min) / (b) \
: (max) / (b) < (a)))
/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Do not check for division by zero. */
#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \
((min) < 0 && (b) == -1 && (a) < - (max))
/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Do not check for division by zero.
Mathematically, % should never overflow, but on x86-like hosts
INT_MIN % -1 traps, and the C standard permits this, so treat this
as an overflow too. */
#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \
INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max)
/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Here, MIN and MAX are for A only, and B need
not be of the same type as the other arguments. The C standard says that
behavior is undefined for shifts unless 0 <= B < wordwidth, and that when
A is negative then A << B has undefined behavior and A >> B has
implementation-defined behavior, but do not check these other
restrictions. */
#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \
((a) < 0 \
? (a) < (min) >> (b) \
: (max) >> (b) < (a))
/* The _GL*_OVERFLOW macros have the same restrictions as the
*_RANGE_OVERFLOW macros, except that they do not assume that operands
(e.g., A and B) have the same type as MIN and MAX. Instead, they assume
that the result (e.g., A + B) has that type. */
#if _GL_HAS_BUILTIN_OVERFLOW_P
# define _GL_ADD_OVERFLOW(a, b, min, max) \
__builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
__builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0)
# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
__builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0)
#else
# define _GL_ADD_OVERFLOW(a, b, min, max) \
((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
: (a) < 0 ? (b) <= (a) + (b) \
: (b) < 0 ? (a) <= (a) + (b) \
: (a) + (b) < (b))
# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
: (a) < 0 ? 1 \
: (b) < 0 ? (a) - (b) <= (a) \
: (a) < (b))
# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
(((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
|| INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
#endif
#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
: (a) < 0 ? (b) <= (a) + (b) - 1 \
: (b) < 0 && (a) + (b) <= (a))
#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \
((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
: (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \
: (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max))
/* Return a nonzero value if A is a mathematical multiple of B, where
A is unsigned, B is negative, and MAX is the maximum value of A's
type. A's type must be the same as (A % B)'s type. Normally (A %
-B == 0) suffices, but things get tricky if -B would overflow. */
#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \
(((b) < -_GL_SIGNED_INT_MAXIMUM (b) \
? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \
? (a) \
: (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \
: (a) % - (b)) \
== 0)
/* Check for integer overflow, and report low order bits of answer.
The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
might not yield numerically correct answers due to arithmetic overflow.
The INT_<op>_WRAPV macros compute the low-order bits of the sum,
difference, and product of two C integers, and return 1 if these
low-order bits are not numerically correct.
These macros work correctly on all known practical hosts, and do not rely
on undefined behavior due to signed arithmetic overflow.
Example usage, assuming A and B are long int:
if (INT_MULTIPLY_OVERFLOW (a, b))
printf ("result would overflow\n");
else
printf ("result is %ld (no overflow)\n", a * b);
Example usage with WRAPV flavor:
long int result;
bool overflow = INT_MULTIPLY_WRAPV (a, b, &result);
printf ("result is %ld (%s)\n", result,
overflow ? "after overflow" : "no overflow");
Restrictions on these macros:
These macros do not check for all possible numerical problems or
undefined or unspecified behavior: they do not check for division
by zero, for bad shift counts, or for shifting negative numbers.
These macros may evaluate their arguments zero or multiple times, so the
arguments should not have side effects.
The WRAPV macros are not constant expressions. They support only
+, binary -, and *.
Because the WRAPV macros convert the result, they report overflow
in different circumstances than the OVERFLOW macros do. For
example, in the typical case with 16-bit 'short' and 32-bit 'int',
if A, B and *R are all of type 'short' then INT_ADD_OVERFLOW (A, B)
returns false because the addition cannot overflow after A and B
are converted to 'int', whereas INT_ADD_WRAPV (A, B, R) returns
true or false depending on whether the sum fits into 'short'.
These macros are tuned for their last input argument being a constant.
A, B, and *R should be integers; they need not be the same type,
and they need not be all signed or all unsigned.
However, none of the integer types should be bit-precise,
and *R's type should not be char, bool, or an enumeration type.
Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
A % B, and A << B would overflow, respectively. */
#define INT_ADD_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
#define INT_SUBTRACT_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
#define INT_NEGATE_OVERFLOW(a) _GL_INT_NEGATE_OVERFLOW (a)
#define INT_MULTIPLY_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
#define INT_DIVIDE_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW)
#define INT_REMAINDER_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW)
#define INT_LEFT_SHIFT_OVERFLOW(a, b) \
INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \
_GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
/* Return 1 if the expression A <op> B would overflow,
where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test,
assuming MIN and MAX are the minimum and maximum for the result type.
Arguments should be free of side effects. */
#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
op_result_overflow (a, b, \
_GL_INT_MINIMUM (_GL_INT_CONVERT (a, b)), \
_GL_INT_MAXIMUM (_GL_INT_CONVERT (a, b)))
/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
Return 1 if the result overflows. See above for restrictions. */
#define INT_ADD_WRAPV(a, b, r) _GL_INT_ADD_WRAPV (a, b, r)
#define INT_SUBTRACT_WRAPV(a, b, r) _GL_INT_SUBTRACT_WRAPV (a, b, r)
#define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
/* The following macros compute A + B, A - B, and A * B, respectively.
If no overflow occurs, they set *R to the result and return 1;
otherwise, they return 0 and may modify *R.
Example usage:
long int result;
if (INT_ADD_OK (a, b, &result))
printf ("result is %ld\n", result);
else
printf ("overflow\n");
A, B, and *R should be integers; they need not be the same type,
and they need not be all signed or all unsigned.
However, none of the integer types should be bit-precise,
and *R's type should not be char, bool, or an enumeration type.
These macros work correctly on all known practical hosts, and do not rely
on undefined behavior due to signed arithmetic overflow.
These macros are not constant expressions.
These macros may evaluate their arguments zero or multiple times, so the
arguments should not have side effects.
These macros are tuned for B being a constant. */
#define INT_ADD_OK(a, b, r) (! INT_ADD_WRAPV (a, b, r))
#define INT_SUBTRACT_OK(a, b, r) (! INT_SUBTRACT_WRAPV (a, b, r))
#define INT_MULTIPLY_OK(a, b, r) (! INT_MULTIPLY_WRAPV (a, b, r))
#endif /* _GL_INTPROPS_H */

View File

@ -1,7 +1,7 @@
/*
Definitions of key bindings.
Copyright (C) 2005-2024
Copyright (C) 2005-2025
Free Software Foundation, Inc.
Written by:
@ -422,7 +422,7 @@ sort_command_names (void)
/* --------------------------------------------------------------------------------------------- */
static void
keymap_add (GArray * keymap, long key, long cmd, const char *caption)
keymap_add (GArray *keymap, long key, long cmd, const char *caption)
{
if (key != 0 && cmd != CK_IgnoreKey)
{
@ -440,7 +440,7 @@ keymap_add (GArray * keymap, long key, long cmd, const char *caption)
/* --------------------------------------------------------------------------------------------- */
void
keybind_cmd_bind (GArray * keymap, const char *keybind, long action)
keybind_cmd_bind (GArray *keymap, const char *keybind, long action)
{
char *caption = NULL;
long key;
@ -483,7 +483,7 @@ keybind_lookup_actionname (long action)
/* --------------------------------------------------------------------------------------------- */
const char *
keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, long action)
keybind_lookup_keymap_shortcut (const global_keymap_t *keymap, long action)
{
if (keymap != NULL)
{
@ -499,7 +499,7 @@ keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, long action)
/* --------------------------------------------------------------------------------------------- */
long
keybind_lookup_keymap_command (const global_keymap_t * keymap, long key)
keybind_lookup_keymap_command (const global_keymap_t *keymap, long key)
{
if (keymap != NULL)
{

View File

@ -1,7 +1,7 @@
/*
File locking
Copyright (C) 2003-2024
Copyright (C) 2003-2025
Free Software Foundation, Inc.
Written by:
@ -57,7 +57,7 @@
#include "lib/global.h"
#include "lib/vfs/vfs.h"
#include "lib/util.h" /* tilde_expand() */
#include "lib/util.h"
#include "lib/lock.h"
#include "lib/widget.h" /* query_dialog() */
@ -117,7 +117,7 @@ lock_build_name (void)
/* --------------------------------------------------------------------------------------------- */
static char *
lock_build_symlink_name (const vfs_path_t * fname_vpath)
lock_build_symlink_name (const vfs_path_t *fname_vpath)
{
const char *elpath;
char *str_filename, *str_dirname, *symlink_name;
@ -198,7 +198,7 @@ lock_get_info (const char *lockfname)
Warning: Might do screen refresh and lose edit->force */
int
lock_file (const vfs_path_t * fname_vpath)
lock_file (const vfs_path_t *fname_vpath)
{
char *lockfname = NULL, *newlock, *msg;
struct stat statbuf;
@ -277,7 +277,7 @@ lock_file (const vfs_path_t * fname_vpath)
*/
int
unlock_file (const vfs_path_t * fname_vpath)
unlock_file (const vfs_path_t *fname_vpath)
{
char *lockfname;
const char *elpath;

View File

@ -1,7 +1,7 @@
/*
Provides a log file to ease tracing the program.
Copyright (C) 2006-2024
Copyright (C) 2006-2025
Free Software Foundation, Inc.
Written by:

View File

@ -53,8 +53,8 @@ gchar **mc_config_get_keys (const mc_config_t * mc_config, const gchar * group,
gchar *mc_config_get_string (mc_config_t * mc_config, const gchar * group, const gchar * param,
const gchar * def);
gchar *mc_config_get_string_raw (mc_config_t * mc_config, const gchar * group, const gchar * param,
const gchar * def);
MC_MOCKABLE gchar *mc_config_get_string_raw (mc_config_t * mc_config, const gchar * group,
const gchar * param, const gchar * def);
gboolean mc_config_get_bool (mc_config_t * mc_config, const gchar * group, const gchar * param,
gboolean def);
int mc_config_get_int (mc_config_t * mc_config, const gchar * group, const gchar * param, int def);
@ -96,7 +96,7 @@ void mc_config_deinit_config_paths (void);
const char *mc_config_get_data_path (void);
const char *mc_config_get_cache_path (void);
const char *mc_config_get_home_dir (void);
MC_MOCKABLE const char *mc_config_get_home_dir (void);
const char *mc_config_get_path (void);
char *mc_config_get_full_path (const char *config_name);
vfs_path_t *mc_config_get_full_vpath (const char *config_name);

View File

@ -1,7 +1,7 @@
/*
Configure module for the Midnight Commander
Copyright (C) 1994-2024
Copyright (C) 1994-2025
Free Software Foundation, Inc.
This file is part of the Midnight Commander.
@ -48,7 +48,7 @@
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path, GError ** mcerror)
mc_config_new_or_override_file (mc_config_t *mc_config, const gchar *ini_path, GError **mcerror)
{
gchar *data, *written_data;
gsize len, total_written;
@ -104,7 +104,7 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path,
/* --------------------------------------------------------------------------------------------- */
mc_config_t *
mc_config_init (const gchar * ini_path, gboolean read_only)
mc_config_init (const gchar *ini_path, gboolean read_only)
{
mc_config_t *mc_config;
struct stat st;
@ -148,7 +148,7 @@ mc_config_init (const gchar * ini_path, gboolean read_only)
/* --------------------------------------------------------------------------------------------- */
void
mc_config_deinit (mc_config_t * mc_config)
mc_config_deinit (mc_config_t *mc_config)
{
if (mc_config != NULL)
{
@ -161,7 +161,7 @@ mc_config_deinit (mc_config_t * mc_config)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_config_has_param (const mc_config_t * mc_config, const char *group, const gchar * param)
mc_config_has_param (const mc_config_t *mc_config, const char *group, const gchar *param)
{
char *value;
gboolean ret;
@ -178,7 +178,7 @@ mc_config_has_param (const mc_config_t * mc_config, const char *group, const gch
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_config_has_group (mc_config_t * mc_config, const char *group)
mc_config_has_group (mc_config_t *mc_config, const char *group)
{
if (mc_config == NULL || group == NULL)
return FALSE;
@ -189,7 +189,7 @@ mc_config_has_group (mc_config_t * mc_config, const char *group)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_config_del_key (mc_config_t * mc_config, const char *group, const gchar * param)
mc_config_del_key (mc_config_t *mc_config, const char *group, const gchar *param)
{
if (mc_config == NULL || group == NULL || param == NULL)
return FALSE;
@ -200,7 +200,7 @@ mc_config_del_key (mc_config_t * mc_config, const char *group, const gchar * par
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_config_del_group (mc_config_t * mc_config, const char *group)
mc_config_del_group (mc_config_t *mc_config, const char *group)
{
if (mc_config == NULL || group == NULL)
return FALSE;
@ -211,7 +211,7 @@ mc_config_del_group (mc_config_t * mc_config, const char *group)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path, gboolean read_only,
mc_config_read_file (mc_config_t *mc_config, const gchar *ini_path, gboolean read_only,
gboolean remove_empty)
{
mc_config_t *tmp_config;
@ -261,7 +261,7 @@ mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path, gboolean r
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_config_save_file (mc_config_t * mc_config, GError ** mcerror)
mc_config_save_file (mc_config_t *mc_config, GError **mcerror)
{
mc_return_val_if_error (mcerror, FALSE);
@ -274,7 +274,7 @@ mc_config_save_file (mc_config_t * mc_config, GError ** mcerror)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_config_save_to_file (mc_config_t * mc_config, const gchar * ini_path, GError ** mcerror)
mc_config_save_to_file (mc_config_t *mc_config, const gchar *ini_path, GError **mcerror)
{
mc_return_val_if_error (mcerror, FALSE);

View File

@ -1,7 +1,7 @@
/*
Configure module for the Midnight Commander
Copyright (C) 1994-2024
Copyright (C) 1994-2025
Free Software Foundation, Inc.
This file is part of the Midnight Commander.
@ -46,7 +46,7 @@
/* --------------------------------------------------------------------------------------------- */
gchar **
mc_config_get_groups (const mc_config_t * mc_config, gsize * len)
mc_config_get_groups (const mc_config_t *mc_config, gsize *len)
{
gchar **ret = NULL;
@ -66,7 +66,7 @@ mc_config_get_groups (const mc_config_t * mc_config, gsize * len)
/* --------------------------------------------------------------------------------------------- */
gchar **
mc_config_get_keys (const mc_config_t * mc_config, const gchar * group, gsize * len)
mc_config_get_keys (const mc_config_t *mc_config, const gchar *group, gsize *len)
{
gchar **ret = NULL;
@ -86,8 +86,8 @@ mc_config_get_keys (const mc_config_t * mc_config, const gchar * group, gsize *
/* --------------------------------------------------------------------------------------------- */
gchar *
mc_config_get_string (mc_config_t * mc_config, const gchar * group,
const gchar * param, const gchar * def)
mc_config_get_string (mc_config_t *mc_config, const gchar *group,
const gchar *param, const gchar *def)
{
GIConv conv;
GString *buffer;
@ -121,8 +121,8 @@ mc_config_get_string (mc_config_t * mc_config, const gchar * group,
/* --------------------------------------------------------------------------------------------- */
gchar *
mc_config_get_string_raw (mc_config_t * mc_config, const gchar * group,
const gchar * param, const gchar * def)
mc_config_get_string_raw (mc_config_t *mc_config, const gchar *group,
const gchar *param, const gchar *def)
{
gchar *ret;
@ -144,7 +144,7 @@ mc_config_get_string_raw (mc_config_t * mc_config, const gchar * group,
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_config_get_bool (mc_config_t * mc_config, const gchar * group, const gchar * param, gboolean def)
mc_config_get_bool (mc_config_t *mc_config, const gchar *group, const gchar *param, gboolean def)
{
if (mc_config == NULL || group == NULL || param == NULL)
return def;
@ -161,7 +161,7 @@ mc_config_get_bool (mc_config_t * mc_config, const gchar * group, const gchar *
/* --------------------------------------------------------------------------------------------- */
int
mc_config_get_int (mc_config_t * mc_config, const gchar * group, const gchar * param, int def)
mc_config_get_int (mc_config_t *mc_config, const gchar *group, const gchar *param, int def)
{
if (mc_config == NULL || group == NULL || param == NULL)
return def;
@ -178,8 +178,8 @@ mc_config_get_int (mc_config_t * mc_config, const gchar * group, const gchar * p
/* --------------------------------------------------------------------------------------------- */
gchar **
mc_config_get_string_list (mc_config_t * mc_config, const gchar * group,
const gchar * param, gsize * length)
mc_config_get_string_list (mc_config_t *mc_config, const gchar *group,
const gchar *param, gsize *length)
{
if (mc_config == NULL || group == NULL || param == NULL)
return NULL;
@ -190,8 +190,8 @@ mc_config_get_string_list (mc_config_t * mc_config, const gchar * group,
/* --------------------------------------------------------------------------------------------- */
gboolean *
mc_config_get_bool_list (mc_config_t * mc_config, const gchar * group,
const gchar * param, gsize * length)
mc_config_get_bool_list (mc_config_t *mc_config, const gchar *group,
const gchar *param, gsize *length)
{
if (mc_config == NULL || group == NULL || param == NULL)
return NULL;
@ -202,8 +202,8 @@ mc_config_get_bool_list (mc_config_t * mc_config, const gchar * group,
/* --------------------------------------------------------------------------------------------- */
int *
mc_config_get_int_list (mc_config_t * mc_config, const gchar * group,
const gchar * param, gsize * length)
mc_config_get_int_list (mc_config_t *mc_config, const gchar *group,
const gchar *param, gsize *length)
{
if (mc_config == NULL || group == NULL || param == NULL)
return NULL;

View File

@ -1,7 +1,7 @@
/*
Configure module for the Midnight Commander
Copyright (C) 1994-2024
Copyright (C) 1994-2025
Free Software Foundation, Inc.
Authors:
@ -125,7 +125,7 @@ mc_config_history_get_recent_item (const char *name)
* Load history from the mc_config
*/
GList *
mc_config_history_load (mc_config_t * cfg, const char *name)
mc_config_history_load (mc_config_t *cfg, const char *name)
{
size_t i;
GList *hist = NULL;
@ -188,7 +188,7 @@ mc_config_history_load (mc_config_t * cfg, const char *name)
* Save history to the mc_config, but don't save config to file
*/
void
mc_config_history_save (mc_config_t * cfg, const char *name, GList * h)
mc_config_history_save (mc_config_t *cfg, const char *name, GList *h)
{
GIConv conv = INVALID_CONV;
GString *buffer;

View File

@ -1,7 +1,7 @@
/*
paths to configuration files
Copyright (C) 2010-2024
Copyright (C) 2010-2025
Free Software Foundation, Inc.
Written by:
@ -56,8 +56,7 @@ static const struct
{
char **basedir;
const char *filename;
} mc_config_files_reference[] =
{
} mc_config_files_reference[] = {
/* *INDENT-OFF* */
/* config */
{ &mc_config_str, MC_CONFIG_FILE },
@ -76,6 +75,8 @@ static const struct
{ &mc_data_str, MC_SKINS_DIR },
{ &mc_data_str, VFS_SHELL_PREFIX },
{ &mc_data_str, MC_ASHRC_FILE },
{ &mc_data_str, MC_KSHRC_FILE },
{ &mc_data_str, MC_MKSHRC_FILE },
{ &mc_data_str, MC_BASHRC_FILE },
{ &mc_data_str, MC_INPUTRC_FILE },
{ &mc_data_str, MC_ZSHRC_FILE },
@ -101,7 +102,7 @@ static const struct
/* --------------------------------------------------------------------------------------------- */
static void
mc_config_mkdir (const char *directory_name, GError ** mcerror)
mc_config_mkdir (const char *directory_name, GError **mcerror)
{
mc_return_if_error (mcerror);
@ -113,7 +114,7 @@ mc_config_mkdir (const char *directory_name, GError ** mcerror)
/* --------------------------------------------------------------------------------------------- */
static char *
mc_config_init_one_config_path (const char *path_base, const char *subdir, GError ** mcerror)
mc_config_init_one_config_path (const char *path_base, const char *subdir, GError **mcerror)
{
char *full_path;
@ -144,7 +145,7 @@ mc_config_init_one_config_path (const char *path_base, const char *subdir, GErro
/* --------------------------------------------------------------------------------------------- */
void
mc_config_init_config_paths (GError ** mcerror)
mc_config_init_config_paths (GError **mcerror)
{
const char *profile_root;
char *dir;

View File

@ -1,7 +1,7 @@
/*
Configure module for the Midnight Commander
Copyright (C) 1994-2024
Copyright (C) 1994-2025
Free Software Foundation, Inc.
This file is part of the Midnight Commander.
@ -42,7 +42,7 @@
/* --------------------------------------------------------------------------------------------- */
static gchar *
mc_config_normalize_before_save (const gchar * value)
mc_config_normalize_before_save (const gchar *value)
{
GIConv conv;
GString *buffer;
@ -74,8 +74,8 @@ mc_config_normalize_before_save (const gchar * value)
/* --------------------------------------------------------------------------------------------- */
void
mc_config_set_string_raw (mc_config_t * mc_config, const gchar * group,
const gchar * param, const gchar * value)
mc_config_set_string_raw (mc_config_t *mc_config, const gchar *group,
const gchar *param, const gchar *value)
{
if (mc_config != NULL && group != NULL && param != NULL && value != NULL)
g_key_file_set_string (mc_config->handle, group, param, value);
@ -84,8 +84,8 @@ mc_config_set_string_raw (mc_config_t * mc_config, const gchar * group,
/* --------------------------------------------------------------------------------------------- */
void
mc_config_set_string_raw_value (mc_config_t * mc_config, const gchar * group,
const gchar * param, const gchar * value)
mc_config_set_string_raw_value (mc_config_t *mc_config, const gchar *group,
const gchar *param, const gchar *value)
{
if (mc_config != NULL && group != NULL && param != NULL && value != NULL)
g_key_file_set_value (mc_config->handle, group, param, value);
@ -94,8 +94,8 @@ mc_config_set_string_raw_value (mc_config_t * mc_config, const gchar * group,
/* --------------------------------------------------------------------------------------------- */
void
mc_config_set_string (mc_config_t * mc_config, const gchar * group,
const gchar * param, const gchar * value)
mc_config_set_string (mc_config_t *mc_config, const gchar *group,
const gchar *param, const gchar *value)
{
if (mc_config != NULL && group != NULL && param != NULL && value != NULL)
{
@ -110,8 +110,7 @@ mc_config_set_string (mc_config_t * mc_config, const gchar * group,
/* --------------------------------------------------------------------------------------------- */
void
mc_config_set_bool (mc_config_t * mc_config, const gchar * group,
const gchar * param, gboolean value)
mc_config_set_bool (mc_config_t *mc_config, const gchar *group, const gchar *param, gboolean value)
{
if (mc_config != NULL && group != NULL && param != NULL)
g_key_file_set_boolean (mc_config->handle, group, param, value);
@ -120,7 +119,7 @@ mc_config_set_bool (mc_config_t * mc_config, const gchar * group,
/* --------------------------------------------------------------------------------------------- */
void
mc_config_set_int (mc_config_t * mc_config, const gchar * group, const gchar * param, int value)
mc_config_set_int (mc_config_t *mc_config, const gchar *group, const gchar *param, int value)
{
if (mc_config != NULL && group != NULL && param != NULL)
g_key_file_set_integer (mc_config->handle, group, param, value);
@ -129,8 +128,8 @@ mc_config_set_int (mc_config_t * mc_config, const gchar * group, const gchar * p
/* --------------------------------------------------------------------------------------------- */
void
mc_config_set_string_list (mc_config_t * mc_config, const gchar * group,
const gchar * param, const gchar * const value[], gsize length)
mc_config_set_string_list (mc_config_t *mc_config, const gchar *group,
const gchar *param, const gchar *const value[], gsize length)
{
if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
g_key_file_set_string_list (mc_config->handle, group, param, value, length);
@ -139,8 +138,8 @@ mc_config_set_string_list (mc_config_t * mc_config, const gchar * group,
/* --------------------------------------------------------------------------------------------- */
void
mc_config_set_bool_list (mc_config_t * mc_config, const gchar * group,
const gchar * param, gboolean value[], gsize length)
mc_config_set_bool_list (mc_config_t *mc_config, const gchar *group,
const gchar *param, gboolean value[], gsize length)
{
if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
g_key_file_set_boolean_list (mc_config->handle, group, param, value, length);
@ -149,8 +148,8 @@ mc_config_set_bool_list (mc_config_t * mc_config, const gchar * group,
/* --------------------------------------------------------------------------------------------- */
void
mc_config_set_int_list (mc_config_t * mc_config, const gchar * group,
const gchar * param, int value[], gsize length)
mc_config_set_int_list (mc_config_t *mc_config, const gchar *group,
const gchar *param, int value[], gsize length)
{
if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
g_key_file_set_integer_list (mc_config->handle, group, param, value, length);

View File

@ -17,6 +17,23 @@
#endif /* SEARCH_TYPE_PCRE */
/*** typedefs(not structures) and defined constants **********************************************/
#if defined(WIN32)
enum mc_search_cbret_t
{
MC_SEARCH_CB_OK = 0,
MC_SEARCH_CB_INVALID = -1,
MC_SEARCH_CB_ABORT = -2,
MC_SEARCH_CB_SKIP = -3,
MC_SEARCH_CB_NOTFOUND = -4
};
#endif
typedef enum mc_search_cbret_t mc_search_cbret_t;
typedef mc_search_cbret_t (*mc_search_fn) (const void *user_data, off_t char_offset,
int *current_char);
typedef mc_search_cbret_t (*mc_update_fn) (const void *user_data, off_t char_offset);
#define MC_SEARCH__NUM_REPLACE_ARGS 64
#ifdef SEARCH_TYPE_GLIB
@ -54,6 +71,19 @@ typedef enum
MC_SEARCH_T_GLOB
} mc_search_type_t;
/**
* enum to store search conditions check results.
* (whether the search condition has BOL (^) or EOL ($) regexp characters).
*/
typedef enum
{
MC_SEARCH_LINE_NONE = 0,
MC_SEARCH_LINE_BEGIN = 1 << 0,
MC_SEARCH_LINE_END = 1 << 1,
MC_SEARCH_LINE_ENTIRE = MC_SEARCH_LINE_BEGIN | MC_SEARCH_LINE_END
} mc_search_line_t;
#if !defined(WIN32)
enum mc_search_cbret_t
{
MC_SEARCH_CB_OK = 0,
@ -62,13 +92,7 @@ enum mc_search_cbret_t
MC_SEARCH_CB_SKIP = -3,
MC_SEARCH_CB_NOTFOUND = -4
};
typedef enum mc_search_cbret_t mc_search_cbret_t;
//XXX/TODO - calling convention
typedef mc_search_cbret_t (*mc_search_fn) (const void *user_data, gsize char_offset,
int *current_char);
typedef mc_search_cbret_t (*mc_update_fn) (const void *user_data, gsize char_offset);
#endif
/*** structures declarations (and typedefs of structures)*****************************************/
@ -169,23 +193,25 @@ void mc_search_free (mc_search_t * lc_mc_search);
gboolean mc_search_prepare (mc_search_t * mc_search);
gboolean mc_search_run (mc_search_t * mc_search, const void *user_data, gsize start_search,
gsize end_search, gsize * found_len);
gboolean mc_search_run (mc_search_t * mc_search, const void *user_data, off_t start_search,
off_t end_search, gsize * found_len);
gboolean mc_search_is_type_avail (mc_search_type_t search_type);
const mc_search_type_str_t *mc_search_types_list_get (size_t * num);
const mc_search_type_str_t *mc_search_types_list_get (size_t *num);
GString *mc_search_prepare_replace_str (mc_search_t * mc_search, GString * replace_str);
char *mc_search_prepare_replace_str2 (mc_search_t * lc_mc_search, const char *replace_str);
gboolean mc_search_is_fixed_search_str (const mc_search_t * lc_mc_search);
gchar **mc_search_get_types_strings_array (size_t * num);
gchar **mc_search_get_types_strings_array (size_t *num);
gboolean mc_search (const gchar * pattern, const gchar * pattern_charset, const gchar * str,
mc_search_type_t type);
mc_search_line_t mc_search_get_line_type (const mc_search_t *search);
int mc_search_getstart_result_by_num (mc_search_t * lc_mc_search, int lc_index);
int mc_search_getend_result_by_num (mc_search_t * lc_mc_search, int lc_index);

View File

@ -2,7 +2,7 @@
Search text engine.
Glob-style pattern matching
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -29,7 +29,6 @@
#include "lib/global.h"
#include "lib/strutil.h"
#include "lib/search.h"
#include "lib/strescape.h"
#include "internal.h"
@ -48,9 +47,8 @@
/* --------------------------------------------------------------------------------------------- */
static GString *
mc_search__glob_translate_to_regex (const GString * astr)
mc_search__glob_translate_to_regex (const GString *astr)
{
const char *str = astr->str;
GString *buff;
gsize loop;
gboolean inside_group = FALSE;
@ -59,31 +57,36 @@ mc_search__glob_translate_to_regex (const GString * astr)
for (loop = 0; loop < astr->len; loop++)
{
const char *str = astr->str;
gboolean not_escaped;
not_escaped = !str_is_char_escaped (str, str + loop);
switch (str[loop])
{
case '*':
if (!strutils_is_char_escaped (str, &(str[loop])))
if (not_escaped)
{
g_string_append (buff, inside_group ? ".*" : "(.*)");
continue;
}
break;
case '?':
if (!strutils_is_char_escaped (str, &(str[loop])))
if (not_escaped)
{
g_string_append (buff, inside_group ? "." : "(.)");
continue;
}
break;
case ',':
if (!strutils_is_char_escaped (str, &(str[loop])))
if (not_escaped)
{
g_string_append_c (buff, inside_group ? '|' : ',');
continue;
}
break;
case '{':
if (!strutils_is_char_escaped (str, &(str[loop])))
if (not_escaped)
{
g_string_append_c (buff, '(');
inside_group = TRUE;
@ -91,7 +94,7 @@ mc_search__glob_translate_to_regex (const GString * astr)
}
break;
case '}':
if (!strutils_is_char_escaped (str, &(str[loop])))
if (not_escaped)
{
g_string_append_c (buff, ')');
inside_group = FALSE;
@ -163,8 +166,8 @@ mc_search__translate_replace_glob_to_regex (const char *str)
/*** public functions ****************************************************************************/
void
mc_search__cond_struct_new_init_glob (const char *charset, mc_search_t * lc_mc_search,
mc_search_cond_t * mc_search_cond)
mc_search__cond_struct_new_init_glob (const char *charset, mc_search_t *lc_mc_search,
mc_search_cond_t *mc_search_cond)
{
GString *tmp;
@ -184,8 +187,8 @@ mc_search__cond_struct_new_init_glob (const char *charset, mc_search_t * lc_mc_s
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_search__run_glob (mc_search_t * lc_mc_search, const void *user_data,
gsize start_search, gsize end_search, gsize * found_len)
mc_search__run_glob (mc_search_t *lc_mc_search, const void *user_data,
off_t start_search, off_t end_search, gsize *found_len)
{
return mc_search__run_regex (lc_mc_search, user_data, start_search, end_search, found_len);
}
@ -193,7 +196,7 @@ mc_search__run_glob (mc_search_t * lc_mc_search, const void *user_data,
/* --------------------------------------------------------------------------------------------- */
GString *
mc_search_glob_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str)
mc_search_glob_prepare_replace_str (mc_search_t *lc_mc_search, GString *replace_str)
{
GString *repl, *res;

View File

@ -2,7 +2,7 @@
Search text engine.
HEX-style pattern matching
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -31,7 +31,6 @@
#include "lib/global.h"
#include "lib/strutil.h"
#include "lib/search.h"
#include "lib/strescape.h"
#include "internal.h"
@ -58,7 +57,7 @@ typedef enum
/* --------------------------------------------------------------------------------------------- */
static GString *
mc_search__hex_translate_to_regex (const GString * astr, mc_search_hex_parse_error_t * error_ptr,
mc_search__hex_translate_to_regex (const GString *astr, mc_search_hex_parse_error_t *error_ptr,
int *error_pos_ptr)
{
GString *buff;
@ -136,8 +135,8 @@ mc_search__hex_translate_to_regex (const GString * astr, mc_search_hex_parse_err
/* --------------------------------------------------------------------------------------------- */
void
mc_search__cond_struct_new_init_hex (const char *charset, mc_search_t * lc_mc_search,
mc_search_cond_t * mc_search_cond)
mc_search__cond_struct_new_init_hex (const char *charset, mc_search_t *lc_mc_search,
mc_search_cond_t *mc_search_cond)
{
GString *tmp;
mc_search_hex_parse_error_t error = MC_SEARCH_HEX_E_OK;
@ -216,8 +215,8 @@ mc_search__cond_struct_new_init_hex (const char *charset, mc_search_t * lc_mc_se
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_search__run_hex (mc_search_t * lc_mc_search, const void *user_data,
gsize start_search, gsize end_search, gsize * found_len)
mc_search__run_hex (mc_search_t *lc_mc_search, const void *user_data,
off_t start_search, off_t end_search, gsize *found_len)
{
return mc_search__run_regex (lc_mc_search, user_data, start_search, end_search, found_len);
}
@ -225,7 +224,7 @@ mc_search__run_hex (mc_search_t * lc_mc_search, const void *user_data,
/* --------------------------------------------------------------------------------------------- */
GString *
mc_search_hex_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str)
mc_search_hex_prepare_replace_str (mc_search_t *lc_mc_search, GString *replace_str)
{
(void) lc_mc_search;

View File

@ -54,7 +54,7 @@ GString *mc_search__toupper_case_str (const char *charset, const GString * str);
void mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * lc_mc_search,
mc_search_cond_t * mc_search_cond);
gboolean mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data,
gsize start_search, gsize end_search, gsize * found_len);
off_t start_search, off_t end_search, gsize * found_len);
GString *mc_search_regex_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str);
/* search/normal.c : */
@ -62,7 +62,7 @@ GString *mc_search_regex_prepare_replace_str (mc_search_t * lc_mc_search, GStrin
void mc_search__cond_struct_new_init_normal (const char *charset, mc_search_t * lc_mc_search,
mc_search_cond_t * mc_search_cond);
gboolean mc_search__run_normal (mc_search_t * lc_mc_search, const void *user_data,
gsize start_search, gsize end_search, gsize * found_len);
off_t start_search, off_t end_search, gsize * found_len);
GString *mc_search_normal_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str);
/* search/glob.c : */
@ -70,7 +70,7 @@ GString *mc_search_normal_prepare_replace_str (mc_search_t * lc_mc_search, GStri
void mc_search__cond_struct_new_init_glob (const char *charset, mc_search_t * lc_mc_search,
mc_search_cond_t * mc_search_cond);
gboolean mc_search__run_glob (mc_search_t * lc_mc_search, const void *user_data,
gsize start_search, gsize end_search, gsize * found_len);
off_t start_search, off_t end_search, gsize * found_len);
GString *mc_search_glob_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str);
/* search/hex.c : */
@ -78,7 +78,7 @@ GString *mc_search_glob_prepare_replace_str (mc_search_t * lc_mc_search, GString
void mc_search__cond_struct_new_init_hex (const char *charset, mc_search_t * lc_mc_search,
mc_search_cond_t * mc_search_cond);
gboolean mc_search__run_hex (mc_search_t * lc_mc_search, const void *user_data,
gsize start_search, gsize end_search, gsize * found_len);
off_t start_search, off_t end_search, gsize * found_len);
GString *mc_search_hex_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str);
/*** inline functions ****************************************************************************/

View File

@ -2,7 +2,7 @@
Search text engine.
Common share code for module.
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -53,7 +53,7 @@ const char *STR_E_RPL_INVALID_TOKEN = N_("Invalid token number %d");
/*** file scope type declarations ****************************************************************/
typedef gboolean (*case_conv_fn) (const char *ch, char **out, size_t * remain);
typedef gboolean (*case_conv_fn) (const char *ch, char **out, size_t *remain);
/*** forward declarations (file scope functions) *************************************************/
@ -64,7 +64,7 @@ typedef gboolean (*case_conv_fn) (const char *ch, char **out, size_t * remain);
/* --------------------------------------------------------------------------------------------- */
static GString *
mc_search__change_case_str (const char *charset, const GString * str, case_conv_fn case_conv)
mc_search__change_case_str (const char *charset, const GString *str, case_conv_fn case_conv)
{
GString *ret;
const char *src_ptr;
@ -153,7 +153,7 @@ mc_search__recode_str (const char *str, gsize str_len, const char *charset_from,
GString *
mc_search__get_one_symbol (const char *charset, const char *str, gsize str_len,
gboolean * just_letters)
gboolean *just_letters)
{
GString *converted_str;
const gchar *next_char;
@ -191,7 +191,7 @@ mc_search__get_one_symbol (const char *charset, const char *str, gsize str_len,
/* --------------------------------------------------------------------------------------------- */
GString *
mc_search__tolower_case_str (const char *charset, const GString * str)
mc_search__tolower_case_str (const char *charset, const GString *str)
{
return mc_search__change_case_str (charset, str, str_tolower);
}
@ -199,7 +199,7 @@ mc_search__tolower_case_str (const char *charset, const GString * str)
/* --------------------------------------------------------------------------------------------- */
GString *
mc_search__toupper_case_str (const char *charset, const GString * str)
mc_search__toupper_case_str (const char *charset, const GString *str)
{
return mc_search__change_case_str (charset, str, str_toupper);
}
@ -207,7 +207,7 @@ mc_search__toupper_case_str (const char *charset, const GString * str)
/* --------------------------------------------------------------------------------------------- */
gchar **
mc_search_get_types_strings_array (size_t * num)
mc_search_get_types_strings_array (size_t *num)
{
gchar **ret;
int lc_index;

View File

@ -2,7 +2,7 @@
Search text engine.
Plain search
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -47,7 +47,7 @@
/* --------------------------------------------------------------------------------------------- */
static void
mc_search__normal_translate_to_regex (GString * str)
mc_search__normal_translate_to_regex (GString *str)
{
gsize loop;
@ -72,6 +72,7 @@ mc_search__normal_translate_to_regex (GString * str)
case '|':
g_string_insert_c (str, loop, '\\');
loop++;
break;
default:
break;
}
@ -82,8 +83,8 @@ mc_search__normal_translate_to_regex (GString * str)
/* --------------------------------------------------------------------------------------------- */
void
mc_search__cond_struct_new_init_normal (const char *charset, mc_search_t * lc_mc_search,
mc_search_cond_t * mc_search_cond)
mc_search__cond_struct_new_init_normal (const char *charset, mc_search_t *lc_mc_search,
mc_search_cond_t *mc_search_cond)
{
mc_search__normal_translate_to_regex (mc_search_cond->str);
mc_search__cond_struct_new_init_regex (charset, lc_mc_search, mc_search_cond);
@ -92,15 +93,15 @@ mc_search__cond_struct_new_init_normal (const char *charset, mc_search_t * lc_mc
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_search__run_normal (mc_search_t * lc_mc_search, const void *user_data,
gsize start_search, gsize end_search, gsize * found_len)
mc_search__run_normal (mc_search_t *lc_mc_search, const void *user_data,
off_t start_search, off_t end_search, gsize *found_len)
{
return mc_search__run_regex (lc_mc_search, user_data, start_search, end_search, found_len);
}
/* --------------------------------------------------------------------------------------------- */
GString *
mc_search_normal_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str)
mc_search_normal_prepare_replace_str (mc_search_t *lc_mc_search, GString *replace_str)
{
(void) lc_mc_search;

View File

@ -2,7 +2,7 @@
Search text engine.
Regex search
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -33,7 +33,6 @@
#include "lib/global.h"
#include "lib/strutil.h"
#include "lib/search.h"
#include "lib/strescape.h"
#include "lib/util.h" /* MC_PTR_FREE */
#include "internal.h"
@ -66,8 +65,7 @@ typedef enum
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_search__regex_str_append_if_special (GString * copy_to, const GString * regex_str,
gsize * offset)
mc_search__regex_str_append_if_special (GString *copy_to, const GString *regex_str, gsize *offset)
{
const char *special_chars[] = {
"\\s", "\\S",
@ -97,7 +95,7 @@ mc_search__regex_str_append_if_special (GString * copy_to, const GString * regex
spec_chr_len = strlen (*spec_chr);
if (strncmp (tmp_regex_str, *spec_chr, spec_chr_len) == 0
&& !strutils_is_char_escaped (regex_str->str, tmp_regex_str))
&& !str_is_char_escaped (regex_str->str, tmp_regex_str))
{
if (strncmp ("\\x", *spec_chr, spec_chr_len) == 0)
{
@ -124,8 +122,8 @@ mc_search__regex_str_append_if_special (GString * copy_to, const GString * regex
/* --------------------------------------------------------------------------------------------- */
static void
mc_search__cond_struct_new_regex_hex_add (const char *charset, GString * str_to,
const GString * one_char)
mc_search__cond_struct_new_regex_hex_add (const char *charset, GString *str_to,
const GString *one_char)
{
GString *upp, *low;
gsize loop;
@ -156,8 +154,8 @@ mc_search__cond_struct_new_regex_hex_add (const char *charset, GString * str_to,
/* --------------------------------------------------------------------------------------------- */
static void
mc_search__cond_struct_new_regex_accum_append (const char *charset, GString * str_to,
GString * str_from)
mc_search__cond_struct_new_regex_accum_append (const char *charset, GString *str_to,
GString *str_from)
{
GString *recoded_part;
gsize loop = 0;
@ -209,7 +207,7 @@ mc_search__cond_struct_new_regex_accum_append (const char *charset, GString * st
* this job itself.
*/
static GString *
mc_search__cond_struct_new_regex_ci_str (const char *charset, const GString * astr)
mc_search__cond_struct_new_regex_ci_str (const char *charset, const GString *astr)
{
GString *accumulator, *spec_char, *ret_str;
gsize loop;
@ -229,13 +227,12 @@ mc_search__cond_struct_new_regex_ci_str (const char *charset, const GString * as
continue;
}
if (astr->str[loop] == '[' && !strutils_is_char_escaped (astr->str, &(astr->str[loop])))
if (astr->str[loop] == '[' && !str_is_char_escaped (astr->str, &(astr->str[loop])))
{
mc_search__cond_struct_new_regex_accum_append (charset, ret_str, accumulator);
while (loop < astr->len && !(astr->str[loop] == ']'
&& !strutils_is_char_escaped (astr->str,
&(astr->str[loop]))))
&& !str_is_char_escaped (astr->str, &(astr->str[loop]))))
{
g_string_append_c (ret_str, astr->str[loop]);
loop++;
@ -267,12 +264,12 @@ mc_search__cond_struct_new_regex_ci_str (const char *charset, const GString * as
* requirement by glib and it might crash otherwise. See: mc ticket 3449.
* Be careful: there might be embedded NULs in the strings. */
static gboolean
mc_search__g_regex_match_full_safe (const GRegex * regex,
const gchar * string,
mc_search__g_regex_match_full_safe (const GRegex *regex,
const gchar *string,
gssize string_len,
gint start_position,
GRegexMatchFlags match_options,
GMatchInfo ** match_info, GError ** error)
GMatchInfo **match_info, GError **error)
{
char *string_safe, *p, *end;
gboolean ret;
@ -320,8 +317,8 @@ mc_search__g_regex_match_full_safe (const GRegex * regex,
/* --------------------------------------------------------------------------------------------- */
static mc_search__found_cond_t
mc_search__regex_found_cond_one (mc_search_t * lc_mc_search, mc_search_regex_t * regex,
GString * search_str)
mc_search__regex_found_cond_one (mc_search_t *lc_mc_search, mc_search_regex_t *regex,
GString *search_str)
{
#ifdef SEARCH_TYPE_GLIB
GError *mcerror = NULL;
@ -366,7 +363,7 @@ mc_search__regex_found_cond_one (mc_search_t * lc_mc_search, mc_search_regex_t *
/* --------------------------------------------------------------------------------------------- */
static mc_search__found_cond_t
mc_search__regex_found_cond (mc_search_t * lc_mc_search, GString * search_str)
mc_search__regex_found_cond (mc_search_t *lc_mc_search, GString *search_str)
{
gsize loop1;
@ -393,7 +390,7 @@ mc_search__regex_found_cond (mc_search_t * lc_mc_search, GString * search_str)
/* --------------------------------------------------------------------------------------------- */
static int
mc_search_regex__get_max_num_of_replace_tokens (const gchar * str, gsize len)
mc_search_regex__get_max_num_of_replace_tokens (const gchar *str, gsize len)
{
int max_token = 0;
gsize loop;
@ -401,7 +398,7 @@ mc_search_regex__get_max_num_of_replace_tokens (const gchar * str, gsize len)
for (loop = 0; loop < len - 1; loop++)
if (str[loop] == '\\' && g_ascii_isdigit (str[loop + 1]))
{
if (strutils_is_char_escaped (str, &str[loop]))
if (str_is_char_escaped (str, &str[loop]))
continue;
if (max_token < str[loop + 1] - '0')
max_token = str[loop + 1] - '0';
@ -410,7 +407,7 @@ mc_search_regex__get_max_num_of_replace_tokens (const gchar * str, gsize len)
{
gsize tmp_len;
if (strutils_is_char_escaped (str, &str[loop]))
if (str_is_char_escaped (str, &str[loop]))
continue;
for (tmp_len = 0;
@ -436,7 +433,7 @@ mc_search_regex__get_max_num_of_replace_tokens (const gchar * str, gsize len)
/* --------------------------------------------------------------------------------------------- */
static char *
mc_search_regex__get_token_by_num (const mc_search_t * lc_mc_search, gsize lc_index)
mc_search_regex__get_token_by_num (const mc_search_t *lc_mc_search, gsize lc_index)
{
int fnd_start = 0, fnd_end = 0;
@ -457,8 +454,8 @@ mc_search_regex__get_token_by_num (const mc_search_t * lc_mc_search, gsize lc_in
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_search_regex__replace_handle_esc_seq (const GString * replace_str, const gsize current_pos,
gsize * skip_len, int *ret)
mc_search_regex__replace_handle_esc_seq (const GString *replace_str, const gsize current_pos,
gsize *skip_len, int *ret)
{
char *curr_str = &(replace_str->str[current_pos]);
char c = curr_str[1];
@ -539,8 +536,8 @@ mc_search_regex__replace_handle_esc_seq (const GString * replace_str, const gsiz
/* --------------------------------------------------------------------------------------------- */
static int
mc_search_regex__process_replace_str (const GString * replace_str, const gsize current_pos,
gsize * skip_len, replace_transform_type_t * replace_flags)
mc_search_regex__process_replace_str (const GString *replace_str, const gsize current_pos,
gsize *skip_len, replace_transform_type_t *replace_flags)
{
int ret = -1;
const char *curr_str = &(replace_str->str[current_pos]);
@ -555,7 +552,7 @@ mc_search_regex__process_replace_str (const GString * replace_str, const gsize c
{
char *tmp_str;
if (strutils_is_char_escaped (replace_str->str, curr_str))
if (str_is_char_escaped (replace_str->str, curr_str))
{
*skip_len = 1;
return REPLACE_PREPARE_T_NOTHING_SPECIAL;
@ -582,7 +579,7 @@ mc_search_regex__process_replace_str (const GString * replace_str, const gsize c
if (curr_str[0] == '\\' && replace_str->len > current_pos + 1)
{
if (strutils_is_char_escaped (replace_str->str, curr_str))
if (str_is_char_escaped (replace_str->str, curr_str))
{
*skip_len = 1;
return REPLACE_PREPARE_T_NOTHING_SPECIAL;
@ -631,8 +628,8 @@ mc_search_regex__process_replace_str (const GString * replace_str, const gsize c
/* --------------------------------------------------------------------------------------------- */
static void
mc_search_regex__process_append_str (GString * dest_str, const char *from, gsize len,
replace_transform_type_t * replace_flags)
mc_search_regex__process_append_str (GString *dest_str, const char *from, gsize len,
replace_transform_type_t *replace_flags)
{
gsize loop;
gsize char_len;
@ -686,9 +683,8 @@ mc_search_regex__process_append_str (GString * dest_str, const char *from, gsize
/* --------------------------------------------------------------------------------------------- */
static void
mc_search_regex__process_escape_sequence (GString * dest_str, const char *from, gsize len,
replace_transform_type_t * replace_flags,
gboolean is_utf8)
mc_search_regex__process_escape_sequence (GString *dest_str, const char *from, gsize len,
replace_transform_type_t *replace_flags, gboolean is_utf8)
{
gsize i = 0;
unsigned int c = 0;
@ -791,8 +787,8 @@ mc_search_regex__process_escape_sequence (GString * dest_str, const char *from,
/* --------------------------------------------------------------------------------------------- */
void
mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * lc_mc_search,
mc_search_cond_t * mc_search_cond)
mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t *lc_mc_search,
mc_search_cond_t *mc_search_cond)
{
if (lc_mc_search->whole_words && !lc_mc_search->is_entire_line)
{
@ -843,7 +839,7 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * lc_mc_
#ifdef HAVE_PCRE2
int errcode;
PCRE2_UCHAR /*char*/ error[BUF_SMALL] = {0};
char error[BUF_SMALL] = "";
size_t erroffset;
int pcre_options = PCRE2_MULTILINE;
#else
@ -883,7 +879,7 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * lc_mc_
if (mc_search_cond->regex_handle == NULL)
{
#ifdef HAVE_PCRE2
pcre2_get_error_message (errcode, error, sizeof(error));
pcre2_get_error_message (errcode, (unsigned char *) error, sizeof (error));
#endif
mc_search_set_error (lc_mc_search, MC_SEARCH_E_REGEX_COMPILE, "%s", error);
return;
@ -908,11 +904,11 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * lc_mc_
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data,
gsize start_search, gsize end_search, gsize * found_len)
mc_search__run_regex (mc_search_t *lc_mc_search, const void *user_data,
off_t start_search, off_t end_search, gsize *found_len)
{
mc_search_cbret_t ret = MC_SEARCH_CB_NOTFOUND;
gsize current_pos, virtual_pos;
off_t current_pos, virtual_pos;
gint start_pos;
gint end_pos;
@ -1020,7 +1016,7 @@ mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data,
/* --------------------------------------------------------------------------------------------- */
GString *
mc_search_regex_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str)
mc_search_regex_prepare_replace_str (mc_search_t *lc_mc_search, GString *replace_str)
{
GString *ret;
@ -1118,3 +1114,30 @@ mc_search_regex_prepare_replace_str (mc_search_t * lc_mc_search, GString * repla
return ret;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Checks whether search condition has BOL (^) or EOL ($) regexp special characters.
*
* @param search search object
* @return check result
*/
mc_search_line_t
mc_search_get_line_type (const mc_search_t *search)
{
mc_search_line_t search_line_type = MC_SEARCH_LINE_NONE;
if (search->search_type == MC_SEARCH_T_REGEX)
{
if (search->original.str->str[0] == '^')
search_line_type |= MC_SEARCH_LINE_BEGIN;
if (search->original.str->str[search->original.str->len - 1] == '$')
search_line_type |= MC_SEARCH_LINE_END;
}
return search_line_type;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -2,7 +2,7 @@
Search text engine.
Interface functions
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -64,7 +64,7 @@ static const mc_search_type_str_t mc_search__list_types[] = {
/* --------------------------------------------------------------------------------------------- */
static mc_search_cond_t *
mc_search__cond_struct_new (mc_search_t * lc_mc_search, const GString * str, const char *charset)
mc_search__cond_struct_new (mc_search_t *lc_mc_search, const GString *str, const char *charset)
{
mc_search_cond_t *mc_search_cond;
@ -133,7 +133,7 @@ mc_search__cond_struct_free (gpointer data)
*/
mc_search_t *
mc_search_new (const gchar * original, const gchar * original_charset)
mc_search_new (const gchar *original, const gchar *original_charset)
{
if (original == NULL)
return NULL;
@ -152,7 +152,7 @@ mc_search_new (const gchar * original, const gchar * original_charset)
*/
mc_search_t *
mc_search_new_len (const gchar * original, gsize original_len, const gchar * original_charset)
mc_search_new_len (const gchar *original, gsize original_len, const gchar *original_charset)
{
mc_search_t *lc_mc_search;
@ -175,7 +175,7 @@ mc_search_new_len (const gchar * original, gsize original_len, const gchar * ori
/* --------------------------------------------------------------------------------------------- */
void
mc_search_free (mc_search_t * lc_mc_search)
mc_search_free (mc_search_t *lc_mc_search)
{
if (lc_mc_search == NULL)
return;
@ -205,7 +205,7 @@ mc_search_free (mc_search_t * lc_mc_search)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_search_prepare (mc_search_t * lc_mc_search)
mc_search_prepare (mc_search_t *lc_mc_search)
{
GPtrArray *ret;
@ -272,8 +272,8 @@ mc_search_prepare (mc_search_t * lc_mc_search)
* is in lc_mc_search->error_str.
*/
gboolean
mc_search_run (mc_search_t * lc_mc_search, const void *user_data,
gsize start_search, gsize end_search, gsize * found_len)
mc_search_run (mc_search_t *lc_mc_search, const void *user_data,
off_t start_search, off_t end_search, gsize *found_len)
{
gboolean ret = FALSE;
@ -338,7 +338,7 @@ mc_search_is_type_avail (mc_search_type_t search_type)
/* --------------------------------------------------------------------------------------------- */
const mc_search_type_str_t *
mc_search_types_list_get (size_t * num)
mc_search_types_list_get (size_t *num)
{
/* don't count last NULL item */
if (num != NULL)
@ -350,7 +350,7 @@ mc_search_types_list_get (size_t * num)
/* --------------------------------------------------------------------------------------------- */
GString *
mc_search_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str)
mc_search_prepare_replace_str (mc_search_t *lc_mc_search, GString *replace_str)
{
GString *ret;
@ -384,7 +384,7 @@ mc_search_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str
/* --------------------------------------------------------------------------------------------- */
char *
mc_search_prepare_replace_str2 (mc_search_t * lc_mc_search, const char *replace_str)
mc_search_prepare_replace_str2 (mc_search_t *lc_mc_search, const char *replace_str)
{
GString *ret;
GString *replace_str2;
@ -398,7 +398,7 @@ mc_search_prepare_replace_str2 (mc_search_t * lc_mc_search, const char *replace_
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_search_is_fixed_search_str (const mc_search_t * lc_mc_search)
mc_search_is_fixed_search_str (const mc_search_t *lc_mc_search)
{
if (lc_mc_search == NULL)
return FALSE;
@ -424,7 +424,7 @@ mc_search_is_fixed_search_str (const mc_search_t * lc_mc_search)
*/
gboolean
mc_search (const gchar * pattern, const gchar * pattern_charset, const gchar * str,
mc_search (const gchar *pattern, const gchar *pattern_charset, const gchar *str,
mc_search_type_t type)
{
gboolean ret;
@ -451,7 +451,7 @@ mc_search (const gchar * pattern, const gchar * pattern_charset, const gchar * s
/* --------------------------------------------------------------------------------------------- */
int
mc_search_getstart_result_by_num (mc_search_t * lc_mc_search, int lc_index)
mc_search_getstart_result_by_num (mc_search_t *lc_mc_search, int lc_index)
{
if (lc_mc_search == NULL)
return 0;
@ -473,7 +473,7 @@ mc_search_getstart_result_by_num (mc_search_t * lc_mc_search, int lc_index)
/* --------------------------------------------------------------------------------------------- */
int
mc_search_getend_result_by_num (mc_search_t * lc_mc_search, int lc_index)
mc_search_getend_result_by_num (mc_search_t *lc_mc_search, int lc_index)
{
if (lc_mc_search == NULL)
return 0;
@ -502,7 +502,7 @@ mc_search_getend_result_by_num (mc_search_t * lc_mc_search, int lc_index)
*/
void
mc_search_set_error (mc_search_t * lc_mc_search, mc_search_error_t code, const gchar * format, ...)
mc_search_set_error (mc_search_t *lc_mc_search, mc_search_error_t code, const gchar *format, ...)
{
lc_mc_search->error = code;

View File

@ -1,7 +1,7 @@
/*
Provides a serialize/unserialize functionality for INI-like formats.
Copyright (C) 2011-2024
Copyright (C) 2011-2025
Free Software Foundation, Inc.
Written by:
@ -56,7 +56,7 @@
static void
G_GNUC_PRINTF (2, 3)
prepend_error_message (GError ** error, const char *format, ...)
prepend_error_message (GError **error, const char *format, ...)
{
char *prepend_str;
char *split_str;
@ -79,7 +79,7 @@ prepend_error_message (GError ** error, const char *format, ...)
static const char *
go_to_end_of_serialized_string (const char *non_serialized_data,
const char *already_serialized_part, size_t * offset)
const char *already_serialized_part, size_t *offset)
{
size_t calculated_offset;
const char *semi_ptr = strchr (non_serialized_data + 1, SRLZ_DELIM_C);
@ -109,7 +109,7 @@ go_to_end_of_serialized_string (const char *non_serialized_data,
*/
char *
mc_serialize_str (const char prefix, const char *data, GError ** error)
mc_serialize_str (const char prefix, const char *data, GError **error)
{
if (data == NULL)
{
@ -132,7 +132,7 @@ mc_serialize_str (const char prefix, const char *data, GError ** error)
#define FUNC_NAME "mc_serialize_str()"
char *
mc_deserialize_str (const char prefix, const char *data, GError ** error)
mc_deserialize_str (const char prefix, const char *data, GError **error)
{
size_t data_len;
@ -196,7 +196,7 @@ mc_deserialize_str (const char prefix, const char *data, GError ** error)
*/
char *
mc_serialize_config (mc_config_t * data, GError ** error)
mc_serialize_config (mc_config_t *data, GError **error)
{
gchar **groups, **group_iterator;
GString *buffer;
@ -278,7 +278,7 @@ mc_serialize_config (mc_config_t * data, GError ** error)
}
mc_config_t *
mc_deserialize_config (const char *data, GError ** error)
mc_deserialize_config (const char *data, GError **error)
{
char *current_group = NULL, *current_param = NULL, *current_value = NULL;
size_t current_position = 0;

View File

@ -1,7 +1,7 @@
/*
Provides a functions for working with shell.
Copyright (C) 2006-2024
Copyright (C) 2006-2025
Free Software Foundation, Inc.
Written by:
@ -68,18 +68,26 @@ mc_shell_get_installed_in_system (void)
/* 3rd choice: look for existing shells supported as MC subshells. */
if (access ("/bin/bash", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/bash");
else if (access ("/bin/zsh", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/zsh");
else if (access ("/bin/oksh", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/oksh");
else if (access ("/bin/ksh", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/ksh");
else if (access ("/bin/ksh93", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/ksh93");
else if (access ("/bin/ash", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/ash");
else if (access ("/bin/dash", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/dash");
else if (access ("/bin/busybox", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/busybox");
else if (access ("/bin/zsh", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/zsh");
else if (access ("/bin/tcsh", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/tcsh");
else if (access ("/bin/csh", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/csh");
else if (access ("/bin/mksh", X_OK) == 0)
mc_shell->path = g_strdup ("/bin/mksh");
/* No fish as fallback because it is so much different from other shells and
* in a way exotic (even though user-friendly by name) that we should not
* present it as a subshell without the user's explicit intention. We rather
@ -142,7 +150,7 @@ mc_shell_get_from_env (void)
/* --------------------------------------------------------------------------------------------- */
static void
mc_shell_recognize_real_path (mc_shell_t * mc_shell)
mc_shell_recognize_real_path (mc_shell_t *mc_shell)
{
if (strstr (mc_shell->path, "/zsh") != NULL || strstr (mc_shell->real_path, "/zsh") != NULL
|| getenv ("ZSH_VERSION") != NULL)
@ -189,6 +197,22 @@ mc_shell_recognize_real_path (mc_shell_t * mc_shell)
mc_shell->type = SHELL_ASH_BUSYBOX;
mc_shell->name = mc_shell->path;
}
else if (strstr (mc_shell->path, "/ksh") != NULL
|| strstr (mc_shell->real_path, "/ksh") != NULL
|| strstr (mc_shell->path, "/ksh93") != NULL
|| strstr (mc_shell->real_path, "/ksh93") != NULL
|| strstr (mc_shell->path, "/oksh") != NULL
|| strstr (mc_shell->real_path, "/oksh") != NULL)
{
mc_shell->type = SHELL_KSH;
mc_shell->name = "ksh";
}
else if (strstr (mc_shell->path, "/mksh") != NULL
|| strstr (mc_shell->real_path, "/mksh") != NULL)
{
mc_shell->type = SHELL_MKSH;
mc_shell->name = "mksh";
}
#if defined(WIN32) //WIN32, TODO/XXX
#endif
else
@ -198,24 +222,40 @@ mc_shell_recognize_real_path (mc_shell_t * mc_shell)
/* --------------------------------------------------------------------------------------------- */
static void
mc_shell_recognize_path (mc_shell_t * mc_shell)
mc_shell_recognize_path (mc_shell_t *mc_shell)
{
/* If shell is not symlinked to busybox, it is safe to assume it is a real shell */
if (strstr (mc_shell->path, "/bash") != NULL || getenv ("BASH") != NULL)
if (strstr (mc_shell->path, "/bash") != NULL || getenv ("BASH_VERSION") != NULL)
{
mc_shell->type = SHELL_BASH;
mc_shell->name = "bash";
}
else if (strstr (mc_shell->path, "/sh") != NULL || getenv ("SH") != NULL)
else if (strstr (mc_shell->path, "/sh") != NULL)
{
mc_shell->type = SHELL_SH;
mc_shell->name = "sh";
}
else if (strstr (mc_shell->path, "/ash") != NULL || getenv ("ASH") != NULL)
else if (strstr (mc_shell->path, "/ash") != NULL || getenv ("BB_ASH_VERSION") != NULL)
{
mc_shell->type = SHELL_ASH_BUSYBOX;
mc_shell->name = "ash";
}
else if (strstr (mc_shell->path, "/ksh") != NULL
|| strstr (mc_shell->path, "/ksh93") != NULL
|| strstr (mc_shell->path, "/oksh") != NULL
|| (getenv ("KSH_VERSION") != NULL
&& strstr (getenv ("KSH_VERSION"), "PD KSH") != NULL))
{
mc_shell->type = SHELL_KSH;
mc_shell->name = "ksh";
}
else if (strstr (mc_shell->path, "/mksh") != NULL
|| (getenv ("KSH_VERSION") != NULL
&& strstr (getenv ("KSH_VERSION"), "MIRBSD KSH") != NULL))
{
mc_shell->type = SHELL_MKSH;
mc_shell->name = "mksh";
}
#if defined(WIN32) //WIN32, TODO/XXX
#endif
else

View File

@ -18,7 +18,9 @@ typedef enum
SHELL_DASH, /* Debian variant of ash */
SHELL_TCSH,
SHELL_ZSH,
SHELL_FISH
SHELL_FISH,
SHELL_KSH, /* Public Domain Korn shell (pdksh) and variants */
SHELL_MKSH /* MirBSD Korn shell (mksh) */
} shell_type_t;
/*** structures declarations (and typedefs of structures)*****************************************/

View File

@ -2,7 +2,7 @@
Skins engine.
Work with colors - backward compatibility
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -147,7 +147,7 @@ mc_skin_colors_old_transform (const char *old_color, const char **group, const c
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_colors_old_configure_one (mc_skin_t * mc_skin, const char *the_color_string)
mc_skin_colors_old_configure_one (mc_skin_t *mc_skin, const char *the_color_string)
{
gchar **colors, **orig_colors;
@ -193,7 +193,7 @@ mc_skin_colors_old_configure_one (mc_skin_t * mc_skin, const char *the_color_str
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_colors_old_configure (mc_skin_t * mc_skin)
mc_skin_colors_old_configure (mc_skin_t *mc_skin)
{
mc_skin_colors_old_configure_one (mc_skin, mc_global.tty.setup_color_string);
mc_skin_colors_old_configure_one (mc_skin, mc_global.tty.term_color_string);

View File

@ -2,7 +2,7 @@
Skins engine.
Work with colors
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -50,7 +50,7 @@ int mc_skin_color__cache[MC_SKIN_COLOR_CACHE_COUNT];
/* --------------------------------------------------------------------------------------------- */
static tty_color_pair_t *
mc_skin_color_get_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
mc_skin_color_get_from_hash (mc_skin_t *mc_skin, const gchar *group, const gchar *key)
{
gchar kname[BUF_TINY];
tty_color_pair_t *mc_skin_color;
@ -71,7 +71,7 @@ mc_skin_color_get_from_hash (mc_skin_t * mc_skin, const gchar * group, const gch
#if 0
static void
mc_skin_color_remove_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
mc_skin_color_remove_from_hash (mc_skin_t *mc_skin, const gchar *group, const gchar *key)
{
gchar kname[BUF_TINY];
if (group == NULL || key == NULL)
@ -88,8 +88,8 @@ mc_skin_color_remove_from_hash (mc_skin_t * mc_skin, const gchar * group, const
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_add_to_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key,
tty_color_pair_t * mc_skin_color)
mc_skin_color_add_to_hash (mc_skin_t *mc_skin, const gchar *group, const gchar *key,
tty_color_pair_t *mc_skin_color)
{
gchar *kname;
@ -106,7 +106,7 @@ mc_skin_color_add_to_hash (mc_skin_t * mc_skin, const gchar * group, const gchar
/* --------------------------------------------------------------------------------------------- */
static tty_color_pair_t *
mc_skin_color_get_with_defaults (const gchar * group, const gchar * name)
mc_skin_color_get_with_defaults (const gchar *group, const gchar *name)
{
tty_color_pair_t *mc_skin_color;
@ -127,7 +127,7 @@ mc_skin_color_get_with_defaults (const gchar * group, const gchar * name)
/* If an alias is found, alloc a new string for the resolved value and free the input parameter.
Otherwise it's a no-op returning the original string. */
static gchar *
mc_skin_color_look_up_alias (mc_skin_t * mc_skin, gchar * str)
mc_skin_color_look_up_alias (mc_skin_t *mc_skin, gchar *str)
{
gchar *orig, *str2;
int hop = 0;
@ -180,7 +180,7 @@ mc_skin_color_look_up_alias (mc_skin_t * mc_skin, gchar * str)
/* --------------------------------------------------------------------------------------------- */
static tty_color_pair_t *
mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
mc_skin_color_get_from_ini_file (mc_skin_t *mc_skin, const gchar *group, const gchar *key)
{
gsize items_count;
gchar **values;
@ -221,7 +221,7 @@ mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_set_default_for_terminal (mc_skin_t * mc_skin)
mc_skin_color_set_default_for_terminal (mc_skin_t *mc_skin)
{
tty_color_pair_t *mc_skin_color;
@ -324,7 +324,7 @@ mc_skin_color_cache_init (void)
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_skin_color_check_inisection (const gchar * group)
mc_skin_color_check_inisection (const gchar *group)
{
return !((strcasecmp ("skin", group) == 0) || (strcasecmp ("aliases", group) == 0)
|| (strcasecmp ("lines", group) == 0) || (strncasecmp ("widget-", group, 7) == 0));
@ -333,7 +333,7 @@ mc_skin_color_check_inisection (const gchar * group)
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_check_bw_mode (mc_skin_t * mc_skin)
mc_skin_color_check_bw_mode (mc_skin_t *mc_skin)
{
gchar **groups, **orig_groups;
@ -356,7 +356,7 @@ mc_skin_color_check_bw_mode (mc_skin_t * mc_skin)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_skin_color_parse_ini_file (mc_skin_t * mc_skin)
mc_skin_color_parse_ini_file (mc_skin_t *mc_skin)
{
gboolean ret = FALSE;
gsize items_count;
@ -408,7 +408,7 @@ mc_skin_color_parse_ini_file (mc_skin_t * mc_skin)
/* --------------------------------------------------------------------------------------------- */
int
mc_skin_color_get (const gchar * group, const gchar * name)
mc_skin_color_get (const gchar *group, const gchar *name)
{
tty_color_pair_t *mc_skin_color;

View File

@ -2,7 +2,7 @@
Skins engine.
Interface functions
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -113,7 +113,7 @@ mc_skin_try_to_load_default (void)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_skin_init (const gchar * skin_override, GError ** mcerror)
mc_skin_init (const gchar *skin_override, GError **mcerror)
{
gboolean is_good_init = TRUE;
GError *error = NULL;
@ -198,7 +198,7 @@ mc_skin_deinit (void)
/* --------------------------------------------------------------------------------------------- */
gchar *
mc_skin_get (const gchar * group, const gchar * key, const gchar * default_value)
mc_skin_get (const gchar *group, const gchar *key, const gchar *default_value)
{
if (mc_global.tty.ugly_line_drawing)
return g_strdup (default_value);

View File

@ -2,7 +2,7 @@
Skins engine.
Set of hardcoded skins
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -47,7 +47,7 @@
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_hardcoded_blackwhite_colors (mc_skin_t * mc_skin)
mc_skin_hardcoded_blackwhite_colors (mc_skin_t *mc_skin)
{
mc_config_set_string (mc_skin->config, "core", "_default_", "default;default");
mc_config_set_string (mc_skin->config, "core", "selected", "A_REVERSE");
@ -85,7 +85,7 @@ mc_skin_hardcoded_blackwhite_colors (mc_skin_t * mc_skin)
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_hardcoded_space_lines (mc_skin_t * mc_skin)
mc_skin_hardcoded_space_lines (mc_skin_t *mc_skin)
{
/* single lines */
set_lines ("vert", " ");
@ -115,7 +115,7 @@ mc_skin_hardcoded_space_lines (mc_skin_t * mc_skin)
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_hardcoded_ugly_lines (mc_skin_t * mc_skin)
mc_skin_hardcoded_ugly_lines (mc_skin_t *mc_skin)
{
/* single lines */
set_lines ("vert", "|");

View File

@ -2,7 +2,7 @@
Skins engine.
Reading and parse ini-files
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -49,7 +49,7 @@
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_get_list_from_dir (const gchar * base_dir, GPtrArray * list)
mc_skin_get_list_from_dir (const gchar *base_dir, GPtrArray *list)
{
gchar *name;
GDir *dir;
@ -99,7 +99,7 @@ string_array_comparator (gconstpointer a, gconstpointer b)
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_skin_ini_file_load_search_in_dir (mc_skin_t * mc_skin, const gchar * base_dir)
mc_skin_ini_file_load_search_in_dir (mc_skin_t *mc_skin, const gchar *base_dir)
{
char *file_name, *file_name2;
@ -147,7 +147,7 @@ mc_skin_list (void)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_skin_ini_file_load (mc_skin_t * mc_skin)
mc_skin_ini_file_load (mc_skin_t *mc_skin)
{
char *file_name;
@ -180,7 +180,7 @@ mc_skin_ini_file_load (mc_skin_t * mc_skin)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_skin_ini_file_parse (mc_skin_t * mc_skin)
mc_skin_ini_file_parse (mc_skin_t *mc_skin)
{
mc_skin->description =
mc_config_get_string (mc_skin->config, "skin", "description", "- no description -");
@ -197,7 +197,7 @@ mc_skin_ini_file_parse (mc_skin_t * mc_skin)
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_set_hardcoded_skin (mc_skin_t * mc_skin)
mc_skin_set_hardcoded_skin (mc_skin_t *mc_skin)
{
mc_skin->config = mc_config_init (NULL, TRUE);

View File

@ -2,7 +2,7 @@
Skins engine.
Work with line draving chars.
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -45,7 +45,7 @@
/* --------------------------------------------------------------------------------------------- */
static int
mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name)
mc_skin_lines_load_frm (mc_skin_t *mc_skin, const char *name)
{
int ret;
char *frm_val;
@ -62,7 +62,7 @@ mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name)
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_lines_parse_ini_file (mc_skin_t * mc_skin)
mc_skin_lines_parse_ini_file (mc_skin_t *mc_skin)
{
if (mc_global.tty.slow_terminal)
mc_skin_hardcoded_space_lines (mc_skin);

35
mcsrc/lib/stdckdint.h Normal file
View File

@ -0,0 +1,35 @@
/* stdckdint.h -- checked integer arithmetic
Copyright 2022-2024 Free Software Foundation, Inc.
This program 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 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_STDCKDINT_H
#define _GL_STDCKDINT_H
#include "intprops-internal.h"
/* Store into *R the low-order bits of A + B, A - B, A * B, respectively.
Return 1 if the result overflows, 0 otherwise.
A, B, and *R can have any integer type other than char, bool, a
bit-precise integer type, or an enumeration type.
These are like the standard macros introduced in C23, except that
arguments should not have side effects. */
#define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r))
#define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r))
#define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r))
#endif /* _GL_STDCKDINT_H */

35
mcsrc/lib/stdckdint.in.h Normal file
View File

@ -0,0 +1,35 @@
/* stdckdint.h -- checked integer arithmetic
Copyright 2022-2024 Free Software Foundation, Inc.
This program 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 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_STDCKDINT_H
#define _GL_STDCKDINT_H
#include "intprops-internal.h"
/* Store into *R the low-order bits of A + B, A - B, A * B, respectively.
Return 1 if the result overflows, 0 otherwise.
A, B, and *R can have any integer type other than char, bool, a
bit-precise integer type, or an enumeration type.
These are like the standard macros introduced in C23, except that
arguments should not have side effects. */
#define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r))
#define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r))
#define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r))
#endif /* _GL_STDCKDINT_H */

View File

@ -1,34 +0,0 @@
#ifndef MC__STRUTILS_ESCAPE_H
#define MC__STRUTILS_ESCAPE_H
#include <config.h>
#include "lib/global.h" /* <glib.h> */
/*** typedefs(not structures) and defined constants **********************************************/
/*** enums ***************************************************************************************/
/*** structures declarations (and typedefs of structures)*****************************************/
/*** global variables defined in .c file *********************************************************/
/*** declarations of public functions ************************************************************/
char *strutils_escape (const char *src, gsize src_len, const char *escaped_chars,
gboolean escape_non_printable);
char *strutils_unescape (const char *src, gsize src_len, const char *unescaped_chars,
gboolean unescape_non_printable);
char *strutils_shell_unescape (const char *text);
char *strutils_shell_unescape_special (const char *text); //WIN32
char *strutils_shell_escape (const char *text);
char *strutils_glob_escape (const char *text);
char *strutils_glob_unescape (const char *text);
char *strutils_regex_escape (const char *text);
char *strutils_regex_unescape (const char *text);
gboolean strutils_is_char_escaped (const char *start, const char *current);
#endif /* MC__STRUTILS_ESCAPE_H */

View File

@ -21,16 +21,16 @@
* function, that works with invalid strings are marked with "I"
* in documentation
* invalid bytes of string are handled as one byte characters with width 1, they
* are displayed as questionmarks, I-maked comparing functions try to keep
* are displayed as question marks, I-marked comparing functions try to keep
* the original value of these bytes.
*/
/* combining characters
* displaynig: all handled as zero with characters, expect combing character
* displaying: all handled as zero with characters, expect combing character
* at the begin of string, this character has with one (space add before),
* so str_term_width is not good for computing width of singles characters
* (never return zero, expect empty string)
* for compatibility are strings composed before displaynig
* for compatibility are strings composed before displaying
* comparing: comparing decompose all string before comparing, n-compare
* functions do not work as is usual, because same strings do not have to be
* same length in UTF-8. So they return 0 if one string is prefix of the other
@ -54,15 +54,15 @@
*/
typedef enum
{
/* success means, that conversion has been finished successfully
/* Success means, that the conversion has been finished successfully
*/
ESTR_SUCCESS = 0,
/* problem means, that not every characters was successfully converted (They are
* replaced with questionmark). So is impossible convert string back.
/* Problem means, that not every character was successfully converted (some are
* replaced with question marks). So it is impossible to convert string back.
*/
ESTR_PROBLEM = 1,
/* failure means, that conversion is not possible (example: wrong encoding
* of input string)
/* Failure means, that the conversion is not possible (example: wrong encoding
* of the input string)
*/
ESTR_FAILURE = 2
} estr_t;
@ -75,9 +75,9 @@ typedef enum
J_RIGHT = 0x02,
J_CENTER = 0x03,
/* if there is enough space for string on terminal,
* string is centered otherwise is aligned to left */
* string is centered otherwise is aligned to the left */
J_CENTER_LEFT = 0x04,
/* fit alignment, if string is to long, is truncated with '~' */
/* fit alignment: if string is too long, truncate with '~' */
J_LEFT_FIT = 0x11,
J_RIGHT_FIT = 0x12,
J_CENTER_FIT = 0x13,
@ -209,7 +209,7 @@ gchar *str_conv_gerror_message (GError * error, const char *def_msg);
estr_t str_vfs_convert_from (GIConv coder, const char *string, GString * buffer);
/* if coder is str_cnv_to_term or str_cnv_not_convert, string is only copied,
* does replace with questionmark
* does replace with question mark
* I
*/
estr_t str_vfs_convert_to (GIConv coder, const char *string, int size, GString * buffer);
@ -353,16 +353,16 @@ gboolean str_isprint (const char *ch);
gboolean str_iscombiningmark (const char *ch);
/* write lower from of first characters in ch into out
* decrase remain by size of returned characters
* decrease remain by size of returned characters
* if out is not big enough, do nothing
*/
gboolean str_toupper (const char *ch, char **out, size_t * remain);
gboolean str_toupper (const char *ch, char **out, size_t *remain);
/* write upper from of first characters in ch into out
* decrase remain by size of returned characters
* decrease remain by size of returned characters
* if out is not big enough, do nothing
*/
gboolean str_tolower (const char *ch, char **out, size_t * remain);
gboolean str_tolower (const char *ch, char **out, size_t *remain);
/* return length of text in characters
* I
@ -538,50 +538,6 @@ const char *str_detect_termencoding (void);
int str_verscmp (const char *s1, const char *s2);
/* Compare version strings:
Compare strings a and b as file names containing version numbers, and return an integer
that is negative, zero, or positive depending on whether a compares less than, equal to,
or greater than b.
Use the following version sort algorithm:
1. Compare the strings' maximal-length non-digit prefixes lexically.
If there is a difference return that difference.
Otherwise discard the prefixes and continue with the next step.
2. Compare the strings' maximal-length digit prefixes, using numeric comparison
of the numbers represented by each prefix. (Treat an empty prefix as zero; this can
happen only at string end.)
If there is a difference, return that difference.
Otherwise discard the prefixes and continue with the next step.
3. If both strings are empty, return 0. Otherwise continue with step 1.
In version sort, lexical comparison is left to right, byte by byte, using the byte's numeric
value (0-255), except that:
1. ASCII letters sort before other bytes.
2. A tilde sorts before anything, even an empty string.
In addition to the version sort rules, the following strings have special priority and sort
before all other strings (listed in order):
1. The empty string.
2. ".".
3. "..".
4. Strings starting with "." sort before other strings.
Before comparing two strings where both begin with non-".", or where both begin with "."
but neither is "." or "..", suffixes matching the C-locale extended regular expression
(\.[A-Za-z~][A-Za-z0-9~]*)*$ are removed and the strings compared without them, using version sort
without special priority; if they do not compare equal, this comparison result is used and
the suffixes are effectively ignored. Otherwise, the entire strings are compared using version sort.
When removing a suffix from a nonempty string, remove the maximal-length suffix such that
the remaining string is nonempty.
*/
int filevercmp (const char *a, const char *b);
/* Like filevercmp, except compare the byte arrays a (of length alen) and b (of length blen)
so that a and b can contain '\0', which sorts just before '\1'. But if alen is -1 treat
a as a string terminated by '\0', and similarly for blen.
@ -607,10 +563,30 @@ char *strrstr_skip_count (const char *haystack, const char *needle, size_t skip_
char *str_replace_all (const char *haystack, const char *needle, const char *replacement);
strtol_error_t xstrtoumax (const char *s, char **ptr, int base, uintmax_t * val,
GPtrArray *str_tokenize (const char *string);
strtol_error_t xstrtoumax (const char *nptr, char **endptr, int base, uintmax_t * val,
const char *valid_suffixes);
uintmax_t parse_integer (const char *str, gboolean * invalid);
char *str_escape (const char *src, gsize src_len, const char *escaped_chars,
gboolean escape_non_printable);
char *str_unescape (const char *src, gsize src_len, const char *unescaped_chars,
gboolean unescape_non_printable);
char *str_shell_unescape (const char *text);
#if defined(WIN32)
char* str_shell_unescape_special(const char* text);
#endif
char *str_shell_escape (const char *text);
char *str_glob_escape (const char *text);
char *str_glob_unescape (const char *text);
char *str_regex_escape (const char *text);
char *str_regex_unescape (const char *text);
gboolean str_is_char_escaped (const char *start, const char *current);
/* --------------------------------------------------------------------------------------------- */
/*** inline functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -656,6 +632,56 @@ str_move (char *dest, const char *src)
return (char *) memmove (dest, src, n);
}
/* --------------------------------------------------------------------------------------------- */
/* Compare version strings:
Compare strings a and b as file names containing version numbers, and return an integer
that is negative, zero, or positive depending on whether a compares less than, equal to,
or greater than b.
Use the following version sort algorithm:
1. Compare the strings' maximal-length non-digit prefixes lexically.
If there is a difference return that difference.
Otherwise discard the prefixes and continue with the next step.
2. Compare the strings' maximal-length digit prefixes, using numeric comparison
of the numbers represented by each prefix. (Treat an empty prefix as zero; this can
happen only at string end.)
If there is a difference, return that difference.
Otherwise discard the prefixes and continue with the next step.
3. If both strings are empty, return 0. Otherwise continue with step 1.
In version sort, lexical comparison is left to right, byte by byte, using the byte's numeric
value (0-255), except that:
1. ASCII letters sort before other bytes.
2. A tilde sorts before anything, even an empty string.
In addition to the version sort rules, the following strings have special priority and sort
before all other strings (listed in order):
1. The empty string.
2. ".".
3. "..".
4. Strings starting with "." sort before other strings.
Before comparing two strings where both begin with non-".", or where both begin with "."
but neither is "." or "..", suffixes matching the C-locale extended regular expression
(\.[A-Za-z~][A-Za-z0-9~]*)*$ are removed and the strings compared without them, using version sort
without special priority; if they do not compare equal, this comparison result is used and
the suffixes are effectively ignored. Otherwise, the entire strings are compared using version sort.
When removing a suffix from a nonempty string, remove the maximal-length suffix such that
the remaining string is nonempty.
*/
static inline int
filevercmp (const char *s1, const char *s2)
{
return filenvercmp (s1, -1, s2, -1);
}
/* --------------------------------------------------------------------------------------------- */
#endif /* MC_STRUTIL_H */

View File

@ -9,6 +9,7 @@ libmcstrutil_la_SOURCES = \
strutil.c \
strutilutf8.c \
strverscmp.c \
tokenize.c \
xstrtol.c
AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)

View File

@ -19,9 +19,7 @@
#include <config.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "lib/strutil.h"
@ -50,7 +48,7 @@
* Otherwise, *len should be nonnegative, s is a char array, and *len does not change.
*/
static ssize_t
file_prefixlen (const char *s, ssize_t * len)
file_prefixlen (const char *s, ssize_t *len)
{
size_t n = (size_t) (*len); /* SIZE_MAX if N == -1 */
size_t i = 0;
@ -184,20 +182,6 @@ verrevcmp (const char *s1, ssize_t s1_len, const char *s2, ssize_t s2_len)
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/* Compare version strings.
*
* @param s1 first string to compare
* @param s2 second string to compare
*
* @return an integer less than, equal to, or greater than zero, if @s1 is <, == or > than @s2.
*/
int
filevercmp (const char *s1, const char *s2)
{
return filenvercmp (s1, -1, s2, -1);
}
/* --------------------------------------------------------------------------------------------- */
/* Compare version strings.
*
* @param a first string to compare

View File

@ -1,7 +1,7 @@
/*
Functions for replacing substrings in strings.
Copyright (C) 2013-2024
Copyright (C) 2013-2025
Free Software Foundation, Inc.
Written by:
@ -26,7 +26,6 @@
#include <config.h>
#include "lib/global.h"
#include "lib/strescape.h"
#include "lib/strutil.h"
/*** global variables ****************************************************************************/
@ -72,7 +71,7 @@ str_replace_all (const char *haystack, const char *needle, const char *replaceme
if (return_str == NULL)
return_str = g_string_sized_new (32);
if (strutils_is_char_escaped (haystack, needle_in_str))
if (str_is_char_escaped (haystack, needle_in_str))
{
char *backslash = needle_in_str - 1;

View File

@ -1,7 +1,7 @@
/*
Functions for escaping and unescaping strings
Copyright (C) 2009-2024
Copyright (C) 2009-2025
Free Software Foundation, Inc.
Written by:
@ -27,7 +27,7 @@
#include <config.h>
#include "lib/global.h"
#include "lib/strescape.h"
#include "lib/strutil.h"
/*** global variables ****************************************************************************/
@ -52,8 +52,8 @@ static const char ESCAPE_GLOB_CHARS[] = "$*\\?";
/* --------------------------------------------------------------------------------------------- */
char *
strutils_escape (const char *src, gsize src_len, const char *escaped_chars,
gboolean escape_non_printable)
str_escape (const char *src, gsize src_len, const char *escaped_chars,
gboolean escape_non_printable)
{
GString *ret;
gsize curr_index;
@ -103,8 +103,8 @@ strutils_escape (const char *src, gsize src_len, const char *escaped_chars,
/* --------------------------------------------------------------------------------------------- */
char *
strutils_unescape (const char *src, gsize src_len, const char *unescaped_chars,
gboolean unescape_non_printable)
str_unescape (const char *src, gsize src_len, const char *unescaped_chars,
gboolean unescape_non_printable)
{
GString *ret;
gsize curr_index;
@ -129,6 +129,16 @@ strutils_unescape (const char *src, gsize src_len, const char *unescaped_chars,
continue;
}
#if defined(WIN32) //WIN32, path/UNC
if (curr_index <= 1 && src[curr_index + 1] == '\\') // retain leading "\\ .."
{
g_string_append_c (ret, '\\');
g_string_append_c (ret, '\\');
++curr_index;
continue;
}
#endif
curr_index++;
if (unescaped_chars == ESCAPE_SHELL_CHARS && src[curr_index] == '$')
@ -182,25 +192,25 @@ strutils_unescape (const char *src, gsize src_len, const char *unescaped_chars,
*/
char *
strutils_shell_escape (const char *src)
str_shell_escape (const char *src)
{
return strutils_escape (src, -1, ESCAPE_SHELL_CHARS, FALSE);
return str_escape (src, -1, ESCAPE_SHELL_CHARS, FALSE);
}
/* --------------------------------------------------------------------------------------------- */
char *
strutils_glob_escape (const char *src)
str_glob_escape (const char *src)
{
return strutils_escape (src, -1, ESCAPE_GLOB_CHARS, TRUE);
return str_escape (src, -1, ESCAPE_GLOB_CHARS, TRUE);
}
/* --------------------------------------------------------------------------------------------- */
char *
strutils_regex_escape (const char *src)
str_regex_escape (const char *src)
{
return strutils_escape (src, -1, ESCAPE_REGEX_CHARS, TRUE);
return str_escape (src, -1, ESCAPE_REGEX_CHARS, TRUE);
}
/* --------------------------------------------------------------------------------------------- */
@ -215,31 +225,34 @@ strutils_regex_escape (const char *src)
*/
char *
strutils_shell_unescape (const char *text)
str_shell_unescape (const char *text)
{
return strutils_unescape (text, -1, ESCAPE_SHELL_CHARS, TRUE);
return str_unescape (text, -1, ESCAPE_SHELL_CHARS, TRUE);
}
char *
strutils_shell_unescape_special (const char *text)
#if defined(WIN32)
char*
str_shell_unescape_special (const char* text)
{
return strutils_unescape (text, -1, ESCAPE_SHELL_CHARS, FALSE);
return str_unescape(text, -1, ESCAPE_SHELL_CHARS, FALSE);
}
#endif
/* --------------------------------------------------------------------------------------------- */
char *
strutils_glob_unescape (const char *text)
str_glob_unescape (const char *text)
{
return strutils_unescape (text, -1, ESCAPE_GLOB_CHARS, TRUE);
return str_unescape (text, -1, ESCAPE_GLOB_CHARS, TRUE);
}
/* --------------------------------------------------------------------------------------------- */
char *
strutils_regex_unescape (const char *text)
str_regex_unescape (const char *text)
{
return strutils_unescape (text, -1, ESCAPE_REGEX_CHARS, TRUE);
return str_unescape (text, -1, ESCAPE_REGEX_CHARS, TRUE);
}
/* --------------------------------------------------------------------------------------------- */
@ -254,7 +267,7 @@ strutils_regex_unescape (const char *text)
*/
gboolean
strutils_is_char_escaped (const char *start, const char *current)
str_is_char_escaped (const char *start, const char *current)
{
int num_esc = 0;

View File

@ -1,7 +1,7 @@
/*
Common strings utilities
Copyright (C) 2007-2024
Copyright (C) 2007-2025
Free Software Foundation, Inc.
Written by:
@ -57,18 +57,16 @@ static const char *const str_utf8_encodings[] = {
/* standard 8bit encodings, no wide or multibytes characters */
static const char *const str_8bit_encodings[] = {
/* Solaris has different names of Windows 1251 encoding */
#ifdef __sun
"ansi-1251",
"ansi1251",
#else
"cp-1251",
"cp1251",
#endif
/* solaris */
"ansi-1251",
"ansi1251",
"cp-1250",
"cp1250",
"cp-866",
"cp866",
/* glibc */
"ibm-866",
"ibm866",
"cp-850",
@ -101,7 +99,7 @@ str_test_not_convert (const char *enc)
/* --------------------------------------------------------------------------------------------- */
static estr_t
_str_convert (GIConv coder, const char *string, int size, GString * buffer)
_str_convert (GIConv coder, const char *string, int size, GString *buffer)
{
estr_t state = ESTR_SUCCESS;
gssize left;
@ -153,9 +151,7 @@ _str_convert (GIConv coder, const char *string, int size, GString * buffer)
case G_CONVERT_ERROR_NO_CONVERSION:
/* Conversion between the requested character sets is not supported. */
g_free (tmp_buff);
tmp_buff = g_strnfill (strlen (string), '?');
g_string_append (buffer, tmp_buff);
g_free (tmp_buff);
mc_g_string_append_c_len (buffer, '?', strlen (string));
return ESTR_FAILURE;
case G_CONVERT_ERROR_ILLEGAL_SEQUENCE:
@ -186,12 +182,7 @@ _str_convert (GIConv coder, const char *string, int size, GString * buffer)
g_string_append (buffer, tmp_buff);
g_free (tmp_buff);
if ((int) bytes_read < left)
{
left = left - bytes_read;
tmp_buff = g_strnfill (left, '?');
g_string_append (buffer, tmp_buff);
g_free (tmp_buff);
}
mc_g_string_append_c_len (buffer, '?', left - bytes_read);
return ESTR_PROBLEM;
case G_CONVERT_ERROR_BAD_URI: /* Don't know how handle this error :( */
@ -281,14 +272,14 @@ str_crt_conv_from (const char *from_enc)
void
str_close_conv (GIConv conv)
{
if (conv != str_cnv_not_convert)
if (conv != INVALID_CONV && conv != str_cnv_not_convert)
g_iconv_close (conv);
}
/* --------------------------------------------------------------------------------------------- */
estr_t
str_convert (GIConv coder, const char *string, GString * buffer)
str_convert (GIConv coder, const char *string, GString *buffer)
{
return _str_convert (coder, string, -1, buffer);
}
@ -296,7 +287,7 @@ str_convert (GIConv coder, const char *string, GString * buffer)
/* --------------------------------------------------------------------------------------------- */
estr_t
str_nconvert (GIConv coder, const char *string, int size, GString * buffer)
str_nconvert (GIConv coder, const char *string, int size, GString *buffer)
{
return _str_convert (coder, string, size, buffer);
}
@ -304,7 +295,7 @@ str_nconvert (GIConv coder, const char *string, int size, GString * buffer)
/* --------------------------------------------------------------------------------------------- */
gchar *
str_conv_gerror_message (GError * mcerror, const char *def_msg)
str_conv_gerror_message (GError *mcerror, const char *def_msg)
{
return used_class.conv_gerror_message (mcerror, def_msg);
}
@ -312,7 +303,7 @@ str_conv_gerror_message (GError * mcerror, const char *def_msg)
/* --------------------------------------------------------------------------------------------- */
estr_t
str_vfs_convert_from (GIConv coder, const char *string, GString * buffer)
str_vfs_convert_from (GIConv coder, const char *string, GString *buffer)
{
estr_t result = ESTR_SUCCESS;
@ -327,7 +318,7 @@ str_vfs_convert_from (GIConv coder, const char *string, GString * buffer)
/* --------------------------------------------------------------------------------------------- */
estr_t
str_vfs_convert_to (GIConv coder, const char *string, int size, GString * buffer)
str_vfs_convert_to (GIConv coder, const char *string, int size, GString *buffer)
{
return used_class.vfs_convert_to (coder, string, size, buffer);
}
@ -335,7 +326,7 @@ str_vfs_convert_to (GIConv coder, const char *string, int size, GString * buffer
/* --------------------------------------------------------------------------------------------- */
void
str_printf (GString * buffer, const char *format, ...)
str_printf (GString *buffer, const char *format, ...)
{
va_list ap;
va_start (ap, format);
@ -347,7 +338,7 @@ str_printf (GString * buffer, const char *format, ...)
/* --------------------------------------------------------------------------------------------- */
void
str_insert_replace_char (GString * buffer)
str_insert_replace_char (GString *buffer)
{
used_class.insert_replace_char (buffer);
}
@ -756,7 +747,7 @@ str_isdigit (const char *ch)
/* --------------------------------------------------------------------------------------------- */
gboolean
str_toupper (const char *ch, char **out, size_t * remain)
str_toupper (const char *ch, char **out, size_t *remain)
{
return used_class.char_toupper (ch, out, remain);
}
@ -764,7 +755,7 @@ str_toupper (const char *ch, char **out, size_t * remain)
/* --------------------------------------------------------------------------------------------- */
gboolean
str_tolower (const char *ch, char **out, size_t * remain)
str_tolower (const char *ch, char **out, size_t *remain)
{
return used_class.char_tolower (ch, out, remain);
}
@ -994,7 +985,7 @@ strrstr_skip_count (const char *haystack, const char *needle, size_t skip_count)
*/
uintmax_t
parse_integer (const char *str, gboolean * invalid)
parse_integer (const char *str, gboolean *invalid)
{
uintmax_t n;
char *suffix;

View File

@ -1,7 +1,7 @@
/*
8bit strings utilities
Copyright (C) 2007-2024
Copyright (C) 2007-2025
Free Software Foundation, Inc.
Written by:
@ -79,7 +79,7 @@ DECLARE_CTYPE_WRAPPER (tolower)
/* --------------------------------------------------------------------------------------------- */
static void
str_8bit_insert_replace_char (GString * buffer)
str_8bit_insert_replace_char (GString *buffer)
{
g_string_append_c (buffer, replch);
}
@ -195,7 +195,7 @@ str_8bit_iscombiningmark (const char *text)
/* --------------------------------------------------------------------------------------------- */
static int
str_8bit_toupper (const char *text, char **out, size_t * remain)
str_8bit_toupper (const char *text, char **out, size_t *remain)
{
if (*remain <= 1)
return FALSE;
@ -209,7 +209,7 @@ str_8bit_toupper (const char *text, char **out, size_t * remain)
/* --------------------------------------------------------------------------------------------- */
static gboolean
str_8bit_tolower (const char *text, char **out, size_t * remain)
str_8bit_tolower (const char *text, char **out, size_t *remain)
{
if (*remain <= 1)
return FALSE;
@ -233,13 +233,17 @@ str_8bit_length (const char *text)
static int
str_8bit_length2 (const char *text, int size)
{
return (size >= 0) ? MIN (strlen (text), (gsize) size) : strlen (text);
size_t length;
length = strlen (text);
return (size >= 0) ? MIN (length, (size_t) size) : length;
}
/* --------------------------------------------------------------------------------------------- */
static gchar *
str_8bit_conv_gerror_message (GError * mcerror, const char *def_msg)
str_8bit_conv_gerror_message (GError *mcerror, const char *def_msg)
{
GIConv conv;
gchar *ret;
@ -272,7 +276,7 @@ str_8bit_conv_gerror_message (GError * mcerror, const char *def_msg)
/* --------------------------------------------------------------------------------------------- */
static estr_t
str_8bit_vfs_convert_to (GIConv coder, const char *string, int size, GString * buffer)
str_8bit_vfs_convert_to (GIConv coder, const char *string, int size, GString *buffer)
{
estr_t result = ESTR_SUCCESS;
@ -443,7 +447,11 @@ str_8bit_term_trim (const char *text, int width)
static int
str_8bit_term_width2 (const char *text, size_t length)
{
return (length != (size_t) (-1)) ? MIN (strlen (text), length) : strlen (text);
size_t text_len;
text_len = strlen (text);
return (length != (size_t) (-1)) ? MIN (text_len, length) : text_len;
}
/* --------------------------------------------------------------------------------------------- */
@ -661,7 +669,12 @@ str_8bit_compare (const char *t1, const char *t2)
static int
str_8bit_ncompare (const char *t1, const char *t2)
{
return strncmp (t1, t2, MIN (strlen (t1), strlen (t2)));
size_t l1, l2;
l1 = strlen (t1);
l2 = strlen (t2);
return strncmp (t1, t2, MIN (l1, l2));
}
/* --------------------------------------------------------------------------------------------- */
@ -703,12 +716,15 @@ str_8bit_casecmp (const char *s1, const char *s2)
static int
str_8bit_ncasecmp (const char *s1, const char *s2)
{
size_t l1, l2;
size_t n;
g_return_val_if_fail (s1 != NULL, 0);
g_return_val_if_fail (s2 != NULL, 0);
n = MIN (strlen (s1), strlen (s2));
l1 = strlen (s1);
l2 = strlen (s2);
n = MIN (l1, l2);
/* code from GLib */

View File

@ -1,7 +1,7 @@
/*
ASCII strings utilities
Copyright (C) 2007-2024
Copyright (C) 2007-2025
Free Software Foundation, Inc.
Written by:
@ -52,7 +52,7 @@ static const char replch = '?';
/* --------------------------------------------------------------------------------------------- */
static void
str_ascii_insert_replace_char (GString * buffer)
str_ascii_insert_replace_char (GString *buffer)
{
g_string_append_c (buffer, replch);
}
@ -168,7 +168,7 @@ str_ascii_iscombiningmark (const char *text)
/* --------------------------------------------------------------------------------------------- */
static int
str_ascii_toupper (const char *text, char **out, size_t * remain)
str_ascii_toupper (const char *text, char **out, size_t *remain)
{
if (*remain <= 1)
return FALSE;
@ -182,7 +182,7 @@ str_ascii_toupper (const char *text, char **out, size_t * remain)
/* --------------------------------------------------------------------------------------------- */
static gboolean
str_ascii_tolower (const char *text, char **out, size_t * remain)
str_ascii_tolower (const char *text, char **out, size_t *remain)
{
if (*remain <= 1)
return FALSE;
@ -206,13 +206,17 @@ str_ascii_length (const char *text)
static int
str_ascii_length2 (const char *text, int size)
{
return (size >= 0) ? MIN (strlen (text), (gsize) size) : strlen (text);
size_t length;
length = strlen (text);
return (size >= 0) ? MIN (length, (size_t) size) : length;
}
/* --------------------------------------------------------------------------------------------- */
static gchar *
str_ascii_conv_gerror_message (GError * mcerror, const char *def_msg)
str_ascii_conv_gerror_message (GError *mcerror, const char *def_msg)
{
/* the same as str_utf8_conv_gerror_message() */
if (mcerror != NULL)
@ -224,7 +228,7 @@ str_ascii_conv_gerror_message (GError * mcerror, const char *def_msg)
/* --------------------------------------------------------------------------------------------- */
static estr_t
str_ascii_vfs_convert_to (GIConv coder, const char *string, int size, GString * buffer)
str_ascii_vfs_convert_to (GIConv coder, const char *string, int size, GString *buffer)
{
(void) coder;
g_string_append_len (buffer, string, size);
@ -423,7 +427,11 @@ str_ascii_term_trim (const char *text, int width)
static int
str_ascii_term_width2 (const char *text, size_t length)
{
return (length != (size_t) (-1)) ? MIN (strlen (text), length) : strlen (text);
size_t text_len;
text_len = strlen (text);
return (length != (size_t) (-1)) ? MIN (text_len, length) : text_len;
}
/* --------------------------------------------------------------------------------------------- */
@ -642,7 +650,12 @@ str_ascii_compare (const char *t1, const char *t2)
static int
str_ascii_ncompare (const char *t1, const char *t2)
{
return strncmp (t1, t2, MIN (strlen (t1), strlen (t2)));
size_t l1, l2;
l1 = strlen (t1);
l2 = strlen (t2);
return strncmp (t1, t2, MIN (l1, l2));
}
/* --------------------------------------------------------------------------------------------- */
@ -658,7 +671,12 @@ str_ascii_casecmp (const char *t1, const char *t2)
static int
str_ascii_ncasecmp (const char *t1, const char *t2)
{
return g_ascii_strncasecmp (t1, t2, MIN (strlen (t1), strlen (t2)));
size_t l1, l2;
l1 = strlen (t1);
l2 = strlen (t2);
return g_ascii_strncasecmp (t1, t2, MIN (l1, l2));
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -1,7 +1,7 @@
/*
UTF-8 strings utilities
Copyright (C) 2007-2024
Copyright (C) 2007-2025
Free Software Foundation, Inc.
Written by:
@ -80,7 +80,7 @@ str_unichar_iscombiningmark (gunichar uni)
/* --------------------------------------------------------------------------------------------- */
static void
str_utf8_insert_replace_char (GString * buffer)
str_utf8_insert_replace_char (GString *buffer)
{
g_string_append (buffer, replch);
}
@ -277,7 +277,7 @@ str_utf8_cprev_noncomb_char (const char **text, const char *begin)
/* --------------------------------------------------------------------------------------------- */
static gboolean
str_utf8_toupper (const char *text, char **out, size_t * remain)
str_utf8_toupper (const char *text, char **out, size_t *remain)
{
gunichar uni;
size_t left;
@ -300,7 +300,7 @@ str_utf8_toupper (const char *text, char **out, size_t * remain)
/* --------------------------------------------------------------------------------------------- */
static gboolean
str_utf8_tolower (const char *text, char **out, size_t * remain)
str_utf8_tolower (const char *text, char **out, size_t *remain)
{
gunichar uni;
size_t left;
@ -398,7 +398,7 @@ str_utf8_length_noncomb (const char *text)
#if 0
static void
str_utf8_questmark_sustb (char **string, size_t * left, GString * buffer)
str_utf8_questmark_sustb (char **string, size_t *left, GString *buffer)
{
char *next;
@ -412,7 +412,7 @@ str_utf8_questmark_sustb (char **string, size_t * left, GString * buffer)
/* --------------------------------------------------------------------------------------------- */
static gchar *
str_utf8_conv_gerror_message (GError * mcerror, const char *def_msg)
str_utf8_conv_gerror_message (GError *mcerror, const char *def_msg)
{
if (mcerror != NULL)
return g_strdup (mcerror->message);
@ -423,7 +423,7 @@ str_utf8_conv_gerror_message (GError * mcerror, const char *def_msg)
/* --------------------------------------------------------------------------------------------- */
static estr_t
str_utf8_vfs_convert_to (GIConv coder, const char *string, int size, GString * buffer)
str_utf8_vfs_convert_to (GIConv coder, const char *string, int size, GString *buffer)
{
estr_t result = ESTR_SUCCESS;
@ -495,10 +495,13 @@ str_utf8_make_make_term_form (const char *text, size_t length)
}
else
{
size_t repl_len;
text++;
/*actual[0] = '?'; */
memcpy (actual, replch, strlen (replch));
actual += strlen (replch);
repl_len = strlen (replch);
memcpy (actual, replch, repl_len);
actual += repl_len;
result.width++;
}
@ -989,14 +992,23 @@ str_utf8_release_search_needle (char *needle, gboolean case_sen)
static const char *
str_utf8_search_first (const char *text, const char *search, gboolean case_sen)
{
char *fold_text;
char *deco_text;
const char *match;
const char *result = NULL;
const char *m;
size_t search_len;
fold_text = case_sen ? (char *) text : g_utf8_casefold (text, -1);
deco_text = g_utf8_normalize (fold_text, -1, G_NORMALIZE_ALL);
if (case_sen)
deco_text = g_utf8_normalize (text, -1, G_NORMALIZE_ALL);
else
{
char *fold_text;
fold_text = g_utf8_casefold (text, -1);
deco_text = g_utf8_normalize (fold_text, -1, G_NORMALIZE_ALL);
g_free (fold_text);
}
search_len = strlen (search);
match = deco_text;
do
@ -1005,10 +1017,11 @@ str_utf8_search_first (const char *text, const char *search, gboolean case_sen)
if (match != NULL)
{
if ((!str_utf8_iscombiningmark (match) || (match == deco_text)) &&
!str_utf8_iscombiningmark (match + strlen (search)))
!str_utf8_iscombiningmark (match + search_len))
{
const char *m = deco_text;
result = text;
m = deco_text;
while (m < match)
{
str_utf8_cnext_noncomb_char (&m);
@ -1022,8 +1035,6 @@ str_utf8_search_first (const char *text, const char *search, gboolean case_sen)
while (match != NULL && result == NULL);
g_free (deco_text);
if (!case_sen)
g_free (fold_text);
return result;
}
@ -1033,14 +1044,23 @@ str_utf8_search_first (const char *text, const char *search, gboolean case_sen)
static const char *
str_utf8_search_last (const char *text, const char *search, gboolean case_sen)
{
char *fold_text;
char *deco_text;
char *match;
const char *result = NULL;
const char *m;
size_t search_len;
fold_text = case_sen ? (char *) text : g_utf8_casefold (text, -1);
deco_text = g_utf8_normalize (fold_text, -1, G_NORMALIZE_ALL);
if (case_sen)
deco_text = g_utf8_normalize (text, -1, G_NORMALIZE_ALL);
else
{
char *fold_text;
fold_text = g_utf8_casefold (text, -1);
deco_text = g_utf8_normalize (fold_text, -1, G_NORMALIZE_ALL);
g_free (fold_text);
}
search_len = strlen (search);
do
{
@ -1048,10 +1068,11 @@ str_utf8_search_last (const char *text, const char *search, gboolean case_sen)
if (match != NULL)
{
if ((!str_utf8_iscombiningmark (match) || (match == deco_text)) &&
!str_utf8_iscombiningmark (match + strlen (search)))
!str_utf8_iscombiningmark (match + search_len))
{
const char *m = deco_text;
result = text;
m = deco_text;
while (m < match)
{
str_utf8_cnext_noncomb_char (&m);
@ -1065,8 +1086,6 @@ str_utf8_search_last (const char *text, const char *search, gboolean case_sen)
while (match != NULL && result == NULL);
g_free (deco_text);
if (!case_sen)
g_free (fold_text);
return result;
}
@ -1346,7 +1365,7 @@ str_utf8_caseprefix (const char *text, const char *prefix)
static char *
str_utf8_create_key_gen (const char *text, gboolean case_sen,
gchar * (*keygen) (const gchar * text, gssize size))
gchar *(*keygen) (const gchar *text, gssize size))
{
char *result;

View File

@ -1,7 +1,7 @@
/*
Compare strings while treating digits characters numerically.
Copyright (C) 1997-2024
Copyright (C) 1997-2025
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@ -39,7 +39,6 @@
#include <config.h>
#include <ctype.h>
#ifdef HAVE_STRVERSCMP
#include <string.h>
#endif /* HAVE_STRVERSCMP */
@ -122,7 +121,7 @@ str_verscmp (const char *s1, const char *s2)
c1 = *p1++;
c2 = *p2++;
/* Hint: '0' is a digit too. */
state = S_N + ((c1 == '0') + (isdigit (c1) != 0));
state = S_N + ((c1 == '0') + (g_ascii_isdigit (c1) ? 1 : 0));
while ((diff = c1 - c2) == 0)
{
@ -132,10 +131,10 @@ str_verscmp (const char *s1, const char *s2)
state = next_state[state];
c1 = *p1++;
c2 = *p2++;
state += (c1 == '0') + (isdigit (c1) != 0);
state += (c1 == '0') + (g_ascii_isdigit (c1) ? 1 : 0);
}
state = result_type[state * 3 + (((c2 == '0') + (isdigit (c2) != 0)))];
state = result_type[state * 3 + (((c2 == '0') + (g_ascii_isdigit (c2) ? 1 : 0)))];
switch (state)
{
@ -143,11 +142,11 @@ str_verscmp (const char *s1, const char *s2)
return diff;
case LEN:
while (isdigit (*p1++))
if (!isdigit (*p2++))
while (g_ascii_isdigit (*p1++))
if (!g_ascii_isdigit (*p2++))
return 1;
return isdigit (*p2) ? -1 : diff;
return g_ascii_isdigit (*p2) ? -1 : diff;
default:
return state;

Some files were not shown because too many files have changed in this diff Show More