示例#1
0
void add_ignore_pattern(ignores *ig, const char* pattern) {
    int i;

    /* Strip off the leading ./ so that matches are more likely. */
    if (strncmp(pattern, "./", 2) == 0) {
        pattern += 2;
    }

    if (is_fnmatch(pattern)) {
        ig->regexes_len++;
        ig->regexes = ag_realloc(ig->regexes, ig->regexes_len * sizeof(char*));
        ig->regexes[ig->regexes_len - 1] = ag_strdup(pattern);
        log_debug("added regex ignore pattern %s", pattern);
    } else {
        /* a balanced binary tree is best for performance, but I'm lazy */
        ig->names_len++;
        ig->names = ag_realloc(ig->names, ig->names_len * sizeof(char*));
        for (i = ig->names_len - 1; i > 0; i--) {
            if (strcmp(pattern, ig->names[i-1]) > 0) {
                break;
            }
            ig->names[i] = ig->names[i-1];
        }
        ig->names[i] = ag_strdup(pattern);
        log_debug("added literal ignore pattern %s", pattern);
    }
}
void update_progress(const char *progress_text) {
    if (!opts.show_progress || progress_text == NULL || !strlen(progress_text)) {
        return;
    }

    char *old_progress_state, *new_progress_state;

    new_progress_state = ag_strdup(progress_text);

    /* Perform the bare minimum within a mutex */
    pthread_mutex_lock(&progress_mtx);
    old_progress_state = last_progress_state;
    last_progress_state = new_progress_state;
    progress_update_required = 1;
    pthread_mutex_unlock(&progress_mtx);

    if (old_progress_state != NULL) {
        free(old_progress_state);
    }
}