MC key-strokes screwed when DISPLAY variable points to valid X-server

2003-07-02 Thread Yuri
I was running from console X-apps (on FreeBSD).
Than started mc (4.6.0).

All up/down keys have no effect as many others.
ENTER key just always copies current directory
into the command line.

I think that's bug.
Should run from console just as purely-console app
regardless of presence/validity of DISPLAY variable.


Yuri


PS: I don't subscribe to mc-devel list so please CC me
responses.
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: [bug] three small bugs in mc (2003-06-25-17)

2003-07-02 Thread David Sterba
Hi,


> When I press F4 in search results box, edit the file and then exit the
> editor, i get back to the search result box (as expected), but instead
of
> seeing file panels under the search result box as in old mc versions, i
see
> the editor screen (just the current file on which the cursor is is
redrawn,
> so it looks quite messy). On older mc's (4.5.55), entire active panel is
> redrawn (and the other half of screen is the editor). The same bug
applies
> to invoking viewer
Are you running MC from screen?

> Small bug in internally handled 'cd' command:
> I have two directories:
> directory /a
> directory /a/mc-2003-06-25-17
> (and nothing more in /a)
> now if I type anywhere in bash 'cd /a/mc*' I get to directory
> '/a/mc-2003-06-25-17', since mc* is expanded to full name of the
directory
> but if I type it into mc command line, I get nowhere and it says
'/a/mc*:
> no such directory' Also commands like 'cd
> /some/dir;some_command_to_launch_there' also don't work
If you want to use wildcards, ${expressions:-or such}, you should
use '$ eval cd /a/mc*'.

> Also sometimes when I'm searching in files and press 's' (even multiple
> times) the suspend does not work and the search continues on (it get
> through about five more files before finally stopping) Note - I have a
486,
> can it be caused by the CPU slowness?
This nappens on my P3 too :-)
Responsibility of file find dialog is in TODO, and a working patch exist.


David
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: [patch] change sort order with single keyboard shortcut

2003-07-02 Thread David Sterba
Hi,

> After applying my patch, following keys start
> to work:
>  Sort by name   Ctrl-F3
>  Sort by extension  Ctrl-F4
>  Sort by modification time  Ctrl-F5
>  Sort by size   Ctrl-F6
>  Keep unsorted  Ctrl-F7
>  Sort by creation time  Ctrl-F8
>  Sort by access timeCtrl-F9
Ctrl-Fx keys are predefined in KDE to switch desktop and most users
don't change it.
You should choose different unused key set. Yes, it may be difficult :-)


David
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel


[PATCH] convert C literals in File Find

2003-07-02 Thread David Sterba
Hi,

I'm sending a patch which adds a checkbox to File Find dialog,
wich determines whether to convert C literals in the content-search
pattern.

I came across some things that should be discussed.

Let's now describe what it does:
- basic "one-letter" escapes: \a \b \e \f \n \r \t
- \ooo - octal number, 0 <= o <= 7, at most 3 digits
- \xHH - hexa number, 0 <= H <= f, a-f, A-F, at most 2 digits
- lets untouched these regex escapes \( \) \[ \] \{ \} \$ \^ \* \.

and now what it does not
- convert double-backslash to single-backslash
  if it would then any backslash should be escaped twice,
  one for C conversion and once for regex

As regexps are matched on 1 line only, there is no reason to type
"\n" to pattern.


