1
1
* 3035_cleanup: (29 commits)
  Indentation.
  doc/NEWS: cosmetics.
  Typo fixes.
  Fix panel recoding
  (edit_status_window): type accuracy in status displaying.
  (edit_get_save_file_as): remove extra code block.
  (symlink_dialog): indentation cosmetics.
  (panel_change_encoding): use vfs_path_as_str().
  Fix for opening some jar files
  Clarify midnight_dlg size in MSG_RESIZE handling.
  Ticket #3043: broken NCurses detection.
  Adjust progress window for file delete operation.
  (move_dir_dir): get rid of extra memory allocation.
  (copy_dir_dir): get rid of extra memory allocation.
  (erase_dir_iff_empty): get rid of extra directory name conversion.
  (recursive_erase): ret rid of extra path conversion.
  (my_mkdir): don't call mc_mkdir() twice in case of failure.
  (my_mkdir_rec): ret rid of double directory name conversion.
  (erase_dir_iff_empty): optimization.
  Add DIR_IS_DOT and DIR_IS_DOTDOT macros
  ...
Этот коммит содержится в:
Andrew Borodin 2013-07-23 14:15:50 +04:00
родитель f3037dbb79 f9eed1fcef
Коммит 89bb1013ae
54 изменённых файлов: 899 добавлений и 1179 удалений

188
doc/NEWS
Просмотреть файл

