Some compatibility improvements for older (C89) environments
Whether this actually works on older environments, I don't really know.
Этот коммит содержится в:
родитель
b340c04450
Коммит
15ebd21195
@ -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"
|
||||
|
@ -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(
|
||||
|
27
deps/strnatcmp.c
поставляемый
27
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 <stddef.h> /* size_t */
|
||||
#include <ctype.h>
|
||||
|
||||
#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
|
||||
|
@ -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')
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user