diff options
| author | Siesh1oo <siesh1oo@siesh1oo.no> | 2014-03-10 14:36:27 +0100 | 
|---|---|---|
| committer | Siesh1oo <siesh1oo@siesh1oo.no> | 2014-03-10 14:36:27 +0100 | 
| commit | f6579282d73aec055e2fc4ebebd1b6313da248fd (patch) | |
| tree | 96c854b247e03acacd61ee43625a746746bf5ddc | |
| parent | c056217e72ff1e2da1340f97ad3a76f3ed486841 (diff) | |
| download | yosys-f6579282d73aec055e2fc4ebebd1b6313da248fd.tar.gz yosys-f6579282d73aec055e2fc4ebebd1b6313da248fd.tar.bz2 yosys-f6579282d73aec055e2fc4ebebd1b6313da248fd.zip  | |
 - frontends/vhdl2verilog/vhdl2verilog.cc: #include <cerrno> for errno; use POSIX getcwd() for portability.
| -rw-r--r-- | frontends/vhdl2verilog/vhdl2verilog.cc | 15 | 
1 files changed, 11 insertions, 4 deletions
diff --git a/frontends/vhdl2verilog/vhdl2verilog.cc b/frontends/vhdl2verilog/vhdl2verilog.cc index 0467810e5..d8568fe94 100644 --- a/frontends/vhdl2verilog/vhdl2verilog.cc +++ b/frontends/vhdl2verilog/vhdl2verilog.cc @@ -26,6 +26,7 @@  #include <stdio.h>  #include <string.h>  #include <dirent.h> +#include <errno.h>  struct Vhdl2verilogPass : public Pass {  	Vhdl2verilogPass() : Pass("vhdl2verilog", "importing VHDL designs using vhdl2verilog") { } @@ -93,9 +94,12 @@ struct Vhdl2verilogPass : public Pass {  			log_error("For some reason mkdtemp() failed!\n");  		if (!out_file.empty() && out_file[0] != '/') { -			char *pwd = get_current_dir_name(); +			char pwd [PATH_MAX]; +			if (!getcwd(pwd, sizeof(pwd))) { +				log_cmd_error("getcwd failed: %s", strerror(errno)); +				log_abort(); +			}  			out_file = pwd + ("/" + out_file); -			free(pwd);  		}  		FILE *f = fopen(stringf("%s/files.list", tempdir_name).c_str(), "wt"); @@ -104,9 +108,12 @@ struct Vhdl2verilogPass : public Pass {  			if (file.empty())  				continue;  			if (file[0] != '/') { -				char *pwd = get_current_dir_name(); +				char pwd [PATH_MAX]; +				if (!getcwd(pwd, sizeof(pwd))) { +					log_cmd_error("getcwd failed: %s", strerror(errno)); +					log_abort(); +				}  				file = pwd + ("/" + file); -				free(pwd);  			}  			fprintf(f, "%s\n", file.c_str());  			log("Adding '%s' to the file list.\n", file.c_str());  | 
