Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit f464064

Browse files
committed
Merge branch '4572_cleanup'
* 4572_cleanup: (53 commits) doc: fix typos in comments Update po/*.po fiies. (mcview_display_hex): refactor, fix coding style. src/vfs/cpio/cpio.c: fix coding style. lib/vfs/path.h: fix coding style. (setup__is_cfg_group_must_panel_config): fix coding style. (check_format_var): fix coding stile. (copy_file_file): handling "Abort" button on chown/chmod/chattr error. buildsys: remove orphaned rpc checks after samba was deleted src/filemanager/chattr.c: fix coding style. (chattrboxes_rename): reduce variable scope. (files_error): fix coding style. (show_version): add output of uintmax_t size. lib/vfs/direntry.c: fix coding style. lib/vfs/vfs.c: fix coding style. (spell_dialog_spell_suggest_show): refactoring. tar: avoid need for base64_init and extra table. (tar_from_header): reword to avoid a cast to unsigned char. tar: avoid casts in tar_checksum. tar: prefer stoint to strtoul and variants. ...
2 parents a24d45f + d11faea commit f464064

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1629
-1048
lines changed

acinclude.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
m4_include([m4.include/gnulib/mc-gnulib-common.m4])
12
m4_include([m4.include/gnulib/mode_t.m4])
23
m4_include([m4.include/gnulib/stat-size.m4])
34
m4_include([m4.include/gnulib/fstypename.m4])
@@ -13,6 +14,7 @@ m4_include([m4.include/ax_check_compile_flag.m4])
1314
m4_include([m4.include/ax_append_flag.m4])
1415
m4_include([m4.include/ax_append_compile_flags.m4])
1516
m4_include([m4.include/mc-cflags.m4])
17+
m4_include([m4.include/mc-stdckdint.m4])
1618
m4_include([m4.include/ax_gcc_func_attribute.m4])
1719
m4_include([m4.include/mc-check-search-type.m4])
1820
m4_include([m4.include/mc-get-fs-info.m4])

configure.ac

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ dnl This macro is redefined in m4.include/gnulib/sys_types_h.m4
243243
dnl to work around a buggy version in autoconf <= 2.69.
244244
AC_HEADER_MAJOR
245245

246+
mc_CHECK_HEADER_STDCKDINT
247+
246248

247249
dnl ############################################################################
248250
dnl Check for types
@@ -260,8 +262,14 @@ AC_TYPE_MODE_T
260262
gl_PROMOTED_TYPE_MODE_T
261263
AC_TYPE_PID_T
262264
AC_TYPE_UID_T
263-
AC_CHECK_TYPE([major_t], [], [AC_DEFINE([major_t], [int], [Type of major device numbers.])])
264-
AC_CHECK_TYPE([minor_t], [], [AC_DEFINE([minor_t], [int], [Type of minor device numbers.])])
265+
266+
dnl Taken from GNU/Linux, and should be good enough on platforms lacking these types.
267+
AC_CHECK_TYPE([dev_t], [unsigned long long int])
268+
AC_CHECK_TYPE([ino_t], [unsigned long long int])
269+
270+
dnl Taken from GNU/Linux, and should be good enough on platforms lacking these types.
271+
AC_CHECK_TYPE([major_t], [unsigned int])
272+
AC_CHECK_TYPE([minor_t], [unsigned int])
265273

266274
AC_STRUCT_ST_BLOCKS
267275
AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev, struct stat.st_mtim, struct stat.st_mtimespec, struct stat.st_mtimensec])

doc/NEWS

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,53 @@ Version 4.8.32
22

33
- Core
44

5-
* Tell the current directory to the terminal using OSC 7 sequence (so it can open new tabs there) (#3088)
6-
* Preserve ext2fs attributes on copy/move operations (#4532)
7-
* Change name of temporary directory: make it unique for each run (#4535)
8-
* Hide password in file operation progress dialog (#4541)
9-
* Support reget in file move operation (#4563)
10-
* Implement nanosecond precision timestamps on non-Linux (macOS, BSD, AIX, Solaris) (#4563)
11-
* Remove remaining mmap code to simplify maintenance (#3960)
5+
* Tell the current directory to the terminal using OSC 7 sequence (so it can open new tabs there) (#3088)
6+
* Preserve ext2fs attributes on copy/move operations (#4532)
7+
* Change name of temporary directory: make it unique for each run (#4535)
8+
* Hide password in file operation progress dialog (#4541)
9+
* Support reget in file move operation (#4563)
10+
* Implement nanosecond precision timestamps on non-Linux (macOS, BSD, AIX, Solaris) (#4563)
11+
* Remove remaining mmap code to simplify maintenance (#3960)
1212

1313
- VFS
1414

15-
* extfs: support unrar-7 (#4518)
15+
* extfs: support unrar-7 (#4518)
1616

1717
- Editor
1818

19-
* Improve syntax highlighting:
20-
- C and C++ (MidnightCommander/mc#195, #4556)
19+
* Improve syntax highlighting:
20+
- C and C++ (MidnightCommander/mc#195, #4556)
2121

2222
- Diff viewer
2323

24-
* Add man page mcdiff.1 (#4224)
24+
* Add man page mcdiff.1 (#4224)
2525

2626
- Misc
2727

28-
* Code cleanup (#4524)
29-
* New skins
28+
* Code cleanup (#4524)
29+
* New skins
3030
- xoria256-thin, xoria256root-thin (#4530)
3131
- modarcon16-defbg-thin, modarcon16-thin, modarcon16root-defbg-thin, modarcon16root-thin (#4530)
3232
- modarin256-defbg-thin, modarin256-thin, modarin256root-defbg-thin, modarin256root-thin (#4530)
3333
- julia256root (#4536)
34-
* mc.ext.ini: clarify escaping of spaces and parenthesis (#4502)
34+
* mc.ext.ini: clarify escaping of spaces and parenthesis (#4502)
3535

3636
- Fixes
3737

38-
* External editor does not work with arguments in $EDITOR (#4533)
39-
* fish shell: strings " cd (printf '%b' ... " in history (#4521)
40-
* Redundant back slashes for autocomplete (#4292)
41-
* subshell: call execl with argv[0] that is not an actual path to Bash (#4549)
42-
* mcedit: php.syntax: comment highlight from start of light only (#4519)
43-
* mcedit: wrong replacement using regular expressions with begin or end of line (#4525, #4526)
44-
* mcedit: losing column position when navigating up/down (MidnightCommander/mc#194)
45-
* mcedit: macro deletes text (#4540)
46-
* mcedit: macros are applied to the pasted text (#4562)
47-
* extfs: iso9660: xorriso is slow to open an ISO image (#3570, #4567)
48-
* extfs: u7z: wrong add of nested directories to archive (#4559)
49-
* extfs: segfault on enter to deleted archive (#4560)
50-
* tar: segfault on copy files from archive (#4561)
51-
* man: typo (#4550)
38+
* External editor does not work with arguments in $EDITOR (#4533)
39+
* fish shell: strings " cd (printf '%b' ... " in history (#4521)
40+
* Redundant back slashes for autocomplete (#4292)
41+
* subshell: call execl with argv[0] that is not an actual path to Bash (#4549)
42+
* mcedit: php.syntax: comment highlight from start of light only (#4519)
43+
* mcedit: wrong replacement using regular expressions with begin or end of line (#4525, #4526)
44+
* mcedit: losing column position when navigating up/down (MidnightCommander/mc#194)
45+
* mcedit: macro deletes text (#4540)
46+
* mcedit: macros are applied to the pasted text (#4562)
47+
* extfs: iso9660: xorriso is slow to open an ISO image (#3570, #4567)
48+
* extfs: u7z: wrong add of nested directories to archive (#4559)
49+
* extfs: segfault on enter to deleted archive (#4560)
50+
* tar: segfault on copy files from archive (#4561)
51+
* man: typo (#4550)
5252

5353

5454
Version 4.8.31

lib/Makefile.am

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ endif
1616
SUBLIB_includes = \
1717
event.h event-types.h \
1818
filehighlight.h \
19+
idx.h \
20+
intprops-internal.h
1921
mcconfig.h \
2022
search.h \
2123
skin.h \
@@ -52,6 +54,9 @@ if CHARSET
5254
libmc_la_SOURCES += charsets.c charsets.h
5355
endif
5456
57+
EXTRA_DIST = \
58+
stdckdint.in.h
59+
5560
AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
5661
5762
libmc_la_LIBADD = \

lib/charsets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ init_translation_table (int cpsource, int cpdisplay)
288288
int i;
289289
GIConv cd;
290290

291-
/* Fill inpit <-> display tables */
291+
/* Fill input <-> display tables */
292292

