Commit Graph

16167 Commits

Author SHA1 Message Date
Andrew Borodin
54d4dfc534 (spell_dialog_spell_suggest_show): refactoring.
Reduce variable scope. Get rid of extra NULL check: g_strdup() handles
NULL correctly. Remove intermediate variable.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:14 +03:00
Andrew Borodin
80f7a162c3 tar: avoid need for base64_init and extra table.
Simplify the code by assuming C99 initializers.

  * (base_64_digits): Remove; no longer needed.
  * (base64_map): Now a constant. Initialized statically,
    and with invalid entries being 0 not 64, and with valid
    entries being 1 greater than before.
  * (tar_base64_init): Remove; only use removed.
  * (tar_from_header): Adjust to new values in base64_map.

Sync with GNU tar 43231ae554d0dacbcc32e2d0fe574c9d0e183258.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:14 +03:00
Andrew Borodin
aadedc361d (tar_from_header): reword to avoid a cast to unsigned char.
Sync with GNU tar b201a3742162adcb2cf1e9618c4c4f4db0d239ae.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:14 +03:00
Andrew Borodin
b6483b8a47 tar: avoid casts in tar_checksum.
* (tar_checksum): recode to avoid casts.
  * (tar_from_header): likewise.

Sync with GNU tar 1521d3dae01f91606c639eb745ea565ef723e38d.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:14 +03:00
Andrew Borodin
7d8deb89c8 tar: prefer stoint to strtoul and variants.
When parsing numbers prefer using strtosysint() (renamed stoint)
to using strtoul() and its variants.
This is simpler and faster and likely more reliable than
relying on quirks of the system strtoul() etc,
and it standardizes how tar deals with parsing integers.
Among other things, the C standard and POSIX don't specify
what strtol() does to errno when conversions cannot be performed,
and it requires strtoul() to support "-" before unsigned numbers.

  * (stoint): rename from strtosysint, move to tar-internal.c and add
    a gboollean * argument for reporting overflow.  All callers changed.
  * (decode_num): prefer stoint() to strtol() etc. Don't rely on
    errno == EINVAL as the standards don't guarantee it.
  * (decode_signed_num): likewise.
  * (decode_record): likewise.
  * (sparse_map_decoder): likewise.
  * (decode_timespec): Simplify by using ckd_sub() rather than checking
    for overflow by hand.
  * tar-sparse.c: remove include of errno.h, it's no lomger used.
  * tar-xheader.c: likewise

Sync with GNU tar d1e72a536f26188230a147d948b9057714fd0b6b.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
5bb5442cd1 src/vfs/tar/tar-xheader.c: indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
465d8b962a (blocking_factor, record_size): change type.
Don't limit blocking factor to INT_MAX.
Prefer signed type for record_size.
Do not exceed IDX_MAX or SSIZE_MAX for record_size;
the SSIZE_MAX limit is needed so that "read" calls behave sensibly.

Sync with GNU tar 3ffe2eb0738504aabee0d3b4d0c03e01739b9d6c.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
ebbff2266a configure.ac: default to GNU/Linux dev_t, ino_t, major_t, minor_t.
This shouldn't affect behavior; it's just a cleanup.

Sync with GNU tar eb9bb9bf8049522230a0654c3f32e6373b945254.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
20b617a8ab tar: avoid strtoul().
This is part of the general trend to prefer signed integer types,
to allow better runtime checking with -fsanitize=undefined etc.

  * (struct tar_stat_info): ue intmax_t, not unsigned, for sparse major
    and minor.
  * (tar_sparse_major): likewise.
  * (tar_sparse_minor): likewise.

Sync with GNU tar 4642cd04edbd57414e004920fa4976d9f3be6206.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
79b10fc8a7 (tar_from_header): ckd_mul() and ckd_add() rather than doing it by hand.
(LG_64): Remove; no longer used.

Sync with GNU tar 414f635d8bba4c8894855040b1e6b77b07dc07bd.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
b9e7ab2f08 (pax_decode_header): use SIZE_MAX.
Sync with GNU tar 281e03ec6ccb9e6da134f8f6b9a9ff51c42f5737.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
c9288158bc (tar_from_header): minor width cleanup.
Use UINTMAX_WIDTH rather than computing it by hand.

Sync with GNU tar fbc60c2334326fc2f748226abe76190ecf39a26b.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
2aeff547ca tar: include stdckdint.h via tar-internal.h.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
ed99e93019 src/vrs/tar/tar-sparse.c: prefer stdckdint.h to intprops.h.
* (oldgnu_add_sparse): prefer ckd_add and ckd_mul to the intprops.h
    equivalents, since stdckdint.h is now standard.
  * (pax_decode_header): likewise.

