예제 #1
0
파일: actions.c 프로젝트: rdebath/sgt
static int search_prompt(char *withdef, char *withoutdef)
{
    char buffer[80];
    int len;

    if (!get_str(last_search ? withdef : withoutdef, buffer, TRUE))
	return 0;		       /* user break */
    if (!last_search && !*buffer) {
	strcpy (message, "Search aborted.");
	return 0;
    }

    if (!*buffer) {
	len = last_search->len;
    } else {
	len = parse_quoted (buffer);
	if (len == -1) {
	    display_beep();
	    strcpy (message, "Invalid escape sequence in search string");
	    return 0;
	}
	if (last_search)
	    free_search(last_search);
	last_search = build_search (buffer, len);
    }

    return 1;
}
예제 #2
0
static char * test_is_extension_good_ko()
{
    struct search_t *search;
    search = create_search();
    add_element(&search->extension, ".cpp");
    mu_assert("test_is_extension_good_ko failed", is_ignored_file(search, "file.c") == 0);
    free_search(search);
    return 0;
}
예제 #3
0
static char * test_is_ignored_file_ko()
{
    struct search_t *search;
    search = create_search();
    add_element(&search->ignore, "rules");
    mu_assert("test_is_ignored_file_ko failed", is_ignored_file(search, "Rules") == 0);
    free_search(search);
    return 0;
}
예제 #4
0
static char * test_is_specific_file_ko()
{
    struct search_t *search;
    search = create_search();
    add_element(&search->specific_file, "Makefile");
    mu_assert("test_is_specific_file_ko failed", is_specific_file(search, "makefile") == 0);
    free_search(search);
    return 0;
}
예제 #5
0
static char * test_two_entries()
{
    struct search_t *search;
    search = create_search();
    char text[] = "this is a the first line\nthis is the second line\n";
    const char *pattern = "line";
    parse_text(search, "fake_file", strlen(text), text, pattern);
    mu_assert("error in number of entry", search->nbentry == 3);
    free_search(search);
    return 0;
}
예제 #6
0
struct searchinfo *alloc_parsesearch(struct searchinfo **head)
{
struct	searchinfo *si;

	*head=0;
	if ((si=alloc_search_andlist(head)) == 0)
	{
		free_search(*head);
		return (0);
	}
	return (si);
}
예제 #7
0
static char * test_one_entry_incase()
{
    struct search_t *search;
    search = create_search();
    search->incase_option = 1;
    char text[] = "this is a the first line\nthis is the second line\n";
    const char *pattern = "First";
    parse_text(search, "fake_file", strlen(text), text, pattern);
    mu_assert("error in number of entry", search->nbentry == 2);
    free_search(search);
    return 0;
}
예제 #8
0
static char * test_cursor_up_top_first_page()
{
    struct display_t *display;
    struct search_t *search;
    int terminal_line_nb;
    char text[] = "this is the first line\nthis the second line\n";
    const char *pattern = "line";

    display = create_display();
    search = create_search();
    terminal_line_nb = 10;

    parse_text(search, "fake_file", strlen(text), text, pattern);
    move_cursor_up(display, search, terminal_line_nb);
    mu_assert("test_cursor_up_top_first_page failed", display->cursor == 1);
    free_search(search);
    free_display(display);

    return 0;
}
예제 #9
0
파일: pismo.c 프로젝트: mmesaros/Holy-Bible
void Print(struct casti *_c) {
  char *k, *s;
  int vb, ve, hb, he, comment;
  struct casti *c;
  static struct strbuf q;

  Rst(&q);

  //nepekne: spoliehame sa, ze vsetko je z jednej knihy
  if (!_c) return;
  k = check_book(_c->k);
  if (!k) return;

  init_search(k);

  hb=vb=-1;
  he=ve=-1;
  for (c=_c; c!=NULL; c=c->n) {
    if (c->h!=-1) {
      hb = c->h;
      vb=-1;
    }
    if (c->v!=-1) vb = c->v;
    ve = vb;
    he = hb;
    if (c->range && c->n) {
      c=c->n;
      if (c->h!=-1) he = c->h;
      if (c->v!=-1) ve = c->v;
    }

    if (hb==-1) { hb = vb; vb = -1; }
    if (he==-1) { he = ve; ve = -1; }
    // zapiseme do kontextu
    if (first.h==-1) {
      first.h=hb;
      first.k=k;
    }
    if (hb!=kontext_last_hb || he!=kontext_last_he) {
      if (hb!=he) Prn(&kontext, ";%s%d-%d", k, hb,he);
      else Prn(&kontext, ";%s%d", k, hb);
      kontext_last_hb = hb; kontext_last_he = he;
    }

    add_search(hb,vb,he,ve);

    vb = ve;
    hb = he;
  }
  last.h = kontext_last_he;
  last.k = k;

  do_search();

  while (get_result(&comment, &s)) {
    if (!comment) printf("%s\n", s);
    else printf("<span class=\"komentar\">(%s)</span>\n", s);
  }
  free_search();

  // do not free k - it might be used in first/last
}