if ((dicname_printed == FALSE) && (GTK_TOGGLE_BUTTON(wordDic->radiob_searchall)->active)) { gtk_text_buffer_insert(GTK_TEXT_BUFFER(wordDic->text_results_buffer), &wordDic->iter, _("Matches in "), -1); gtk_text_buffer_insert_with_tags_by_name(GTK_TEXT_BUFFER(wordDic->text_results_buffer), &wordDic->iter, dicfile->name, -1, "brown_foreground", NULL); gtk_text_buffer_insert(GTK_TEXT_BUFFER(wordDic->text_results_buffer), &wordDic->iter, ":\n", -1); dicname_printed = TRUE; }
print_matches_in(dicfile);
static void search_in_dicfile(GjitenDicfile *dicfile, unsigned char *srchstrg) {  gint srchresp, roff, rlen;  gchar repstr[1024];  guint32 respos, oldrespos;  gint printit;  gint match_criteria = EXACT_MATCH;  gchar *currchar;  gint match_type = ANY_MATCH;  gint gjit_search = SRCH_START;  //Detect Japanese  engsrch = TRUE;  jpsrch = FALSE;  currchar = srchstrg;  do {     if (g_unichar_iswide(g_utf8_get_char(currchar)) == TRUE) { //FIXME: this doesn't detect all Japanese      engsrch = FALSE;      jpsrch = TRUE;      break;    }  }  while ((currchar = g_utf8_find_next_char(currchar, srchstrg + strlen(srchstrg))) != NULL);    // Verb deinfelction  if (GTK_TOGGLE_BUTTON(wordDic->checkb_verb)->active) print_verb_inflections(dicfile, srchstrg);    if (jpsrch == TRUE) {    if (GTK_TOGGLE_BUTTON(wordDic->radiob_jpexact)->active) match_criteria = EXACT_MATCH;    if (GTK_TOGGLE_BUTTON(wordDic->radiob_startw)->active) match_criteria = START_WITH_MATCH;    if (GTK_TOGGLE_BUTTON(wordDic->radiob_endw)->active) match_criteria = END_WITH_MATCH;    if (GTK_TOGGLE_BUTTON(wordDic->radiob_any)->active) match_criteria = ANY_MATCH;  }  else {    if (GTK_TOGGLE_BUTTON(wordDic->radiob_engexact)->active) match_criteria = EXACT_MATCH;    if (GTK_TOGGLE_BUTTON(wordDic->radiob_words)->active) match_criteria = WORD_MATCH;    if (GTK_TOGGLE_BUTTON(wordDic->radiob_partial)->active) match_criteria = ANY_MATCH;  }  oldrespos = srchpos = 0;    do { // search loop    oldrespos = respos;        srchresp = search4string(gjit_search, dicfile, srchstrg, &respos, &roff, &rlen, repstr);    if (srchresp != SRCH_OK)  {      return;   //No more matches    }    if (gjit_search == SRCH_START) {      srchpos = respos;      gjit_search = SRCH_CONT;    }    srchpos++;    if (oldrespos == respos) continue;    // Check match type and search options    printit = FALSE;    if (jpsrch) {      match_type = get_jp_match_type(repstr, srchstrg, roff);      switch (match_criteria) {      case EXACT_MATCH : 				if (match_type == EXACT_MATCH) printit = TRUE;				break;      case START_WITH_MATCH:				if ((match_type == START_WITH_MATCH) || (match_type == EXACT_MATCH)) printit = TRUE;				break;      case END_WITH_MATCH:				if ((match_type == END_WITH_MATCH) || (match_type == EXACT_MATCH)) printit = TRUE;				break;      case ANY_MATCH:				printit = TRUE;				break;      }    }    else { //Non-japanese search      switch (match_criteria) {      case EXACT_MATCH:				//Must lie between two '/' delimiters				if ((repstr[roff - 1] == '/') && (repstr[roff + strlen(srchstrg)] == '/')) printit = TRUE;				//take "/(n) expression/" into accont				else if ((repstr[roff - 2] == ')') && (repstr[roff + strlen(srchstrg)] == '/')) printit = TRUE;				//also match verbs starting with a 'to'. eg: "/(n) to do_something/"				else if ((repstr[roff - 2] == 'o') && (repstr[roff - 3] == 't') && (repstr[roff + strlen(srchstrg)] == '/') 								 && ((repstr[roff - 5] == ')') || (repstr[roff - 4] == '/'))) printit = TRUE;				break;      case WORD_MATCH:				if ((g_unichar_isalpha(g_utf8_get_char(repstr + roff + strlen(srchstrg))) == FALSE)  &&						(g_unichar_isalpha(g_utf8_get_char(repstr + roff - 1)) == FALSE)) {					/*						printf("---------\n");						printf("%s", repstr);						if (g_unichar_isalpha(g_utf8_get_char(repstr + roff - 1)) == FALSE)  printf("beg:%s", repstr + roff - 1);						if (g_unichar_isalpha(g_utf8_get_char(repstr + roff + strlen(srchstrg))) == FALSE)  						printf("end:%s", repstr + roff + strlen(srchstrg));						printf("---------\n");					*/					printit = TRUE;				}				break;      case ANY_MATCH:				printit = TRUE;				break;      }    }      if (printit) {      /*      printf("offset: %d: ", roff);      printf("jptype: %d\n", match_type);      printf("criteria: %d\n", match_criteria);      */			//Print dicfile name if all dictionaries are selected      if ((dicname_printed == FALSE) && (GTK_TOGGLE_BUTTON(wordDic->radiob_searchall)->active)) {				gtk_text_buffer_insert(GTK_TEXT_BUFFER(wordDic->text_results_buffer), &wordDic->iter, _("Matches in "), -1);				gtk_text_buffer_insert_with_tags_by_name(GTK_TEXT_BUFFER(wordDic->text_results_buffer), &wordDic->iter,  																								 dicfile->name, -1, "brown_foreground", NULL);				gtk_text_buffer_insert(GTK_TEXT_BUFFER(wordDic->text_results_buffer), &wordDic->iter, ":\n", -1);				dicname_printed = TRUE;      }      print_result(repstr, roff, srchstrg);      //get_kanji_and_reading(repstr); FIXME      word_matches++;    }    if ((gjitenApp->conf->searchlimit_enabled == TRUE) && (word_matches >= gjitenApp->conf->maxwordmatches)) {      gtk_text_buffer_insert_with_tags_by_name(GTK_TEXT_BUFFER(wordDic->text_results_buffer), &wordDic->iter,  																							 _("Results truncated"), -1, "red_foreground", NULL);      return;    }  } while (srchresp == SRCH_OK);}