Some more compatibility improvements for C89 environments
This compiles now fine with gcc 2.95 on Haiku.
Этот коммит содержится в:
родитель
15ebd21195
Коммит
e29a42a02a
@ -71,10 +71,10 @@ static void browse_draw_info(struct dir *dr) {
|
||||
ncaddstr(4, 9, dr->flags & FF_DIR ? "Directory" : dr->flags & FF_FILE ? "File" : "Other");
|
||||
|
||||
if(e) {
|
||||
time_t t = (time_t)e->mtime;
|
||||
ncaddstr(4, 9, fmtmode(e->mode));
|
||||
ncprint(4, 26, "%d", e->uid);
|
||||
ncprint(4, 38, "%d", e->gid);
|
||||
time_t t = (time_t)e->mtime;
|
||||
strftime(mbuf, sizeof(mbuf), "%Y-%m-%d %H:%M:%S %z", localtime(&t));
|
||||
ncaddstr(5, 18, mbuf);
|
||||
}
|
||||
|
@ -77,13 +77,14 @@ void dir_curpath_leave() {
|
||||
|
||||
|
||||
void dir_setlasterr(const char *path) {
|
||||
int req;
|
||||
if(!path) {
|
||||
free(lasterr);
|
||||
lasterr = NULL;
|
||||
lasterrl = 0;
|
||||
return;
|
||||
}
|
||||
int req = strlen(path)+1;
|
||||
req = strlen(path)+1;
|
||||
if(lasterrl < req) {
|
||||
lasterrl = req;
|
||||
lasterr = xrealloc(lasterr, lasterrl);
|
||||
@ -93,12 +94,12 @@ void dir_setlasterr(const char *path) {
|
||||
|
||||
|
||||
void dir_seterr(const char *fmt, ...) {
|
||||
va_list va;
|
||||
free(dir_fatalerr);
|
||||
dir_fatalerr = NULL;
|
||||
if(!fmt)
|
||||
return;
|
||||
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
dir_fatalerr = xmalloc(1024); /* Should be enough for everything... */
|
||||
vsnprintf(dir_fatalerr, 1023, fmt, va);
|
||||
|
@ -45,13 +45,13 @@ static hl_t *links = NULL;
|
||||
/* recursively checks a dir structure for hard links and fills the lookup array */
|
||||
static void hlink_init(struct dir *d) {
|
||||
struct dir *t;
|
||||
int r;
|
||||
|
||||
for(t=d->sub; t!=NULL; t=t->next)
|
||||
hlink_init(t);
|
||||
|
||||
if(!(d->flags & FF_HLNKC))
|
||||
return;
|
||||
int r;
|
||||
hl_put(links, d, &r);
|
||||
}
|
||||
|
||||
|
@ -164,6 +164,7 @@ static char *dir_read(int *err) {
|
||||
buf = xmalloc(buflen);
|
||||
|
||||
while(1) {
|
||||
size_t len, req;
|
||||
errno = 0;
|
||||
if ((item = readdir(dir)) == NULL) {
|
||||
if(errno)
|
||||
@ -172,7 +173,8 @@ static char *dir_read(int *err) {
|
||||
}
|
||||
if(item->d_name[0] == '.' && (item->d_name[1] == 0 || (item->d_name[1] == '.' && item->d_name[2] == 0)))
|
||||
continue;
|
||||
size_t len = strlen(item->d_name), req = off+3+len;
|
||||
len = strlen(item->d_name);
|
||||
req = off+3+len;
|
||||
if(req > buflen) {
|
||||
buflen = req < buflen*2 ? buflen*2 : req;
|
||||
buf = xrealloc(buf, buflen);
|
||||
|
@ -122,8 +122,6 @@ static void argv_parse(int argc, char **argv) {
|
||||
char *import = NULL;
|
||||
char *dir = NULL;
|
||||
|
||||
uic_theme = getenv("NO_COLOR") ? 0 : 2;
|
||||
|
||||
static yopt_opt_t opts[] = {
|
||||
{ 'h', 0, "-h,-?,--help" },
|
||||
{ 'q', 0, "-q" },
|
||||
@ -149,6 +147,8 @@ static void argv_parse(int argc, char **argv) {
|
||||
{0,0,NULL}
|
||||
};
|
||||
|
||||
uic_theme = getenv("NO_COLOR") ? 0 : 2;
|
||||
|
||||
dir_ui = -1;
|
||||
si = 0;
|
||||
|
||||
|
@ -36,10 +36,11 @@
|
||||
|
||||
static void set_level(void) {
|
||||
static int done = 0;
|
||||
const char *lvl;
|
||||
char nlvl[2];
|
||||
if(done)
|
||||
return;
|
||||
const char *lvl = getenv("NCDU_LEVEL");
|
||||
lvl = getenv("NCDU_LEVEL");
|
||||
/* too lazy to count beyond 9 */
|
||||
if(lvl && *lvl >= '1' && *lvl < '9' && lvl[1] == 0) {
|
||||
nlvl[0] = 1 + *lvl;
|
||||
|
@ -147,10 +147,13 @@ char *fmtmode(unsigned short mode) {
|
||||
|
||||
|
||||
void read_locale() {
|
||||
#ifdef HAVE_LOCALE_H
|
||||
char *locale_thou_sep;
|
||||
#endif
|
||||
thou_sep = '.';
|
||||
#ifdef HAVE_LOCALE_H
|
||||
setlocale(LC_ALL, "");
|
||||
char *locale_thou_sep = localeconv()->thousands_sep;
|
||||
locale_thou_sep = localeconv()->thousands_sep;
|
||||
if(locale_thou_sep && 1 == strlen(locale_thou_sep))
|
||||
thou_sep = locale_thou_sep[0];
|
||||
#endif
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user