Daviddiff -X .diffignore -urNp mc/src/ChangeLog mc-clit/src/ChangeLog
--- mc/src/ChangeLogThu Jul  3 01:35:21 CEST 2003
+++ mc-clit/src/ChangeLog   Thu Jul  3 01:35:21 CEST 2003
@@ -0,0 +1,10 @@
+2003-07-03  David Sterba  <[EMAIL PROTECTED]>
+
+   * find.c: Add a 'convert C literals' checkbox to Find File dialog.
+   (convert_x_digit): New func.
+   (translate_c_literals): New func. Converts all C escape sequences
+   to chars. Lets escaped regex symbols untouched. See comment for
+   further details.
+   (find_parm_callback): If set, convert literals before regex search.
+   (find_parameters): Add checkbox, lower the buttons.
+
diff -X .diffignore -urNp mc/src/find.c mc-clit/src/find.c
--- mc/src/find.c   Wed Apr 16 17:26:29 2003
+++ mc-clit/src/find.c  Thu Jul  3 01:28:10 2003
@@ -46,7 +46,7 @@
 #include "../vfs/vfs.h"
 
 /* Size of the find parameters window */
-#define FIND_Y 14
+#define FIND_Y 15
 static int FIND_X = 50;
 
 /* Size of the find window */
@@ -71,6 +71,7 @@ static WInput *in_start;  /* Start path *
 static WInput *in_name;/* Pattern to search */
 static WInput *in_with;/* Text inside filename */
 static WCheck *case_sense; /* "case sensitive" checkbox */
+static WCheck *conv_literals;  /* "convert C literals" checkbox */
 
 static int running = 0;/* nice flag */
 static char *find_pattern; /* Pattern to search */
