From 57be9e29052bab715ac05f96fa91d0ac9c02a5d4 Mon Sep 17 00:00:00 2001
From: yorhel <yorhel@ce56bc8d-f834-0410-b703-f827bd498a76>
Date: Fri, 10 Oct 2008 10:56:48 +0000
Subject: [PATCH] Current directory is assumed when no directory is given on
 the commandline (more du-like), and give a proper error if a given dir
 exceeds PATH_MAX

git-svn-id: svn://blicky.net/ncdu/trunk@43 ce56bc8d-f834-0410-b703-f827bd498a76
---
 ChangeLog  |  1 +
 src/main.c | 11 ++++-------
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a0debf8..b69e77a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 svn - ?
 	- Fixed incorrect apparent size on directory refresh
 	- Browsing keys now work while file info window is displayed
+	- Current directory is assumed when no directory is specified
 
 1.4 - 2008-09-10
 	- Removed the startup window
diff --git a/src/main.c b/src/main.c
index af9b5c1..6928e02 100644
--- a/src/main.c
+++ b/src/main.c
@@ -43,7 +43,6 @@ void parseCli(int argc, char **argv) {
   sflags = 0;
   sdelay = 100;
   bflags = BF_SIZE | BF_DESC;
-  sdir[0] = '\0';
 
  /* read from commandline */
   for(i=1; i<argc; i++) {
@@ -88,14 +87,12 @@ void parseCli(int argc, char **argv) {
     } else {
       sdir[PATH_MAX - 1] = 0;
       strncpy(sdir, argv[i], PATH_MAX);
-      if(sdir[PATH_MAX - 1] != 0)
-        sdir[0] = 0;
+      if(sdir[PATH_MAX - 1] != 0) {
+        printf("Error: path length exceeds PATH_MAX\n");
+        exit(1);
+      }
     }
   }
-  if(!sdir[0]) {
-    printf("Please specify a directory.\nSee '%s -h' for more information.\n", argv[0]);
-    exit(1);
-  }
 }
 
 
-- 
GitLab