Re: [PING] was Re: [PATCH] Dynamically load XOpenDisplay, XQueryPointerand XCloseDisplay (2nd try)

2003-02-24 Thread Pavel Tsekov
On Sun, 23 Feb 2003, Pavel Roskin wrote:

 Hello!
 
   I just looked at your patch, and it looks good, but it needs testing with
   both glib-1.2 and glib-2.0, which would take some time.
 
  JFYI, I've tested the patch with both versions. On Cygwin, OpenBSD and
  Solaris I have glib-1.2. On Linux I'have glib-1.2 and glib-2.0, but the
  configure script picks up glib-2.0.
 
 Yes, I see that you did an excellent job.  My testing couldn't find any
 problems.  I have applied your patch.  Thank you!

Thank you! :) I see that you modified the patch a bit. I've fetched 
your changes from cvs and that's what I will use in the Cygwin version of 
MC.

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


Re: Retain orig. filename as suffix for tmp. filename

2003-02-24 Thread Adam Byrtek / alpha
On Mon, Feb 24, 2003 at 02:22:16AM -0500, Pavel Roskin wrote:
 If you preserve the whole filename, you are more likely to have spaces for
 some other special characters in the filename.  Some programs have
 problems with spaces in the filename (e.g. rpm 4.1).
 
 Even worse, some programs could be exploited by giving them bogus
 filenames as arguments.  I like your idea, but the security issue should
 be addressed (actually, it exists already because the extension can have
 bad stuff too).

Is filtering it with is_printable() and substituting spaces with '_'
enough?

Regards

-- 

  _.|._ |_  _.   :  Adam Byrtek /alpha/
 (_|||_)| |(_|   :  email  alpha@(irc.pl|debian.org)
 |   :  jabber alpha.pl(at)jabber.org, pgp 0xB25952C0
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: [Debian BTS] ru_RU.UTF-8 locale

2003-02-24 Thread Jakub Jelinek
On Mon, Feb 24, 2003 at 11:49:14AM +0100, Adam Byrtek / alpha wrote:
 Hi, I know there are several people here which use the Russian locale.
 Could you please try to reproduce this bug report or tell me whether I
 can close it? Maybe this guy just doesn't know how to configure
 UTF-8 terminal properly? Unfortunately I can't contact him...

mc doesn't work in UTF-8 locales.
A few days I hacked mc up so that at least the things I use often in mc
sort-of work with UTF-8, you can find the patch in
ftp://people.redhat.com/jakub/mc/
But view is not done at all and there is still a lot of places which need
changing.
The first thing to decide is what all locales mc wants to support.
E.g. supporting just ASCII compatible charsets (like UTF-8) is easier
than supporting ASCII incompatible ones.

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


Re: [Debian BTS] ru_RU.UTF-8 locale

2003-02-24 Thread Andrew V. Samoilov
Jakub Jelinek wrote:
On Mon, Feb 24, 2003 at 11:49:14AM +0100, Adam Byrtek / alpha wrote:

Hi, I know there are several people here which use the Russian locale.
Could you please try to reproduce this bug report or tell me whether I
can close it? Maybe this guy just doesn't know how to configure
UTF-8 terminal properly? Unfortunately I can't contact him...


mc doesn't work in UTF-8 locales.
A few days I hacked mc up so that at least the things I use often in mc
sort-of work with UTF-8, you can find the patch in
ftp://people.redhat.com/jakub/mc/
But view is not done at all and there is still a lot of places which need
changing.
The first thing to decide is what all locales mc wants to support.
E.g. supporting just ASCII compatible charsets (like UTF-8) is easier
than supporting ASCII incompatible ones.
	Jakub
Can you upload UTF8 related patches there?

--
Regards,
Andrew V. Samoilov


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


Re: Retain orig. filename as suffix for tmp. filename

2003-02-24 Thread Oswald Buddenhagen
On Mon, Feb 24, 2003 at 11:27:53AM +0100, Adam Byrtek / alpha wrote:
 On Mon, Feb 24, 2003 at 02:26:13AM +0100, Oswald Buddenhagen wrote:
   +if (basename  *basename==PATH_SEP)
   + basename++;
  this is totally bogus.
 
 No, this is not 'totally bogus'. Filename var always contains at least
 one PATH_SEP:
 
ok.

 So this 'if' is just to protect from the impossible. As all
 programmers know impossible happens about once a year to (and I want
 to be protected just in case some code changes etc.), and we surely
 dont want to increment NULL of increment beyond the string. Result is
 not so important in impossible case :)
 
then add an assert(basename); and increment right away. it's nonsense to
handle the impossible in any other way than bailing out.

greetings

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: Retain orig. filename as suffix for tmp. filename

2003-02-24 Thread Adam Byrtek / alpha
On Mon, Feb 24, 2003 at 03:35:32PM +0100, Oswald Buddenhagen wrote:
 then add an assert(basename); and increment right away. 

Sounds wise, thats what 'assert' is for... Thanks.