@@ -118,6 +119,122 @@ static void get_list_info (char **file, 
 static regex_t *r; /* Pointer to compiled content_pattern */
  
 static int case_sensitive = 1;
+static int convert_literals = 0;
+
+static int convert_x_digit (const char c);
+
+/* Translates C escape sequences to chars,
+ * result is allocated and should be freed.
+ *
+ * Notes:
+ * - "\\" is *not* translated to "\"
+ * - hexa constant is limited to 2 digits
+ * - octal constant is limited to 3 digits
+ * - the regex escapes go through: ()[]{}$^*.
+ * - "\n" has no sense because regexps are matched only on 1 line
+ */
+static char*
+translate_c_literals (const char *str)
+{
+char *result, *p;
+int val;
+
+/* Translation won't be longer than original */
+p = result = g_malloc (strlen (str) + 1);
+
+while (*str) {
+   if (*str != '\\') {
+   *p++ = *str++;
+   continue;
+   }
+
+   str++;
+   if (!*str) {
+   /* Malformed literal */
+   g_free (result);
+   return NULL;
+   }
+
+   /* Ocal number */
+   if ('0' <= *str && *str <= '7') {
+   val = *str++ - '0';
+
+   /* Second digit */
+   if ('0' <= *str && *str <= '7')
+   val = val * 8 + *str++ - '0';
+   else {
+   *p++ = val;
+   continue;
+   }
+
+   /* Last digit */
+   if ('0' <= *str && *str <= '7')
+   val = val * 8 + *str++ - '0';
+
+   *p++ = val;
+   continue;
+   }
+
+   switch (*str) {
+   case 'a': *p++ = '\a'; str++; break;
+   case 'b': *p++ = '\b'; str++; break;
+   case 'e': *p++ = '\e'; str++; break;
+   case 'f': *p++ = '\f'; str++; break;
+   case 'n': *p++ = '\n'; str++; break;
+   case 'r': *p++ = '\r'; str++; break;
+   case 't': *p++ = '\t'; str++; break;
+   case 'x':
+   /* Hexa number */
+   str++;
+   if (!*str || !isxdigit (*str)) {
+   g_free (result);
+   return NULL;
+   }
+
+   val = convert_x_digit (*str++);
+
+   /* Second digit */
+   if (isxdigit (*str))
+   val = val * 16 + convert_x_digit (*str++);
+
+   *p++ = val;
+   break;
+
+   /* Possible regexp */
+   case '(':
+   case ')':
+   case '[':
+   case ']':
+   case '{':
+   case '}':
+   case '*':
+   case '^':
+   case '$':
+   case '\\':
+   case '.': *p++ = '\\'; *p++ = *str++; break;
+
+   /* Invalid */
+   default:
+   g_free (result);
+   return NULL;
+   }
+}
+*p = 0;
+
+return result;

Re: [PATCH] File search responsiveness

2003-07-02 Thread David Sterba
Hi,

I forgot to remove some debugging code and sent it with the patch.


 David

diff -X .diffignore -urNp mc/src/ChangeLog mc-find/src/ChangeLog
--- mc/src/ChangeLogThu Jul  3 01:39:14 CEST 2003
+++ mc-find/src/ChangeLog   Thu Jul  3 01:39:14 CEST 2003
@@ -0,0 +1,7 @@
+
+   * file.c: New enum for find progress state. Add context vars
+   for last position.
+   (check_find_events): New func.
+   (search_content): Resume operation and return status to the caller.
+   (run_process): Init.
+
diff -X .diffignore -urNp mc/src/find.c mc-find/src/find.c
--- mc/src/find.c   Wed Apr 16 17:26:29 2003
+++ mc-find/src/find.c  Thu Jul  3 01:39:10 2003
@@ -43,6 +43,7 @@
 #include "wtools.h"
 #include "cmd.h"   /* view_file_at_line */
 #include "boxes.h"
+#include "key.h"
 #include "../vfs/vfs.h"
 
 /* Size of the find parameters window */
@@ -64,6 +65,12 @@ enum {
 B_VIEW
 };
 
+typedef enum {
+FIND_CONT,
+FIND_SUSPEND,
+FIND_ABORT
+} FindProgressStatus;
+
 /* List of directories to be ignored, separated by ':' */
 char *find_ignore_dirs = 0;
 
@@ -80,6 +87,11 @@ static int matches;  /* Number of matche
 static int is_start;   /* Status of the start/stop toggle button */
 static char *old_dir;
 
+/* Where did we stop */
+static int resuming;
+static int last_line;
+static int last_pos;
+
 static Dlg_head *find_dlg; /* The dialog */
 
 static WButton *stop_button;   /* pointer to the stop button */
@@ -437,32 +449,61 @@ get_line_at (int file_fd, char *buf, int
 return buffer;
 }
 
-/* 
+static FindProgressStatus
+check_find_events(Dlg_head *h)
+{
+Gpm_Event event;
+int c;
+
+c = get_event (&event, h->mouse_status == MOU_REPEAT, 0);
+if (c != EV_NONE) {
+   dlg_process_event (h, c, &event);
+   if (h->ret_value == B_ENTER
+   || h->ret_value == B_CANCEL
+   || h->ret_value == B_AGAIN
+   || h->ret_value == B_PANELIZE) {
+   /* dialog terminated */
+   return FIND_ABORT;
+   }
+   if (!h->send_idle_msg) {
+   /* searching suspended */
+   return FIND_SUSPEND;
+   }
+}
+
+return FIND_CONT;
+}
+
+/*
  * search_content:
  *
  * Search the global (FIXME) regexp compiled content_pattern string in the
  * DIRECTORY/FILE.  It will add the found entries to the find listbox.
+ *
+ * returns 0 if do_search should look for another file
+ * 1 if do_search should exit and proceed to the event handler
  */
