From 861555876837449fd8fc480845f642dab4a68b1e Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 12 Nov 2019 15:59:58 +0300 Subject: Use path_name in cc::lexer class --- libbuild2/cc/lexer.test.cxx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'libbuild2/cc/lexer.test.cxx') diff --git a/libbuild2/cc/lexer.test.cxx b/libbuild2/cc/lexer.test.cxx index 0aeadba..68bb152 100644 --- a/libbuild2/cc/lexer.test.cxx +++ b/libbuild2/cc/lexer.test.cxx @@ -23,7 +23,7 @@ namespace build2 main (int argc, char* argv[]) { bool loc (false); - const char* file (nullptr); + path file; for (int i (1); i != argc; ++i) { @@ -33,23 +33,28 @@ namespace build2 loc = true; else { - file = argv[i]; + file = path (argv[i]); break; } } try { + path_name in; ifdstream is; - if (file != nullptr) + + if (!file.empty ()) + { + in = path_name (file); is.open (file); + } else { - file = "stdin"; + in = path_name (""); is.open (fddup (stdin_fd ())); } - lexer l (is, path (file)); + lexer l (is, in); // No use printing eos since we will either get it or loop forever. // @@ -58,7 +63,7 @@ namespace build2 cout << t; if (loc) - cout << ' ' << t.file << ':' << t.line << ':' << t.column; + cout << ' ' << *t.file << ':' << t.line << ':' << t.column; cout << endl; } -- cgit v1.1