void debug_location16(struct location16 *l16p, struct location16 *r16p) { fprintf(f_log, "%c%06d.%d.%d b=%d; sc=%d; ec=%d", id_prefix(l16p->text_id), XidVal(l16p->text_id), l16p->unit_id, l16p->word_id, l16p->branch_id, mask_sc(l16p->start_column), logo_mask(l16p->end_column) ); if (prop_sc(l16p->start_column)) selemx_print_fields(f_log, prop_sc(l16p->start_column)); fputs(" :: ", f_log); if (r16p) { fprintf(f_log, "%c%06d.%d.%d b=%d; sc=%d; ec=%d", id_prefix(r16p->text_id), XidVal(r16p->text_id), r16p->unit_id, r16p->word_id, r16p->branch_id, mask_sc(r16p->start_column), logo_mask(r16p->end_column) ); if (prop_sc(r16p->start_column)) selemx_print_fields(f_log, prop_sc(r16p->start_column)); } if (nl_16) fputc('\n', f_log); }
void show_results(struct Datum *dp) { int i; switch (res_gran) { case g_not_set: case g_text: case g_record: for (i = 0; i < dp->count; ++i) { struct location8 *l8p = dp->l.l8p[i]; if ('x' == id_prefix(l8p->text_id)) fprintf(out_f, "%s.x%06d\n", cbd_lang ? cbd_lang : se_curr_project, XidVal(l8p->text_id)); else fprintf(out_f, "%c%06d\n", id_prefix(l8p->text_id), XidVal(l8p->text_id)); } break; case g_field: for (i = 0; i < dp->count; ++i) { struct location8 *l8p = dp->l.l8p[i]; fprintf(out_f, "%c%06d.%d\n", id_prefix(l8p->text_id), XidVal(l8p->text_id), l8p->unit_id); } break; case g_word: case g_grapheme: for (i = 0; i < dp->count; ++i) { int last_id_printed = 0; struct location8 *l8p = dp->l.l8p[i]; fprintf(out_f, "%c%06d.%d.%d", id_prefix(l8p->text_id), XidVal(l8p->text_id), l8p->unit_id, l8p->word_id); while (more_in_unit(l8p, dp->l.l8p[i+1])) { #if 0 if (l8p->word_id != dp->l.l8p[i+1]->word_id) #else if (dp->l.l8p[i+1]->word_id != last_id_printed) #endif { fprintf(out_f, ",%d",dp->l.l8p[++i]->word_id); l8p = dp->l.l8p[i]; last_id_printed = l8p->word_id; } else ++i; } fputc('\n',out_f); } break; } }
void debug_location8(struct location8 *l8p, struct location8 *r8p) { fprintf(f_log, "%c%06d.%d.%d\n", id_prefix(l8p->text_id), XidVal(l8p->text_id), l8p->unit_id, l8p->word_id); fputs(" :: ", f_log); if (r8p) { fprintf(f_log, "%c%06d.%d.%d\n", id_prefix(r8p->text_id), XidVal(r8p->text_id), r8p->unit_id, r8p->word_id); } }
static void put_results(struct Datum *res) { if (show_count) printf("%lu\n",(unsigned long)res->count); else if (res->count) { if (xmldir) xmldir_results(xmldir,res->count); if ('v' == id_prefix(res->l.l8p[0]->text_id)) { if (!strcmp(return_index, "cat")) vid_display_proj = vid_proj_xmd; else vid_display_proj = vid_proj_xtf; vid_show_results(res); } else show_results(res); } else if (xmldir) xmldir_results(xmldir,res->count); }
int main(int argc, char * const*argv) { struct token *toks = NULL; int ntoks = 0; static struct Datum result; f_log = stderr; exit_on_error = TRUE; setlocale(LC_ALL,LOCALE); options(argc, argv, "28cdg:o:p:P:stuvx:"); if (!out_f) out_f = stdout; if (doing_debug) f_log = fopen("se.dbg","w"); /*atf2utf8_init();*/ charsets_init(); langtag_init(); tokinit(); if (pretrim_file || pretrim_args) pretrim_setup(); if (xmldir) toks = tokenize(xmldir_toks(xmldir),&ntoks); else toks = tokenize((const char **)(argv+optind),&ntoks); if (show_tokens) { showtoks(toks,ntoks); } else { binop_init(); binop24_init(); result = evaluate(toks, -1, lm_any, NULL); progress("se: result.count == %lu\n", (unsigned long)result.count); if (do_uniq && (res_gran == g_word || res_gran == g_grapheme)) do_uniq = 0; if (do_uniq && result.count > 1) { uniq(&result); progress("se: post-uniq result.count == %lu\n", (unsigned long)result.count); } if (show_count) printf("%lu\n",(unsigned long)result.count); else if (result.count) { if (xmldir) xmldir_results(xmldir,result.count); if ('v' == id_prefix(result.l.l8p[0]->text_id)) { if (!strcmp(return_index, "cat")) vid_display_proj = vid_proj_xmd; else vid_display_proj = vid_proj_xtf; vid_show_results(&result); } else show_results(&result); } else if (xmldir) xmldir_results(xmldir,result.count); } if (pretrim_args) { list_free(pretrim_args, NULL); pretrim_args = NULL; } if (pretrim) { hash_free(pretrim, NULL); pretrim = NULL; free(pretrim_lines); free(pretrim_content); pretrim_content = NULL; pretrim_lines = NULL; } langtag_term(); return 0; }