about summary refs log blame commit diff stats
path: root/015literal_noninteger.cc
blob: 554bcdd5150ba6cfc9cde3aa2c501c4ee2dd43e9 (plain) (tree)
ass="w"> maybe(get(Recipe, r).name) << "first ingredient of 'save' should be a string, but got " << inst.ingredients.at(0).to_string() << '\n' << end(); break; } if (!is_mu_string(inst.ingredients.at(1))) { raise_error << maybe(get(Recipe, r).name) << "second ingredient of 'save' should be an address:array:character, but got " << inst.ingredients.at(1).to_string() << '\n' << end(); break; } break; } :(before "End Primitive Recipe Implementations") case SAVE: { if (Current_scenario) break; // do nothing in tests string filename; if (is_literal_string(current_instruction().ingredients.at(0))) { filename = current_instruction().ingredients.at(0).name; } else if (is_mu_string(current_instruction().ingredients.at(0))) { filename = read_mu_string(ingredients.at(0).at(0)); } ofstream fout(("lesson/"+filename).c_str()); string contents = read_mu_string(ingredients.at(1).at(0)); fout << contents; fout.close(); if (!exists("lesson/.git")) break; // bug in git: git diff -q messes up --exit-code // explicitly say '--all' for git 1.9 int status = system("cd lesson; git add --all .; git diff HEAD --exit-code >/dev/null || git commit -a -m . >/dev/null"); if (status != 0) raise_error << "error in commit: contents " << contents << '\n' << end(); break; } :(code) bool exists(const string& filename) { struct stat dummy; return 0 == stat(filename.c_str(), &dummy); }