Commit Graph

143 Commits

Author SHA1 Message Date
Johannes Altmanninger
0ea77d2ec7 Ticket #4597: fix CSI parser
fish shell 4.0 wants to send sequences like "\x1b[=5u",
so strip them from the output as well.

See https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences

In future we should probably pass through some sequences like bracketed paste.

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-11-01 18:10:09 +01:00
Yury V. Zaytsev
dd12be7c82 (extract_line): remove extra const qualifier erroneously introduced in bb4e152
```
../../lib/util.c:637:7: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
  637 | const const char *
      |       ^
```

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-18 19:46:17 +02: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
6718b3ec26 Indentation using GNU indent-2.2.13.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03:00
Andrew Borodin
a802f14c2e (path_trunc): optimization.
Get rid of double conversion of path: remove passwords using
vfs_path_from_str_flags (path, VPF_STRIP_PASSWORD).

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03:00
Andrew Borodin
fe42478b97 Update copyright years.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-01-01 09:46:17 +03:00
TobiasW
f78f9b2eda Ticket #4509: support for lzo/lzop compression format.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-26 17:27:11 +03:00
Andrew Borodin
d4e59aa022 Refactoring: avoid create an empty strings.
* (name_quote): return NULL instead of an empty string.
  * (fake_name_quote): likewise.
  * (expand_format): likewise.
  * Related changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
7257f794d2 Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):

/*** forward declarations (file scope functions) *************************************************/

/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);

/*** file scope variables ************************************************************************/

