Re: [PATCH] concat_dir_and_file() needs fixes
- From: Roland Illig <roland illig gmx de>
- To: Jindrich Novy <jnovy redhat com>
- Cc: mc-devel gnome org
- Subject: Re: [PATCH] concat_dir_and_file() needs fixes
- Date: Fri, 02 Dec 2005 15:58:33 +0100
Jindrich Novy wrote:
--- 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;
+
It's obvious that you used mcedit here. :) (Hint: trailing white-space.)
+ /* Return filename when dir is empty */
+ if (!i) return g_strdup (filename);
This looks almost good, except that "i" is not a boolean variable. You
should use "if (i == 0)" instead.
+
+ if (file != NULL && *file == PATH_SEP)
+ file++;
Maybe we should rather make sure that this function is never called with
non-empty "dir" and "file" starting with a slash. Otherwise we might
hide bugs. How often do you want to concatenate two absolute paths?
Roland
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]