-- 

  _.|._ |_  _.   :  Adam Byrtek /alpha/
 (_|||_)| |(_|   :  email  alpha@(irc.pl|debian.org)
 |   :  jabber alpha.pl(at)jabber.org, pgp 0xB25952C0
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: [Debian BTS] ru_RU.UTF-8 locale

2003-02-24 Thread Jakub Jelinek
On Mon, Feb 24, 2003 at 04:07:57PM +0200, Andrew V. Samoilov wrote:
 Jakub Jelinek wrote:
  On Mon, Feb 24, 2003 at 11:49:14AM +0100, Adam Byrtek / alpha wrote:
  
 Hi, I know there are several people here which use the Russian locale.
 Could you please try to reproduce this bug report or tell me whether I
 can close it? Maybe this guy just doesn't know how to configure
 UTF-8 terminal properly? Unfortunately I can't contact him...
  
  
  mc doesn't work in UTF-8 locales.
  A few days I hacked mc up so that at least the things I use often in mc
  sort-of work with UTF-8, you can find the patch in
  ftp://people.redhat.com/jakub/mc/
  But view is not done at all and there is still a lot of places which need
  changing.
  The first thing to decide is what all locales mc wants to support.
  E.g. supporting just ASCII compatible charsets (like UTF-8) is easier
  than supporting ASCII incompatible ones.
  
  Jakub
 
 Can you upload UTF8 related patches there?

This is the UTF-8 patch which assumes UTF-8ized slang (AFAIK the original
UTF-8 patch we use in slang is from Debian, then we have a linedrawing patch
and I had to fix two places in slang so that linedrawing worked even
in say cs_CZ locale or some other non-latin1 non-UTF-8 locale).
MB_CUR_MAX == 1 assumptions are in about every file in mc/src :(.

--- mc-4.6.0/src/util.c.jj  2003-01-28 17:58:23.0 -0500
+++ mc-4.6.0/src/util.c 2003-02-21 08:36:36.0 -0500
@@ -35,6 +35,7 @@
 #include string.h
 #include ctype.h
 
+#include tty.h
 #include global.h
 #include profile.h
 #include main.h  /* mc_home */
@@ -47,6 +48,10 @@
 #include charsets.h
 #endif
 
+#ifdef UTF8
+#include wctype.h
+#endif
+
 static const char app_text [] = Midnight-Commander;
 int easy_patterns = 1;
 
@@ -73,8 +78,31 @@ is_8bit_printable (unsigned char c)
 }
 
 int
+mbstrlen (const char *str)
+{
+#ifdef UTF8
+if (SLsmg_Is_Unicode) {
+   static mbstate_t s;
+   int len;
+
+   len = mbsrtowcs (NULL, str, -1, s);
+   if (len  0) {
+   memset (s, 0, sizeof (s));
+   return -1;
+   }
+   return len;
+} else
+#endif
+   return strlen (str);
+}
+
+int
 is_printable (int c)
 {
+#ifdef UTF8
+if (SLsmg_Is_Unicode)
+   return iswprint (c);
+#endif
 c = 0xff;
 
 #ifdef HAVE_CHARSET
@@ -217,25 +245,90 @@ char *
 name_trunc (const char *txt, int trunc_len)
 {
 static char x[MC_MAXPATHLEN + MC_MAXPATHLEN];
-int txt_len;
+int txt_len, first, skip;
 char *p;
+const char *str;
 
 if (trunc_len  sizeof (x) - 1) {
trunc_len = sizeof (x) - 1;
 }
-txt_len = strlen (txt);
-if (txt_len = trunc_len) {
-   strcpy (x, txt);
-} else {
-   int y = (trunc_len / 2) + (trunc_len % 2);
-   strncpy (x, txt, y);
-   strncpy (x + y, txt + txt_len - (trunc_len / 2), trunc_len / 2);
-   x[y] = '~';
-}
-x[trunc_len] = 0;
-for (p = x; *p; p++)
-   if (!is_printable (*p))
-   *p = '?';
+txt_len = mbstrlen (txt);
+first = 0;
+skip = 0;
+if (txt_len  trunc_len) {
+   first = trunc_len / 2;
+   skip = txt_len - trunc_len + 1;
+}
+
+#ifdef UTF8
+if (SLsmg_Is_Unicode) {
+   mbstate_t s;
+   int mbmax;
+
+   str = txt;
+   memset (s, 0, sizeof (s));
+   mbmax = MB_CUR_MAX;
+   p = x;
+   while (p  x + sizeof (x) - 1  trunc_len) {
+   wchar_t wc;
+   int len;
+
+   len = mbrtowc (wc, str, mbmax, s);
+   if (!len)
+   break;
+   if (len  0) {
+   memset (s, 0, sizeof (s));
+   *p = '?';
+   len = 1;
+   str++;
+   } else if (!is_printable (wc)) {
+   *p = '?';
+   str += len;
+   len = 1;
+   } else if (p = x + sizeof (x) - len)
+   break;
+   else {
+   memcpy (p, str, len);
+   str += len;
+   }
+   if (first) {
+   --trunc_len;
+   --first;
+   p += len;
+   if (!first  p  x + sizeof (x) - 1  trunc_len) {
+   *p++ = '~';
+   --trunc_len;
+   }
+   } else if (skip)
+   --skip;
+   else {
+   --trunc_len;
+   p += len;
+   }
+   }
+} else
+#endif
+{
+   str = txt;
+   p = x;
+   while (p  x + sizeof (x) - 1) {
+   if (*str == '\0')
+   break;
+   else if (!is_printable (*str))
+   *p++ = '?';
+   else
+   *p++ = *str;
+   ++str;
+   if (first) {
+   --first;
+   if (!first) {
+   *p++ = '~';
+   str += skip;
+   }
+   }
+   }
+}
+*p = '\0';
 return x;
 }
 
@@ -664,12 +757,14 @@ short-month-name sizes for different loc
 size_t i18n_checktimelength