@ -2,137 +2,139 @@ Version 4.8.9
- VFS
* extfs: support unrar-5 (#3015)
* extfs: use xorriso (if exists) for writing into ISO images (#3027)
* extfs: support unrar-5 (#3015)
* extfs: use xorriso (if exists) for writing into ISO images (#3027)
- Editor
* Support unlimited file size (#1743)
* Support unlimited file size (#1743)
- Misc
* Lot of code cleanups (#2990, #2071, #2164, #2998, #3003, #3005, #3022)
* Display additional info while viewing (by F3) *.iso files (#2006)
* New skins:
- modarin256: set of 256-color skins from Oliver Lange (#2737)
* Lot of code cleanups (#2990, #2071, #2164, #2998, #3003, #3005, #3022)
* Display additional info while viewing (by F3) *.iso files (#2006)
* New skins:
- modarin256: set of 256-color skins from Oliver Lange (#2737)
- Fixes
* Fail to link if system lib does not contain strverscmp (#2992)
* Segfault when mc's temporary directory doesn't belong to the correct user (#3021)
* Race condition when creating temporary directory (#3025)
* Mouse doesn't work in screen and tmux (#3011)
* Incorrect file size in copy/move overwrite query dialog (#3000)
* Garbage in subshell prompt (#3001)
* Incorrect WLabel redraw after text change (#2991)
* Find File: "All charsets" options don't work (#3026)
* When an unknown key is pressed, it is interpreted as garbage (#2988)
* Segfault on creating new file in external editor (#3020)
* Rotating dash is not removed when mc finishes reading the directory (#2163)
* mcedit: word completion failed if word to be completed is begun from begin of file (#2245)
* mcview: broken switch between raw and parse modes (#2968)
* Hex viewer: continue search doesn't work (#2706)
* sftpfs: broken SSH aliases (#2923)
* Fail to link if system lib does not contain strverscmp (#2992)
* Segfault when mc's temporary directory doesn't belong to the correct user (#3021)
* Race condition when creating temporary directory (#3025)
* Mouse doesn't work in screen and tmux (#3011)
* Incorrect file size in copy/move overwrite query dialog (#3000)
* Garbage in subshell prompt (#3001)
* Incorrect WLabel redraw after text change (#2991)
* Find File: "All charsets" options don't work (#3026)
* When an unknown key is pressed, it is interpreted as garbage (#2988)
* Segfault on creating new file in external editor (#3020)
* Rotating dash is not removed when mc finishes reading the directory (#2163)
* mcedit: word completion failed if word to be completed is begun from begin of file (#2245)
* mcview: broken switch between raw and parse modes (#2968)
* Hex viewer: continue search doesn't work (#2706)
* sftpfs: broken SSH aliases (#2923)
Version 4.8.8
- Core
* Make copy/move progress dialog window wider up to 2/3 of screen width (#2076)
* Ask file name before create new file in editor (#2585)
* Support newer extended mouse protocol SGR-1006 instead of URXVT-1015 (#2956)
* Allow skip directory scanning before file operation. Print directory count and size in addition to directory name (#2101)
* Add jump support to target line in some external editors and viewers (#2206)
* Make copy/move progress dialog window wider up to 2/3 of screen width (#2076)
* Ask file name before create new file in editor (#2585)
* Support newer extended mouse protocol SGR-1006 instead of URXVT-1015 (#2956)
* Allow skip directory scanning before file operation. Print directory count and size in addition to directory name (#2101)
* Add jump support to target line in some external editors and viewers (#2206)
- Editor
* Update syntax highlighting:
- Jal programming language (#2855)
- gplink configuration files (.lkr extension) (#2855)
- Makefile with .mak extension (#2896)
- ZSH configuration files (#2950)
- Fortran (#2962)
* Update syntax highlighting:
- Jal programming language (#2855)
- gplink configuration files (.lkr extension) (#2855)
- Makefile with .mak extension (#2896)
- ZSH configuration files (#2950)
- Fortran (#2962)
- Misc
* Code cleanup (#2944, #2954)
* Report real compiler in MC_CHECK_ONE_CFLAG instead of 'gcc'
* Hints files now translated via Transifex (#2980)
* Code cleanup (#2944, #2954)
* Report real compiler in MC_CHECK_ONE_CFLAG instead of 'gcc'
* Hints files now translated via Transifex (#2980)
- Fixes
* Segfault in file operation due to unhandled regexp error (#2493)
* Tab completion vs. spaces and escaping (#55)\
* Special chars are not escaped in autocompletion of filenames (#2626)
* Buttons in the 'Directory hotlist' window are placed incorrectly (#2958)
* Mouse doesn't select text in subshell in native console (#2964)
* Mouse click below non-droppeddown menubar activates menu box (#2971)
* Insufficient quoting and wrong message in user menu (#2947)
* mcedit: floating point exception (division by zero) (#2953)
* mcedit: broken autocompletion (#2957)
* mcview: broken magic mode (#2976)
* Broken opening of .war archives (#2974)
* Segfault in file operation due to unhandled regexp error (#2493)
* Tab completion vs. spaces and escaping (#55)\
* Special chars are not escaped in autocompletion of filenames (#2626)
* Buttons in the 'Directory hotlist' window are placed incorrectly (#2958)
* Mouse doesn't select text in subshell in native console (#2964)
* Mouse click below non-droppeddown menubar activates menu box (#2971)
* Insufficient quoting and wrong message in user menu (#2947)
* mcedit: floating point exception (division by zero) (#2953)
* mcedit: broken autocompletion (#2957)
* mcview: broken magic mode (#2976)
* Broken opening of .war archives (#2974)
Version 4.8.7
- Core
* Minimal GLib version is 2.12.0
* Implementation of suspend/resume in copy/move file operations (#2111)
* Start of widget subsystem reimplementation (#2919)
* Minimal GLib version is 2.12.0
* Implementation of suspend/resume in copy/move file operations (#2111)
* Start of widget subsystem reimplementation (#2919)
- VFS
* uc1541 extfs plug-in updated up to version 2.5 (#2935)
* uc1541 extfs plug-in updated up to version 2.5 (#2935)
- Editor
* Reset selection after text paste (only in non-persistent selection mode) (#2660)
* Don't indent blank lines (#303).
* Add .psgi as Perl syntax highlighting (#2912)
* Place cursor after inserted chars (#319)
* Add option in ini file to save spelling language (spell_language=NONE for disable aspell support) (#2914)
* Reset selection after text paste (only in non-persistent selection mode) (#2660)
* Don't indent blank lines (#303).
* Add .psgi as Perl syntax highlighting (#2912)
* Place cursor after inserted chars (#319)
* Add option in ini file to save spelling language (spell_language=NONE for disable aspell support) (#2914)
- Misc
* Code cleanup (#2888, #1950)
* Minimal "check" utility version is 0.9.8
* Remove the empty contrib/dist/debian/ since it maintained separately in Debian (#2871)
* mc.ext updates:
- add support of SVG images (#2895)
- add support of .asm file extension (#2892)
- add support of .hh file extension (#2892)
- all file extension for source files now are case insensitive (#2892)
- add support of JNG and MNG images (#2893)
- add support of Gnumeric's spreadsheets (#2894)
- add support of .war archives (#2891)
- make a choice between arj and unarj archivers (#2890)
- make a choice between 7z and 7za archivers (#2890)
- add support of ape, aac and wvm4a media formats (#2767)
- add support of cbr and cbz comic books (#2739)
- add support of epub e-book format (#2739)
- add support of PAR archives (#2739)
- use libreoffice instead of ooffice, if found, to open ODT files (#2723)
- use dvicat if dvi2tty not found to view DVI files (#1686)
- use 'see' utility as default pdf viewer, if found (#1686)
- use 'see' utility to view images in console (#1686)
* Highlight OGV files as media (#2934)
* Added new translations:
- Persian (fa)
- Croatian (hr)
* Code cleanup (#2888, #1950)
* Minimal "check" utility version is 0.9.8
* Remove the empty contrib/dist/debian/ since it maintained separately in Debian (#2871)
* mc.ext updates:
- add support of SVG images (#2895)
- add support of .asm file extension (#2892)
- add support of .hh file extension (#2892)
- all file extension for source files now are case insensitive (#2892)
- add support of JNG and MNG images (#2893)
- add support of Gnumeric's spreadsheets (#2894)
- add support of .war archives (#2891)
- make a choice between arj and unarj archivers (#2890)
- make a choice between 7z and 7za archivers (#2890)
- add support of ape, aac and wvm4a media formats (#2767)
- add support of cbr and cbz comic books (#2739)
- add support of epub e-book format (#2739)
- add support of PAR archives (#2739)
- use libreoffice instead of ooffice, if found, to open ODT files (#2723)
- use dvicat if dvi2tty not found to view DVI files (#1686)
- use 'see' utility as default pdf viewer, if found (#1686)
- use 'see' utility to view images in console (#1686)
* Highlight OGV files as media (#2934)
* Added new translations:
- Persian (fa)
- Croatian (hr)
- Fixes
* Build failure on Cygwin (#2917)
* Fail to check ncurses library if --with-ncurses-inc and --with-ncurses-libs options are used (#2926)
* Crash on Solaris while trying to copy a file (#2906)
* CVE-2012-4463: Does not sanitize MC_EXT_SELECTED variable properly (#2913)
* Attributes of existing directories are never preserved when copying (#2924)
* Broken path completion on paths starting with ~/ (#2898)
* Terminal settings are not changed when window is resized (#2198)
* Enter into symlink to compressed patch shows empty patch (#2910)
* Test failure on Cygwin due to incorrect linkage flag (#2918)
* Non-portable test (#2883)
* Build failure on Cygwin (#2917)
* Fail to check ncurses library if --with-ncurses-inc and --with-ncurses-libs options are used (#2926)
* Crash on Solaris while trying to copy a file (#2906)
* CVE-2012-4463: Does not sanitize MC_EXT_SELECTED variable properly (#2913)
* Attributes of existing directories are never preserved when copying (#2924)
* Broken path completion on paths starting with ~/ (#2898)
* Terminal settings are not changed when window is resized (#2198)
* Enter into symlink to compressed patch shows empty patch (#2910)
* Test failure on Cygwin due to incorrect linkage flag (#2918)
* Non-portable test (#2883)
Version 4.8.6
@ -141,6 +143,7 @@ Version 4.8.6
* mcedit: two-columns extra offset of cursor after tab character (#2881)
* diffviewer: cannot open file if name contains '$' (#2873)
Version 4.8.5
- Core
@ -198,6 +201,7 @@ Version 4.8.5
* extfs: uc1541 broken handling (#2864)
* mc.ext: OGV format handled as audio (#2869)
Version 4.8.4
- Core
@ -674,7 +678,7 @@ Version 4.7.5-pre1
* Incorrect key event handling in "Listing mode" dialog (#2045)
* Usability of field history in "Find file" dialog (#2046, #2407)
* Find "Whole words" search bug (#2396)
* Directory ignorance does't work in file find (#2366, #2434)
* Directory ignorance doesn't work in file find (#2366, #2434)
* Incorrect line jump when started as editor (#2344)
* User menu in standalone mcedit doesn't show filetype-specific items (#1651)
* Configure script doesn't set samba configdir (#2419)

Просмотреть файл

@ -1,93 +0,0 @@
Hint: Use C-x t to copy tagged file names to the command line.
Hint: Use C-x p to copy the current pathname to the command line.
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.
Hint: Need to quote a character? Use Control-q and the character.
Hint: Tired of these messages? Turn them off from the Options/Layout menu.
Hint: Selecting directories: add a slash to the end of the matching pattern.
Hint: If your terminal lacks functions keys, use the ESC+number sequence.
Hint: The homepage of GNU Midnight Commander:
http://www.midnight-commander.org/
Hint: Please send any bug reports to mc-devel@gnome.org
Hint: Tab changes your current panel.
Hint: VFS coolness: tap enter on a tar file to examine its contents.
Hint: We also have a nice manual page.
Hint: Do you want lynx-style navigation? Set it in the Configuration dialog.
Hint: % macros work even on the command line.
Hint: M-! will allow you to execute programs and see the output in the
viewer.
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.
Hint: Setting the CDPATH variable can save you keystrokes in cd commands.
Hint: If you want to see your .* files, say so in the Configuration dialog.
Hint: Want to see your *~ backup files? Set it in the Configuration dialog.
Hint: Completion works on all input lines in all dialogs. Just press M-Tab.
Hint: On slow terminals the -s flag may help.
Hint: Find File: you can work on the files found using the Panelize button.
Hint: Want to do complex searches? Use the External Panelize command.
Hint: To change directory halfway through typing a command, use M-c (quick
cd).
Note: Shell commands will not work when you are on a non-local file system.
Hint: Bring text back from the dead with C-y.
Hint: Are some of your keys not working? Look at Options/Learn keys.
Hint: To look at the output of a command in the viewer, use M-!
Hint: F13 (or Shift-F3) invokes the viewer in raw mode.
Hint: You may specify the editor for F4 with the shell variable EDITOR.
Hint: You may specify the external viewer with the shell vars VIEWER or
PAGER.
Hint: You can disable all requests for confirmation in Options/Confirmation.
Hint: Leap to frequently used directories in a single bound with C-.
Hint: You can do anonymous FTP with mc by typing 'cd ftp://machine.edu'
Hint: FTP is built in the Midnight Commander, check the File/FTP link menu.
Hint: M-t changes quickly the listing mode.
Hint: You can specify the username when doing ftps: 'cd
ftp://user@machine.edu'
Hint: You can browse RPM files by tapping enter on top of an rpm file.
Hint: To mark directories on the select dialog box, append a slash.
Hint: To use the mouse cut and paste may require holding the shift key
Hint: Key frequently visited ftp sites in the hotlist: type C-.

Просмотреть файл

@ -1,96 +0,0 @@
Dritta: usa C-x t per copiare i file selezionati sulla linea di comando.
Dritta: usa C-x p per copiare il percorso corrente sulla linea di comando.
Dritta: completamento: usa M-Tab (o Esc+Tab). Due volte per la lista.
Dritta: usa M-p e M-n per accedere alla storia dei comandi.
Dritta: devi inserire un carattere speciale? Usa C-q e il carattere.
Dritta: stanco di questi messaggi? Disattivali dal menu Opzioni/Aspetto.
Dritta: selezione directory: inserisci uno slash alla fine della selezione.
Dritta: se al tuo terminale mancano i tasti funzione usa ESC+numero tasto.
Dritta: la home page del Midnight Commander:
http://www.midnight-commander.org/
Dritta: prego spedire i bug report a mc-devel@gnome.org
Dritta: tab cambia il pannello corrente.
Dritta: magico VFS; premi invio su un file tar per esaminarne il contenuto.
Dritta: c'è anche un bel manuale.
Dritta: navigazione stile lynx? Impostala in finestra di configurazione.
Dritta: le macro % funzionano anche sulla linea di comando!
Dritta: M-! permette di eseguire programmi e vedere il risultato nel viewer.
Dritta: il formato della lista file è impostabile; "man mc" per i dettagli.
Dritta: %D/%T espande i file selezionati nella directory opposta.
Dritta: vuoi la tua shell? Premi C-o e torna nuovamente a MC con C-o.
Dritta: impostare la variabile CDPATH può far risparmiare tasti nei comandi
cd.
Dritta: se vuoi vedere i tuoi file .* impostalo nella Configurazione.
Dritta: vuoi vedere i tuoi *~ file di backup? Impostalo nella
Configurazione.
Dritta: il completamento funziona su tutti gli input. Basta premere M-Tab.
Dritta: con terminali lenti può aiutare la flag -s.
Dritta: trova file: puoi elaborare i file trovati usando il bottone
Pannellizza.
Dritta: vuoi fare ricerche complesse? Usa il comando Pannellizza.
Dritta: per cambiare directory mentre batti un comando, usa M-c (cd rapido).
Nota: i comandi di shell non funzionano se non sei in un file system locale.
Dritta: riesuma il testo nell'editor integrato con C-u.
Dritta: non ti funzionano alcuni tasti? Guarda in Opzioni/Impara tasti.
Dritta: per vedere il risultato di un comando nel visualizzatore, usa M-!
Dritta: F13 (o Shift-F3) invoca il visualizzatore in modo 'raw'.
Dritta: puoi specificare l'editor per F4 con la variabile shell EDITOR.
Dritta: puoi specificare il visualizzatore esterno con la variabile shell
PAGER.
Dritta: puoi disabilitare tutte le richieste di conferma in
Opzioni/Conferme.
Hint: Leap to frequently used directories in a single bound with C-.
Dritta: puoi fare FTP anonimo con mc battendo 'cd ftp://macchina.edu'
Dritta: l'FTP è integrato nel Midnight Commander, controlla il menu FTP.
Dritta: M-t cambia velocemente il modo listato.
Dritta: puoi dare il nome utente facendo ftp: 'cd ftp://utente@macchina.edu'
Dritta: puoi navigare attraverso i file RPM battendo invio su di essi.
Dritta: per selezionare directory in Seleziona, aggiungere uno slash in
fondo.
Dritta: per usare il taglia incolla del mouse devi tener premuto il tasto
shift.
Hint: Key frequently visited ftp sites in the hotlist: type C-.

Просмотреть файл

@ -74,6 +74,9 @@
#define MC_MAXFILENAMELEN MAXNAMLEN
#define DIR_IS_DOT(x) ((x)[0] == '.' && (x)[1] == '\0')
#define DIR_IS_DOTDOT(x) ((x)[0] == '.' && (x)[1] == '.' && (x)[2] == '\0')
/*** enums ***************************************************************************************/
/*** structures declarations (and typedefs of structures)*****************************************/

Просмотреть файл

@ -1,6 +1,6 @@
/*
Skins engine.
Work with colors - backward compability
Work with colors - backward compatibility
Copyright (C) 2009, 2010, 2011, 2012
The Free Software Foundation, Inc.

Просмотреть файл

@ -493,8 +493,8 @@ int str_casecmp (const char *t1, const char *t2);
int str_ncasecmp (const char *t1, const char *t2);
/* return, how many bytes are are same from start in text and prefix
* both strings are decomposed befor comapring and return value is counted
* in decomposed form, too. caling with prefix, prefix, you get size in bytes
* both strings are decomposed before comparing and return value is counted
* in decomposed form, too. calling with prefix, prefix, you get size in bytes
* of prefix in decomposed form,
* I
*/

Просмотреть файл

@ -101,12 +101,11 @@ static estr_t
_str_convert (GIConv coder, const char *string, int size, GString * buffer)
{
estr_t state = ESTR_SUCCESS;
gchar *tmp_buff = NULL;
gssize left;
gsize bytes_read = 0;
gsize bytes_written = 0;
GError *error = NULL;
errno = 0;
errno = 0; /* FIXME: is it really needed? */
if (coder == INVALID_CONV)
return ESTR_FAILURE;
@ -121,9 +120,7 @@ _str_convert (GIConv coder, const char *string, int size, GString * buffer)
}
*/
if (size < 0)
{
size = strlen (string);
}
else
{
left = strlen (string);
@ -134,11 +131,14 @@ _str_convert (GIConv coder, const char *string, int size, GString * buffer)
left = size;
g_iconv (coder, NULL, NULL, NULL, NULL);
while (left)
while (left != 0)
{
gchar *tmp_buff;
GError *error = NULL;
tmp_buff = g_convert_with_iconv ((const gchar *) string,
left, coder, &bytes_read, &bytes_written, &error);
if (error)
if (error != NULL)
{
int code = error->code;
@ -167,17 +167,13 @@ _str_convert (GIConv coder, const char *string, int size, GString * buffer)
g_free (tmp_buff);
}
if ((int) bytes_read < left)
{
string += bytes_read + 1;
size -= (bytes_read + 1);
left -= (bytes_read + 1);
g_string_append_c (buffer, *(string - 1));
}
else
{
if ((int) bytes_read >= left)
return ESTR_PROBLEM;
}
string += bytes_read + 1;
size -= (bytes_read + 1);
left -= (bytes_read + 1);
g_string_append_c (buffer, *(string - 1));
state = ESTR_PROBLEM;
break;
@ -202,31 +198,26 @@ _str_convert (GIConv coder, const char *string, int size, GString * buffer)
return ESTR_FAILURE;
}
}
else if (tmp_buff == NULL)
{
g_string_append (buffer, string);
return ESTR_PROBLEM;
}
else if (*tmp_buff == '\0')
{
g_free (tmp_buff);
g_string_append (buffer, string);
return state;
}
else
{
if (tmp_buff != NULL)
{
if (*tmp_buff)
{
g_string_append (buffer, tmp_buff);
g_free (tmp_buff);
string += bytes_read;
left -= bytes_read;
}
else
{
g_free (tmp_buff);
g_string_append (buffer, string);
return state;
}
}
else
{
g_string_append (buffer, string);
return ESTR_PROBLEM;
}
g_string_append (buffer, tmp_buff);
g_free (tmp_buff);
string += bytes_read;
left -= bytes_read;
}
}
return state;
}
@ -251,13 +242,10 @@ str_conv_gerror_message (GError * error, const char *def_msg)
estr_t
str_vfs_convert_from (GIConv coder, const char *string, GString * buffer)
{
estr_t result;
estr_t result = ESTR_SUCCESS;
if (coder == str_cnv_not_convert)
{
g_string_append (buffer, string != NULL ? string : "");
result = ESTR_SUCCESS;
}
else
result = _str_convert (coder, string, -1, buffer);
@ -275,11 +263,13 @@ str_printf (GString * buffer, const char *format, ...)
{
va_list ap;
va_start (ap, format);
#if GLIB_CHECK_VERSION (2, 14, 0)
g_string_append_vprintf (buffer, format, ap);
#else
{
gchar *tmp;
tmp = g_strdup_vprintf (format, ap);
g_string_append (buffer, tmp);
g_free (tmp);
@ -306,14 +296,10 @@ str_translate_char (GIConv conv, const char *keys, size_t ch_size, char *output,
cnv = g_iconv (conv, (gchar **) & keys, &left, &output, &out_size);
if (cnv == (size_t) (-1))
{
return (errno == EINVAL) ? ESTR_PROBLEM : ESTR_FAILURE;
}
else
{
output[0] = '\0';
return ESTR_SUCCESS;
}
output[0] = '\0';
return ESTR_SUCCESS;
}
@ -335,15 +321,17 @@ str_detect_termencoding (void)
static int
str_test_encoding_class (const char *encoding, const char **table)
{
int t;
int result = 0;
if (encoding == NULL)
return result;
for (t = 0; table[t] != NULL; t++)
if (encoding != NULL)
{
result += (g_ascii_strncasecmp (encoding, table[t], strlen (table[t])) == 0);
int t;
for (t = 0; table[t] != NULL; t++)
if (g_ascii_strncasecmp (encoding, table[t], strlen (table[t])) == 0)
result++;
}
return result;
}
@ -351,17 +339,11 @@ static void
str_choose_str_functions (void)
{
if (str_test_encoding_class (codeset, str_utf8_encodings))
{
used_class = str_utf8_init ();
}
else if (str_test_encoding_class (codeset, str_8bit_encodings))
{
used_class = str_8bit_init ();
}
else
{
used_class = str_ascii_init ();
}
}
gboolean
@ -828,6 +810,7 @@ strrstr_skip_count (const char *haystack, const char *needle, size_t skip_count)
len = semi - haystack - 1;
}
while (skip_count-- != 0);
return semi;
}

Просмотреть файл

@ -107,25 +107,21 @@ str_8bit_cprev_char (const char **text)
static int
str_8bit_cnext_noncomb_char (const char **text)
{
if (*text[0] != '\0')
{
(*text)++;
return 1;
}
else
if (*text[0] == '\0')
return 0;
(*text)++;
return 1;
}
static int
str_8bit_cprev_noncomb_char (const char **text, const char *begin)
{
if ((*text) != begin)
{
(*text)--;
return 1;
}
else
if ((*text) == begin)
return 0;
(*text)--;
return 1;
}
static int
@ -170,6 +166,7 @@ str_8bit_toupper (const char *text, char **out, size_t * remain)
{
if (*remain <= 1)
return 0;
(*out)[0] = char_toupper (text[0]);
(*out)++;
(*remain)--;
@ -181,6 +178,7 @@ str_8bit_tolower (const char *text, char **out, size_t * remain)
{
if (*remain <= 1)
return 0;
(*out)[0] = char_tolower (text[0]);
(*out)++;
(*remain)--;
@ -217,10 +215,7 @@ str_8bit_conv_gerror_message (GError * error, const char *def_msg)
buf = g_string_new ("");
if (str_convert (conv, error->message, buf) != ESTR_FAILURE)
{
ret = buf->str;
g_string_free (buf, FALSE);
}
ret = g_string_free (buf, FALSE);
else
{
ret = g_strdup (def_msg != NULL ? def_msg : "");
@ -236,20 +231,16 @@ str_8bit_conv_gerror_message (GError * error, const char *def_msg)
static estr_t
str_8bit_vfs_convert_to (GIConv coder, const char *string, int size, GString * buffer)
{
estr_t result;
estr_t result = ESTR_SUCCESS;
if (coder == str_cnv_not_convert)
{
g_string_append_len (buffer, string, size);
result = ESTR_SUCCESS;
}
else
result = str_nconvert (coder, (char *) string, size, buffer);
return result;
}
static const char *
str_8bit_term_form (const char *text)
{
@ -264,9 +255,7 @@ str_8bit_term_form (const char *text)
length = strlen (text);
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
actual[0] = '\0';
return result;
@ -278,7 +267,7 @@ str_8bit_fit_to_term (const char *text, int width, align_crt_t just_mode)
static char result[BUF_MEDIUM];
char *actual;
size_t remain;
int ident;
int ident = 0;
size_t length;
size_t pos = 0;
@ -288,7 +277,6 @@ str_8bit_fit_to_term (const char *text, int width, align_crt_t just_mode)
if ((int) length <= width)
{
ident = 0;
switch (HIDE_FIT (just_mode))
{
case J_CENTER_LEFT:
@ -307,9 +295,8 @@ str_8bit_fit_to_term (const char *text, int width, align_crt_t just_mode)
remain -= ident;
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
if (width - length - ident > 0)
{
if (remain <= width - length - ident)
@ -318,51 +305,38 @@ str_8bit_fit_to_term (const char *text, int width, align_crt_t just_mode)
actual += width - length - ident;
}
}
else if (IS_FIT (just_mode))
{
for (; pos + 1 <= (gsize) width / 2 && remain > 1; actual++, pos++, remain--)
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
if (remain <= 1)
goto finally;
actual[0] = '~';
actual++;
remain--;
pos += length - width + 1;
for (; pos < length && remain > 1; pos++, actual++, remain--)
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
else
{
if (IS_FIT (just_mode))
switch (HIDE_FIT (just_mode))
{
for (; pos + 1 <= (gsize) width / 2 && remain > 1; actual++, pos++, remain--)
{
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
if (remain <= 1)
goto finally;
actual[0] = '~';
actual++;
remain--;
pos += length - width + 1;
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
case J_CENTER:
ident = (length - width) / 2;
break;
case J_RIGHT:
ident = length - width;
break;
}
else
{
ident = 0;
switch (HIDE_FIT (just_mode))
{
case J_CENTER:
ident = (length - width) / 2;
break;
case J_RIGHT:
ident = length - width;
break;
}
pos += ident;
for (; pos < (gsize) (ident + width) && remain > 1; pos++, actual++, remain--)
{
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
}
pos += ident;
for (; pos < (gsize) (ident + width) && remain > 1; pos++, actual++, remain--)
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
finally:
actual[0] = '\0';
return result;
@ -383,27 +357,23 @@ str_8bit_term_trim (const char *text, int width)
if (width > 0)
{
if (width < (int) length)
if (width >= (int) length)
{
if (width <= 3)
{
memset (actual, '.', width);
actual += width;
}
else
{
memset (actual, '.', 3);
actual += 3;
remain -= 3;
pos += length - width + 3;
for (; pos < length && remain > 1; pos++, actual++, remain--)
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
for (; pos < length && remain > 1; pos++, actual++, remain--)
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
else if (width <= 3)
{
memset (actual, '.', width);
actual += width;
}
else
{
memset (actual, '.', 3);
actual += 3;
remain -= 3;
pos += length - width + 3;
for (; pos < length && remain > 1; pos++, actual++, remain--)
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
@ -449,16 +419,11 @@ str_8bit_term_substring (const char *text, int start, int width)
{
pos += start;
for (; pos < length && width > 0 && remain > 1; pos++, width--, actual++, remain--)
{
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
}
for (; width > 0 && remain > 1; actual++, remain--, width--)
{
actual[0] = ' ';
}
actual[0] = '\0';
return result;
@ -480,9 +445,7 @@ str_8bit_trunc (const char *text, int width)
if ((int) length > width)
{
for (; pos + 1 <= (gsize) width / 2 && remain > 1; actual++, pos++, remain--)
{
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
if (remain <= 1)
goto finally;
@ -491,18 +454,13 @@ str_8bit_trunc (const char *text, int width)
remain--;
pos += length - width + 1;
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
}
else
{
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
}
finally:
@ -543,24 +501,24 @@ str_8bit_strdown (const char *str)
{
char *rets, *p;
rets = g_strdup (str);
if (rets == NULL)
if (str == NULL)
return NULL;
rets = g_strdup (str);
for (p = rets; *p != '\0'; p++)
*p = char_tolower (*p);
return rets;
}
static const char *
str_8bit_search_first (const char *text, const char *search, int case_sen)
{
char *fold_text;
char *fold_search;
const char *match;
size_t offsset;
size_t offset;
fold_text = (case_sen) ? (char *) text : str_8bit_strdown (text);
fold_search = (case_sen) ? (char *) search : str_8bit_strdown (search);
@ -568,8 +526,8 @@ str_8bit_search_first (const char *text, const char *search, int case_sen)
match = g_strstr_len (fold_text, -1, fold_search);
if (match != NULL)
{
offsset = match - fold_text;
match = text + offsset;
offset = match - fold_text;
match = text + offset;
}
if (!case_sen)
@ -587,7 +545,7 @@ str_8bit_search_last (const char *text, const char *search, int case_sen)
char *fold_text;
char *fold_search;
const char *match;
size_t offsset;
size_t offset;
fold_text = (case_sen) ? (char *) text : str_8bit_strdown (text);
fold_search = (case_sen) ? (char *) search : str_8bit_strdown (search);
@ -595,8 +553,8 @@ str_8bit_search_last (const char *text, const char *search, int case_sen)
match = g_strrstr_len (fold_text, -1, fold_search);
if (match != NULL)
{
offsset = match - fold_text;
match = text + offsset;
offset = match - fold_text;
match = text + offset;
}
if (!case_sen)
@ -684,10 +642,11 @@ str_8bit_ncasecmp (const char *s1, const char *s2)
s2++;
}
if (n != 0)
return (((gint) (guchar) * s1) - ((gint) (guchar) * s2));
else
if (n == 0)
return 0;
return (((gint) (guchar) * s1) - ((gint) (guchar) * s2));
#endif
}
@ -695,8 +654,10 @@ static int
str_8bit_prefix (const char *text, const char *prefix)
{
int result;
for (result = 0; text[result] != '\0' && prefix[result] != '\0'
&& text[result] == prefix[result]; result++);
return result;
}
@ -704,13 +665,13 @@ static int
str_8bit_caseprefix (const char *text, const char *prefix)
{
int result;
for (result = 0; text[result] != '\0' && prefix[result] != '\0'
&& char_toupper (text[result]) == char_toupper (prefix[result]); result++);
return result;
}
static void
str_8bit_fix_string (char *text)
{

Просмотреть файл

@ -73,25 +73,21 @@ str_ascii_cprev_char (const char **text)
static int
str_ascii_cnext_noncomb_char (const char **text)
{
if (*text[0] != '\0')
{
(*text)++;
return 1;
}
else
if (*text[0] == '\0')
return 0;
(*text)++;
return 1;
}
static int
str_ascii_cprev_noncomb_char (const char **text, const char *begin)
{
if ((*text) != begin)
{
(*text)--;
return 1;
}
else
if ((*text) == begin)
return 0;
(*text)--;
return 1;
}
static int
@ -136,6 +132,7 @@ str_ascii_toupper (const char *text, char **out, size_t * remain)
{
if (*remain <= 1)
return 0;
(*out)[0] = (char) g_ascii_toupper ((gchar) text[0]);
(*out)++;
(*remain)--;
@ -147,6 +144,7 @@ str_ascii_tolower (const char *text, char **out, size_t * remain)
{
if (*remain <= 1)
return 0;
(*out)[0] = (char) g_ascii_tolower ((gchar) text[0]);
(*out)++;
(*remain)--;
@ -169,7 +167,7 @@ static gchar *
str_ascii_conv_gerror_message (GError * error, const char *def_msg)
{
/* the same as str_utf8_conv_gerror_message() */
if ((error != NULL) && (error->message != NULL))
if (error != NULL)
return g_strdup (error->message);
return g_strdup (def_msg != NULL ? def_msg : "");
@ -183,7 +181,6 @@ str_ascii_vfs_convert_to (GIConv coder, const char *string, int size, GString *
return ESTR_SUCCESS;
}
static const char *
str_ascii_term_form (const char *text)
{
@ -214,7 +211,7 @@ str_ascii_fit_to_term (const char *text, int width, align_crt_t just_mode)
static char result[BUF_MEDIUM];
char *actual;
size_t remain;
int ident;
int ident = 0;
size_t length;
size_t pos = 0;
@ -224,7 +221,6 @@ str_ascii_fit_to_term (const char *text, int width, align_crt_t just_mode)
if ((int) length <= width)
{
ident = 0;
switch (HIDE_FIT (just_mode))
{
case J_CENTER_LEFT:
@ -259,56 +255,53 @@ str_ascii_fit_to_term (const char *text, int width, align_crt_t just_mode)
actual += width - length - ident;
}
}
else
else if (IS_FIT (just_mode))
{
if (IS_FIT (just_mode))
/* copy prefix of text, that is not wider than width / 2 */
for (; pos + 1 <= (gsize) width / 2 && remain > 1; actual++, pos++, remain--)
{
/* copy prefix of text, that is not wider than width / 2 */
for (; pos + 1 <= (gsize) width / 2 && remain > 1; actual++, pos++, remain--)
{
actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
}
if (remain <= 1)
goto finally;
actual[0] = '~';
actual++;
remain--;
pos += length - width + 1;
/* copy suffix of text */
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
}
actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
}
else
if (remain <= 1)
goto finally;
actual[0] = '~';
actual++;
remain--;
pos += length - width + 1;
/* copy suffix of text */
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
ident = 0;
switch (HIDE_FIT (just_mode))
{
case J_CENTER:
ident = (length - width) / 2;
break;
case J_RIGHT:
ident = length - width;
break;
}
/* copy substring text, substring start from ident and take width
* characters from text */
pos += ident;
for (; pos < (gsize) (ident + width) && remain > 1; pos++, actual++, remain--)
{
actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
}
actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
}
}
else
{
switch (HIDE_FIT (just_mode))
{
case J_CENTER:
ident = (length - width) / 2;
break;
case J_RIGHT:
ident = length - width;
break;
}
/* copy substring text, substring start from ident and take width
* characters from text */
pos += ident;
for (; pos < (gsize) (ident + width) && remain > 1; pos++, actual++, remain--)
{
actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
}
}
finally:
actual[0] = '\0';
return result;
@ -330,32 +323,29 @@ str_ascii_term_trim (const char *text, int width)
if (width > 0)
{
if (width < (int) length)
if (width >= (int) length)
{
if (width <= 3)
/* copy all characters */
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
memset (actual, '.', width);
actual += width;
}
else
{
memset (actual, '.', 3);
actual += 3;
remain -= 3;
pos += length - width + 3;
/* copy suffix of text */
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
}
actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
}
}
else if (width <= 3)
{
memset (actual, '.', width);
actual += width;
}
else
{
/* copy all characters */
memset (actual, '.', 3);
actual += 3;
remain -= 3;
pos += length - width + 3;
/* copy suffix of text */
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
@ -414,9 +404,7 @@ str_ascii_term_substring (const char *text, int start, int width)
/* if text is shorter then width, add space to the end */
for (; width > 0 && remain > 1; actual++, remain--, width--)
{
actual[0] = ' ';
}
actual[0] = '\0';
return result;
@ -585,9 +573,7 @@ static void
str_ascii_fix_string (char *text)
{
for (; text[0] != '\0'; text++)
{
text[0] = ((unsigned char) text[0] < 128) ? text[0] : '?';
}
}
static char *
@ -614,8 +600,10 @@ static int
str_ascii_prefix (const char *text, const char *prefix)
{
int result;
for (result = 0; text[result] != '\0' && prefix[result] != '\0'
&& text[result] == prefix[result]; result++);
return result;
}
@ -623,12 +611,13 @@ static int
str_ascii_caseprefix (const char *text, const char *prefix)
{
int result;
for (result = 0; text[result] != '\0' && prefix[result] != '\0'
&& g_ascii_toupper (text[result]) == g_ascii_toupper (prefix[result]); result++);
return result;
}
struct str_class
str_ascii_init (void)
{

Просмотреть файл

@ -64,9 +64,9 @@ str_utf8_is_valid_char (const char *ch, size_t size)
switch (g_utf8_get_char_validated (ch, size))
{
case (gunichar) (-2):
return -2;
return (-2);
case (gunichar) (-1):
return -1;
return (-1);
default:
return 1;
}
@ -96,8 +96,10 @@ str_utf8_cnext_char_safe (const char **text)
static void
str_utf8_cprev_char_safe (const char **text)
{
const char *result = g_utf8_prev_char (*text);
const char *t = result;
const char *result, *t;
result = g_utf8_prev_char (*text);
t = result;
str_utf8_cnext_char_safe (&t);
if (t == *text)
(*text) = result;
@ -108,15 +110,13 @@ str_utf8_cprev_char_safe (const char **text)
static void
str_utf8_fix_string (char *text)
{
gunichar uni;
while (text[0] != '\0')
{
gunichar uni;
uni = g_utf8_get_char_validated (text, -1);
if ((uni != (gunichar) (-1)) && (uni != (gunichar) (-2)))
{
text = g_utf8_next_char (text);
}
else
{
text[0] = '?';
@ -128,42 +128,54 @@ str_utf8_fix_string (char *text)
static int
str_utf8_isspace (const char *text)
{
gunichar uni = g_utf8_get_char_validated (text, -1);
gunichar uni;
uni = g_utf8_get_char_validated (text, -1);
return g_unichar_isspace (uni);
}
static int
str_utf8_ispunct (const char *text)
{
gunichar uni = g_utf8_get_char_validated (text, -1);
gunichar uni;
uni = g_utf8_get_char_validated (text, -1);
return g_unichar_ispunct (uni);
}
static int
str_utf8_isalnum (const char *text)
{
gunichar uni = g_utf8_get_char_validated (text, -1);
gunichar uni;
uni = g_utf8_get_char_validated (text, -1);
return g_unichar_isalnum (uni);
}
static int
str_utf8_isdigit (const char *text)
{
gunichar uni = g_utf8_get_char_validated (text, -1);
gunichar uni;
uni = g_utf8_get_char_validated (text, -1);
return g_unichar_isdigit (uni);
}
static int
str_utf8_isprint (const char *ch)
{
gunichar uni = g_utf8_get_char_validated (ch, -1);
gunichar uni;
uni = g_utf8_get_char_validated (ch, -1);
return g_unichar_isprint (uni);
}
static gboolean
str_utf8_iscombiningmark (const char *ch)
{
gunichar uni = g_utf8_get_char_validated (ch, -1);
gunichar uni;
uni = g_utf8_get_char_validated (ch, -1);
return str_unichar_iscombiningmark (uni);
}
@ -171,6 +183,7 @@ static int
str_utf8_cnext_noncomb_char (const char **text)
{
int count = 0;
while ((*text)[0] != '\0')
{
str_utf8_cnext_char_safe (text);
@ -178,6 +191,7 @@ str_utf8_cnext_noncomb_char (const char **text)
if (!str_utf8_iscombiningmark (*text))
break;
}
return count;
}
@ -185,6 +199,7 @@ static int
str_utf8_cprev_noncomb_char (const char **text, const char *begin)
{
int count = 0;
while ((*text) != begin)
{
str_utf8_cprev_char_safe (text);
@ -192,6 +207,7 @@ str_utf8_cprev_noncomb_char (const char **text, const char *begin)
if (!str_utf8_iscombiningmark (*text))
break;
}
return count;
}
@ -248,24 +264,16 @@ str_utf8_length (const char *text)
while (!g_utf8_validate (start, -1, &end) && start[0] != '\0')
{
if (start != end)
{
result += g_utf8_strlen (start, end - start);
}
result++;
start = end + 1;
}
if (start == text)
{
result = g_utf8_strlen (text, -1);
}
else
{
if (start[0] != '\0' && start != end)
{
result += g_utf8_strlen (start, end - start);
}
}
else if (start[0] != '\0' && start != end)
result += g_utf8_strlen (start, end - start);
return result;
}
@ -291,16 +299,9 @@ str_utf8_length2 (const char *text, int size)
}
if (start == text)
{
result = g_utf8_strlen (text, size);
}
else
{
if (start[0] != '\0' && start != end && size > 0)
{
result += g_utf8_strlen (start, min (end - start, size));
}
}
else if (start[0] != '\0' && start != end && size > 0)
result += g_utf8_strlen (start, min (end - start, size));
return result;
}
@ -334,7 +335,7 @@ str_utf8_length_noncomb (const char *text)
static gchar *
str_utf8_conv_gerror_message (GError * error, const char *def_msg)
{
if ((error != NULL) && (error->message != NULL))
if (error != NULL)
return g_strdup (error->message);
return g_strdup (def_msg != NULL ? def_msg : "");
@ -343,13 +344,10 @@ str_utf8_conv_gerror_message (GError * error, const char *def_msg)
static estr_t
str_utf8_vfs_convert_to (GIConv coder, const char *string, int size, GString * buffer)
{
estr_t result;
estr_t result = ESTR_SUCCESS;
if (coder == str_cnv_not_convert)
{
g_string_append_len (buffer, string, size);
result = ESTR_SUCCESS;
}
else
result = str_nconvert (coder, (char *) string, size, buffer);
@ -383,15 +381,13 @@ str_utf8_make_make_term_form (const char *text, size_t length)
if (length != 0 && text[0] != '\0')
{
uni = g_utf8_get_char_validated (text, -1);
if ((uni != (gunichar) (-1)) && (uni != (gunichar) (-2)))
if ((uni != (gunichar) (-1)) && (uni != (gunichar) (-2))
&& str_unichar_iscombiningmark (uni))
{
if (str_unichar_iscombiningmark (uni))
{
actual[0] = ' ';
actual++;
result.width++;
result.compose = TRUE;
}
actual[0] = ' ';
actual++;
result.width++;
result.compose = TRUE;
}
}
@ -429,6 +425,7 @@ str_utf8_make_make_term_form (const char *text, size_t length)
actual += strlen (replch);
result.width++;
}
if (length != (size_t) (-1))
length--;
}
@ -452,9 +449,8 @@ str_utf8_term_form (const char *text)
g_free (composed);
}
else
{
g_strlcpy (result, pre_form->text, sizeof (result));
}
return result;
}
@ -471,13 +467,13 @@ struct utf8_tool
static gboolean
utf8_tool_copy_chars_to_end (struct utf8_tool *tool)
{
size_t left;
gunichar uni;
tool->compose = FALSE;
while (tool->cheked[0] != '\0')
{
gunichar uni;
size_t left;
uni = g_utf8_get_char (tool->cheked);
tool->compose = tool->compose || str_unichar_iscombiningmark (uni);
left = g_unichar_to_utf8 (uni, NULL);
@ -488,6 +484,7 @@ utf8_tool_copy_chars_to_end (struct utf8_tool *tool)
tool->remain -= left;
tool->cheked = g_utf8_next_char (tool->cheked);
}
return TRUE;
}
@ -496,16 +493,18 @@ utf8_tool_copy_chars_to_end (struct utf8_tool *tool)
static gboolean
utf8_tool_copy_chars_to (struct utf8_tool *tool, int to_ident)
{
size_t left;
gunichar uni;
int w;
tool->compose = FALSE;
while (tool->cheked[0] != '\0')
{
gunichar uni;
size_t left;
int w = 0;
uni = g_utf8_get_char (tool->cheked);
if (!str_unichar_iscombiningmark (uni))
if (str_unichar_iscombiningmark (uni))
tool->compose = TRUE;
else
{
w = 1;
if (g_unichar_iswide (uni))
@ -513,11 +512,6 @@ utf8_tool_copy_chars_to (struct utf8_tool *tool, int to_ident)
if (tool->ident + w > to_ident)
return TRUE;
}
else
{
w = 0;
tool->compose = TRUE;
}
left = g_unichar_to_utf8 (uni, NULL);
if (tool->remain <= left)
@ -528,6 +522,7 @@ utf8_tool_copy_chars_to (struct utf8_tool *tool, int to_ident)
tool->cheked = g_utf8_next_char (tool->cheked);
tool->ident += w;
}
return TRUE;
}
@ -539,6 +534,7 @@ utf8_tool_insert_space (struct utf8_tool *tool, int count)
return 1;
if (tool->remain <= (gsize) count)
return 0;
memset (tool->actual, ' ', count);
tool->actual += count;
tool->remain -= count;
@ -551,6 +547,7 @@ utf8_tool_insert_char (struct utf8_tool *tool, char ch)
{
if (tool->remain <= 1)
return 0;
tool->actual[0] = ch;
tool->actual++;
tool->remain--;
@ -575,24 +572,27 @@ utf8_tool_skip_chars_to (struct utf8_tool *tool, int to_ident)
}
tool->cheked = g_utf8_next_char (tool->cheked);
}
uni = g_utf8_get_char (tool->cheked);
while (str_unichar_iscombiningmark (uni))
{
tool->cheked = g_utf8_next_char (tool->cheked);
uni = g_utf8_get_char (tool->cheked);
}
return TRUE;
}
static void
utf8_tool_compose (char *buffer, size_t size)
{
char *composed = g_utf8_normalize (buffer, -1, G_NORMALIZE_DEFAULT_COMPOSE);
char *composed;
composed = g_utf8_normalize (buffer, -1, G_NORMALIZE_DEFAULT_COMPOSE);
g_strlcpy (buffer, composed, size);
g_free (composed);
}
static const char *
str_utf8_fit_to_term (const char *text, int width, align_crt_t just_mode)
{
@ -624,37 +624,34 @@ str_utf8_fit_to_term (const char *text, int width, align_crt_t just_mode)
utf8_tool_copy_chars_to_end (&tool);
utf8_tool_insert_space (&tool, width - pre_form->width - tool.ident);
}
else if (IS_FIT (just_mode))
{
tool.ident = 0;
utf8_tool_copy_chars_to (&tool, width / 2);
utf8_tool_insert_char (&tool, '~');
tool.ident = 0;
utf8_tool_skip_chars_to (&tool, pre_form->width - width + 1);
utf8_tool_copy_chars_to_end (&tool);
utf8_tool_insert_space (&tool, width - (pre_form->width - tool.ident + 1));
}
else
{
if (IS_FIT (just_mode))
tool.ident = 0;
switch (HIDE_FIT (just_mode))
{
tool.ident = 0;
utf8_tool_copy_chars_to (&tool, width / 2);
utf8_tool_insert_char (&tool, '~');
tool.ident = 0;
utf8_tool_skip_chars_to (&tool, pre_form->width - width + 1);
utf8_tool_copy_chars_to_end (&tool);
utf8_tool_insert_space (&tool, width - (pre_form->width - tool.ident + 1));
case J_CENTER:
tool.ident = (width - pre_form->width) / 2;
break;
case J_RIGHT:
tool.ident = width - pre_form->width;
break;
}
else
{
tool.ident = 0;
switch (HIDE_FIT (just_mode))
{
case J_CENTER:
tool.ident = (width - pre_form->width) / 2;
break;
case J_RIGHT:
tool.ident = width - pre_form->width;
break;
}
utf8_tool_skip_chars_to (&tool, 0);
utf8_tool_insert_space (&tool, tool.ident);
utf8_tool_copy_chars_to (&tool, width);
utf8_tool_insert_space (&tool, width - tool.ident);
}
utf8_tool_skip_chars_to (&tool, 0);
utf8_tool_insert_space (&tool, tool.ident);
utf8_tool_copy_chars_to (&tool, width);
utf8_tool_insert_space (&tool, width - tool.ident);
}
tool.actual[0] = '\0';
@ -683,27 +680,22 @@ str_utf8_term_trim (const char *text, int width)
tool.remain = sizeof (result);
tool.compose = FALSE;
if ((gsize) width < pre_form->width)
if ((gsize) width >= pre_form->width)
utf8_tool_copy_chars_to_end (&tool);
else if (width <= 3)
{
if (width <= 3)
{
memset (tool.actual, '.', width);
tool.actual += width;
tool.remain -= width;
}
else
{
memset (tool.actual, '.', 3);
tool.actual += 3;
tool.remain -= 3;
tool.ident = 0;
utf8_tool_skip_chars_to (&tool, pre_form->width - width + 3);
utf8_tool_copy_chars_to_end (&tool);
}
memset (tool.actual, '.', width);
tool.actual += width;
tool.remain -= width;
}
else
{
memset (tool.actual, '.', 3);
tool.actual += 3;
tool.remain -= 3;
tool.ident = 0;
utf8_tool_skip_chars_to (&tool, pre_form->width - width + 3);
utf8_tool_copy_chars_to_end (&tool);
}
@ -731,7 +723,9 @@ str_utf8_term_width1 (const char *text)
static int
str_utf8_term_char_width (const char *text)
{
gunichar uni = g_utf8_get_char_validated (text, -1);
gunichar uni;
uni = g_utf8_get_char_validated (text, -1);
return (str_unichar_iscombiningmark (uni)) ? 0 : ((g_unichar_iswide (uni)) ? 2 : 1);
}
@ -778,7 +772,9 @@ str_utf8_trunc (const char *text, int width)
tool.remain = sizeof (result);
tool.compose = FALSE;
if (pre_form->width > (gsize) width)
if (pre_form->width <= (gsize) width)
utf8_tool_copy_chars_to_end (&tool);
else
{
tool.ident = 0;
utf8_tool_copy_chars_to (&tool, width / 2);
@ -788,10 +784,6 @@ str_utf8_trunc (const char *text, int width)
utf8_tool_skip_chars_to (&tool, pre_form->width - width + 1);
utf8_tool_copy_chars_to_end (&tool);
}
else
{
utf8_tool_copy_chars_to_end (&tool);
}
tool.actual[0] = '\0';
if (tool.compose)
@ -807,8 +799,9 @@ str_utf8_offset_to_pos (const char *text, size_t length)
else
{
int result;
GString *buffer = g_string_new (text);
GString *buffer;
buffer = g_string_new (text);
str_utf8_fix_string (buffer->str);
result = g_utf8_offset_to_pointer (buffer->str, length) - buffer->str;
g_string_free (buffer, TRUE);
@ -819,15 +812,13 @@ str_utf8_offset_to_pos (const char *text, size_t length)
static int
str_utf8_column_to_pos (const char *text, size_t pos)
{
static int result;
gunichar uni;
int width;
width = 0;
result = 0;
int result = 0;
int width = 0;
while (text[0] != '\0')
{
gunichar uni;
uni = g_utf8_get_char_validated (text, 6);
if ((uni != (gunichar) (-1)) && (uni != (gunichar) (-2)))
{
@ -851,6 +842,7 @@ str_utf8_column_to_pos (const char *text, size_t pos)
text++;
width++;
}
if ((gsize) width > pos)
return result;
@ -863,30 +855,26 @@ str_utf8_column_to_pos (const char *text, size_t pos)
static char *
str_utf8_create_search_needle (const char *needle, int case_sen)
{
if (needle != NULL)
{
if (case_sen)
{
return g_utf8_normalize (needle, -1, G_NORMALIZE_ALL);
}
else
{
char *fold = g_utf8_casefold (needle, -1);
char *result = g_utf8_normalize (fold, -1, G_NORMALIZE_ALL);
g_free (fold);
return result;
}
}
else
char *fold, *result;
if (needle == NULL)
return NULL;
if (case_sen)
return g_utf8_normalize (needle, -1, G_NORMALIZE_ALL);
fold = g_utf8_casefold (needle, -1);
result = g_utf8_normalize (fold, -1, G_NORMALIZE_ALL);
g_free (fold);
return result;
}
static void
str_utf8_release_search_needle (char *needle, int case_sen)
{
(void) case_sen;
if (needle != NULL)
g_free (needle);
g_free (needle);
}
static const char *
@ -910,7 +898,6 @@ str_utf8_search_first (const char *text, const char *search, int case_sen)
if ((!str_utf8_iscombiningmark (match) || (match == deco_text)) &&
!str_utf8_iscombiningmark (match + strlen (search)))
{
result = text;
m = deco_text;
while (m < match)
@ -920,9 +907,7 @@ str_utf8_search_first (const char *text, const char *search, int case_sen)
}
}
else
{
str_utf8_cnext_char (&match);
}
}
}
while (match != NULL && result == NULL);
@ -954,7 +939,6 @@ str_utf8_search_last (const char *text, const char *search, int case_sen)
if ((!str_utf8_iscombiningmark (match) || (match == deco_text)) &&
!str_utf8_iscombiningmark (match + strlen (search)))
{
result = text;
m = deco_text;
while (m < match)
@ -964,9 +948,7 @@ str_utf8_search_last (const char *text, const char *search, int case_sen)
}
}
else
{
match[0] = '\0';
}
}
}
while (match != NULL && result == NULL);
@ -1091,12 +1073,15 @@ static int
str_utf8_ncompare (const char *t1, const char *t2)
{
char *n1, *n2;
size_t l1, l2;
int result;
n1 = str_utf8_normalize (t1);
n2 = str_utf8_normalize (t2);
result = strncmp (n1, n2, min (strlen (n1), strlen (n2)));
l1 = strlen (n1);
l2 = strlen (n2);
result = strncmp (n1, n2, min (l1, l2));
g_free (n1);
g_free (n2);
@ -1125,12 +1110,15 @@ static int
str_utf8_ncasecmp (const char *t1, const char *t2)
{
char *n1, *n2;
size_t l1, l2;
int result;
n1 = str_utf8_casefold_normalize (t1);
n2 = str_utf8_casefold_normalize (t2);
result = strncmp (n1, n2, min (strlen (n1), strlen (n2)));
l1 = strlen (n1);
l2 = strlen (n2);
result = strncmp (n1, n2, min (l1, l2));
g_free (n1);
g_free (n2);
@ -1141,14 +1129,18 @@ str_utf8_ncasecmp (const char *t1, const char *t2)
static int
str_utf8_prefix (const char *text, const char *prefix)
{
char *t = str_utf8_normalize (text);
char *p = str_utf8_normalize (prefix);
const char *nt = t;
const char *np = p;
const char *nnt = t;
const char *nnp = p;
char *t, *p;
const char *nt, *np;
const char *nnt, *nnp;
int result;
t = str_utf8_normalize (text);
p = str_utf8_normalize (prefix);
nt = t;
np = p;
nnt = t;
nnp = p;
while (nt[0] != '\0' && np[0] != '\0')
{
str_utf8_cnext_char_safe (&nnt);
@ -1172,14 +1164,18 @@ str_utf8_prefix (const char *text, const char *prefix)
static int
str_utf8_caseprefix (const char *text, const char *prefix)
{
char *t = str_utf8_casefold_normalize (text);
char *p = str_utf8_casefold_normalize (prefix);
const char *nt = t;
const char *np = p;
const char *nnt = t;
const char *nnp = p;
char *t, *p;
const char *nt, *np;
const char *nnt, *nnp;
int result;
t = str_utf8_casefold_normalize (text);
p = str_utf8_casefold_normalize (prefix);
nt = t;
np = p;
nnt = t;
nnp = p;
while (nt[0] != '\0' && np[0] != '\0')
{
str_utf8_cnext_char_safe (&nnt);
@ -1207,9 +1203,7 @@ str_utf8_create_key_gen (const char *text, int case_sen,
char *result;
if (case_sen)
{
result = str_utf8_normalize (text);
}
else
{
gboolean dot;

Просмотреть файл

@ -5,9 +5,11 @@
#ifdef USE_NCURSES
#ifdef HAVE_NCURSES_CURSES_H
#include <ncurses/curses.h>
#elif HAVE_NCURSES_NCURSES_H || HAVE_NCURSESW_CURSES_H
#elif defined (HAVE_NCURSES_NCURSES_H)
#include <ncurses/ncurses.h>
#elif HAVE_NCURSES_HCURSES_H || HAVE_NCURSES_H
#elif defined (HAVE_NCURSESW_CURSES_H)
#include <ncursesw/curses.h>
#elif defined (HAVE_NCURSES_HCURSES_H) || defined (HAVE_NCURSES_H)
#include <ncurses.h>
#else
#include <curses.h>

Просмотреть файл

@ -800,7 +800,7 @@ vfs_parse_ls_lga (const char *p, struct stat * s, char **filename, char **linkna
if (num_spaces != NULL)
{
*num_spaces = column_ptr[idx] - column_ptr[idx - 1] - strlen (columns[idx - 1]);
if (strcmp (columns[idx], "..") == 0)
if (DIR_IS_DOTDOT (columns[idx]))
vfs_parce_ls_final_num_spaces = *num_spaces;
}

Просмотреть файл

@ -1033,6 +1033,39 @@ vfs_path_element_need_cleanup_converter (const vfs_path_element_t * element)
{
return (element->dir.converter != str_cnv_from_term && element->dir.converter != INVALID_CONV);
}
/* --------------------------------------------------------------------------------------------- */
/**
* Change encoding for last part (vfs_path_element_t) of vpath
*
* @param vpath pointer to path structure
* encoding name of charset
*
* @return pointer to path structure (for use function in anoter functions)
*/
vfs_path_t *
vfs_path_change_encoding (vfs_path_t * vpath, const char *encoding)
{
vfs_path_element_t *path_element;
path_element = (vfs_path_element_t *) vfs_path_get_by_index (vpath, -1);
/* don't add current encoding */
if ((path_element->encoding != NULL) && (strcmp (encoding, path_element->encoding) == 0))
return vpath;
g_free (path_element->encoding);
path_element->encoding = g_strdup (encoding);
if (vfs_path_element_need_cleanup_converter (path_element))
str_close_conv (path_element->dir.converter);
path_element->dir.converter = str_crt_conv_from (path_element->encoding);
g_free (vpath->str);
vpath->str = vfs_path_to_str_flags (vpath, 0, VPF_NONE);
return vpath;
}
#endif
/* --------------------------------------------------------------------------------------------- */

Просмотреть файл

@ -83,6 +83,7 @@ struct vfs_class *vfs_prefix_to_class (const char *prefix);
#ifdef HAVE_CHARSET
gboolean vfs_path_element_need_cleanup_converter (const vfs_path_element_t * element);
vfs_path_t *vfs_path_change_encoding (vfs_path_t * vpath, const char *encoding);
#endif
char *vfs_path_serialize (const vfs_path_t * vpath, GError ** error);

Просмотреть файл

@ -588,40 +588,6 @@ _vfs_get_cwd (void)
}
/* --------------------------------------------------------------------------------------------- */
#ifdef HAVE_CHARSET
/**
* Change encoding for last part (vfs_path_element_t) of vpath
*
* @param vpath pointer to path structure
* encoding name of charset
*
* @return pointer to path structure (for use function in anoter functions)
*/
vfs_path_t *
vfs_change_encoding (vfs_path_t * vpath, const char *encoding)
{
vfs_path_element_t *path_element;
path_element = (vfs_path_element_t *) vfs_path_get_by_index (vpath, -1);
/* don't add current encoding */
if ((path_element->encoding != NULL) && (strcmp (encoding, path_element->encoding) == 0))
return vpath;
g_free (path_element->encoding);
path_element->encoding = g_strdup (encoding);
if (vfs_path_element_need_cleanup_converter (path_element))
str_close_conv (path_element->dir.converter);
path_element->dir.converter = str_crt_conv_from (path_element->encoding);
return vpath;
}
#endif /* HAVE_CHARSET */
/* --------------------------------------------------------------------------------------------- */
/**
* Preallocate space for file in new place for ensure that file
* will be fully copied with less fragmentation.

Просмотреть файл

@ -272,10 +272,6 @@ void vfs_free_handle (int handle);
void vfs_setup_cwd (void);
char *_vfs_get_cwd (void);
#ifdef HAVE_CHARSET
vfs_path_t *vfs_change_encoding (vfs_path_t * vpath, const char *encoding);
#endif
int vfs_preallocate (int dest_desc, off_t src_fsize, off_t dest_fsize);
/**

Просмотреть файл

@ -97,7 +97,7 @@ struct WDialog
/* Internal variables */
GList *widgets; /* widgets list */
GList *current; /* Curently active widget */
GList *current; /* Currently active widget */
unsigned long widget_id; /* maximum id of all widgets */
void *data; /* Data can be passed to dialog */
char *event_group; /* Name of event group for this dialog */

Просмотреть файл

@ -509,7 +509,7 @@ copy_region (WInput * in, int x_first, int x_last)
if (last == first)
{
/* Copy selected files to clipboard */
mc_event_raise (MCEVENT_GROUP_FILEMANAGER, "panel_save_curent_file_to_clip_file", NULL);
mc_event_raise (MCEVENT_GROUP_FILEMANAGER, "panel_save_current_file_to_clip_file", NULL);
/* try use external clipboard utility */
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", NULL);
return;

Просмотреть файл

@ -213,7 +213,7 @@ filename_completion_function (const char *text, int state, input_complete_t flag
All entries except "." and ".." match. */
if (filename_len == 0)
{
if (!strcmp (entry->d_name, ".") || !strcmp (entry->d_name, ".."))
if (DIR_IS_DOT (entry->d_name) || DIR_IS_DOTDOT (entry->d_name))
continue;
}
else

Просмотреть файл

@ -685,6 +685,11 @@ type/i/^zip\ archive
Open=%cd %p/uzip://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip
# jar(zip)
type/i/^Java\ Jar\ file\ data\ \(zip\)
Open=%cd %p/uzip://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip
# zoo
shell/i/.zoo
Open=%cd %p/uzoo://

Просмотреть файл

@ -144,7 +144,7 @@ context default
keyword whole dstring yellow
keyword whole wstring yellow
# D array atributes
# D array attributes
keyword wholeright .sizeof yellow
keyword wholeright .length yellow
keyword wholeright .ptr yellow
@ -154,7 +154,7 @@ context default
keyword wholeright .keys yellow
keyword wholeright .values yellow
keyword wholeright .rehash yellow
# D types atributes
# D types attributes
keyword wholeright .init yellow
keyword wholeright .alignof yellow
keyword wholeright .mangleof yellow
@ -178,7 +178,7 @@ context default
# union
keyword wholeright .offsetof yellow
# D 2.0 atributes
# D 2.0 attributes
keyword wholeright .idup yellow
# unary operators

Просмотреть файл

@ -230,7 +230,7 @@ void edit_show_margin_cmd (WDialog * h);
void edit_show_numbers_cmd (WDialog * h);
void edit_date_cmd (WEdit * edit);
void edit_goto_cmd (WEdit * edit);
int eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark);
gboolean eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark);
void edit_status (WEdit * edit, gboolean active);
void edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_insertion);
void edit_update_screen (WEdit * edit);

Просмотреть файл

@ -1534,7 +1534,7 @@ edit_move_block_to_right (WEdit * edit)
off_t start_mark, end_mark;
long cur_bol, start_bol;
if (eval_marks (edit, &start_mark, &end_mark))
if (!eval_marks (edit, &start_mark, &end_mark))
return;
start_bol = edit_buffer_get_bol (&edit->buffer, start_mark);
@ -1572,7 +1572,7 @@ edit_move_block_to_left (WEdit * edit)
off_t cur_bol, start_bol;
int i;
if (eval_marks (edit, &start_mark, &end_mark))
if (!eval_marks (edit, &start_mark, &end_mark))
return;
start_bol = edit_buffer_get_bol (&edit->buffer, start_mark);
@ -1708,7 +1708,7 @@ void
user_menu (WEdit * edit, const char *menu_file, int selected_entry)
{
char *block_file;
int nomark;
gboolean nomark;
off_t curs;
off_t start_mark, end_mark;
struct stat status;
@ -1717,8 +1717,8 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
block_file = mc_config_get_full_path (EDIT_BLOCK_FILE);
block_file_vpath = vfs_path_from_str (block_file);
curs = edit->buffer.curs1;
nomark = eval_marks (edit, &start_mark, &end_mark);
if (nomark == 0)
nomark = !eval_marks (edit, &start_mark, &end_mark);
if (!nomark)
edit_save_block (edit, block_file, start_mark, end_mark);
/* run shell scripts from menu */
@ -1729,7 +1729,7 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
FILE *fd;
/* i.e. we have marked block */
if (nomark == 0)
if (!nomark)
rc = edit_block_delete_cmd (edit);
if (rc == 0)
@ -1737,7 +1737,7 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
off_t ins_len;
ins_len = edit_insert_file (edit, block_file_vpath);
if (nomark == 0 && ins_len > 0)
if (!nomark && ins_len > 0)
edit_set_markers (edit, start_mark, start_mark + ins_len, 0, 0);
}
/* truncate block file */

Просмотреть файл

@ -659,7 +659,7 @@ edit_buffer_read_file (edit_buffer_t * buf, int fd, off_t size)
}
/* fullfill other parts of b2 from end to begin */
/* fulfill other parts of b2 from end to begin */
data_size = EDIT_BUF_SIZE;
for (--i; i >= 0; i--)
{
@ -708,7 +708,7 @@ edit_buffer_write_file (edit_buffer_t * buf, int fd)
off_t data_size, sz;
void *b;
/* write all fullfilled parts of b1 from begin to end */
/* write all fulfilled parts of b1 from begin to end */
if (buf->b1->len != 0)
{
data_size = EDIT_BUF_SIZE;
@ -747,7 +747,7 @@ edit_buffer_write_file (edit_buffer_t * buf, int fd)
if (sz == data_size)
{
/* write other fullfilled parts of b2 from end to begin */
/* write other fulfilled parts of b2 from end to begin */
data_size = EDIT_BUF_SIZE;
while (--i >= 0)
{

Просмотреть файл

@ -418,36 +418,34 @@ edit_get_save_file_as (WEdit * edit)
N_("&Macintosh format (CR)")
};
quick_widget_t quick_widgets[] = {
/* *INDENT-OFF* */
QUICK_LABELED_INPUT (N_("Enter file name:"), input_label_above,
vfs_path_as_str (edit->filename_vpath), "save-as",
&filename_res, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
QUICK_SEPARATOR (TRUE),
QUICK_LABEL (N_("Change line breaks to:"), NULL),
QUICK_RADIO (LB_NAMES, lb_names, (int *) &cur_lb, NULL),
QUICK_BUTTONS_OK_CANCEL,
QUICK_END
/* *INDENT-ON* */
};
quick_dialog_t qdlg = {
-1, -1, 64,
N_("Save As"), "[Save File As]",
quick_widgets, NULL, NULL
};
if (quick_dialog (&qdlg) != B_CANCEL)
{
quick_widget_t quick_widgets[] = {
/* *INDENT-OFF* */
QUICK_LABELED_INPUT (N_("Enter file name:"), input_label_above,
vfs_path_as_str (edit->filename_vpath), "save-as",
&filename_res, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
QUICK_SEPARATOR (TRUE),
QUICK_LABEL (N_("Change line breaks to:"), NULL),
QUICK_RADIO (LB_NAMES, lb_names, (int *) &cur_lb, NULL),
QUICK_BUTTONS_OK_CANCEL,
QUICK_END
/* *INDENT-ON* */
};
char *fname;
quick_dialog_t qdlg = {
-1, -1, 64,
N_("Save As"), "[Save File As]",
quick_widgets, NULL, NULL
};
if (quick_dialog (&qdlg) != B_CANCEL)
{
char *fname;
edit->lb = cur_lb;
fname = tilde_expand (filename_res);
g_free (filename_res);
ret_vpath = vfs_path_from_str (fname);
g_free (fname);
}
edit->lb = cur_lb;
fname = tilde_expand (filename_res);
g_free (filename_res);
ret_vpath = vfs_path_from_str (fname);
g_free (fname);
}
return ret_vpath;
@ -552,8 +550,9 @@ edit_block_delete (WEdit * edit)
off_t curs_pos;
long curs_line, c1, c2;
if (eval_marks (edit, &start_mark, &end_mark))
if (!eval_marks (edit, &start_mark, &end_mark))
return 0;
if (edit->column_highlight && edit->mark2 < 0)
edit_mark_cmd (edit, FALSE);
if ((end_mark - start_mark) > option_max_undo / 2)
@ -762,7 +761,7 @@ edit_search_fix_search_start_if_selection (WEdit * edit)
if (!edit_search_options.only_in_selection)
return;
if (eval_marks (edit, &start_mark, &end_mark) != 0)
if (!eval_marks (edit, &start_mark, &end_mark) != 0)
return;
if (edit_search_options.backwards)
@ -786,7 +785,6 @@ editcmd_find (WEdit * edit, gsize * len)
off_t search_end;
off_t start_mark = 0;
off_t end_mark = edit->buffer.size;
int mark_res = 0;
char end_string_symbol;
end_string_symbol = edit_search_get_current_end_line_char (edit);
@ -794,8 +792,7 @@ editcmd_find (WEdit * edit, gsize * len)
/* prepare for search */
if (edit_search_options.only_in_selection)
{
mark_res = eval_marks (edit, &start_mark, &end_mark);
if (mark_res != 0)
if (!eval_marks (edit, &start_mark, &end_mark))
{
edit->search->error = MC_SEARCH_E_NOTFOUND;
edit->search->error_str = g_strdup (_("Search string not found"));
@ -2215,66 +2212,65 @@ edit_close_cmd (WEdit * edit)
/**
if mark2 is -1 then marking is from mark1 to the cursor.
Otherwise its between the markers. This handles this.
Returns 1 if no text is marked.
Returns FALSE if no text is marked.
*/
int
gboolean
eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark)
{
if (edit->mark1 != edit->mark2)
{
off_t start_bol, start_eol;
off_t end_bol, end_eol;
off_t diff1, diff2;
long col1, col2;
long end_mark_curs;
long end_mark_curs;
if (edit->end_mark_curs < 0)
end_mark_curs = edit->buffer.curs1;
else
end_mark_curs = edit->end_mark_curs;
if (edit->mark2 >= 0)
{
*start_mark = min (edit->mark1, edit->mark2);
*end_mark = max (edit->mark1, edit->mark2);
}
else
{
*start_mark = min (edit->mark1, end_mark_curs);
*end_mark = max (edit->mark1, end_mark_curs);
edit->column2 = edit->curs_col + edit->over_col;
}
if (edit->column_highlight
&& (((edit->mark1 > end_mark_curs) && (edit->column1 < edit->column2))
|| ((edit->mark1 < end_mark_curs) && (edit->column1 > edit->column2))))
{
start_bol = edit_buffer_get_bol (&edit->buffer, *start_mark);
start_eol = edit_buffer_get_eol (&edit->buffer, start_bol - 1) + 1;
end_bol = edit_buffer_get_bol (&edit->buffer, *end_mark);
end_eol = edit_buffer_get_eol (&edit->buffer, *end_mark);
col1 = min (edit->column1, edit->column2);
col2 = max (edit->column1, edit->column2);
diff1 = edit_move_forward3 (edit, start_bol, col2, 0) -
edit_move_forward3 (edit, start_bol, col1, 0);
diff2 = edit_move_forward3 (edit, end_bol, col2, 0) -
edit_move_forward3 (edit, end_bol, col1, 0);
*start_mark -= diff1;
*end_mark += diff2;
*start_mark = max (*start_mark, start_eol);
*end_mark = min (*end_mark, end_eol);
}
return 0;
}
else
if (edit->mark1 == edit->mark2)
{
*start_mark = *end_mark = 0;
edit->column2 = edit->column1 = 0;
return 1;
return FALSE;
}
if (edit->end_mark_curs < 0)
end_mark_curs = edit->buffer.curs1;
else
end_mark_curs = edit->end_mark_curs;
if (edit->mark2 >= 0)
{
*start_mark = min (edit->mark1, edit->mark2);
*end_mark = max (edit->mark1, edit->mark2);
}
else
{
*start_mark = min (edit->mark1, end_mark_curs);
*end_mark = max (edit->mark1, end_mark_curs);
edit->column2 = edit->curs_col + edit->over_col;
}
if (edit->column_highlight
&& ((edit->mark1 > end_mark_curs && edit->column1 < edit->column2)
|| (edit->mark1 < end_mark_curs && edit->column1 > edit->column2)))
{
off_t start_bol, start_eol;
off_t end_bol, end_eol;
long col1, col2;
off_t diff1, diff2;
start_bol = edit_buffer_get_bol (&edit->buffer, *start_mark);
start_eol = edit_buffer_get_eol (&edit->buffer, start_bol - 1) + 1;
end_bol = edit_buffer_get_bol (&edit->buffer, *end_mark);
end_eol = edit_buffer_get_eol (&edit->buffer, *end_mark);
col1 = min (edit->column1, edit->column2);
col2 = max (edit->column1, edit->column2);
diff1 = edit_move_forward3 (edit, start_bol, col2, 0) -
edit_move_forward3 (edit, start_bol, col1, 0);
diff2 = edit_move_forward3 (edit, end_bol, col2, 0) -
edit_move_forward3 (edit, end_bol, col1, 0);
*start_mark -= diff1;
*end_mark += diff2;
*start_mark = max (*start_mark, start_eol);
*end_mark = min (*end_mark, end_eol);
}
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
@ -2290,7 +2286,7 @@ edit_block_copy_cmd (WEdit * edit)
unsigned char *copy_buf;
edit_update_curs_col (edit);
if (eval_marks (edit, &start_mark, &end_mark))
if (!eval_marks (edit, &start_mark, &end_mark))
return;
copy_buf = edit_get_block (edit, start_mark, end_mark, &size);
@ -2337,7 +2333,7 @@ edit_block_move_cmd (WEdit * edit)
unsigned char *copy_buf = NULL;
off_t start_mark, end_mark;
if (eval_marks (edit, &start_mark, &end_mark))
if (!eval_marks (edit, &start_mark, &end_mark))
return;
if (!edit->column_highlight && edit->buffer.curs1 > start_mark && edit->buffer.curs1 < end_mark)
@ -2436,12 +2432,12 @@ int
edit_block_delete_cmd (WEdit * edit)
{
off_t start_mark, end_mark;
if (eval_marks (edit, &start_mark, &end_mark))
{
edit_delete_line (edit);
return 0;
}
return edit_block_delete (edit);
return edit_block_delete (edit);
edit_delete_line (edit);
return 0;
}
/* --------------------------------------------------------------------------------------------- */
@ -2889,8 +2885,9 @@ edit_copy_to_X_buf_cmd (WEdit * edit)
{
off_t start_mark, end_mark;
if (eval_marks (edit, &start_mark, &end_mark))
if (!eval_marks (edit, &start_mark, &end_mark))
return TRUE;
if (!edit_save_block_to_clip_file (edit, start_mark, end_mark))
{
edit_error_dialog (_("Copy to clipboard"), get_sys_error (_("Unable to save to file")));
@ -2909,8 +2906,9 @@ edit_cut_to_X_buf_cmd (WEdit * edit)
{
off_t start_mark, end_mark;
if (eval_marks (edit, &start_mark, &end_mark))
if (!eval_marks (edit, &start_mark, &end_mark))
return TRUE;
if (!edit_save_block_to_clip_file (edit, start_mark, end_mark))
{
edit_error_dialog (_("Cut to clipboard"), _("Unable to save to file"));
@ -2996,7 +2994,7 @@ edit_save_block_cmd (WEdit * edit)
char *exp, *tmp;
gboolean ret = FALSE;
if (eval_marks (edit, &start_mark, &end_mark))
if (!eval_marks (edit, &start_mark, &end_mark))
return TRUE;
tmp = mc_config_get_full_path (EDIT_CLIP_FILE);
@ -3068,7 +3066,7 @@ edit_sort_cmd (WEdit * edit)
off_t start_mark, end_mark;
int e;
if (eval_marks (edit, &start_mark, &end_mark))
if (!eval_marks (edit, &start_mark, &end_mark))
{
edit_error_dialog (_("Sort block"), _("You must first highlight a block of text"));
return 0;

Просмотреть файл

@ -385,7 +385,7 @@ editcmd_dialog_completion_show (const WEdit * edit, int max_len, GString ** comp
for (i = num_compl - 1; i >= 0; i--) /* reverse order */
listbox_add_item (compl_list, LISTBOX_APPEND_AT_END, 0, (char *) compl[i]->str, NULL);
/* pop up the dialog and apply the choosen completion */
/* pop up the dialog and apply the chosen completion */
if (dlg_run (compl_dlg) == B_ENTER)
{
listbox_get_current (compl_list, &curr, NULL);
@ -457,7 +457,7 @@ editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l
g_free (label_def);
}
/* pop up the dialog and apply the choosen completion */
/* pop up the dialog and apply the chosen completion */
if (dlg_run (def_dlg) == B_ENTER)
{
char *tmp_curr_def = (char *) curr_def;

Просмотреть файл

@ -294,8 +294,8 @@ edit_status_window (WEdit * edit)
edit_move (2, w->lines - 1);
tty_printf ("%3ld %5ld/%ld %6ld/%ld",
edit->curs_col + edit->over_col,
edit->buffer.curs_line + 1, edit->buffer.lines + 1, edit->buffer.curs1,
edit->buffer.size);
edit->buffer.curs_line + 1, edit->buffer.lines + 1, (long) edit->buffer.curs1,
(long) edit->buffer.size);
}
/*

Просмотреть файл

@ -1062,16 +1062,17 @@ symlink_dialog (const vfs_path_t * existing_vpath, const vfs_path_t * new_vpath,
char **ret_existing, char **ret_new)
{
quick_widget_t quick_widgets[] = {
/* *INDENT-OFF* */
QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
input_label_above,
vfs_path_as_str (existing_vpath), "input-2", ret_existing, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
QUICK_SEPARATOR (FALSE),
QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above,
vfs_path_as_str (new_vpath), "input-1", ret_new, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
QUICK_BUTTONS_OK_CANCEL,
QUICK_END
/* *INDENT-ON* */
/* *INDENT-OFF* */
QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
input_label_above, vfs_path_as_str (existing_vpath), "input-2",
ret_existing, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
QUICK_SEPARATOR (FALSE),
QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above,
vfs_path_as_str (new_vpath), "input-1",
ret_new, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
QUICK_BUTTONS_OK_CANCEL,
QUICK_END
/* *INDENT-ON* */
};
quick_dialog_t qdlg = {

Просмотреть файл

@ -266,7 +266,7 @@ select_unselect_cmd (const char *title, const char *history_name, gboolean do_se
for (i = 0; i < current_panel->count; i++)
{
if (strcmp (current_panel->dir.list[i].fname, "..") == 0)
if (DIR_IS_DOTDOT (current_panel->dir.list[i].fname))
continue;
if (S_ISDIR (current_panel->dir.list[i].st.st_mode) && files_only != 0)
continue;
@ -941,7 +941,7 @@ mkdir_cmd (void)
const char *name = "";
/* If 'on' then automatically fills name with current selected item name */
if (auto_fill_mkdir_name && strcmp (selection (current_panel)->fname, "..") != 0)
if (auto_fill_mkdir_name && !DIR_IS_DOTDOT (selection (current_panel)->fname))
name = selection (current_panel)->fname;
dir =
@ -1607,7 +1607,7 @@ smart_dirsize_cmd (void)
file_entry *entry;
entry = &(panel->dir.list[panel->selected]);
if ((S_ISDIR (entry->st.st_mode) && (strcmp (entry->fname, "..") == 0)) || panel->dirs_marked)
if ((S_ISDIR (entry->st.st_mode) && DIR_IS_DOTDOT (entry->fname)) || panel->dirs_marked)
dirsizes_cmd ();
else
single_dirsize_cmd ();
@ -1622,7 +1622,7 @@ single_dirsize_cmd (void)
file_entry *entry;
entry = &(panel->dir.list[panel->selected]);
if (S_ISDIR (entry->st.st_mode) && strcmp (entry->fname, "..") != 0)
if (S_ISDIR (entry->st.st_mode) && !DIR_IS_DOTDOT (entry->fname))
{
size_t marked = 0;
uintmax_t total = 0;
@ -1668,7 +1668,7 @@ dirsizes_cmd (void)
for (i = 0; i < panel->count; i++)
if (S_ISDIR (panel->dir.list[i].st.st_mode)
&& ((panel->dirs_marked && panel->dir.list[i].f.marked)
|| !panel->dirs_marked) && strcmp (panel->dir.list[i].fname, "..") != 0)
|| !panel->dirs_marked) && !DIR_IS_DOTDOT (panel->dir.list[i].fname))
{
vfs_path_t *p;
size_t marked = 0;

Просмотреть файл

@ -400,7 +400,7 @@ do_cd_command (char *orig_cmd)
{
sync_tree (mc_config_get_home_dir ());
}
else if (strcmp (cmd + operand_pos, "..") == 0)
else if (DIR_IS_DOTDOT (cmd + operand_pos))
{
if (vfs_path_elements_count (current_panel->cwd_vpath) != 1 ||
strlen (vfs_path_get_by_index (current_panel->cwd_vpath, 0)->path) > 1)

Просмотреть файл

@ -172,9 +172,7 @@ handle_dirent (dir_list * list, const char *fltr, struct dirent *dp,
{
vfs_path_t *vpath;
if (dp->d_name[0] == '.' && dp->d_name[1] == 0)
return 0;
if (dp->d_name[0] == '.' && dp->d_name[1] == '.' && dp->d_name[2] == 0)
if (DIR_IS_DOT (dp->d_name) || DIR_IS_DOTDOT (dp->d_name))
return 0;
if (!panels_options.show_dot_files && (dp->d_name[0] == '.'))
return 0;
@ -449,7 +447,7 @@ do_sort (dir_list * list, sortfn * sort, int top, gboolean reverse_f, gboolean c
/* If there is an ".." entry the caller must take care to
ensure that it occupies the first list element. */
if (strcmp (list->list[0].fname, "..") == 0)
if (DIR_IS_DOTDOT (list->list[0].fname))
dot_dot_found = 1;
reverse = reverse_f ? -1 : 1;
@ -510,9 +508,7 @@ handle_path (dir_list * list, const char *path,
{
vfs_path_t *vpath;
if (path[0] == '.' && path[1] == 0)
return 0;
if (path[0] == '.' && path[1] == '.' && path[2] == 0)
if (DIR_IS_DOT (path) || DIR_IS_DOTDOT (path))
return 0;
vpath = vfs_path_from_str (path);

Просмотреть файл

@ -614,16 +614,16 @@ get_file_encoding_local (const vfs_path_t * filename_vpath, char *buf, int bufle
* Invoke the "file" command on the file and match its output against PTR.
* have_type is a flag that is set if we already have tried to determine
* the type of that file.
* Return 1 for match, 0 for no match, -1 errors.
* Return TRUE for match, FALSE otherwise.
*/
static gboolean
regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_type,
gboolean case_insense, GError ** error)
regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, gboolean case_insense,
gboolean * have_type, GError ** error)
{
gboolean found = FALSE;
/* Following variables are valid if *have_type is 1 */
/* Following variables are valid if *have_type is TRUE */
static char content_string[2048];
#ifdef HAVE_CHARSET
static char encoding_id[21]; /* CSISO51INISCYRILLIC -- 20 */
@ -634,7 +634,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_
if (!use_file_to_check_type)
return FALSE;
if (*have_type == 0)
if (!*have_type)
{
vfs_path_t *localfile_vpath;
const char *realname; /* name used with "file" */
@ -644,7 +644,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_
#endif /* HAVE_CHARSET */
/* Don't repeate even unsuccessful checks */
*have_type = 1;
*have_type = TRUE;
localfile_vpath = mc_getlocalcopy (filename_vpath);
if (localfile_vpath == NULL)
@ -782,7 +782,7 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char *
int view_at_line_number;
char *include_target;
int include_target_len;
int have_type = 0; /* Flag used by regex_check_type() */
gboolean have_type = FALSE; /* Flag used by regex_check_type() */
if (filename_vpath == NULL)
return 0;
@ -968,7 +968,7 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char *
if (case_insense)
p += 2;
found = regex_check_type (filename_vpath, p, &have_type, case_insense, &error);
found = regex_check_type (filename_vpath, p, case_insense, &have_type, &error);
if (error != NULL)
{
g_error_free (error);

Просмотреть файл

@ -524,9 +524,7 @@ do_compute_dir_size (const vfs_path_t * dirname_vpath, void *ui,
{
vfs_path_t *tmp_vpath;
if (strcmp (dirent->d_name, ".") == 0)
continue;
if (strcmp (dirent->d_name, "..") == 0)
if (DIR_IS_DOT (dirent->d_name) || DIR_IS_DOTDOT (dirent->d_name))
continue;
tmp_vpath = vfs_path_append_new (dirname_vpath, dirent->d_name, NULL);
@ -1030,7 +1028,8 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const vfs_path_t * v
int return_status;
struct stat buf;
file_progress_show_deleting (ctx, vfs_path_as_str (vpath));
file_progress_show_deleting (ctx, vfs_path_as_str (vpath), &tctx->progress_count);
file_progress_show_count (ctx, tctx->progress_count, ctx->progress_count);
if (check_progress_buttons (ctx) == FILE_ABORT)
return FILE_ABORT;
@ -1053,9 +1052,11 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const vfs_path_t * v
ctx->skip_all = TRUE;
break;
}
if (tctx->progress_count == 0)
return FILE_CONT;
return progress_update_one (tctx, ctx, buf.st_size);
return check_progress_buttons (ctx);
}
/* --------------------------------------------------------------------------------------------- */
@ -1067,62 +1068,50 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const vfs_path_t * v
skipall->remove as much as possible
*/
static FileProgressStatus
recursive_erase (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
recursive_erase (FileOpTotalContext * tctx, FileOpContext * ctx, const vfs_path_t * vpath)
{
struct dirent *next;
struct stat buf;
DIR *reading;
char *path;
const char *s;
FileProgressStatus return_status = FILE_CONT;
vfs_path_t *vpath;
if (strcmp (s, "..") == 0)
return FILE_RETRY;
vpath = vfs_path_from_str (s);
reading = mc_opendir (vpath);
if (reading == NULL)
{
return_status = FILE_RETRY;
goto ret;
}
return FILE_RETRY;
while ((next = mc_readdir (reading)) && return_status != FILE_ABORT)
{
vfs_path_t *tmp_vpath;
struct stat buf;
if (!strcmp (next->d_name, "."))
if (DIR_IS_DOT (next->d_name) || DIR_IS_DOTDOT (next->d_name))
continue;
if (!strcmp (next->d_name, ".."))
continue;
path = mc_build_filename (s, next->d_name, NULL);
tmp_vpath = vfs_path_from_str (path);
tmp_vpath = vfs_path_append_new (vpath, next->d_name, NULL);
if (mc_lstat (tmp_vpath, &buf) != 0)
{
g_free (path);
mc_closedir (reading);
vfs_path_free (tmp_vpath);
return_status = FILE_RETRY;
goto ret;
return FILE_RETRY;
}
if (S_ISDIR (buf.st_mode))
return_status = recursive_erase (tctx, ctx, path);
return_status = recursive_erase (tctx, ctx, tmp_vpath);
else
return_status = erase_file (tctx, ctx, tmp_vpath);
vfs_path_free (tmp_vpath);
g_free (path);
}
mc_closedir (reading);
if (return_status == FILE_ABORT)
goto ret;
file_progress_show_deleting (ctx, s);
if (return_status == FILE_ABORT)
return FILE_ABORT;
s = vfs_path_as_str (vpath);
file_progress_show_deleting (ctx, s, NULL);
file_progress_show_count (ctx, tctx->progress_count, ctx->progress_count);
if (check_progress_buttons (ctx) == FILE_ABORT)
{
return_status = FILE_ABORT;
goto ret;
}
return FILE_ABORT;
mc_refresh ();
while (my_rmdir (s) != 0 && !ctx->skip_all)
@ -1131,14 +1120,12 @@ recursive_erase (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s)
if (return_status == FILE_RETRY)
continue;
if (return_status == FILE_ABORT)
goto ret;
break;
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
break;
}
ret:
vfs_path_free (vpath);
return return_status;
}
@ -1151,20 +1138,18 @@ check_dir_is_empty (const vfs_path_t * vpath)
{
DIR *dir;
struct dirent *d;
int i;
int i = 1;
dir = mc_opendir (vpath);
if (!dir)
if (dir == NULL)
return -1;
for (i = 1, d = mc_readdir (dir); d; d = mc_readdir (dir))
{
if (d->d_name[0] == '.' && (d->d_name[1] == '\0' ||
(d->d_name[1] == '.' && d->d_name[2] == '\0')))
continue; /* "." or ".." */
i = 0;
break;
}
for (d = mc_readdir (dir); d != NULL; d = mc_readdir (dir))
if (!DIR_IS_DOT (d->d_name) && !DIR_IS_DOTDOT (d->d_name))
{
i = 0;
break;
}
mc_closedir (dir);
return i;
@ -1173,26 +1158,21 @@ check_dir_is_empty (const vfs_path_t * vpath)
/* --------------------------------------------------------------------------------------------- */
static FileProgressStatus
erase_dir_iff_empty (FileOpContext * ctx, const char *s)
erase_dir_iff_empty (FileOpContext * ctx, const vfs_path_t * vpath, size_t count)
{
FileProgressStatus error;
vfs_path_t *s_vpath;
FileProgressStatus error = FILE_CONT;
const char *s;
if (strcmp (s, "..") == 0)
return FILE_SKIP;
s = vfs_path_as_str (vpath);
if (strcmp (s, ".") == 0)
return FILE_SKIP;
file_progress_show_deleting (ctx, s);
file_progress_show_deleting (ctx, s, NULL);
file_progress_show_count (ctx, count, ctx->progress_count);
if (check_progress_buttons (ctx) == FILE_ABORT)
return FILE_ABORT;
mc_refresh ();
s_vpath = vfs_path_from_str (s);
if (check_dir_is_empty (s_vpath) == 1) /* not empty or error */
if (check_dir_is_empty (vpath) == 1) /* not empty or error */
{
while (my_rmdir (s) != 0 && !ctx->skip_all)
{
@ -1200,15 +1180,11 @@ erase_dir_iff_empty (FileOpContext * ctx, const char *s)
if (error == FILE_SKIPALL)
ctx->skip_all = TRUE;
if (error != FILE_RETRY)
{
vfs_path_free (s_vpath);
return error;
}
break;
}
}
vfs_path_free (s_vpath);
return FILE_CONT;
return error;
}
/* }}} */
@ -2028,11 +2004,9 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
struct dirent *next;
struct stat buf, cbuf;
DIR *reading;
char *dest_dir = NULL;
FileProgressStatus return_status = FILE_CONT;
struct utimbuf utb;
struct link *lp;
vfs_path_t *src_vpath, *dst_vpath, *dest_dir_vpath = NULL;
vfs_path_t *src_vpath, *dst_vpath;
gboolean do_mkdir = TRUE;
src_vpath = vfs_path_from_str (s);
@ -2109,15 +2083,11 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
if (mc_stat (dst_vpath, &buf) != 0)
{
/* Here the dir doesn't exist : make it ! */
if (move_over)
if (move_over && mc_rename (src_vpath, dst_vpath) == 0)
{
if (mc_rename (src_vpath, dst_vpath) == 0)
{
return_status = FILE_CONT;
goto ret;
}
return_status = FILE_CONT;
goto ret;
}
dest_dir = g_strdup (d);
}
else
{
@ -2145,26 +2115,29 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
}
/* Dive into subdir if exists */
if (toplevel && ctx->dive_into_subdirs)
dest_dir = mc_build_filename (d, x_basename (s), NULL);
else
{
dest_dir = g_strdup (d);
do_mkdir = FALSE;
vfs_path_t *tmp;
tmp = dst_vpath;
dst_vpath = vfs_path_append_new (dst_vpath, x_basename (s), NULL);
vfs_path_free (tmp);
}
else
do_mkdir = FALSE;
}
dest_dir_vpath = vfs_path_from_str (dest_dir);
d = vfs_path_as_str (dst_vpath);
if (do_mkdir)
{
while (my_mkdir (dest_dir_vpath, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU) != 0)
while (my_mkdir (dst_vpath, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU) != 0)
{
if (ctx->skip_all)
return_status = FILE_SKIPALL;
else
{
return_status =
file_error (_("Cannot create target directory \"%s\"\n%s"), dest_dir);
return_status = file_error (_("Cannot create target directory \"%s\"\n%s"), d);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
}
@ -2173,8 +2146,8 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
}
lp = g_new0 (struct link, 1);
mc_stat (dest_dir_vpath, &buf);
lp->vfs = vfs_path_get_by_index (dest_dir_vpath, -1)->class;
mc_stat (dst_vpath, &buf);
lp->vfs = vfs_path_get_by_index (dst_vpath, -1)->class;
lp->ino = buf.st_ino;
lp->dev = buf.st_dev;
dest_dirs = g_slist_prepend (dest_dirs, lp);
@ -2182,14 +2155,13 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
if (ctx->preserve_uidgid)
{
while (mc_chown (dest_dir_vpath, cbuf.st_uid, cbuf.st_gid) != 0)
while (mc_chown (dst_vpath, cbuf.st_uid, cbuf.st_gid) != 0)
{
if (ctx->skip_all)
return_status = FILE_SKIPALL;
else
{
return_status =
file_error (_("Cannot chown target directory \"%s\"\n%s"), dest_dir);
return_status = file_error (_("Cannot chown target directory \"%s\"\n%s"), d);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
}
@ -2207,12 +2179,11 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
{
char *path;
vfs_path_t *tmp_vpath;
/*
* Now, we don't want '.' and '..' to be created / copied at any time
*/
if (!strcmp (next->d_name, "."))
continue;
if (!strcmp (next->d_name, ".."))
if (DIR_IS_DOT (next->d_name) || DIR_IS_DOTDOT (next->d_name))
continue;
/* get the filename and add it to the src directory */
@ -2224,7 +2195,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
{
char *mdpath;
mdpath = mc_build_filename (dest_dir, next->d_name, NULL);
mdpath = mc_build_filename (d, next->d_name, NULL);
/*
* From here, we just intend to recursively copy subdirs, not
* the double functionality of copying different when the target
@ -2239,47 +2210,50 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
{
char *dest_file;
dest_file = mc_build_filename (dest_dir, x_basename (path), NULL);
dest_file = mc_build_filename (d, x_basename (path), NULL);
return_status = copy_file_file (tctx, ctx, path, dest_file);
g_free (dest_file);
}
g_free (path);
if (do_delete && return_status == FILE_CONT)
{
if (ctx->erase_at_end)
{
lp = g_new0 (struct link, 1);
lp->src_vpath = vfs_path_clone (tmp_vpath);
lp->src_vpath = tmp_vpath;
lp->st_mode = buf.st_mode;
erase_list = g_slist_append (erase_list, lp);
tmp_vpath = NULL;
}
else if (S_ISDIR (buf.st_mode))
return_status = erase_dir_iff_empty (ctx, path);
return_status = erase_dir_iff_empty (ctx, tmp_vpath, tctx->progress_count);
else
return_status = erase_file (tctx, ctx, tmp_vpath);
}
g_free (path);
vfs_path_free (tmp_vpath);
}
mc_closedir (reading);
if (ctx->preserve)
{
mc_chmod (dest_dir_vpath, cbuf.st_mode & ctx->umask_kill);
struct utimbuf utb;
mc_chmod (dst_vpath, cbuf.st_mode & ctx->umask_kill);
utb.actime = cbuf.st_atime;
utb.modtime = cbuf.st_mtime;
mc_utime (dest_dir_vpath, &utb);
mc_utime (dst_vpath, &utb);
}
else
{
cbuf.st_mode = umask (-1);
umask (cbuf.st_mode);
cbuf.st_mode = 0100777 & ~cbuf.st_mode;
mc_chmod (dest_dir_vpath, cbuf.st_mode & ctx->umask_kill);
mc_chmod (dst_vpath, cbuf.st_mode & ctx->umask_kill);
}
ret:
g_free (dest_dir);
vfs_path_free (dest_dir_vpath);
free_link (parent_dirs->data);
g_slist_free_1 (parent_dirs);
ret_fast:
@ -2297,12 +2271,10 @@ FileProgressStatus
move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, const char *d)
{
struct stat sbuf, dbuf, destbuf;
struct link *lp;
char *destdir;
FileProgressStatus return_status;
gboolean move_over = FALSE;
gboolean dstat_ok;
vfs_path_t *src_vpath, *dst_vpath, *destdir_vpath;
vfs_path_t *src_vpath, *dst_vpath;
src_vpath = vfs_path_from_str (s);
dst_vpath = vfs_path_from_str (d);
@ -2328,24 +2300,27 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
}
if (!dstat_ok)
destdir = g_strdup (d); /* destination doesn't exist */
; /* destination doesn't exist */
else if (!ctx->dive_into_subdirs)
{
destdir = g_strdup (d);
move_over = TRUE;
}
else
destdir = mc_build_filename (d, x_basename (s), NULL);
{
vfs_path_t *tmp;
destdir_vpath = vfs_path_from_str (destdir);
tmp = dst_vpath;
dst_vpath = vfs_path_append_new (dst_vpath, x_basename (s), NULL);
vfs_path_free (tmp);
}
d = vfs_path_as_str (dst_vpath);
/* Check if the user inputted an existing dir */
retry_dst_stat:
if (mc_stat (destdir_vpath, &destbuf) == 0)
if (mc_stat (dst_vpath, &destbuf) == 0)
{
if (move_over)
{
return_status = copy_dir_dir (tctx, ctx, s, destdir, FALSE, TRUE, TRUE, NULL);
return_status = copy_dir_dir (tctx, ctx, s, d, FALSE, TRUE, TRUE, NULL);
if (return_status != FILE_CONT)
goto ret;
@ -2356,22 +2331,20 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
else
{
if (S_ISDIR (destbuf.st_mode))
return_status = file_error (_("Cannot overwrite directory \"%s\"\n%s"), destdir);
return_status = file_error (_("Cannot overwrite directory \"%s\"\n%s"), d);
else
return_status = file_error (_("Cannot overwrite file \"%s\"\n%s"), destdir);
return_status = file_error (_("Cannot overwrite file \"%s\"\n%s"), d);
if (return_status == FILE_SKIPALL)
ctx->skip_all = TRUE;
if (return_status == FILE_RETRY)
goto retry_dst_stat;
}
g_free (destdir);
vfs_path_free (destdir_vpath);
goto ret_fast;
}
retry_rename:
if (mc_rename (src_vpath, destdir_vpath) == 0)
if (mc_rename (src_vpath, dst_vpath) == 0)
{
return_status = FILE_CONT;
goto ret;
@ -2390,7 +2363,7 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
goto ret;
}
/* Failed because of filesystem boundary -> copy dir instead */
return_status = copy_dir_dir (tctx, ctx, s, destdir, FALSE, FALSE, TRUE, NULL);
return_status = copy_dir_dir (tctx, ctx, s, d, FALSE, FALSE, TRUE, NULL);
if (return_status != FILE_CONT)
goto ret;
@ -2407,11 +2380,10 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
{
for (; erase_list != NULL && return_status != FILE_ABORT;)
{
lp = (struct link *) erase_list->data;
struct link *lp = (struct link *) erase_list->data;
if (S_ISDIR (lp->st_mode))
return_status = erase_dir_iff_empty (ctx, vfs_path_as_str (lp->src_vpath));
return_status = erase_dir_iff_empty (ctx, lp->src_vpath, tctx->progress_count);
else
return_status = erase_file (tctx, ctx, lp->src_vpath);
@ -2419,11 +2391,9 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
free_link (lp);
}
}
erase_dir_iff_empty (ctx, s);
erase_dir_iff_empty (ctx, src_vpath, tctx->progress_count);
ret:
g_free (destdir);
vfs_path_free (destdir_vpath);
erase_list = free_linklist (erase_list);
ret_fast:
vfs_path_free (src_vpath);
@ -2441,15 +2411,8 @@ erase_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const vfs_path_t * s_
{
FileProgressStatus error;
/*
if (strcmp (s, "..") == 0)
return FILE_SKIP;
if (strcmp (s, ".") == 0)
return FILE_SKIP;
*/
file_progress_show_deleting (ctx, vfs_path_as_str (s_vpath));
file_progress_show_deleting (ctx, vfs_path_as_str (s_vpath), NULL);
file_progress_show_count (ctx, tctx->progress_count, ctx->progress_count);
if (check_progress_buttons (ctx) == FILE_ABORT)
return FILE_ABORT;
@ -2467,7 +2430,7 @@ erase_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const vfs_path_t * s_
{ /* not empty */
error = query_recursive (ctx, vfs_path_as_str (s_vpath));
if (error == FILE_CONT)
error = recursive_erase (tctx, ctx, vfs_path_as_str (s_vpath));
error = recursive_erase (tctx, ctx, s_vpath);
return error;
}
@ -2672,7 +2635,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
else
source = panel_get_file (panel);
if (strcmp (source, "..") == 0)
if (DIR_IS_DOTDOT (source))
{
g_free (source);
message (D_ERROR, MSG_ERROR, _("Cannot operate on \"..\"!"));

Просмотреть файл

@ -230,8 +230,13 @@ typedef struct
/* Dialog and widgets for the operation progress window */
WDialog *op_dlg;
WLabel *file_string[2];
WLabel *file_label[2];
/* Source file: label and name */
WLabel *src_file_label;
WLabel *src_file;
/* Target file: label and name */
WLabel *tgt_file_label;
WLabel *tgt_file;
WGauge *progress_file_gauge;
WLabel *progress_file_label;
@ -743,53 +748,66 @@ file_op_context_create_ui (FileOpContext * ctx, gboolean with_eta,
ui = ctx->ui;
ui->replace_result = REPLACE_YES;
ui->showing_eta = with_eta && ctx->progress_totals_computed;
ui->showing_bps = with_eta;
ui->op_dlg =
dlg_create (TRUE, 0, 0, dlg_height, dlg_width, dialog_colors, NULL, NULL, NULL,
op_names[ctx->operation], DLG_CENTER);
ui->file_label[0] = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->file_label[0]);
ui->file_string[0] = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->file_string[0]);
ui->file_label[1] = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->file_label[1]);
ui->file_string[1] = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->file_string[1]);
ui->progress_file_gauge = gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0);
if (!classic_progressbar && (current_panel == right_panel))
ui->progress_file_gauge->from_left_to_right = FALSE;
add_widget_autopos (ui->op_dlg, ui->progress_file_gauge, WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL);
ui->progress_file_label = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->progress_file_label);
if (verbose && dialog_type == FILEGUI_DIALOG_MULTI_ITEM)
if (dialog_type != FILEGUI_DIALOG_DELETE_ITEM)
{
ui->total_bytes_label = hline_new (y++, -1, -1);
add_widget (ui->op_dlg, ui->total_bytes_label);
ui->showing_eta = with_eta && ctx->progress_totals_computed;
ui->showing_bps = with_eta;
if (ctx->progress_totals_computed)
ui->src_file_label = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->src_file_label);
ui->src_file = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->src_file);
ui->tgt_file_label = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->tgt_file_label);
ui->tgt_file = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->tgt_file);
ui->progress_file_gauge = gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0);
if (!classic_progressbar && (current_panel == right_panel))
ui->progress_file_gauge->from_left_to_right = FALSE;
add_widget_autopos (ui->op_dlg, ui->progress_file_gauge, WPOS_KEEP_TOP | WPOS_KEEP_HORZ,
NULL);
ui->progress_file_label = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->progress_file_label);
if (verbose && dialog_type == FILEGUI_DIALOG_MULTI_ITEM)
{
ui->progress_total_gauge =
gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0);
if (!classic_progressbar && (current_panel == right_panel))
ui->progress_total_gauge->from_left_to_right = FALSE;
add_widget_autopos (ui->op_dlg, ui->progress_total_gauge,
WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL);
ui->total_bytes_label = hline_new (y++, -1, -1);
add_widget (ui->op_dlg, ui->total_bytes_label);
if (ctx->progress_totals_computed)
{
ui->progress_total_gauge =
gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0);
if (!classic_progressbar && (current_panel == right_panel))
ui->progress_total_gauge->from_left_to_right = FALSE;
add_widget_autopos (ui->op_dlg, ui->progress_total_gauge,
WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL);
}
ui->total_files_processed_label = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->total_files_processed_label);
ui->time_label = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->time_label);
}
}
else
{
ui->src_file = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->src_file);
ui->total_files_processed_label = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->total_files_processed_label);
ui->time_label = label_new (y++, x, "");
add_widget (ui->op_dlg, ui->time_label);
}
add_widget (ui->op_dlg, hline_new (y++, -1, -1));
@ -1021,14 +1039,14 @@ file_progress_show_source (FileOpContext * ctx, const vfs_path_t * s_vpath)
char *s;
s = vfs_path_tokens_get (s_vpath, -1, 1);
label_set_text (ui->file_label[0], _("Source"));
label_set_text (ui->file_string[0], truncFileString (ui->op_dlg, s));
label_set_text (ui->src_file_label, _("Source"));
label_set_text (ui->src_file, truncFileString (ui->op_dlg, s));
g_free (s);
}
else
{
label_set_text (ui->file_label[0], "");
label_set_text (ui->file_string[0], "");
label_set_text (ui->src_file_label, "");
label_set_text (ui->src_file, "");
}
}
@ -1046,21 +1064,21 @@ file_progress_show_target (FileOpContext * ctx, const vfs_path_t * s_vpath)
if (s_vpath != NULL)
{
label_set_text (ui->file_label[1], _("Target"));
label_set_text (ui->file_string[1],
label_set_text (ui->tgt_file_label, _("Target"));
label_set_text (ui->tgt_file,
truncFileStringSecure (ui->op_dlg, vfs_path_as_str (s_vpath)));
}
else
{
label_set_text (ui->file_label[1], "");
label_set_text (ui->file_string[1], "");
label_set_text (ui->tgt_file_label, "");
label_set_text (ui->tgt_file, "");
}
}
/* --------------------------------------------------------------------------------------------- */
void
file_progress_show_deleting (FileOpContext * ctx, const char *s)
file_progress_show_deleting (FileOpContext * ctx, const char *s, size_t * count)
{
FileOpContextUI *ui;
@ -1068,8 +1086,10 @@ file_progress_show_deleting (FileOpContext * ctx, const char *s)
return;
ui = ctx->ui;
label_set_text (ui->file_label[0], _("Deleting"));
label_set_text (ui->file_label[0], truncFileStringSecure (ui->op_dlg, s));
label_set_text (ui->src_file, truncFileStringSecure (ui->op_dlg, s));
if (count != NULL)
(*count)++;
}
/* --------------------------------------------------------------------------------------------- */
@ -1077,7 +1097,7 @@ file_progress_show_deleting (FileOpContext * ctx, const char *s)
FileProgressStatus
file_progress_real_query_replace (FileOpContext * ctx,
enum OperationMode mode, const char *destname,
struct stat * _s_stat, struct stat * _d_stat)
struct stat *_s_stat, struct stat *_d_stat)
{
FileOpContextUI *ui;

Просмотреть файл

@ -36,7 +36,7 @@ void file_progress_show_total (FileOpTotalContext * tctx, FileOpContext * ctx,
uintmax_t copied_bytes, gboolean show_summary);
void file_progress_show_source (FileOpContext * ctx, const vfs_path_t * s_vpath);
void file_progress_show_target (FileOpContext * ctx, const vfs_path_t * path);
void file_progress_show_deleting (FileOpContext * ctx, const char *path);
void file_progress_show_deleting (FileOpContext * ctx, const char *path, size_t * count);
/*** inline functions ****************************************************************************/
#endif /* MC__FILEGUI_H */

Просмотреть файл

@ -72,54 +72,33 @@ get_absolute_name (const vfs_path_t * vpath)
/* --------------------------------------------------------------------------------------------- */
static int
my_mkdir_rec (const char *s, mode_t mode)
my_mkdir_rec (const vfs_path_t * s_vpath, mode_t mode)
{
char *p, *q;
vfs_path_t *q;
int result;
vfs_path_t *s_vpath;
s_vpath = vfs_path_from_str (s);
if (mc_mkdir (s_vpath, mode) == 0)
{
vfs_path_free (s_vpath);
return 0;
}
else if (errno != ENOENT)
{
vfs_path_free (s_vpath);
return -1;
}
if (errno != ENOENT)
return (-1);
/* FIXME: should check instead if s is at the root of that filesystem */
/* FIXME: should check instead if s_vpath is at the root of that filesystem */
if (!vfs_file_is_local (s_vpath))
{
vfs_path_free (s_vpath);
return -1;
}
return (-1);
if (!strcmp (s, PATH_SEP_STR))
if (strcmp (vfs_path_as_str (s_vpath), PATH_SEP_STR) == 0)
{
errno = ENOTDIR;
vfs_path_free (s_vpath);
return -1;
return (-1);
}
p = mc_build_filename (s, "..", NULL);
{
vfs_path_t *vpath;
vpath = vfs_path_from_str (p);
q = g_strdup (vfs_path_as_str (vpath));
vfs_path_free (vpath);
}
g_free (p);
q = vfs_path_append_new (s_vpath, "..", NULL);
result = my_mkdir_rec (q, mode);
vfs_path_free (q);
if (result == 0)
result = mc_mkdir (s_vpath, mode);
vfs_path_free (s_vpath);
g_free (q);
return result;
}
@ -132,11 +111,7 @@ my_mkdir (const vfs_path_t * s_vpath, mode_t mode)
{
int result;
result = mc_mkdir (s_vpath, mode);
if (result != 0)
result = my_mkdir_rec (vfs_path_as_str (s_vpath), mode);
result = my_mkdir_rec (s_vpath, mode);
if (result == 0)
{
vfs_path_t *my_s;

Просмотреть файл

@ -717,7 +717,7 @@ find_parameters (char **start_dir, ssize_t * start_dir_len,
char *temp_dir;
temp_dir = in_start->buffer;
if ((temp_dir[0] == '\0') || ((temp_dir[0] == '.') && (temp_dir[1] == '\0')))
if (*temp_dir == '\0' || DIR_IS_DOT (temp_dir))
temp_dir = g_strdup (vfs_path_as_str (current_panel->cwd_vpath));
else
temp_dir = g_strdup (temp_dir);
@ -768,7 +768,7 @@ find_parameters (char **start_dir, ssize_t * start_dir_len,
s = tilde_expand (*start_dir);
canonicalize_pathname (s);
if (s[0] == '.' && s[1] == '\0')
if (DIR_IS_DOT (s))
{
*start_dir = g_strdup (vfs_path_as_str (current_panel->cwd_vpath));
/* FIXME: is current_panel->cwd_vpath canonicalized? */
@ -792,7 +792,7 @@ find_parameters (char **start_dir, ssize_t * start_dir_len,
}
if (!options.ignore_dirs_enable || in_ignore->buffer[0] == '\0'
|| (in_ignore->buffer[0] == '.' && in_ignore->buffer[1] == '\0'))
|| DIR_IS_DOT (in_ignore->buffer))
*ignore_dirs = NULL;
else
*ignore_dirs = g_strdup (in_ignore->buffer);
@ -1306,7 +1306,7 @@ do_search (WDialog * h)
;
} /* while (!dp) */
if (strcmp (dp->d_name, ".") == 0 || strcmp (dp->d_name, "..") == 0)
if (DIR_IS_DOT (dp->d_name) || DIR_IS_DOTDOT (dp->d_name))
{
/* skip invalid filenames */
while ((dp = mc_readdir (dirp)) != NULL && !str_is_valid_string (dp->d_name))

Просмотреть файл

@ -1384,6 +1384,9 @@ midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
return MSG_HANDLED;
case MSG_RESIZE:
/* dlg_set_size() is surplus for this case */
w->lines = LINES;
w->cols = COLS;
setup_panels ();
menubar_arrange (the_menubar);
return MSG_HANDLED;

Просмотреть файл

@ -779,10 +779,10 @@ read_file_system_list (int need_fs_type)
char *name;
struct stat statbuf;
if (strcmp (d->d_name, "..") == 0)
if (DIR_IS_DOT (d->d_name))
continue;
if (strcmp (d->d_name, ".") == 0)
if (DIR_IS_DOTDOT (d->d_name))
name = g_strdup ("/");
else
name = g_strconcat ("/", d->d_name, (char *) NULL);
@ -1610,7 +1610,7 @@ my_statfs (struct my_statfs *myfs_stats, const char *path)
** This is the "other side" of the hack to read_file_system_list() in
** mountlist.c.
** It's not the most efficient approach, but consumes less memory. It
** also accomodates QNX's ability to mount filesystems on the fly.
** also accommodates QNX's ability to mount filesystems on the fly.
*/
struct mount_entry *entry;
struct fs_usage fs_use;

Просмотреть файл

@ -501,10 +501,8 @@ string_file_size (file_entry * fe, int len)
static char buffer[BUF_TINY];
/* Don't ever show size of ".." since we don't calculate it */
if (!strcmp (fe->fname, ".."))
{
if (DIR_IS_DOTDOT (fe->fname))
return _("UP--DIR");
}
#ifdef HAVE_STRUCT_STAT_ST_RDEV
if (S_ISBLK (fe->st.st_mode) || S_ISCHR (fe->st.st_mode))
@ -528,7 +526,7 @@ string_file_size_brief (file_entry * fe, int len)
return _("SYMLINK");
}
if ((S_ISDIR (fe->st.st_mode) || fe->f.link_to_dir) && strcmp (fe->fname, ".."))
if ((S_ISDIR (fe->st.st_mode) || fe->f.link_to_dir) && !DIR_IS_DOTDOT (fe->fname))
{
return _("SUB-DIR");
}
@ -1007,7 +1005,7 @@ display_mini_info (WPanel * panel)
else
tty_print_string (str_fit_to_term (_("<readlink failed>"), w->cols - 2, J_LEFT));
}
else if (strcmp (panel->dir.list[panel->selected].fname, "..") == 0)
else if (DIR_IS_DOTDOT (panel->dir.list[panel->selected].fname))
{
/* FIXME:
* while loading directory (do_load_dir() and do_reload_dir()),
@ -3881,8 +3879,8 @@ event_update_panels (const gchar * event_group_name, const gchar * event_name,
/* event callback */
static gboolean
panel_save_curent_file_to_clip_file (const gchar * event_group_name, const gchar * event_name,
gpointer init_data, gpointer data)
panel_save_current_file_to_clip_file (const gchar * event_group_name, const gchar * event_name,
gpointer init_data, gpointer data)
{
(void) event_group_name;
(void) event_name;
@ -4377,7 +4375,7 @@ do_file_mark (WPanel * panel, int idx, int mark)
return;
/* Only '..' can't be marked, '.' isn't visible */
if (strcmp (panel->dir.list[idx].fname, "..") == 0)
if (DIR_IS_DOTDOT (panel->dir.list[idx].fname))
return;
file_mark (panel, idx, mark);
@ -4537,10 +4535,11 @@ panel_change_encoding (WPanel * panel)
encoding = get_codepage_id (panel->codepage);
if (encoding != NULL)
{
vfs_change_encoding (panel->cwd_vpath, encoding);
vfs_path_change_encoding (panel->cwd_vpath, encoding);
if (!do_panel_cd (panel, panel->cwd_vpath, cd_parse_command))
message (D_ERROR, MSG_ERROR, _("Cannot chdir to \"%s\""), panel->cwd_vpath->str);
message (D_ERROR, MSG_ERROR, _("Cannot chdir to \"%s\""),
vfs_path_as_str (panel->cwd_vpath));
}
}
@ -4567,14 +4566,19 @@ remove_encoding_from_path (const vfs_path_t * vpath)
vfs_path_element_t *path_element;
path_element = vfs_path_element_clone (vfs_path_get_by_index (vpath, indx));
vfs_path_add_element (ret_vpath, path_element);
if (path_element->encoding == NULL)
{
vfs_path_add_element (ret_vpath, path_element);
continue;
}
converter = str_crt_conv_to (path_element->encoding);
if (converter == INVALID_CONV)
{
vfs_path_add_element (ret_vpath, path_element);
continue;
}
g_free (path_element->encoding);
path_element->encoding = NULL;
@ -4589,6 +4593,7 @@ remove_encoding_from_path (const vfs_path_t * vpath)
str_close_conv (converter);
str_close_conv (path_element->dir.converter);
path_element->dir.converter = INVALID_CONV;
vfs_path_add_element (ret_vpath, path_element);
}
g_string_free (tmp_conv, TRUE);
return ret_vpath;
@ -4770,8 +4775,8 @@ panel_init (void)
mc_skin_get ("widget-panel", "filename-scroll-right-char", "}");
mc_event_add (MCEVENT_GROUP_FILEMANAGER, "update_panels", event_update_panels, NULL, NULL);
mc_event_add (MCEVENT_GROUP_FILEMANAGER, "panel_save_curent_file_to_clip_file",
panel_save_curent_file_to_clip_file, NULL, NULL);
mc_event_add (MCEVENT_GROUP_FILEMANAGER, "panel_save_current_file_to_clip_file",
panel_save_current_file_to_clip_file, NULL, NULL);
}

Просмотреть файл

@ -429,10 +429,7 @@ do_panelize_cd (struct WPanel *panel)
for (i = 0; i < panelized_panel.count; i++)
{
if (panelized_same
|| (panelized_panel.list.list[i].fname[0] == '.'
&& panelized_panel.list.list[i].fname[1] == '.'
&& panelized_panel.list.list[i].fname[2] == '\0'))
if (panelized_same || DIR_IS_DOTDOT (panelized_panel.list.list[i].fname))
{
list->list[i].fnamelen = panelized_panel.list.list[i].fnamelen;
list->list[i].fname = g_strndup (panelized_panel.list.list[i].fname,

Просмотреть файл

@ -257,7 +257,8 @@ tree_show_mini_info (WTree * tree, int tree_lines, int tree_cols)
tty_setcolor (tree->is_panel ? NORMAL_COLOR : TREE_NORMALC (h));
tty_draw_hline (w->y + line, w->x + 1, ' ', tree_cols);
widget_move (w, line, 1);
tty_print_string (str_fit_to_term (tree->selected_ptr->name->str, tree_cols, J_LEFT_FIT));
tty_print_string (str_fit_to_term
(vfs_path_as_str (tree->selected_ptr->name), tree_cols, J_LEFT_FIT));
}
}
@ -316,7 +317,11 @@ show_tree (WTree * tree)
}
else if (current->sublevel == tree->selected_ptr->sublevel)
{
for (j = strlen (current->name->str) - 1; current->name->str[j] != PATH_SEP; j--);
const char *cname;
cname = vfs_path_as_str (current->name);
for (j = strlen (cname) - 1; cname[j] != PATH_SEP; j--)
;
if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
i++;
}
@ -355,8 +360,8 @@ show_tree (WTree * tree)
if (current->sublevel == topsublevel)
/* Show full name */
tty_print_string (str_fit_to_term
(current->name->str, tree_cols + (tree->is_panel ? 0 : 1),
J_LEFT_FIT));
(vfs_path_as_str (current->name),
tree_cols + (tree->is_panel ? 0 : 1), J_LEFT_FIT));
else
{
/* Sub level directory */
@ -403,8 +408,10 @@ show_tree (WTree * tree)
}
else if (current->sublevel == tree->selected_ptr->sublevel)
{
for (j = strlen (current->name->str) - 1; current->name->str[j] != PATH_SEP;
j--)
const char *cname;
cname = vfs_path_as_str (current->name);
for (j = strlen (cname) - 1; cname[j] != PATH_SEP; j--)
;
if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
break;
@ -762,7 +769,7 @@ tree_copy (WTree * tree, const char *default_dest)
return;
g_snprintf (msg, sizeof (msg), _("Copy \"%s\" directory to:"),
str_trunc (tree->selected_ptr->name->str, 50));
str_trunc (vfs_path_as_str (tree->selected_ptr->name), 50));
dest = input_expand_dialog (Q_ ("DialogTitle|Copy"),
msg, MC_HISTORY_FM_TREE_COPY, default_dest,
INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD);
@ -776,7 +783,8 @@ tree_copy (WTree * tree, const char *default_dest)
tctx = file_op_total_context_new ();
file_op_context_create_ui (ctx, FALSE, FILEGUI_DIALOG_MULTI_ITEM);
tctx->ask_overwrite = FALSE;
copy_dir_dir (tctx, ctx, tree->selected_ptr->name->str, dest, TRUE, FALSE, FALSE, NULL);
copy_dir_dir (tctx, ctx, vfs_path_as_str (tree->selected_ptr->name), dest, TRUE, FALSE,
FALSE, NULL);
file_op_total_context_destroy (tctx);
file_op_context_destroy (ctx);
}
@ -799,7 +807,7 @@ tree_move (WTree * tree, const char *default_dest)
return;
g_snprintf (msg, sizeof (msg), _("Move \"%s\" directory to:"),
str_trunc (tree->selected_ptr->name->str, 50));
str_trunc (vfs_path_as_str (tree->selected_ptr->name), 50));
dest =
input_expand_dialog (Q_ ("DialogTitle|Move"), msg, MC_HISTORY_FM_TREE_MOVE, default_dest,
INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD);
@ -823,7 +831,7 @@ tree_move (WTree * tree, const char *default_dest)
ctx = file_op_context_new (OP_MOVE);
tctx = file_op_total_context_new ();
file_op_context_create_ui (ctx, FALSE, FILEGUI_DIALOG_ONE_ITEM);
move_dir_dir (tctx, ctx, tree->selected_ptr->name->str, dest);
move_dir_dir (tctx, ctx, vfs_path_as_str (tree->selected_ptr->name), dest);
file_op_total_context_destroy (tctx);
file_op_context_destroy (ctx);
@ -868,7 +876,7 @@ tree_rmdir (void *data)
char *buf;
int result;
buf = g_strdup_printf (_("Delete %s?"), tree->selected_ptr->name->str);
buf = g_strdup_printf (_("Delete %s?"), vfs_path_as_str (tree->selected_ptr->name));
result = query_dialog (Q_ ("DialogTitle|Delete"), buf, D_ERROR, 2, _("&Yes"), _("&No"));
g_free (buf);

Просмотреть файл

@ -715,10 +715,13 @@ tree_store_remove_entry (const vfs_path_t * name_vpath)
while (current != NULL && vfs_path_equal_len (current->name, base->name, len))
{
gboolean ok;
const char *cname;
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP);
cname = vfs_path_as_str (current->name);
ok = (cname[len] == '\0' || cname[len] == PATH_SEP);
if (!ok)
break;
old = current;
current = current->next;
remove_entry (old);
@ -736,6 +739,8 @@ tree_store_mark_checked (const char *subname)
vfs_path_t *name;
tree_entry *current, *base;
int flag = 1;
const char *cname;
if (!ts.loaded)
return;
@ -743,10 +748,11 @@ tree_store_mark_checked (const char *subname)
return;
/* Calculate the full name of the subdirectory */
if (subname[0] == '.' && (subname[1] == 0 || (subname[1] == '.' && subname[2] == 0)))
if (DIR_IS_DOT (subname) || DIR_IS_DOTDOT (subname))
return;
if (ts.check_name->str[0] == PATH_SEP && ts.check_name->str[1] == 0)
cname = vfs_path_as_str (ts.check_name);
if (cname[0] == PATH_SEP && cname[1] == '\0')
name = vfs_path_build_filename (PATH_SEP_STR, subname, NULL);
else
name = vfs_path_append_new (ts.check_name, subname, NULL);
@ -777,10 +783,11 @@ tree_store_mark_checked (const char *subname)
{
gboolean ok;
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP
|| len == 1);
cname = vfs_path_as_str (current->name);
ok = (cname[len] == '\0' || cname[len] == PATH_SEP || len == 1);
if (!ok)
break;
current->mark = 0;
current = current->next;
}
@ -832,10 +839,13 @@ tree_store_start_check (const vfs_path_t * vpath)
while (current != NULL && vfs_path_equal_len (current->name, ts.check_name, len))
{
gboolean ok;
const char *cname;
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP || len == 1);
cname = vfs_path_as_str (current->name);
ok = (cname[len] == '\0' || cname[len] == PATH_SEP || len == 1);
if (!ok)
break;
current->mark = 1;
current = current->next;
}
@ -865,11 +875,13 @@ tree_store_end_check (void)
while (current != NULL && vfs_path_equal_len (current->name, ts.check_name, len))
{
gboolean ok;
const char *cname;
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP || len == 1);
cname = vfs_path_as_str (current->name);
ok = (cname[len] == '\0' || cname[len] == PATH_SEP || len == 1);
if (!ok)
break;
old = current;
current = current->next;
if (old->mark)
@ -915,18 +927,12 @@ tree_store_rescan (const vfs_path_t * vpath)
{
vfs_path_t *tmp_vpath;
if (dp->d_name[0] == '.')
{
if (dp->d_name[1] == 0 || (dp->d_name[1] == '.' && dp->d_name[2] == 0))
continue;
}
if (DIR_IS_DOT (dp->d_name) || DIR_IS_DOTDOT (dp->d_name))
continue;
tmp_vpath = vfs_path_append_new (vpath, dp->d_name, NULL);
if (mc_lstat (tmp_vpath, &buf) != -1)
{
if (S_ISDIR (buf.st_mode))
tree_store_mark_checked (dp->d_name);
}
if (mc_lstat (tmp_vpath, &buf) != -1 && S_ISDIR (buf.st_mode))
tree_store_mark_checked (dp->d_name);
vfs_path_free (tmp_vpath);
}
mc_closedir (dirp);

Просмотреть файл

@ -44,7 +44,7 @@
* Lazyness/widgeting attack: This file does use the dialog manager
* and uses mainly the dialog to achieve the help work. there is only
* one specialized widget and it's only used to forward the mouse messages
* to the appropiate routine.
* to the appropriate routine.
*/
@ -542,7 +542,7 @@ help_show (WDialog * h, const char *paint_start)
}
break;
case ' ':
/* word delimeter */
/* word delimiter */
if (painting)
help_print_word (h, word, &col, &line, TRUE);
break;

Просмотреть файл

@ -20,7 +20,7 @@
* Lazyness/widgeting attack: This file does use the dialog manager
* and uses mainly the dialog to achieve the help work. there is only
* one specialized widget and it's only used to forward the mouse messages
* to the appropiate routine.
* to the appropriate routine.
*
* This file is included by help.c and man2hlp.c
*/

Просмотреть файл

@ -1221,7 +1221,7 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt)
bPathNotEq = strcmp (p_subshell_cwd, p_current_panel_cwd);
}
if (bPathNotEq && strcmp (pcwd, ".") != 0)
if (bPathNotEq && !DIR_IS_DOT (pcwd))
{
char *cwd;

Просмотреть файл

@ -265,9 +265,9 @@ extfs_find_entry_int (struct entry *dir, const char *name, GSList * list,
c = *q;
*q = '\0';
if (strcmp (p, ".") != 0)
if (!DIR_IS_DOT (p))
{
if (strcmp (p, "..") == 0)
if (DIR_IS_DOTDOT (p))
pent = pent->dir;
else
{
@ -300,7 +300,7 @@ extfs_find_entry_int (struct entry *dir, const char *name, GSList * list,
}
/* When we load archive, we create automagically
* non-existant directories
* non-existent directories
*/
if (pent == NULL && make_dirs)
pent = extfs_generate_entry (dir->inode->archive, p, pdir, S_IFDIR | 0777);
@ -540,7 +540,7 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc)
*(p++) = '\0';
q = cfn;
}
if (S_ISDIR (hstat.st_mode) && (strcmp (p, ".") == 0 || strcmp (p, "..") == 0))
if (S_ISDIR (hstat.st_mode) && (DIR_IS_DOT (p) || DIR_IS_DOTDOT (p)))
goto read_extfs_continue;
pent = extfs_find_entry (current_archive->root_entry, q, TRUE, FALSE);
if (pent == NULL)

Просмотреть файл

@ -93,7 +93,7 @@ Files appearing before their parent directories in the listings
are now cached and printed later. This fixes a bug that would
cause some directories to be listed twice.
Temporary filenames are choosen better. That is, they are
Temporary filenames are chosen better. That is, they are
generated using tmpnam(3). Previously, hardcoded filenames
(in the current directory) would be used.

Просмотреть файл

@ -61,7 +61,7 @@ Changelog:
2.0 Added reading raw D64 image, and mapping for jokers. Now it is
possible to read files with PET-ASCII/control sequences in filenames.
Working with d64 images only. Added workaround for space at the
beggining of the filename.
beginning of the filename.
1.2 Added configuration env variables: UC1541_VERBOSE and UC1541_HIDE_DEL.
First one, if set to any value, will cause that error messages from
c1541 program will be redirected as a failure messages visible in MC.
@ -439,7 +439,7 @@ class Uc1541(object):
if '/' in display_name:
display_name = display_name.replace('/', '|')
# workaround for space and dash at the beggining of the
# workaround for space and dash at the beginning of the
# filename
char_map = {' ': '~',
'-': '_'}

Просмотреть файл

@ -32,7 +32,7 @@ SVAL(buf,pos)
returns the value of the unsigned short (16 bit) little-endian integer at
offset pos within buffer buf. An integer of this type is sometimes
refered to as "USHORT".
referred to as "USHORT".
-----------------------------------------------------------------------------
IVAL(buf,pos)
@ -93,7 +93,7 @@ RSSVAL(buf,pos,val)
sets the value of the unsigned short (16 bit) big-endian integer at
offset pos within buffer buf to value val.
refered to as "USHORT".
referred to as "USHORT".
-----------------------------------------------------------------------------
RSIVAL(buf,pos,val)
@ -127,7 +127,7 @@ mdrcnt: the maximum number of bytes of data which should be returned
param: a pointer to the parameters to be sent.
data: a pointer to the data to be sent.
rparam: a pointer to a pointer which will be set to point to the returned
paramters. The caller of call_api() must deallocate this memory.
parameters. The caller of call_api() must deallocate this memory.
rdata: a pointer to a pointer which will be set to point to the returned
data. The caller of call_api() must deallocate this memory.

Просмотреть файл

@ -236,7 +236,7 @@ interpret_interfaces (char *s, struct interface **interfaces, const char *descri
if (iface->bcast.s_addr != MKBCADDR (iface->ip.s_addr, iface->nmask.s_addr))
{
DEBUG (2, ("Warning: inconsistant interface %s\n", inet_ntoa (iface->ip)));
DEBUG (2, ("Warning: inconsistent interface %s\n", inet_ntoa (iface->ip)));
}
iface->next = NULL;

Просмотреть файл

@ -2343,7 +2343,7 @@ lp_killunused (BOOL (*snumused) (int))
#endif /* 0 */
#if 0
/***************************************************************************
save the curent values of all global and sDefault parameters into the
save the current values of all global and sDefault parameters into the
defaults union. This allows swat and testparm to show only the
changed (ie. non-default) parameters.
***************************************************************************/

Просмотреть файл

@ -167,7 +167,7 @@ EatComment (FILE * InFile)
static int
Continuation (char *line, int pos)
/* ------------------------------------------------------------------------ **
* Scan backards within a string to discover if the last non-whitespace
* Scan backwards within a string to discover if the last non-whitespace
* character is a line-continuation character ('\\').
*
* Input: line - A pointer to a buffer containing the string to be

Просмотреть файл

@ -705,7 +705,7 @@ undelfs_chdir (const vfs_path_t * vpath)
/* We may use access because ext2 file systems are local */
/* this could be fixed by making an ext2fs io manager to use */
/* our vfs, but that is left as an excercise for the reader */
/* our vfs, but that is left as an exercise for the reader */
fd = open (file, O_RDONLY);
if (fd == -1)
{