Remove macros defined in lib/intprops-internal.h.

Sync with GNU tar a9372cf08a05723b2a06efff3402077598138238.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
730fdef61d (tar_read_header): simplify read_header overflow checking.
Use ckd_add instead of doing overflow checking by hand.
Although the old code was correct on all practical hosts,
the new code is simpler and works even on weird hosts
where SIZE_MAX <= INT_MAX.

Sync with GNU tar 8a3fc529729acf38276b27f6b7bc50962dfab799.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
40c912b9b7 (tar_xheader_read): cleaner overflow checking.
Prefer ckd_add() to doing overflow checking by hand.

Sync with GNU tar 927d67855e2e83b6b06eb9095f65e4e695d6af7e.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
9e44b293f4 (from_header): use ckd_mul().
Sync with GNU tar c6a5af16ba0ceff08b58d8a26cdbed2b300ccd0a.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
c87a4a8db5 src/vfs/tar/tar-internal.c: clarify includes.
Don't include stdint.h, since inttypes.h includes it.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
72d0b4f878 Add some files and code rom Gnulib as preparation to TAR updates.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Yury V. Zaytsev
0775539b08 Fix typos/improve grammar in charsets.c / strutil.h
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 15:07:13 +03:00
Andrew Borodin
92bb95998e src/filemanager/filenot.c: remove useless code.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:13 +03:00
Andrew Borodin
d2aa6486dd (mc_tmpdir): reduce variable scope.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:07:12 +03:00
Andrew Borodin
d6a93efb2b (create_sequence): reduce variable scope, trivial refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
0780ef2970 Refactoring of file and directory delete routines.
* (file_progress_show_deleting): take 'vfs_path_t *' instead of 'char *'.
  * (try_erase_dir): likewise.
  * (erase_file): sync with new file_progress_show_deleting().
  * (recursive_erase): sync with new file_progress_show_deleting() and
    try_erase_dir().
  * (erase_dir_iff_empty): likewise.
  * (erase_dir): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
6cb97d18f1 src/strutil/xstrtol.c: sync with gnulib.
Sync with gnulib 64ddc975e72cb55d2b2d755c25603bd70312aa5e:
  This patch alters xstrtoumax behavior slightly, in areas are not
  likely to affect any real callers, by making xstrtoumax behave more
  like the system strtol. In particular, it lets xstrtoumax support
  bases other than those required by POSIX, if the underlying
  implementation does; this removes the need for an g_assert().

  * lib/strutil/strtol.c: Do not include stdio.h.
  (xstrtoumax): Use same parameter names as POSIX, to make it
  easier for outsiders to follow. Do not require the base to be 0-36,
  as the underlying implementation is allowed to support other bases.

Sync with gnulib 16b33e6649425fcdce095f262da98b539d2f7448.

  * (xstrtoumax): Don't update *endptr if strtol doesn't.
  Also, if the underlying strtol gives an unusual error number and
  sets *endpnr = nptr, assume that's an error not a missing number.

Sync with gnulib bd1e981434c98751b1106a1744e77a27317b52b3
  * (xstrtoumax): Stop worrying about hypothetical implementations that
  are causing more confusion than the code is worth. Instead, go back
  more to old way of doing things.  None of this matters for practical
  applications.

