diff --git a/Makefile.am b/Makefile.am index acd27df..f5ef951 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,6 +45,8 @@ EXTRA_DIST=ncdu.1 doc/ncdu.pod ncdu.1: $(srcdir)/doc/ncdu.pod pod2man --center "ncdu manual" --release "@PACKAGE@-@VERSION@" "$(srcdir)/doc/ncdu.pod" >ncdu.1 +# This target exists more for documentation purposes than actual use; some +# dependencies have minor ncdu-specific changes. update-deps: wget -q https://raw.github.com/attractivechaos/klib/master/khashl.h -O "$(srcdir)/deps/khashl.h" wget -q http://g.blicky.net/ylib.git/plain/yopt.h -O "$(srcdir)/deps/yopt.h" diff --git a/configure.ac b/configure.ac index d2562d4..9d57782 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,11 @@ AC_INIT([ncdu],[1.16],[projects@yorhel.nl]) AC_CONFIG_SRCDIR([src/global.h]) -AC_CONFIG_HEADER([config.h]) +AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign std-options subdir-objects]) # Check for programs. +AC_USE_SYSTEM_EXTENSIONS AC_PROG_CC AC_PROG_INSTALL AC_PROG_RANLIB @@ -22,6 +23,8 @@ AC_TYPE_INT64_T AC_TYPE_UINT64_T AC_SYS_LARGEFILE AC_STRUCT_ST_BLOCKS +AC_C_INLINE +AC_C_FLEXIBLE_ARRAY_MEMBER # Check for library functions. AC_CHECK_FUNCS( diff --git a/deps/strnatcmp.c b/deps/strnatcmp.c index e253eec..21815d9 100644 --- a/deps/strnatcmp.c +++ b/deps/strnatcmp.c @@ -28,35 +28,22 @@ * Eric Sosman pointed out that ctype functions take a parameter whose * value must be that of an unsigned int, even on platforms that have * negative chars in their default char type. + * + * ncdu edits: + * - static inline -> #define for better compatibility + * - don't use ctype.h, for more predictable results */ #include /* size_t */ -#include #include "strnatcmp.h" /* These are defined as macros to make it easier to adapt this code to * different characters types or comparison functions. */ -static inline int -nat_isdigit(nat_char a) -{ - return isdigit((unsigned char) a); -} - - -static inline int -nat_isspace(nat_char a) -{ - return isspace((unsigned char) a); -} - - -static inline nat_char -nat_toupper(nat_char a) -{ - return toupper((unsigned char) a); -} +#define nat_isdigit(a) ((a) >= '0' && (a) <= '9') +#define nat_isspace(a) ((a) == ' ' || (a) == '\t' || (a) == '\r' || (a) == '\n') +#define nat_toupper(a) (a) static int diff --git a/src/dir_import.c b/src/dir_import.c index 0f42d5e..687e93f 100644 --- a/src/dir_import.c +++ b/src/dir_import.c @@ -465,7 +465,7 @@ static int iteminfo(void) { C(rint64(&iv, UINT64_MAX)); ctx->buf_dir->flags |= FF_EXT; ctx->buf_ext->mtime = iv; - // Accept decimal numbers, but discard the fractional part because our data model doesn't support it. + /* Accept decimal numbers, but discard the fractional part because our data model doesn't support it. */ if(*ctx->buf == '.') { con(1); while(*ctx->buf >= '0' && *ctx->buf <= '9') diff --git a/src/dir_mem.c b/src/dir_mem.c index fa19c6a..7b40571 100644 --- a/src/dir_mem.c +++ b/src/dir_mem.c @@ -127,7 +127,7 @@ static int item(struct dir *dir, const char *name, struct dir_ext *ext, unsigned item = xmalloc(dir->flags & FF_EXT ? dir_ext_memsize(name) : dir_memsize(name)); memcpy(item, dir, offsetof(struct dir, name)); strcpy(item->name, name); - if(dir->flags & FF_EXT) + if(item->flags & FF_EXT) memcpy(dir_ext_ptr(item), ext, sizeof(struct dir_ext)); item_add(item); diff --git a/src/global.h b/src/global.h index a5d1b02..52f899c 100644 --- a/src/global.h +++ b/src/global.h @@ -70,7 +70,7 @@ struct dir { struct dir *parent, *next, *prev, *sub, *hlnk; int items; unsigned short flags; - char name[]; + char name[FLEXIBLE_ARRAY_MEMBER]; }; /* A note on the ino and dev fields above: ino is usually represented as ino_t, diff --git a/src/shell.c b/src/shell.c index 04e6033..e30bc65 100644 --- a/src/shell.c +++ b/src/shell.c @@ -40,7 +40,7 @@ static void set_level(void) { if(done) return; const char *lvl = getenv("NCDU_LEVEL"); - // too lazy to count beyond 9 + /* too lazy to count beyond 9 */ if(lvl && *lvl >= '1' && *lvl < '9' && lvl[1] == 0) { nlvl[0] = 1 + *lvl; nlvl[1] = 0; diff --git a/src/util.h b/src/util.h index 0eceb36..19689d3 100644 --- a/src/util.h +++ b/src/util.h @@ -73,17 +73,12 @@ extern int subwinr, subwinc; extern int si; -/* Macros/functions for managing struct dir and struct dir_ext */ +/* Macros for managing struct dir and struct dir_ext */ #define dir_memsize(n) (offsetof(struct dir, name)+1+strlen(n)) #define dir_ext_offset(n) ((dir_memsize(n) + 7) & ~7) #define dir_ext_memsize(n) (dir_ext_offset(n) + sizeof(struct dir_ext)) - -static inline struct dir_ext *dir_ext_ptr(struct dir *d) { - return d->flags & FF_EXT - ? (struct dir_ext *) ( ((char *)d) + dir_ext_offset(d->name) ) - : NULL; -} +#define dir_ext_ptr(d) ((d)->flags & FF_EXT ? (struct dir_ext *) ( ((char *)(d)) + dir_ext_offset((d)->name) ) : NULL) /* Instead of using several ncurses windows, we only draw to stdscr.