| 958 | } |
| 959 | |
| 960 | bool HandleDifferentCommand(std::vector<std::string> const& args, |
| 961 | cmExecutionStatus& status) |
| 962 | { |
| 963 | /* |
| 964 | FILE(DIFFERENT <variable> FILES <lhs> <rhs>) |
| 965 | */ |
| 966 | |
| 967 | // Evaluate arguments. |
| 968 | char const* file_lhs = nullptr; |
| 969 | char const* file_rhs = nullptr; |
| 970 | char const* var = nullptr; |
| 971 | enum Doing |
| 972 | { |
| 973 | DoingNone, |
| 974 | DoingVar, |
| 975 | DoingFileLHS, |
| 976 | DoingFileRHS |
| 977 | }; |
| 978 | Doing doing = DoingVar; |
| 979 | for (unsigned int i = 1; i < args.size(); ++i) { |
| 980 | if (args[i] == "FILES") { |
| 981 | doing = DoingFileLHS; |
| 982 | } else if (doing == DoingVar) { |
| 983 | var = args[i].c_str(); |
| 984 | doing = DoingNone; |
| 985 | } else if (doing == DoingFileLHS) { |
| 986 | file_lhs = args[i].c_str(); |
| 987 | doing = DoingFileRHS; |
| 988 | } else if (doing == DoingFileRHS) { |
| 989 | file_rhs = args[i].c_str(); |
| 990 | doing = DoingNone; |
| 991 | } else { |
| 992 | status.SetError(cmStrCat("DIFFERENT given unknown argument ", args[i])); |
| 993 | return false; |
| 994 | } |
| 995 | } |
| 996 | if (!var) { |
| 997 | status.SetError("DIFFERENT not given result variable name."); |
| 998 | return false; |
| 999 | } |
| 1000 | if (!file_lhs || !file_rhs) { |
| 1001 | status.SetError("DIFFERENT not given FILES option with two file names."); |
| 1002 | return false; |
| 1003 | } |
| 1004 | |
| 1005 | // Compare the files. |
| 1006 | char const* result = |
| 1007 | cmSystemTools::FilesDiffer(file_lhs, file_rhs) ? "1" : "0"; |
| 1008 | status.GetMakefile().AddDefinition(var, result); |
| 1009 | return true; |
| 1010 | } |
| 1011 | |
| 1012 | bool HandleCopyCommand(std::vector<std::string> const& args, |
| 1013 | cmExecutionStatus& status) |
nothing calls this directly
no test coverage detected
searching dependent graphs…