Add commemt.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
4e9f4b97cb (user_menu_cmd): port to GPtrArray.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
bb4e152c59 (extract_line): optionally return the lengh of the line.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
bb5b35be9e (user_menu_cmd): refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
5288f994c4 (user_file_menu_cmd): move to src/usermenu.h and make inline.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
2db4f47bdd (tr_utf8_search_{first,last}): minor refactoring.
Reduce variable scope.
Call strlen(search) before loop.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
87f46330d5 (str_utf8_make_make_term_form): call strlen() one time.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
cb4c49f143 strutils: don't call strlen() in MIN() macro.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
bc79d61b2d (str_verscmp): glibification.
Use g_ascii_isdigit() instead of isdigit().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
b5f465a3d8 (filevercmp): make inline.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
f47688a781 lib/vfs/interface.c: add missed INDENT-ON, indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
3da5412999 maint/utils/update-years.sh: add tests/src/vfs/extfs/helpers-list/test_all.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
1ecda3f616 doc/NEWS: indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Dmitry Atamanov
8fc494fa63 Ticket #4572: code cleanup before 4.8.33 release
Add shtml to mc.ext.ini (closes MidnightCommander/mc#205)

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 15:05:58 +03:00
Yury V. Zaytsev
a24d45ffab Merge branch '3972_fix_illumos'
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:38 +02:00
Yury V. Zaytsev
8f723b8a7f charset: reimplement is_supported_encoding to use iconv instead of mc built-in charset table
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Andrew Borodin
f4ef5c64a4 (edit_draw_this_line): fix printable character recognition in 8-bit locales when displaying UTF-8
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Yury V. Zaytsev
c079a09612 tests: edit_complete_word_cmd - fix -Winvalid-source-encoding to make it easier to debug
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Andrew Borodin
35c103fa97 (str_crt_conv_from): handle INVALID_CONV.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Andrew Borodin
3526dfcf34 (str_nconvert_to_display, str_nconvert_to_input): handle invalid conversion.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Yury V. Zaytsev
1e0e6b5e1e charset: rename IBM866 to CP866 for iconv and adjust charset names for codeset
```
linux $ iconv -l | grep 866
866//
866NAV//
CP866//
CP866NAV//
CSIBM866//
IBM866//
IBM866NAV//

solaris $ iconv -l | grep 866
    CP866 (CP866, CP-866, CP_866, 866),
    IBM-866,

macos % iconv -l | grep 866
CP866 866 CSIBM866 IBM866 MSCP866

musl/src/locale/codepages.h: "cp866\0"
```

On glibc-based systems, codeset will be set to charmap name, on most other systems it seems to be taken from locale name.

## Linux

```
zaytsev@fedora:~$ locale -a | grep ru
ru_RU
ru_RU.cp866
ru_RU.ibm866
ru_RU.iso88595
ru_RU.koi8r
ru_RU.utf8
russian
ru_UA
ru_UA.koi8u
ru_UA.utf8

zaytsev@fedora:~/src$ LC_ALL=ru_RU.cp866 LANG=ru_RU.cp866 ./a.out
IBM866

zaytsev@fedora:~/src$ LC_ALL=ru_RU.koi8r LANG=ru_RU.koi8r ./a.out
KOI8-R

zaytsev@fedora:~/src$ LC_ALL=ru_RU.iso88595 LANG=ru_RU.iso88595 ./a.out
ISO-8859-5
```

## macOS

```
ru_RU.ISO8859-5
ru_RU.CP866
ru_RU.CP1251
ru_RU.UTF-8
ru_RU.KOI8-R
ru_RU

zaytsev@Yurys-MBP mc % LANG=ru_RU.CP866 LC_ALL=ru_RU.CP866 ./a.out
CP866

zaytsev@Yurys-MBP mc % LANG=ru_RU.ISO8859-5 LC_ALL=ru_RU.ISO8859-5 ./a.out
ISO8859-5
```

## FreeBSD

```
ru_RU.CP1251
ru_RU.CP866
ru_RU.ISO8859-5
ru_RU.KOI8-R
ru_RU.UTF-8

zaytsev@cfarm240:~ $ LANG=ru_RU.ISO8859-5 LC_ALL=ru_RU.ISO8859-5 ./a.out
ISO8859-5

zaytsev@cfarm240:~ $ LANG=ru_RU.CP866 LC_ALL=ru_RU.CP866 ./a.out
CP866
```

## Solaris

```
ru
ru.UTF-8
ru.koi8-r
ru_RU
ru_RU.ANSI1251
ru_RU.ISO8859-5
ru_RU.KOI8-R
ru_RU.UTF-8

zaytsev@gcc-solaris10:~/src$ LANG=ru_RU.ISO8859-5 LC_ALL=ru_RU.ISO8859-5 ./a.o>
ISO8859-5

zaytsev@gcc-solaris10:~/src$ LANG=ru.koi8-r LC_ALL=ru.koi8-r ./a.out
KOI8-R
```

## AIX

```
zaytsev@gcc111:[/home/zaytsev]locale -a
C
POSIX
en_US.8859-15
en_US.IBM-858
en_US.ISO8859-1
en_US

-bash-5.1$ LANG=en_US.ISO8859-1 LC_ALL=en_US.ISO8859-1 ./a.out
ISO8859-1
```

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Yury V. Zaytsev
f34e2ae715 tests: use UTF-8 to prevent creation of invalid converters
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Yury V. Zaytsev
319598df41 tests: path_len - fix assertions, now test should fail
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Yury V. Zaytsev
07e24c0289 lib/path: clarify conditions for creating converters
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Yury V. Zaytsev
ffd6fd11f7 ydiff: fix -Wdiscarded-qualifiers warning
```
../../../src/diffviewer/ydiff.c:613:17: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  613 |         next_ch = g_utf8_next_char (str);
```

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Yury V. Zaytsev
faea164957 buildsys: add warning for non-GNU gettext and fix shellcheck issues
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00