static struct
{
    ...
    bcback_fn callback;
} fbuts[] =
{
    ...
    { B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
    ...
    { B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
    { B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Kian-Meng Ang
5001232704 Fix various typos in the source code (closes MidnightCommander/mc#177).
Found via `codespell -S
po,doc,./misc/syntax,./src/vfs/extfs/helpers/README.it -L
parm,rouge,sav,ect,vie,te,dum,clen,wee,dynamc,childs,ths,fo,nin,unx,nd,iif,iterm,ser,makrs,wil`

Co-authored-by: Yury V. Zaytsev <yury@shurup.com>
Signed-off-by: Kian-Meng Ang <kianmeng@cpan.org>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2023-01-28 21:38:05 +03:00
Andrew Borodin
57c61b7681 Update copyright years.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
3ad5f5502f Add Ronna (10^27), and Quetta (10^30) SI prefixes.
As voted for in Nov 2022 by the BIPM:
https://www.bipm.org/en/cgpm-2022/resolution-3

Sync with gnulib 0ad3ea4951f77835d02180021589f3a849d885f2.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
b42e58dfbc Fix detection of zip-compressed file.
(compression_type): add COMPRESSION_ZIP value.
(decompress_extension): support COMPRESSION_ZIP.
(get_compression_type): fix zip-file detection.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-09 14:06:25 +03:00
Andrew Borodin
395569c685 Ticket #4404: wrong decompressot for zip files.
In quick view panel mode, gzip is used for view zip-files.

Initial commit:
(get_compression_type): use hex values instead of octal ones.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-09 14:06:25 +03:00
Andrew Borodin
9f53bf5617 Include <stddef.h> where ptrdiff_t is used.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-03-13 13:17:26 +03:00
Andrew Borodin
2c205c5928 Update copyright years.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-03-13 13:17:26 +03:00
Andrew Borodin
4e8b00f003 Use g_get_monotonic_time() instead of g_get_real_time().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2021-11-21 15:00:39 +03:00
Andrew Borodin
c32c4b316b lib/util.c: remove unneeded include.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2021-11-21 15:00:39 +03:00
Andrew Borodin
536fb676d8 (vfs_path_free): add 2nd parameter...
...to free or not to free the string representation
of vfs_path_t object.

It allows to get rid of string duplication in following cases:

vfs_path_t *vpath;
char *path;
...
vpath = vfs_path_from_str (...);
path = g_strdup (vfs_path_as_str (vpath));
vfs_path_free (vpath);

Now we can write:

vfs_path_t *vpath;
char *path;
...
vpath = vfs_path_from_str (...);
path = vfs_path_free (vpath, FALSE);

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2021-03-14 19:52:39 +03:00
Andrew Borodin
9ee52e77c3 Ticket #4179: code clean up before 4.8.27 release.
Update copyright years.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2021-03-14 19:30:42 +03:00
Andreas Mohr
40b96b67dd (x_basename): the NULL check is unnecessary...
...because the pointer can't be NULL.

Found by Coverity.
Coverity id #110817.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2020-12-31 16:26:47 +03:00
Andreas Mohr
57f5ab7c23 Add break before empty default in switch.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2020-12-31 16:26:47 +03:00
Andrew Borodin
9040cc3476 Fix typos. 2020-12-31 16:26:46 +03:00
Andrew Borodin
78893d85b8 Drop mc_timer. Use g_get_real_time() instead.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2020-12-12 20:39:01 +03:00
Andrew Borodin
31b37a1f79 Ticket #4050: code cleanup before 4.8.25 release.
Update copyright years.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2020-02-29 19:10:17 +03:00
Andrew Borodin
f4d448629f lib/util.c: fix coding style.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2019-02-03 12:47:59 +03:00
Andrew Borodin
1dd8a47987 Ticket #3955: code cleanup before 4.8.23 release.
Update copyright years.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2019-02-03 12:44:40 +03:00
Adam Borowski
5eb9bd605e Ticket #3906: ZSTD support.
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2018-03-19 15:00:23 +03:00
Andrew Borodin
ddd645526a Update copyright years. 2018-02-04 11:30:22 +03:00
Andrew Borodin
069306eb2e Ticket #3883: size_trunc_sep() breaks on multibyte locales.
The bug was introduced in b3867a6e15.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2017-12-02 14:41:35 +03:00
Andrew Borodin
cebede5e84 (diff_two_paths): optimizate path comparision.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2017-11-17 16:01:29 +03:00
Andrew Borodin
72056890a7 (diff_two_paths): minor optimization: exit loop ASAP.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2017-11-17 16:01:29 +03:00
Andrew Borodin
02effb2499 (diff_two_paths): reduce variable scopes.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2017-11-17 16:01:29 +03:00
Andrew Borodin
e9fd11bfcd Update copyright years.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2017-01-22 19:12:55 +03:00
Andrew Borodin
28ca14d73a Aggressive use of whitespace() and whiteness() macros.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2017-01-22 18:44:22 +03:00
Andrew Borodin
496abc0e1f Rename mc_config_get_profile_root() to mc_get_profile_root()
...and move it out from lib/mcconfig.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-12-04 09:37:50 +03:00
Andrew Borodin
83504f2bb5 Revert "(size_trunc_len): align to properly use either IEC or SI prefixes with the unit B (byte)."
This reverts commit bae814d0d4.
2016-11-08 13:19:37 +03:00
Andrew Borodin
e3d457eb3d Revert "Ticket #3666: (size_trunc_len): fix segfault because of small buffer usage."
This reverts commit 3024f309c2.
2016-11-08 13:19:29 +03:00
Michael Osipov
3024f309c2 Ticket #3666: (size_trunc_len): fix segfault because of small buffer usage.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-11-06 18:30:41 +03:00
Michael Osipov
bae814d0d4 (size_trunc_len): align to properly use either IEC or SI prefixes with the unit B (byte).
Additionally always put a space between number and unit which is
required by the norms.

It is important to note that really small buffers have to be bigger than it
appears because they store bytes and non-Latin scripts need more than one byte
with UTF-8 to encode them, e.g., the string "1023 МиБ" in Russian requires
11 bytes + null terminator.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-10-26 13:33:12 +03:00
Michael Osipov
b3867a6e15 Ticket #3666: Improper use of IEC and SI prefixes for size in size_trunc().
size_trunc() has been aligned to properly use either IEC or SI prefixes with
the unit B (byte). Additionally always put a space between number and unit
which is required by the norms.

Obsolete gettext message ids have been removed and some cleaned up for
duplicate words or leading spaces.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-10-26 13:33:12 +03:00
Andrew Borodin
2151edaff2 Get rid of global variables mc_main_config and mc_panels_config.
Use mc_global.main_config and mc_global.panels_congig instead.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-05-07 16:19:02 +03:00
Andrew Borodin
28ce7e566e (load_mc_home_file): return data length.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-03-04 09:23:36 +03:00
Andrew Borodin
8fc0e1d76d Ticket #2673: support LZIP compression.
Thanks Matias A. Fonzo <selk at dragora.org> for the original patch.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-01-28 16:45:36 +03:00
Andreas Mohr
b5ccd12d32 Ticket #3523: support lz4 compress format.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-01-02 14:02:08 +03:00
Andrew Borodin
471ea781ca Update copyright years.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2016-01-01 11:48:10 +03:00
Andrew Borodin
fd4d25ae27 (strip_ctrl_codes): add missing default case.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2015-05-03 20:12:18 +03:00
Andrew Borodin
2789e6e390 Ticket #3431: add missing default cases.
Introduce -Wswitch-default check.

Some minor cosmetics.

Thanks Andreas Mohr <and at gmx dot li> for original patch.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2015-05-03 19:43:50 +03:00
Andreas Mohr
e9e6868789 is_7bit_printable() is used only if support of charset selection and conversion is disabled. 2015-05-03 19:43:49 +03:00
Andrew Borodin
b698b7e834 Ticket #3435: clang compiler fixes/cleanups.
Since O_* macros are used in lib/global.h, include <fcntl.h> there.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2015-05-03 19:43:49 +03:00