293293
if (cpsource < 0 || cpdisplay < 0 || cpsource == cpdisplay)
294294
{

lib/idx.h

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/* A type for indices and sizes.
2+
Copyright (C) 2020-2024 Free Software Foundation, Inc.
3+
This file is part of the GNU C Library.
4+
5+
The GNU C Library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
The GNU C Library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with the GNU C Library; if not, see
17+
<https://www.gnu.org/licenses/>. */
18+
19+
#ifndef _IDX_H
20+
#define _IDX_H
21+
22+
/* Get ptrdiff_t. */
23+
#include <stddef.h>
24+
25+
/* Get PTRDIFF_MAX. */
26+
#include <stdint.h>
27+
28+
/* The type 'idx_t' holds an (array) index or an (object) size.
29+
Its implementation promotes to a signed integer type,
30+
which can hold the values
31+
0..2^63-1 (on 64-bit platforms) or
32+
0..2^31-1 (on 32-bit platforms).
33+
34+
Why a signed integer type?
35+
36+
* Security: Signed types can be checked for overflow via
37+
'-fsanitize=undefined', but unsigned types cannot.
38+
39+
* Comparisons without surprises: ISO C99 § 6.3.1.8 specifies a few
40+
surprising results for comparisons, such as
41+
42+
(int) -3 < (unsigned long) 7 => false
43+
(int) -3 < (unsigned int) 7 => false
44+
and on 32-bit machines:
45+
(long) -3 < (unsigned int) 7 => false
46+
47+
This is surprising because the natural comparison order is by
48+
value in the realm of infinite-precision signed integers (ℤ).
49+
50+
The best way to get rid of such surprises is to use signed types
51+
for numerical integer values, and use unsigned types only for
52+
bit masks and enums.
53+
54+
Why not use 'size_t' directly?
55+
56+
* Because 'size_t' is an unsigned type, and a signed type is better.
57+
See above.
58+
59+
Why not use 'ssize_t'?
60+
61+
* 'ptrdiff_t' is more portable; it is standardized by ISO C
62+
whereas 'ssize_t' is standardized only by POSIX.
63+
64+
* 'ssize_t' is not required to be as wide as 'size_t', and some
65+
now-obsolete POSIX platforms had 'size_t' wider than 'ssize_t'.
66+
67+
* Conversely, some now-obsolete platforms had 'ptrdiff_t' wider
68+
than 'size_t', which can be a win and conforms to POSIX.
69+
70+
Won't this cause a problem with objects larger than PTRDIFF_MAX?
71+
72+
* Typical modern or large platforms do not allocate such objects,
73+
so this is not much of a problem in practice; for example, you
74+
can safely write 'idx_t len = strlen (s);'. To port to older
75+
small platforms where allocations larger than PTRDIFF_MAX could
76+
in theory be a problem, you can use Gnulib's ialloc module, or
77+
functions like ximalloc in Gnulib's xalloc module.
78+
79+
Why not use 'ptrdiff_t' directly?
80+
81+
* Maintainability: When reading and modifying code, it helps to know that
82+
a certain variable cannot have negative values. For example, when you
83+
have a loop
84+
85+
int n = ...;
86+
for (int i = 0; i < n; i++) ...
87+
88+
or
89+
90+
ptrdiff_t n = ...;
91+
for (ptrdiff_t i = 0; i < n; i++) ...
92+
93+
you have to ask yourself "what if n < 0?". Whereas in
94+
95+
idx_t n = ...;
96+
for (idx_t i = 0; i < n; i++) ...
97+
98+
you know that this case cannot happen.
99+
100+
Similarly, when a programmer writes
101+
102+
idx_t = ptr2 - ptr1;
103+
104+
there is an implied assertion that ptr1 and ptr2 point into the same
105+
object and that ptr1 <= ptr2.
106+
107+
* Being future-proof: In the future, range types (integers which are
108+
constrained to a certain range of values) may be added to C compilers
109+
or to the C standard. Several programming languages (Ada, Haskell,
110+
Common Lisp, Pascal) already have range types. Such range types may
111+
help producing good code and good warnings. The type 'idx_t' could
112+
then be typedef'ed to a range type that is signed after promotion. */
113+
114+
#ifdef __cplusplus
115+
extern "C" {
116+
#endif
117+
118+
119+
/* In the future, idx_t could be typedef'ed to a signed range type.
120+
The clang "extended integer types", supported in Clang 11 or newer
121+
<https://clang.llvm.org/docs/LanguageExtensions.html#extended-integer-types>,
122+
are a special case of range types. However, these types don't support binary
123+
operators with plain integer types (e.g. expressions such as x > 1).
124+
Therefore, they don't behave like signed types (and not like unsigned types
125+
either). So, we cannot use them here. */
126+
127+
/* Use the signed type 'ptrdiff_t'. */
128+
/* Note: ISO C does not mandate that 'size_t' and 'ptrdiff_t' have the same
129+
size, but it is so on all platforms we have seen since 1990. */
130+
typedef ptrdiff_t idx_t;
131+
132+
/* IDX_MAX is the maximum value of an idx_t. */
133+
#define IDX_MAX PTRDIFF_MAX
134+
135+
/* So far no need has been found for an IDX_WIDTH macro.
136+
Perhaps there should be another macro IDX_VALUE_BITS that does not
137+
count the sign bit and is therefore one less than PTRDIFF_WIDTH. */
138+
139+
140+
#ifdef __cplusplus
141+
}
142+
#endif
143+
144+
#endif /* _IDX_H */

0 commit comments

Comments
 (0)