[PATCH] concat_dir_and_file() needs fixes
- From: Jindrich Novy <jnovy redhat com>
- To: mc-devel gnome org
- Subject: [PATCH] concat_dir_and_file() needs fixes
- Date: Fri, 02 Dec 2005 13:44:13 +0100
Hello mc-devel,
1)
There's a bug in concat_dir_and_file(). If you try to reproduce the PHP
syntax highlighting problem in:
http://mail.gnome.org/archives/mc-devel/2005-December/msg00000.html
then you'll get this message in the "Load syntax file" error dialog:
Error in file /usr/share/mc//syntax/php.syntax on line 4367
Note the two slashes in the path.
2)
When looking at concat_dir_and_file() to figure out what happens in 1)
you see:
char *
concat_dir_and_file (const char *dir, const char *file)
{
int i = strlen (dir);
if (dir [i-1] == PATH_SEP)
return g_strconcat (dir, file, (char *) NULL);
else
return g_strconcat (dir, PATH_SEP_STR, file, (char *) NULL);
}
what's odd -> imagine that dir="".
Patch to fix the both the bugs is attached.
Jindrich
--
Jindrich Novy <jnovy redhat com>, http://people.redhat.com/jnovy/
(o_ _o)
//\ The worst evil in the world is refusal to think. //\
V_/_ _\_V
--- mc-4.6.1a/src/util.c.jn 2005-12-02 11:08:26.000000000 +0100
+++ mc-4.6.1a/src/util.c 2005-12-02 13:11:19.000000000 +0100
@@ -1515,9 +1515,16 @@
/* If filename is NULL, then we just append PATH_SEP to the dir */
char *
-concat_dir_and_file (const char *dir, const char *file)
+concat_dir_and_file (const char *dir, const char *filename)
{
int i = strlen (dir);
+ const char *file = filename;
+
+ /* Return filename when dir is empty */
+ if (!i) return g_strdup (filename);
+
+ if (file != NULL && *file == PATH_SEP)
+ file++;
if (dir [i-1] == PATH_SEP)
return g_strconcat (dir, file, (char *) NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]