Patchwork monitor: Ignore "." and ".." when completing file name.

login
register
mail settings
Submitter Kusanagi Kouichi
Date Oct. 20, 2010, 9 a.m.
Message ID <20101020090002.59B583E403B@msa101.auone-net.jp>
Download mbox | patch
Permalink /patch/68415/
State New
Headers show

Comments

Kusanagi Kouichi - Oct. 20, 2010, 9 a.m.
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
---
 monitor.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
Luiz Capitulino - Oct. 20, 2010, 4:58 p.m.
On Wed, 20 Oct 2010 18:00:01 +0900
Kusanagi Kouichi <slash@ac.auone-net.jp> wrote:

> 
> Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>

Applied to the Monitor queue, thanks.

> ---
>  monitor.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 260cc02..61607c5 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -3976,6 +3976,11 @@ static void file_completion(const char *input)
>          d = readdir(ffs);
>          if (!d)
>              break;
> +
> +        if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) {
> +            continue;
> +        }
> +
>          if (strstart(d->d_name, file_prefix, NULL)) {
>              memcpy(file, input, input_path_len);
>              if (input_path_len < sizeof(file))

Patch

diff --git a/monitor.c b/monitor.c
index 260cc02..61607c5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3976,6 +3976,11 @@  static void file_completion(const char *input)
         d = readdir(ffs);
         if (!d)
             break;
+
+        if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) {
+            continue;
+        }
+
         if (strstart(d->d_name, file_prefix, NULL)) {
             memcpy(file, input, input_path_len);
             if (input_path_len < sizeof(file))