die() deprecated and replaced with xerr, xerrx
This commit is contained in:
parent
fb4eb6b180
commit
36737dbb58
|
@ -17,14 +17,14 @@ long_line_column=72
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
current_page=6
|
current_page=6
|
||||||
FILE_NAME_0=176;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class_test.cpp;0
|
FILE_NAME_0=289;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class_test.cpp;0
|
||||||
FILE_NAME_1=1332;Make;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/Makefile;0
|
FILE_NAME_1=0;Make;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/Makefile;0
|
||||||
FILE_NAME_2=0;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class.cpp;0
|
FILE_NAME_2=0;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class.cpp;0
|
||||||
FILE_NAME_3=0;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class.hpp;0
|
FILE_NAME_3=0;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class.hpp;0
|
||||||
FILE_NAME_4=0;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class_tags.hpp;0
|
FILE_NAME_4=0;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class_tags.hpp;0
|
||||||
FILE_NAME_5=0;C;0;16;1;1;1;/home/kolan/projects/include/xmalloc.c;0
|
FILE_NAME_5=150;C;0;16;1;1;1;/home/kolan/projects/include/xerror.h;0
|
||||||
FILE_NAME_6=679;C;0;16;1;1;1;/home/kolan/projects/include/xmalloc.h;0
|
FILE_NAME_6=299;C;0;16;1;1;1;/home/kolan/projects/include/xerror.c;0
|
||||||
FILE_NAME_7=146;C;0;16;1;1;1;/home/kolan/projects/include/xerror.h;0
|
FILE_NAME_7=412;C;0;16;1;1;1;/home/kolan/projects/include/xmalloc.c;0
|
||||||
|
|
||||||
[build-menu]
|
[build-menu]
|
||||||
NF_00_LB=_Сделать
|
NF_00_LB=_Сделать
|
||||||
|
|
|
@ -14,23 +14,20 @@ using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc != 1) {
|
if (argc != 2)
|
||||||
die("Usage: ./tex_table_class_test /path/to/table.tex", -1);
|
xerrx(-1, "Usage: ./tex_table_class_test /path/to/table.tex", NULL);
|
||||||
}
|
|
||||||
|
|
||||||
FILE *tex_file = fopen(argv[1], "rb");
|
FILE *tex_file = fopen(argv[1], "rb");
|
||||||
if (!tex_file)
|
if (!tex_file)
|
||||||
die("main()", errno);
|
xerr(errno, "Cannot open %s", argv[1]);
|
||||||
|
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
int result = fstat(fileno(tex_file), &stat_buf);
|
if (fstat(fileno(tex_file), &stat_buf) == -1)
|
||||||
if (result == -1)
|
xerr(errno, "Cannot stat %s", argv[1]);
|
||||||
die("main()", errno);
|
|
||||||
|
|
||||||
char *tex_buf = (char *)xmalloc((size_t)stat_buf.st_size + 1);
|
char *tex_buf = (char *)xmalloc((size_t)stat_buf.st_size + 1);
|
||||||
if (fread(tex_buf, 1, (size_t)stat_buf.st_size, tex_file) != (size_t)stat_buf.st_size)
|
if (fread(tex_buf, 1, (size_t)stat_buf.st_size, tex_file) != (size_t)stat_buf.st_size)
|
||||||
die("main()", errno);
|
xerrx(errno, "Error reading %s", argv[1]);
|
||||||
|
|
||||||
tex_buf[stat_buf.st_size] = 0;
|
tex_buf[stat_buf.st_size] = 0;
|
||||||
|
|
||||||
fclose(tex_file);
|
fclose(tex_file);
|
||||||
|
|
Loading…
Reference in New Issue