--- src/pinfo.c.~00~ 2006-03-09 20:44:51.000000000 +0100 +++ src/pinfo.c 2007-02-18 16:25:51.880672691 +0100 @@ -471,6 +471,7 @@ else /* open new info file */ { char *tmp; + long len; fclose(id); /*tmp = addinfosuffix(work_return_value.file); */ tmp = strdup(work_return_value.file); @@ -478,12 +479,31 @@ id = openinfo(tmp, 0); xfree(tmp); tmp = 0; - /* if the file doesn't exist */ + if (id != NULL) + { + /* test for empty file */ + fseek(id, 0L, SEEK_END); + len = ftell(id); + rewind(id); + /* on error len = -1 is returned by ftell, it is good for us here + * rewind clears file errors, it will be handled later */ + if (len == 0) + { + fclose(id); + id = 0; + } + } + else + len = -1; + /* if the file doesn't exist or its length is 0 */ if (id == NULL) { attrset(bottomline); mvhline(maxy - 1, 0, ' ', maxx); - mvaddstr(maxy - 1, 0, _("File not found. Press any key...")); + if (len == 0) + mvaddstr(maxy - 1, 0, _("File is empty. Press any key...")); + else + mvaddstr(maxy - 1, 0, _("File not found. Press any key...")); move(0, 0); attrset(normal); getch();