diff --git a/ppremake/configure.in b/ppremake/configure.in index da189e9fc8..f50c9e3de9 100644 --- a/ppremake/configure.in +++ b/ppremake/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(ppremake.cxx) -AM_INIT_AUTOMAKE(ppremake, 1.01) +AM_INIT_AUTOMAKE(ppremake, 1.02) AM_CONFIG_HEADER(config.h) AC_PREFIX_DEFAULT(/usr/local/panda) diff --git a/ppremake/ppCommandFile.cxx b/ppremake/ppCommandFile.cxx index b8068e75a6..0ed5fbb89d 100644 --- a/ppremake/ppCommandFile.cxx +++ b/ppremake/ppCommandFile.cxx @@ -153,8 +153,8 @@ write_makefile_line(const string &line) { while (wi != words.end()) { col += (*wi).length() + 1; if (col > 72) { - (*_out) << " \\\n "; - col = 4 + (*wi).length(); + (*_out) << " \\\n "; + col = 4 + (*wi).length(); } (*_out) << " " << (*wi); ++wi; @@ -389,7 +389,7 @@ read_line(string line) { // that start at the beginning of the line. size_t comment = line.find(begin_comment); while (comment != string::npos && - !(comment == 0 || isspace(line[comment - 1]))) { + !(comment == 0 || isspace(line[comment - 1]))) { comment = line.find(begin_comment, comment + begin_comment.length()); } @@ -424,23 +424,26 @@ read_line(string line) { // Find the beginning of the line--skip initial whitespace. size_t p = 0; while (p < line.length() && isspace(line[p])) { - p++; + p++; } if (p == line.length()) { - // The line is empty. Make it truly empty. - line = ""; - + // The line is empty. Make it truly empty. + line = ""; } else { - if (p + 1 < line.length() && line[p] == COMMAND_PREFIX && - isalpha(line[p + 1])) { - // This is a special command. - return handle_command(line.substr(p + 1)); - } + if (((p+1) < line.length()) && (line[p] == COMMAND_PREFIX) && + isalpha(line[p + 1])) { + // This is a special command. + return handle_command(line.substr(p + 1)); + } } - + if (!_in_for && !failed_if()) { - return _write_state->write_line(_scope->expand_string(line)); + if(line[p+1]==COMMAND_PREFIX) { + // double prefix at start of line indicates echo single prefix, like '\\' in C + line.erase(0,1); + } + return _write_state->write_line(_scope->expand_string(line)); } } } @@ -668,7 +671,7 @@ handle_if_command() { _params = _scope->expand_string(_params); string::const_iterator si; for (si = _params.begin(); si != _params.end() && is_empty; ++si) { - is_empty = isspace(*si); + is_empty = isspace(*si); } } @@ -784,14 +787,14 @@ handle_begin_command() { if (contains_whitespace(name)) { cerr << "Attempt to define scope named \"" << name - << "\".\nScope names may not contain whitespace.\n"; + << "\".\nScope names may not contain whitespace.\n"; return false; } if (name.find(SCOPE_DIRNAME_SEPARATOR) != string::npos) { cerr << "Attempt to define scope named \"" << name - << "\".\nScope names may not contain the '" - << SCOPE_DIRNAME_SEPARATOR << "' character.\n"; + << "\".\nScope names may not contain the '" + << SCOPE_DIRNAME_SEPARATOR << "' character.\n"; return false; } @@ -940,14 +943,14 @@ handle_defsub_command(bool is_defsub) { for (fi = formals.begin(); fi != formals.end(); ++fi) { if (!is_valid_formal(*fi)) { cerr << command << " " << subroutine_name - << ": invalid formal parameter name '" << (*fi) << "'\n"; + << ": invalid formal parameter name '" << (*fi) << "'\n"; return false; } } if (_in_for) { cerr << command << " may not appear within another block scoping command like\n" - << "#forscopes, #foreach, #formap, #defsub, or #defun.\n"; + << "#forscopes, #foreach, #formap, #defsub, or #defun.\n"; return false; } @@ -1004,7 +1007,7 @@ handle_output_command() { if (filename[0] != '/') { filename = prefix + filename; } - + nest->_filename = filename; // Generate an in-memory copy of the file first. @@ -1031,7 +1034,7 @@ handle_end_command() { string name = trim_blanks(_scope->expand_string(_params)); if (name != _block_nesting->_name) { cerr << "end " << name << " encountered where end " - << _block_nesting->_name << " expected.\n"; + << _block_nesting->_name << " expected.\n"; return false; } @@ -1086,8 +1089,8 @@ handle_end_command() { } else if (nest->_state == BS_output) { if (!_in_for) { if (!nest->_output) { - cerr << "Error while writing " << nest->_filename << "\n"; - return false; + cerr << "Error while writing " << nest->_filename << "\n"; + return false; } // Now compare the file we generated to the file that's already @@ -1096,8 +1099,8 @@ handle_end_command() { nest->_output << ends; const char *generated_file = nest->_output.str(); if (!compare_output(generated_file, nest->_filename, - (nest->_flags & OF_notouch) != 0)) { - return false; + (nest->_flags & OF_notouch) != 0)) { + return false; } } } @@ -1281,7 +1284,7 @@ handle_defer_command() { if (PPSubroutine::get_func(varname) != (const PPSubroutine *)NULL) { cerr << "Warning: variable " << varname - << " shadowed by function definition.\n"; + << " shadowed by function definition.\n"; } // Skip whitespace between the variable name and its definition. @@ -1320,7 +1323,7 @@ handle_define_command() { if (PPSubroutine::get_func(varname) != (const PPSubroutine *)NULL) { cerr << "Warning: variable " << varname - << " shadowed by function definition.\n"; + << " shadowed by function definition.\n"; } // Skip whitespace between the variable name and its definition. @@ -1359,7 +1362,7 @@ handle_set_command() { if (PPSubroutine::get_func(varname) != (const PPSubroutine *)NULL) { cerr << "Warning: variable " << varname - << " shadowed by function definition.\n"; + << " shadowed by function definition.\n"; } // Skip whitespace between the variable name and its definition. @@ -1588,7 +1591,7 @@ replay_formap(const string &varname, const string &mapvar) { PPScope::MapVariableDefinition &def = _scope->find_map_variable(mapvar); if (&def == &PPScope::_null_map_def) { cerr << "Undefined map variable: #formap " << varname << " " - << mapvar << "\n"; + << mapvar << "\n"; return false; } @@ -1630,7 +1633,7 @@ replay_formap(const string &varname, const string &mapvar) { //////////////////////////////////////////////////////////////////// bool PPCommandFile:: compare_output(const string &new_contents, const string &filename, - bool notouch) { + bool notouch) { bool exists = (access(filename.c_str(), F_OK) == 0); bool differ = false; @@ -1656,8 +1659,8 @@ compare_output(const string &new_contents, const string &filename, if (exists) { if (unlink(filename.c_str()) < 0) { - cerr << "Unable to remove old " << filename << "\n"; - return false; + cerr << "Unable to remove old " << filename << "\n"; + return false; } } @@ -1683,7 +1686,7 @@ compare_output(const string &new_contents, const string &filename, // makefiles know we did something. if (!notouch) { if (utime(filename.c_str(), (struct utimbuf *)NULL) < 0) { - cerr << "Warning: unable to touch " << filename << "\n"; + cerr << "Warning: unable to touch " << filename << "\n"; } } } @@ -1701,7 +1704,7 @@ compare_output(const string &new_contents, const string &filename, bool PPCommandFile:: failed_if() const { return (_if_nesting != (IfNesting *)NULL && - (_if_nesting->_state == IS_off || _if_nesting->_state == IS_done)); + (_if_nesting->_state == IS_off || _if_nesting->_state == IS_done)); } //////////////////////////////////////////////////////////////////// diff --git a/ppremake/ppDependableFile.cxx b/ppremake/ppDependableFile.cxx index 5258907717..00cd83b69f 100644 --- a/ppremake/ppDependableFile.cxx +++ b/ppremake/ppDependableFile.cxx @@ -80,23 +80,23 @@ update_from_cache(const vector &words) { dep._okcircular = false; if (dirpath.length() > 1 && dirpath[0] == '/') { - // If the first character is '/', it means that the file has - // been marked okcircular. - dep._okcircular = true; - dirpath = dirpath.substr(1); + // If the first character is '/', it means that the file has + // been marked okcircular. + dep._okcircular = true; + dirpath = dirpath.substr(1); } if (dirpath.length() > 2 && dirpath.substr(0, 2) == "*/") { - // This is an extra include file, not a file in this source - // tree. - _extra_includes.push_back(dirpath.substr(2)); + // This is an extra include file, not a file in this source + // tree. + _extra_includes.push_back(dirpath.substr(2)); } else { - dep._file = - tree->get_dependable_file_by_dirpath(dirpath, false); - if (dep._file != (PPDependableFile *)NULL) { - _dependencies.push_back(dep); - } + dep._file = + tree->get_dependable_file_by_dirpath(dirpath, false); + if (dep._file != (PPDependableFile *)NULL) { + _dependencies.push_back(dep); + } } } @@ -351,11 +351,11 @@ compute_dependencies(string &circularity) { if (!in) { // Can't read the file, or the file doesn't exist. Interesting. if (exists()) { - cerr << "Warning: dependent file " << get_pathname() - << " exists but cannot be read.\n"; + cerr << "Warning: dependent file " << get_pathname() + << " exists but cannot be read.\n"; } else { - cerr << "Warning: dependent file " << get_pathname() - << " does not exist.\n"; + cerr << "Warning: dependent file " << get_pathname() + << " does not exist.\n"; } } else { @@ -365,30 +365,30 @@ compute_dependencies(string &circularity) { string line; getline(in, line); while (!in.fail() && !in.eof()) { - if (line.substr(0, 16) == "/* okcircular */") { - okcircular = true; - } else { - string filename = check_include(line); - if (!filename.empty() && filename.find('/') == string::npos) { - Dependency dep; - dep._okcircular = okcircular; - dep._file = tree->find_dependable_file(filename); - if (dep._file != (PPDependableFile *)NULL) { - // All right! Here's a file we depend on. Add it to the - // list. - _dependencies.push_back(dep); - - } else { - // It's an include file from somewhere else, not from within - // our source tree. We don't care about it, but we do need - // to record it so we can easily check later if the cache - // file has gone stale. - _extra_includes.push_back(filename); - } - } - okcircular = false; - } - getline(in, line); + if (line.substr(0, 16) == "/* okcircular */") { + okcircular = true; + } else { + string filename = check_include(line); + if (!filename.empty() && filename.find('/') == string::npos) { + Dependency dep; + dep._okcircular = okcircular; + dep._file = tree->find_dependable_file(filename); + if (dep._file != (PPDependableFile *)NULL) { + // All right! Here's a file we depend on. Add it to the + // list. + _dependencies.push_back(dep); + + } else { + // It's an include file from somewhere else, not from within + // our source tree. We don't care about it, but we do need + // to record it so we can easily check later if the cache + // file has gone stale. + _extra_includes.push_back(filename); + } + } + okcircular = false; + } + getline(in, line); } } } @@ -406,13 +406,13 @@ compute_dependencies(string &circularity) { if (!(*di)._okcircular) { circ = (*di)._file->compute_dependencies(circularity); if (circ != (PPDependableFile *)NULL) { - // Oops, a circularity. Silly user. - circularity = get_dirpath() + " => " + circularity; - - if (circ == this) { - _flags |= F_circularity; - _circularity = circularity; - } + // Oops, a circularity. Silly user. + circularity = get_dirpath() + " => " + circularity; + + if (circ == this) { + _flags |= F_circularity; + _circularity = circularity; + } } } } diff --git a/ppremake/ppremake.cxx b/ppremake/ppremake.cxx index a82eb77ab4..7b88d2c996 100644 --- a/ppremake/ppremake.cxx +++ b/ppremake/ppremake.cxx @@ -230,7 +230,7 @@ main(int argc, char *argv[]) { case 'D': if (!check_dependencies(optarg)) { - dependencies_stale = true; + dependencies_stale = true; } any_d = true; break; @@ -305,7 +305,7 @@ main(int argc, char *argv[]) { PPMain ppmain(&global_scope); if (!ppmain.read_source(".")) { - exit(1); + exit(1); } if (report_depends || report_needs) { @@ -319,11 +319,11 @@ main(int argc, char *argv[]) { for (int i = 1; i < argc; i++) { cerr << "\n"; if (report_depends) { - ppmain.report_depends(argv[i]); + ppmain.report_depends(argv[i]); } cerr << "\n"; if (report_needs) { - ppmain.report_needs(argv[i]); + ppmain.report_needs(argv[i]); } } @@ -332,14 +332,14 @@ main(int argc, char *argv[]) { if (argc < 2) { if (!ppmain.process_all()) { - exit(1); + exit(1); } } else { for (int i = 1; i < argc; i++) { - if (!ppmain.process(argv[i])) { - cerr << "Unable to process " << argv[i] << ".\n"; - exit(1); - } + if (!ppmain.process(argv[i])) { + cerr << "Unable to process " << argv[i] << ".\n"; + exit(1); + } } } }