static int check_patch(git_patch_parsed *patch) { git_diff_delta *delta = patch->base.delta; if (check_filenames(patch) < 0) return -1; if (delta->old_file.path && delta->status != GIT_DELTA_DELETED && !delta->new_file.mode) delta->new_file.mode = delta->old_file.mode; if (delta->status == GIT_DELTA_MODIFIED && !(delta->flags & GIT_DIFF_FLAG_BINARY) && delta->new_file.mode == delta->old_file.mode && git_array_size(patch->base.hunks) == 0) return git_parse_err("patch with no hunks"); if (delta->status == GIT_DELTA_ADDED) { memset(&delta->old_file.id, 0x0, sizeof(git_oid)); delta->old_file.id_abbrev = 0; } if (delta->status == GIT_DELTA_DELETED) { memset(&delta->new_file.id, 0x0, sizeof(git_oid)); delta->new_file.id_abbrev = 0; } return 0; }
int main(int argc, char **argv) { char *in_filename; char *out_filename; argc--; argv++; if (argc == 2) { in_filename = argv[0]; out_filename = argv[1]; } else if (argc == 1) { in_filename = NULL; out_filename = argv[0]; } else { fprintf(stderr, "Not enough arguments\n\n"); usage(); exit(1); } int ret = check_filenames(in_filename, out_filename); if (ret == 1) { fprintf(stderr, "Files are the same.\n"); } if (ret > 0) { exit(1); } exit(process_file(in_filename, out_filename)); }
void Main_GUI::run() { statusBar()->clearMessage(); QString input_name = QDir::fromNativeSeparators(input_line->text()); QString output_name = QDir::fromNativeSeparators(output_line->text()); if (!check_filenames(input_name, output_name)) return; // we need C file descriptors for communication with TTF_autohint FILE* input; FILE* output; again: if (!open_files(input_name, &input, output_name, &output)) return; QProgressDialog dialog; dialog.setCancelButtonText(tr("Cancel")); dialog.setMinimumDuration(1000); dialog.setWindowModality(Qt::WindowModal); const unsigned char* error_string; TA_Info_Func info_func = info; GUI_Progress_Data gui_progress_data = {-1, true, &dialog}; Info_Data info_data; info_data.data = NULL; // must be deallocated after use info_data.data_wide = NULL; // must be deallocated after use info_data.data_len = 0; info_data.data_wide_len = 0; info_data.hinting_range_min = min_box->value(); info_data.hinting_range_max = max_box->value(); info_data.hinting_limit = no_limit_box->isChecked() ? 0 : limit_box->value(); info_data.gray_strong_stem_width = gray_box->isChecked(); info_data.gdi_cleartype_strong_stem_width = gdi_box->isChecked(); info_data.dw_cleartype_strong_stem_width = dw_box->isChecked(); info_data.increase_x_height = no_increase_box->isChecked() ? 0 : increase_box->value(); info_data.x_height_snapping_exceptions = x_height_snapping_exceptions; info_data.windows_compatibility = wincomp_box->isChecked(); info_data.pre_hinting = pre_box->isChecked(); info_data.hint_with_components = hint_box->isChecked(); info_data.latin_fallback = fallback_box->currentIndex(); info_data.symbol = symbol_box->isChecked(); if (info_box->isChecked()) { int ret = build_version_string(&info_data); if (ret == 1) QMessageBox::information( this, "TTFautohint", tr("Can't allocate memory for <b>TTFautohint</b> options string" " in <i>name</i> table."), QMessageBox::Ok, QMessageBox::Ok); else if (ret == 2) QMessageBox::information( this, "TTFautohint", tr("<b>TTFautohint</b> options string" " in <i>name</i> table too long."), QMessageBox::Ok, QMessageBox::Ok); } else info_func = NULL; QByteArray snapping_string = snapping_line->text().toLocal8Bit(); TA_Error error = TTF_autohint("in-file, out-file," "hinting-range-min, hinting-range-max," "hinting-limit," "gray-strong-stem-width," "gdi-cleartype-strong-stem-width," "dw-cleartype-strong-stem-width," "error-string," "progress-callback, progress-callback-data," "info-callback, info-callback-data," "ignore-restrictions," "windows-compatibility," "pre-hinting," "hint-with-components," "increase-x-height," "x-height-snapping-exceptions," "fallback-script, symbol", input, output, info_data.hinting_range_min, info_data.hinting_range_max, info_data.hinting_limit, info_data.gray_strong_stem_width, info_data.gdi_cleartype_strong_stem_width, info_data.dw_cleartype_strong_stem_width, &error_string, gui_progress, &gui_progress_data, info_func, &info_data, ignore_restrictions, info_data.windows_compatibility, info_data.pre_hinting, info_data.hint_with_components, info_data.increase_x_height, snapping_string.constData(), info_data.latin_fallback, info_data.symbol); if (info_box->isChecked()) { free(info_data.data); free(info_data.data_wide); } fclose(input); fclose(output); if (error) { if (handle_error(error, error_string, output_name)) goto again; } else statusBar()->showMessage(tr("Auto-hinting finished.")); }