-static void
+static int
 search_content (Dlg_head *h, char *directory, char *filename)
 {
 struct stat s;
 char buffer [BUF_SMALL];
 char *fname;
 int file_fd;
+int ret_val = 0;
 
 fname = concat_dir_and_file (directory, filename);
 
 if (mc_stat (fname, &s) != 0 || !S_ISREG (s.st_mode)){
g_free (fname);
-   return;
+   return 0;
 }
 
 file_fd = mc_open (fname, O_RDONLY);
 g_free (fname);
 
 if (file_fd == -1)
-   return;
+   return 0;
 
 g_snprintf (buffer, sizeof (buffer), _("Grepping in %s"), name_trunc (filename, 
FIND2_X_USE));
 
@@ -480,7 +521,15 @@ search_content (Dlg_head *h, char *direc
char *p;
int found = 0;
 
-   while ((p = get_line_at (file_fd, buffer, &pos, &n_read, sizeof (buffer), 
&has_newline))){
+   if (resuming) {
+  /* We've been previously suspended, start from the previous positio n */
+  resuming = 0;
+  line = last_line;
+  pos = last_pos;
+   }
+
+while ((p = get_line_at (file_fd, buffer, &pos, &n_read, sizeof (buffer), 
&has_newline))
+   && (ret_val == 0)) {
if (found == 0){/* Search in binary line once */
if (regexec (r, p, 1, 0, 0) == 0){
g_free (p);
@@ -494,10 +543,34 @@ search_content (Dlg_head *h, char *direc
found = 0;
}
g_free (p);
+
+   if ((line & 0xff) == 0) {
+   FindProgressStatus res;
+
+   res = check_find_events(h);
+   switch (res) {
+   case FIND_ABORT:
+   stop_idle (h);
+   ret_val = 1;
+   break;
+
+   case FIND_SUSPEND:
+   resuming = 1;
+   last_line = line;
+   last_pos = pos;
+   ret_val = 1;
+   break;
+
+   default:
+   break;
+   }
+   }
}
 }
 disable_interrupt_key ();
 mc_close (file_fd);
+
+return ret_val;
 }
 
 static int
@@ -593,9 +666,12 @@ do_search (struct Dlg_head *h)
 }
 
 if (regexp_match (find_pattern, dp->d_name, match_file)){
-   if (content_pattern)
-   search_content (h, directory, dp->d_name);
-   else 
+   if (content_pattern) {
+   if (search_content (h, directory, dp->d_name)) {
+   g_free (tmp_name);
+   retu

Re: very slow start of mc (4.6.0) on FreeBSD5.1-Release

2003-07-02 Thread Rob Ristroph

> "Michal" == Michal Szwaczko <[EMAIL PROTECTED]> writes:
Michal> 
Michal> On Wed, Jul 02, 2003 at 10:58:07AM +0200, Oliver Hoffmann wrote:
>> Hi developers!
>> 
>> I just installed FreeBSD5.1-Release and I wonder why it takes 35s on my 
>> Athlon1000-system to start the program. Similar boxes with FreeBSD4.8 or 
>> Debian 3.0 have a startup time of less than 2s.
>> Even mc -V takes ages.
>> What's wrong?
>> Thanks for hints. Maybe I could help you as well.
Michal> 
Michal> Your DNS is not configured or not responding. 
Michal> mc does gethostbyname() on startup IIRC. 
Michal> Check your /etc/resolv.conf 
Michal> 
Michal> Try to do netstat -a or anything that resolves hostnames 
Michal> If it freezes - it's your DNS configuration's fault. 
Michal> mc is no exception as it uses gethostbyname().
Michal> 
Michal> Anyway, it's for mc-users rather than mc-devel, try there ...
Michal> 
Michal> HTH

Sometime ago I made a floppy linux that had mc on it:

http://rgr.freeshell.org/flinux/mc-link/

This calling of gethostbyname() was a problem for me, because I needed
to include libnss libraries on the floppy which had limited space, but
I didn't really ever need to resolve a host name (the networking was
only IP address based.)  As I remember, I believe mc did not directly
link to the library, but loaded it when you needed it, thus tricking
me into thinking it didn't need that library because that library
wasn't listed in the output of "ldd /usr/bin/mc".

I considered changing the midnight commander code at the time but
managed to squeeze everything on a floppy in the end.

Perhaps in a future version of my floppy I might change mc to not call
gethostbyname() if it can't find that library; if so I will submit a
patch.  However, it works great now and I am very appreciative to all
the programmers who have worked in midnight commander.

--Rob

___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: very slow start of mc (4.6.0) on FreeBSD5.1-Release

2003-07-02 Thread Michal Szwaczko
On Wed, Jul 02, 2003 at 10:58:07AM +0200, Oliver Hoffmann wrote:
> Hi developers!
> 
> I just installed FreeBSD5.1-Release and I wonder why it takes 35s on my 
> Athlon1000-system to start the program. Similar boxes with FreeBSD4.8 or 
> Debian 3.0 have a startup time of less than 2s.
> Even mc -V takes ages.
> What's wrong?
> Thanks for hints. Maybe I could help you as well.

Your DNS is not configured or not responding. 
mc does gethostbyname() on startup IIRC. 
Check your /etc/resolv.conf 

Try to do netstat -a or anything that resolves hostnames 
If it freezes - it's your DNS configuration's fault. 
mc is no exception as it uses gethostbyname().

Anyway, it's for mc-users rather than mc-devel, try there ... 

HTH

-- 
[ MichaƂ 'Mikey' Szwaczko  | GPG Key#:0x653CBD53 ]
[ Developer/Troubleshooter | GNU Generation Now! ]
[ Warez? Get'em at 127.0.0.1 ]
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: very slow start of mc (4.6.0) on FreeBSD5.1-Release

2003-07-02 Thread Pavel Roskin
On Wed, 2 Jul 2003, Oliver Hoffmann wrote:

> Hi developers!
>
> I just installed FreeBSD5.1-Release and I wonder why it takes 35s on my
> Athlon1000-system to start the program. Similar boxes with FreeBSD4.8 or
> Debian 3.0 have a startup time of less than 2s.
> Even mc -V takes ages.
> What's wrong?
> Thanks for hints. Maybe I could help you as well.

Try debugging mc.  Interrupt it while it's waiting and give command
"where" in gdb.  My guess it that you have the DISPLAY environment that
points to a host that doesn't accept or reject connection attempts (e.g.
it's down or it's firewalled).

-- 
Regards,
Pavel Roskin
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: BUG: viewing compressed files

2003-07-02 Thread Pavel Roskin
On Mon, 30 Jun 2003, Dmitry Semyonov wrote:

> > In 4.6.0a if I enter the "Raw mode" then press F10, then F3 again
> > filename changes into "archive-2002.gz", but it changes back into
> > "archive-2002.gz#ugz" if I press F8 to enter "Parse mode" again...
> >
> > Does anybody have similar problems?
>
> I have exactly the same problem, at least with gz files.

I'm terribly sorry.  I think what I was testing wasn't the latest version.
I can reproduce the problem now.  The "type" entries in mc.ext were not
matched correctly.  The problem was introduced by a recent patch from
Andrew Samoilov.  I'm sorry that I didn't test that patch sufficiently.

Patch:

===
--- ChangeLog
+++ ChangeLog
@@ -1 +1,6 @@
+2003-07-02  Pavel Roskin  <[EMAIL PROTECTED]>
+
+   * ext.c (regex_check_type): Set content_shift to skip the
+   filename.
+
 2003-06-27  David Sterba  <[EMAIL PROTECTED]>
--- ext.c
+++ ext.c
@@ -419,6 +419,7 @@ regex_check_type (char *filename, int fi
if (islocal) {
if (!strncmp (content_string, filename, file_len)) {
/* Skip "filename: " */
+   content_shift = file_len;
if (content_string[content_shift] == ':') {
content_shift++;
/* Solaris' file prints tab(s) after ':' */
===

-- 
Regards,
Pavel Roskin
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel


very slow start of mc (4.6.0) on FreeBSD5.1-Release

2003-07-02 Thread Oliver Hoffmann
Hi developers!

I just installed FreeBSD5.1-Release and I wonder why it takes 35s on my 
Athlon1000-system to start the program. Similar boxes with FreeBSD4.8 or 
Debian 3.0 have a startup time of less than 2s.
Even mc -V takes ages.
What's wrong?
Thanks for hints. Maybe I could help you as well.

Ragards,

Oliver Hoffmann


___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel