Exemple #1
0
bool
atf_check::run_output_check(const atf::check::check_result &r,
                            const std::string &stdxxx)
    const
{
    atf::fs::path path("/");
    std::string arg;
    output_check_t check = m_stdout_check;

    if (stdxxx == "stdout") {
        path = r.stdout_path();
        arg = m_stdout_arg.c_str();
        check = m_stdout_check;
    } else if (stdxxx == "stderr") {
        path = r.stderr_path();
        arg = m_stderr_arg.c_str();
        check = m_stderr_check;
    } else
        UNREACHABLE;

    if (check == oc_empty) {
        if (!file_empty(path)) {
            std::cerr << "Fail: incorrect " << stdxxx << std::endl;
            print_diff(atf::fs::path("/dev/null"), path);

            return false;
        }
    } else if (check == oc_file) {
        if (atf::io::cmp(path, atf::fs::path(arg)) != 0) {
            std::cerr << "Fail: incorrect " << stdxxx << std::endl;
            print_diff(atf::fs::path(arg), path);

            return false;
        }
    } else if (check == oc_inline) {
        std::string decoded = decode(arg);
        atf::fs::path path2 = atf::fs::path(atf::config::get("atf_workdir")) \
                              / "inline.XXXXXX";
        atf::fs::temp_file temp(path2);
        temp.write(decoded);

        if (atf::io::cmp(path, temp.get_path()) != 0) {
            std::cerr << "Fail: incorrect " << stdxxx << std::endl;
            print_diff(temp.get_path(), path);

            return false;
        }
    } else if (check == oc_save) {
        std::ifstream ifs(path.c_str(), std::fstream::binary);
        ifs >> std::noskipws;
        std::istream_iterator< char > begin(ifs), end;

        std::ofstream ofs(arg.c_str(), std::fstream::binary
                                     | std::fstream::trunc);
        std::ostream_iterator <char> obegin(ofs);

        std::copy(begin, end, obegin);
    }
Exemple #2
0
int main(int argc, char **argv)
{
	diff *d;
	char **a, **b, *m;
	size_t la, lb;		/*lengths */
	FILE *fa, *fb;

	if (argc < 3)
		return fprintf(stderr, "usage: %s file file\n", argv[0]);

	fa = fopen_or_fail(argv[1], "r");
	fb = fopen_or_fail(argv[2], "r");

	a = fill_array_with_lines(fa, &la);
	b = fill_array_with_lines(fb, &lb);

	if (!(d = lcs(a, la, b, lb)))
		return 0;	/*empty files */
	print_diff(d, a, b);

	while ((m = *(a++)))
		free(m);
	while ((m = *(b++)))
		free(m);

	free(d->c);
	free(d);
	fclose(fa);
	fclose(fb);
	return 0;
}
Exemple #3
0
static void 
print_diff_now (struct mi_timestamp *start)
  {
    struct mi_timestamp now;
    timestamp (&now);
    print_diff (start, &now);
  }
Exemple #4
0
/*
 * Xfrom-to (e.g. R10-15)
 * A - change allowed
 * S - change required, semantic
 * R - change required, random
 * F - change forbidden
 */
static enum df check(const char *range, unsigned char *o, unsigned char *n)
{
	char strict;
	unsigned long long from, to;
	enum df ret;

	if (sscanf(range, "%c%llu-%llu", &strict, &from, &to) != 3) {
		printf("Unknown range format %s.\n", range);
		return FAIL;
	}

	switch (toupper(strict)) {
	case 'A':
		ret = OK;
		break;
	case 'S':
		ret = memcmp(&o[from], &n[from], to - from + 1) != 0 ? OK : FAIL;
		break;
	case 'R': /* FIXME - random test */
		ret = memcmp(&o[from], &n[from], to - from + 1) != 0 ? OK : FAIL;
		break;
	case 'F':
		ret = memcmp(&o[from], &n[from], to - from + 1) == 0 ? OK : FAIL;
		break;
	default:
		ret = FAIL;
		break;
	}

	if (ret == FAIL)
		print_diff(from,  to - from + 1, o, n);

	return ret;
}
Exemple #5
0
int main(int argc, char* argv[])
{
  const size_t size = (argc > 1) ? atoi(argv[1]) : 32;
  cmpvec inputData;
  for (size_t i = 0; i < size; ++i) {
    inputData.push_back(CMP(0.1 + i, 0.2 * i));
  }

  cmpvec bf;
  ft_bf(size, inputData, bf);

  if (0) {
    cmpvec gsl;
    ft_gsl(size, inputData, gsl);
    print_diff(bf, gsl);
  }

  if(0) {
    cmpvec fftw;
    ft_fftw(size, inputData, fftw);
    print_diff(bf, fftw);
  }

  if(0) {
    cmpvec fftw_d;
    const int isz = size;
    ft_fftw_d(1, &isz, inputData, fftw_d);
    print_diff(bf, fftw_d);
  }

  if(1) {
    cmpvec fftw_d1;
    const int sz1[] = { 3, 5 };
    ft_fftw_d(2, &sz1[0], inputData, fftw_d1);

    cmpvec fftw_d2;
    const int sz2[] = { 5, 3  };
    ft_fftw_d(2, &sz2[0], inputData, fftw_d2);

    print_both(fftw_d1, fftw_d2);
  }

  return 0;
}
Exemple #6
0
int main(int argc, char **argv) {
	int opt, sprofdiff = 0;

#ifdef DEBUG
	/* disable buffering so the output mixes correctly */
	setvbuf(stdout, NULL, _IONBF, 0);
	setvbuf(stderr, NULL, _IONBF, 0);
#endif

	/* parse arguments */
	while ((opt = getopt(argc, argv, "b:dp:s:")) != -1) {
		switch (opt) {
		case 'b':
			/* additional binary specified */
			binary_add(optarg);
			break;
		case 'd':
			/* generate output for sprofdiff */
			sprofdiff = 1;
			break;
		case 'p':
			/* minimum percentage specified */
			minimum_perc = atof(optarg);
			if (minimum_perc < 0 || minimum_perc > 100) {
				fprintf(stderr, "error: cut-off percentage "
					"makes no sense: %g\n", minimum_perc);
				exit(1);
			}
			break;
		case 's':
			/* source tree directory specified */
			src_path = optarg;
			break;
		default: usage(argv[0]);
		}
	}

	/* load samples */
	if (optind >= argc) usage(argv[0]);
	for (; optind < argc; optind++) {
		struct endpoint_info *e; 
		load_trace(argv[optind]);
		for(e = endpoints; e; e = e->next)
			e->seen = 0;
	}

	/* print report */
	if (sprofdiff) {
		print_diff();
	} else {
		print_report();
	}
	return 0;
}
Exemple #7
0
void print_error(string expected, string actual)
{
    int expected_lines = std::count(expected.begin(), expected.end(), '\n');
    int actual_lines = std::count(actual.begin(), actual.end(), '\n');

    cerr << endl << "Did not get expected content" << endl << "expected (" << expected_lines << " lines): ->" << expected << "<-" << endl
    << "actual (" << actual_lines << " lines):   ->" << actual << "<-" << endl;
    cerr << endl;

    print_diff(expected, actual);
}
Exemple #8
0
int main(void) 
{
        size_t i,j;
        diff *d;
        d = lcs(x, y);
        print_diff(d, x, y);
        for(i = 0; i <= (d->m); i++) {
                putchar('\n');
                for(j = 0; j < d->n; j++)
                        printf("%d ", d->c[i*d->n+j]);
        }
        putchar('\n');
        return 0;
}
Exemple #9
0
int main(int argc, char const *argv[]) {
  assert(argc == 3);

  FILE *file1 = fopen(argv[1], "r");
  FILE *file2 = fopen(argv[2], "r");

  assert(file1 != NULL && file2 != NULL);

  char file1_line[BUFFER_LINE_SIZE];
  char file2_line[BUFFER_LINE_SIZE];

  char *file1_line_ptr = file1_line;
  char *file2_line_ptr = file2_line;

  while (true) {
    file1_line_ptr = fgets(file1_line, BUFFER_LINE_SIZE, file1);
    file2_line_ptr = fgets(file2_line, BUFFER_LINE_SIZE, file2);
    if (file1_line_ptr == NULL && file2_line_ptr == NULL) {
      printf("Files are identical\n");
      break;
    } else if (file1_line_ptr == NULL) {
      print_diff(argv[1], "", argv[2], file2_line);
      break;
    } else if (file2_line_ptr == NULL) {
      print_diff(argv[1], file1_line, argv[2], "");
      break;
    } else if (strcmp(file1_line, file2_line) != 0) {
      print_diff(argv[1], file1_line, argv[2], file2_line);
      break;
    }
  }

  fclose(file1);
  fclose(file2);

  return 0;
}
Exemple #10
0
// Finally, the entry point for the PHP code.
const char *wikidiff_do_diff(const char *text1, const char *text2, int num_lines_context)
{
	try {
		std::vector<std::string> lines1;
		std::vector<std::string> lines2;
		std::string ret;
		
		// constant reallocation is bad for performance (note: we might want to reduce this
		// later, it might be too much)
		ret.reserve(strlen(text1) + strlen(text2) + 10000);
		
		line_explode(text1, lines1);
		line_explode(text2, lines2);
		print_diff(lines1, lines2, num_lines_context, ret);
		
		return strdup(ret.c_str());
	} catch (std::bad_alloc &e) {
		return strdup("Out of memory in diff.");
	} catch (...) {
		return strdup("Unknown exception in diff.");
	}
}
//diffs workdir and index - ie unstaged changes
//equivalent to `git diff` - WORKS
int diff(git_repository* repo) {
  git_diff_list* diff;

  git_index* index;  

  git_reference* ref_head;
  git_commit* head;
  git_tree* head_tree;


  git_repository_index(&index, repo);
  git_index_read(index);

  git_repository_head(&ref_head, repo);
  git_reference_peel((git_object**) &head, ref_head, GIT_OBJ_COMMIT);
  git_commit_tree(&head_tree, head);
	git_diff_index_to_workdir(&diff, repo, index, NULL);

  print_diff(diff);

  return 0;
}
Exemple #12
0
/**
 * The robot following/avoid a light infinitely
 * @global _mode_light_ it must be set
 */
void go_light()
{
    _go_light_running_ = 1;

    while(_go_light_running_)
    {
        int diff;
        diff = light_diff();
        diff *= _light_environnement_; /* Go more efficiently to the light specifing the environnement */

        /* Invert the mode */
        if(_mode_light_ == GO_DARK)
        {
            diff= -diff;
        }

        print_diff(diff);
        driveb(_motor_initial_speed_, diff);
    }

    stop();
    _go_light_running_ = -1;
}
Exemple #13
0
int main(int argc, char **argv) {
    IDEAL* pp;
    IDEAL** Ms;
    IDEAL** Rads;

    char M_name[MAX_LABEL_LENGTH];
    char N_name[MAX_LABEL_LENGTH];

    /* learn who we really are */
    progname = (const char *)strrchr(argv[0], '/');
    progname = progname ? (progname + 1) : argv[0];

    /* handle cmdline */
    handle_cmdline(&argc, &argv);

    /* initializing needed things */
    init_constants();

    if ( !(i < numofMs) || !(j < nilindex) ) {
        fprintf(stderr, "i must be less than numofMs = m*(pi - 1) + 1, "
                        "j must be less than nilindex = l*(p - 1) + 1.\n");
        exit(EXIT_FAILURE);
    }

    /* we need at most 2 IDEALs per array */
    Ms   = (IDEAL**) malloc(2*sizeof(IDEAL*));
    Rads = (IDEAL**) malloc(2*sizeof(IDEAL*));

    if (Ms == NULL || Rads == NULL) {
        fprintf(stderr, "Unable to allocate memory for ideals' arrays.\n");
        exit(EXIT_FAILURE);
    }

    /* do the job */
    if ((output_control & WAS_SPECIFIED_M) && (output_control & WAS_SPECIFIED_RAD)) {
        /* both M_pi(m,i) and Rad^j were specified, process only them*/
        pp = ideal_create(q);
        ideal_init(pp, pi, m, i);
        Ms[0] = pp;

        pp = ideal_create(q);
        ideal_init(pp, p, l, l*(p - 1) - j);
        Rads[0] = pp;

        sprintf(M_name, "M_%llu(%u,%llu)", pi, m, i);
        sprintf(N_name, "Rad^%llu", j);

        if (ideal_issubset(Rads[0], Ms[0])) {
            print_diff(Ms[0], Ms[0], Rads[0], M_name, N_name, use_colors);

            if (debug >= 2) {
                fprintf(stdout, "%s\t\t=\n", N_name);
                if (use_colors) {
                    color_ideal_print(SPECIAL_COLOR, Rads[0], isspecial_integer);
                } else {
                    ideal_print(Rads[0]);
                }
                fprintf(stdout, "\n");
            }
        } else if (ideal_issubset(Ms[0], Rads[0])) {
            print_diff(Rads[0], Rads[0], Ms[0], N_name, M_name, use_colors);

            if (debug >= 2) {
                fprintf(stdout, "%s\t\t=\n", M_name);
                if (use_colors) {
                    color_ideal_print(SPECIAL_COLOR, Ms[0], isspecial_integer);
                } else {
                    ideal_print(Ms[0]);
                }
                fprintf(stdout, "\n");
            }
        } else {
            /* we will store intersection here */
            pp = ideal_create(q);
            Ms[1] = pp;

            if (debug >= 2) {
                fprintf(stdout, "%s\t\t=\n", M_name);
                if (use_colors) {
                    color_ideal_print(SPECIAL_COLOR, Ms[0], isspecial_integer);
                } else {
                    ideal_print(Ms[0]);
                }
                fprintf(stdout, "\n");
            }

            if (debug >= 2) {
                fprintf(stdout, "%s\t\t=\n", N_name);
                if (use_colors) {
                    color_ideal_print(SPECIAL_COLOR, Rads[0], isspecial_integer);
                } else {
                    ideal_print(Rads[0]);
                }
                fprintf(stdout, "\n");
            }

            ideal_intersect(Ms[1], Ms[0], Rads[0]);

            sprintf(N_name, "(M_%llu(%u,%llu) /\\ Rad^%llu)", pi, m, i, j);

            sprintf(M_name, "M_%llu(%u,%llu)", pi, m, i);
            print_diff(Ms[0], Ms[0], Ms[1], M_name, N_name, use_colors);

            sprintf(M_name, "Rad^%llu", j);
            print_diff(Rads[0], Rads[0], Ms[1], M_name, N_name, use_colors);
        }
    } else if (output_control & WAS_SPECIFIED_RAD) {
        /* only Rad^j was specified, find sup and inf M_pi(m,k) and process all three of them */
        unsigned long long Mpi_to_Rad, Rad_to_Mpi;

        Rad_to_Mpi = maximum_Pi_for_P(l*(p - 1) - j, p, m);
        Mpi_to_Rad = minimum_Pi_for_P(l*(p - 1) - j, p, m, lambda);

        if (Mpi_to_Rad == Rad_to_Mpi) {
            fprintf(stdout, "Rad^%llu == M_%llu(%u,%llu)\n\n",
                    j, pi, m, Rad_to_Mpi);
            goto end;
        }

        pp = ideal_create(q);
        ideal_init(pp, pi, m, Rad_to_Mpi);
        Ms[0] = pp;

        pp = ideal_create(q);
        ideal_init(pp, pi, m, Mpi_to_Rad);
        Ms[1] = pp;

        pp = ideal_create(q);
        ideal_init(pp, p, l, l*(p - 1) - j);
        Rads[0] = pp;

        fprintf(stdout, "M_%llu(%u,%llu) -> Rad^%llu -> M_%llu(%u,%llu)\n\n",
                pi, m, Mpi_to_Rad, j, pi, m, Rad_to_Mpi);

        sprintf(N_name, "Rad^%llu", j);

        sprintf(M_name, "M_%llu(%u,%llu)", pi, m, Mpi_to_Rad);
        print_diff(Ms[1], Ms[1], Rads[0], M_name, N_name, use_colors);

        sprintf(M_name, "M_%llu(%u,%llu)", pi, m, Rad_to_Mpi);
        print_diff(Ms[0], Rads[0], Ms[0], N_name, M_name, use_colors);

        if (debug >= 2) {
            fprintf(stdout, "%s\t\t=\n", N_name);
            if (use_colors) {
                color_ideal_print(SPECIAL_COLOR, Rads[0], isspecial_integer);
            } else {
                ideal_print(Rads[0]);
            }
            fprintf(stdout, "\n");
        }
    } else if (output_control & WAS_SPECIFIED_M) {
        /* only M_pi(m,i) was specified, find sup and inf Rad^j and process all three of them */
        unsigned long long Mpi_to_Rad, Rad_to_Mpi;

        Rad_to_Mpi = minimum_P_for_Pi(i, p, m);
        Mpi_to_Rad = maximum_P_for_Pi(i, p, m, l, lambda, numofMs - 1);

        if (Mpi_to_Rad == Rad_to_Mpi) {
            fprintf(stdout, "M_%llu(%u,%llu) == Rad^%llu\n\n",
                    pi, m, i, l*(p - 1) - Rad_to_Mpi);
            goto end;
        }

        pp = ideal_create(q);
        ideal_init(pp, p, l, Mpi_to_Rad);
        Rads[0] = pp;

        pp = ideal_create(q);
        ideal_init(pp, p, l, Rad_to_Mpi);
        Rads[1] = pp;

        pp = ideal_create(q);
        ideal_init(pp, pi, m, i);
        Ms[0] = pp;

        fprintf(stdout, "Rad^%llu -> M_%llu(%u,%llu) -> Rad^%llu\n\n",
                l*(p - 1) - Rad_to_Mpi, pi, m, i, l*(p - 1) - Mpi_to_Rad);

        sprintf(M_name, "M_%llu(%u,%llu)", pi, m, i);

        sprintf(N_name, "Rad^%llu", l*(p - 1) - Rad_to_Mpi);
        print_diff(Rads[1], Rads[1], Ms[0], N_name, M_name, use_colors);

        sprintf(N_name, "Rad^%llu", l*(p - 1) - Mpi_to_Rad);
        print_diff(Rads[0], Ms[0], Rads[0], M_name, N_name, use_colors);

        if (debug >= 2) {
            fprintf(stdout, "%s\t\t=\n", M_name);
            if (use_colors) {
                color_ideal_print(SPECIAL_COLOR, Ms[0], isspecial_integer);
            } else {
                ideal_print(Ms[0]);
            }
            fprintf(stdout, "\n");
        }
    } else {
        fprintf(stderr, "Incorrect usage. See --help.\n");
    }

end:
    /* do cleanup */
    dbg_msg_l(5, "Freeing Ms...\n");
    for (i = 0; i < 2; ++i) {
        ideal_free(Ms[i]);
    }
    free(Ms);

    dbg_msg_l(5, "Freeing Rads...\n");
    for (i = 0; i < 2; ++i) {
        ideal_free(Rads[i]);
    }
    free(Rads);

    return 0;
}
Exemple #14
0
static int compare_files(const char *inp, const char *out, const char *output_prefix) {
	struct stat st_in, st_out;
	int ret = 0;

	if (lstat(inp, &st_in)) {
		perror("lstat(INPUT) failed");
		return 2;
	}
	if (lstat(out, &st_out)) {
		perror("lstat(OUTPUT) failed");
		return 2;
	}

	if (st_in.st_size != st_out.st_size) {
		print_diff(output_prefix, "Size differs",
				st_in.st_size, st_out.st_size);
		ret = 1;
	}

	if (st_in.st_size > 0) {
		if (S_ISREG(st_in.st_mode)) {
			FILE *f = fopen(out, "rb");
			char buf[sizeof(randumness)];

			if (!f) {
				perror("Unable to open output file for reading");
				ret = 2;
			} else {
				if (fread(buf, sizeof(buf), 1, f) != 1) {
					perror("Output file read failed");
					ret = 2;
				} else if (memcmp(buf, randumness, sizeof(buf))) {
					fprintf(stderr, "[%s] File contents differ\n",
							output_prefix);
					ret = 1;
				}

				fclose(f);
			}
		} else if (S_ISLNK(st_in.st_mode)) {
			char buf[sizeof(ex_linkdest)];

			switch (readlink(out, buf, sizeof(buf))) {
				case -1:
					perror("readlink(OUTPUT) failed");
					ret = 2;
					break;
				case sizeof(buf) - 1:
					if (memcmp(buf, ex_linkdest, sizeof(buf))) {
						buf[sizeof(buf) - 1] = 0;
						fprintf(stderr, "[%s] Symlink target differs: %s vs %s\n",
								output_prefix, ex_linkdest, buf);
						ret = 1;
					}
					break;
				default:
					fprintf(stderr, "[%s] Invalid length when getting symlink target\n",
							output_prefix);
			}
		} else {
			fprintf(stderr, "[%s] Unhandled non-empty file format\n",
					output_prefix);
			ret = 77;
		}
	}

#ifdef S_ISCHR
	if (S_ISCHR(st_in.st_mode) && st_in.st_rdev != st_out.st_rdev) {
		print_diff_x(output_prefix, "Character device rdev differs",
				st_in.st_rdev, st_out.st_rdev);
		ret = 1;
	}
#endif
#ifdef S_ISBLK
	if (S_ISBLK(st_in.st_mode) && st_in.st_rdev != st_out.st_rdev) {
		print_diff_x(output_prefix, "Block device rdev differs",
				st_in.st_rdev, st_out.st_rdev);
		ret = 1;
	}
#endif

	if (st_in.st_mode != st_out.st_mode) {
		print_diff_x(output_prefix, "Mode differs",
				st_in.st_mode, st_out.st_mode);
		ret = 1;
	}

	if (st_in.st_uid != st_out.st_uid) {
		print_diff(output_prefix, "UID differs",
				st_in.st_uid, st_out.st_uid);
		ret = 1;
	}

	if (st_in.st_gid != st_out.st_gid) {
		print_diff(output_prefix, "GID differs",
				st_in.st_gid, st_out.st_gid);
		ret = 1;
	}

	if (st_in.st_mtime != st_out.st_mtime) {
		print_diff(output_prefix, "mtime (in seconds) differs",
				st_in.st_mtime, st_out.st_mtime);
		ret = 1;
	}

	return ret;
}
Exemple #15
0
int print_gpios(struct pci_dev *sb, int show_all, int show_diffs)
{
	int i, j, size, defaults_size = 0;
	const io_register_t *gpio_registers;
	const gpio_default_t *gpio_defaults = NULL;
	uint32_t gpio_diff;

	if (show_diffs && !show_all)
		printf("\n========== GPIO DIFFS ===========\n\n");
	else
		printf("\n============= GPIOS =============\n\n");

	switch (sb->device_id) {
	case PCI_DEVICE_ID_INTEL_Z68:
	case PCI_DEVICE_ID_INTEL_P67:
	case PCI_DEVICE_ID_INTEL_H67:
	case PCI_DEVICE_ID_INTEL_Q65:
	case PCI_DEVICE_ID_INTEL_QS67:
	case PCI_DEVICE_ID_INTEL_Q67:
	case PCI_DEVICE_ID_INTEL_B65:
	case PCI_DEVICE_ID_INTEL_C202:
	case PCI_DEVICE_ID_INTEL_C204:
	case PCI_DEVICE_ID_INTEL_C206:
	case PCI_DEVICE_ID_INTEL_H61:
		gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
		gpio_registers = pch_gpio_registers;
		size = ARRAY_SIZE(pch_gpio_registers);
		gpio_defaults = cp_pch_desktop_defaults;
		defaults_size = ARRAY_SIZE(cp_pch_desktop_defaults);
		break;
	case PCI_DEVICE_ID_INTEL_UM67:
	case PCI_DEVICE_ID_INTEL_HM65:
	case PCI_DEVICE_ID_INTEL_HM67:
	case PCI_DEVICE_ID_INTEL_QM67:
		gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
		gpio_registers = pch_gpio_registers;
		size = ARRAY_SIZE(pch_gpio_registers);
		gpio_defaults = cp_pch_mobile_defaults;
		defaults_size = ARRAY_SIZE(cp_pch_mobile_defaults);
		break;
	case PCI_DEVICE_ID_INTEL_Z77:
	case PCI_DEVICE_ID_INTEL_Z75:
	case PCI_DEVICE_ID_INTEL_Q77:
	case PCI_DEVICE_ID_INTEL_Q75:
	case PCI_DEVICE_ID_INTEL_B75:
	case PCI_DEVICE_ID_INTEL_H77:
	case PCI_DEVICE_ID_INTEL_C216:
		gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
		gpio_registers = pch_gpio_registers;
		size = ARRAY_SIZE(pch_gpio_registers);
		gpio_defaults = pp_pch_desktop_defaults;
		defaults_size = ARRAY_SIZE(pp_pch_desktop_defaults);
		break;
	case PCI_DEVICE_ID_INTEL_QM77:
	case PCI_DEVICE_ID_INTEL_QS77:
	case PCI_DEVICE_ID_INTEL_HM77:
	case PCI_DEVICE_ID_INTEL_UM77:
	case PCI_DEVICE_ID_INTEL_HM76:
	case PCI_DEVICE_ID_INTEL_HM75:
	case PCI_DEVICE_ID_INTEL_HM70:
		gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
		gpio_registers = pch_gpio_registers;
		size = ARRAY_SIZE(pch_gpio_registers);
		gpio_defaults = pp_pch_mobile_defaults;
		defaults_size = ARRAY_SIZE(pp_pch_mobile_defaults);
		break;
	case PCI_DEVICE_ID_INTEL_ICH10R:
		gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
		gpio_registers = ich10_gpio_registers;
		size = ARRAY_SIZE(ich10_gpio_registers);
		break;
	case PCI_DEVICE_ID_INTEL_ICH9DH:
	case PCI_DEVICE_ID_INTEL_ICH9DO:
	case PCI_DEVICE_ID_INTEL_ICH9R:
	case PCI_DEVICE_ID_INTEL_ICH9:
	case PCI_DEVICE_ID_INTEL_ICH9M:
	case PCI_DEVICE_ID_INTEL_ICH9ME:
		gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
		gpio_registers = ich9_gpio_registers;
		size = ARRAY_SIZE(ich9_gpio_registers);
		break;
	case PCI_DEVICE_ID_INTEL_ICH8:
	case PCI_DEVICE_ID_INTEL_ICH8M:
		gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
		gpio_registers = ich8_gpio_registers;
		size = ARRAY_SIZE(ich8_gpio_registers);
		break;
	case PCI_DEVICE_ID_INTEL_ICH7:
	case PCI_DEVICE_ID_INTEL_ICH7M:
	case PCI_DEVICE_ID_INTEL_ICH7DH:
	case PCI_DEVICE_ID_INTEL_ICH7MDH:
	case PCI_DEVICE_ID_INTEL_NM10:
		gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
		gpio_registers = ich7_gpio_registers;
		size = ARRAY_SIZE(ich7_gpio_registers);
		break;
	case PCI_DEVICE_ID_INTEL_ICH6:
		gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
		gpio_registers = ich6_gpio_registers;
		size = ARRAY_SIZE(ich6_gpio_registers);
		break;
	case PCI_DEVICE_ID_INTEL_ICH5:
		gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
		gpio_registers = ich5_gpio_registers;
		size = ARRAY_SIZE(ich5_gpio_registers);
		break;
	case PCI_DEVICE_ID_INTEL_ICH4:
	case PCI_DEVICE_ID_INTEL_ICH4M:
		gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
		gpio_registers = ich4_gpio_registers;
		size = ARRAY_SIZE(ich4_gpio_registers);
		break;
	case PCI_DEVICE_ID_INTEL_ICH2:
		gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
		gpio_registers = ich2_gpio_registers;
		size = ARRAY_SIZE(ich2_gpio_registers);
		break;
	case PCI_DEVICE_ID_INTEL_ICH:
	case PCI_DEVICE_ID_INTEL_ICH0:
		gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
		gpio_registers = ich0_gpio_registers;
		size = ARRAY_SIZE(ich0_gpio_registers);
		break;

	case PCI_DEVICE_ID_INTEL_I63XX:
		gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
		gpio_registers = i631x_gpio_registers;
		size = ARRAY_SIZE(i631x_gpio_registers);
		break;

	case PCI_DEVICE_ID_INTEL_3400_DESKTOP:
	case PCI_DEVICE_ID_INTEL_3400_MOBILE:
	case PCI_DEVICE_ID_INTEL_P55:
	case PCI_DEVICE_ID_INTEL_PM55:
	case PCI_DEVICE_ID_INTEL_H55:
	case PCI_DEVICE_ID_INTEL_QM57:
	case PCI_DEVICE_ID_INTEL_H57:
	case PCI_DEVICE_ID_INTEL_HM55:
	case PCI_DEVICE_ID_INTEL_Q57:
	case PCI_DEVICE_ID_INTEL_HM57:
	case PCI_DEVICE_ID_INTEL_3400_MOBILE_SFF:
	case PCI_DEVICE_ID_INTEL_B55_A:
	case PCI_DEVICE_ID_INTEL_QS57:
	case PCI_DEVICE_ID_INTEL_3400:
	case PCI_DEVICE_ID_INTEL_3420:
	case PCI_DEVICE_ID_INTEL_3450:
	case PCI_DEVICE_ID_INTEL_B55_B:
		gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
		gpio_registers = i631x_gpio_registers;
		size = ARRAY_SIZE(i631x_gpio_registers);
		break;

	case PCI_DEVICE_ID_INTEL_82371XX:
		printf("This southbridge has GPIOs in the PM unit.\n");
		return 1;
	case 0x1234: // Dummy for non-existent functionality
		printf("This southbridge does not have GPIOBASE.\n");
		return 1;
	default:
		printf("Error: Dumping GPIOs on this southbridge is not (yet) supported.\n");
		return 1;
	}

	printf("GPIOBASE = 0x%04x (IO)\n\n", gpiobase);

	j = 0;
	for (i = 0; i < size; i++) {
		if (show_all)
			print_reg(&gpio_registers[i]);

		if (show_diffs &&
		    (j < defaults_size) &&
		    (gpio_defaults[j].addr == gpio_registers[i].addr)) {
			gpio_diff = get_diff(&gpio_registers[i],
					     gpio_defaults[j].def);
			if (gpio_diff) {
				if (!show_all)
					print_reg(&gpio_registers[i]);
				print_diff(&gpio_registers[i],
					   gpio_defaults[j].def, gpio_diff);
				if (!show_all)
					printf("\n");
			}
			j++;
		}
	}

	return 0;
}
Exemple #16
0
static void
captured_mi_execute_command (struct ui_out *uiout, void *data)
{
  struct captured_mi_execute_command_args *args =
    (struct captured_mi_execute_command_args *) data;
  struct mi_parse *context = args->command;

  struct mi_timestamp cmd_finished;

  switch (context->op)
    {

    case MI_COMMAND:
      /* A MI command was read from the input stream.  */
      if (mi_debug_p)
	/* FIXME: gdb_???? */
	fprintf_unfiltered (raw_stdout, " token=`%s' command=`%s' args=`%s'\n",
			    context->token, context->command, context->args);
      /* FIXME: cagney/1999-09-25: Rather than this convoluted
         condition expression, each function should return an
         indication of what action is required and then switch on
         that.  */
      args->action = EXECUTE_COMMAND_DISPLAY_PROMPT;

      if (do_timings)
	current_command_ts = context->cmd_start;

      args->rc = mi_cmd_execute (context);

      if (do_timings)
          timestamp (&cmd_finished);

      if (!target_can_async_p () || !target_executing)
	{
	  /* Print the result if there were no errors.

	     Remember that on the way out of executing a command, you have
	     to directly use the mi_interp's uiout, since the command could 
	     have reset the interpreter, in which case the current uiout 
	     will most likely crash in the mi_out_* routines.  */
	  if (args->rc == MI_CMD_DONE)
	    {
	      fputs_unfiltered (context->token, raw_stdout);
	      fputs_unfiltered ("^done", raw_stdout);
	      mi_out_put (uiout, raw_stdout);
	      mi_out_rewind (uiout);
	      /* Have to check cmd_start, since the command could be
		 -enable-timings.  */
	      if (do_timings && context->cmd_start)
		  print_diff (context->cmd_start, &cmd_finished);
	      fputs_unfiltered ("\n", raw_stdout);
	    }
	  else if (args->rc == MI_CMD_ERROR)
	    {
	      if (mi_error_message)
		{
		  fputs_unfiltered (context->token, raw_stdout);
		  fputs_unfiltered ("^error,msg=\"", raw_stdout);
		  fputstr_unfiltered (mi_error_message, '"', raw_stdout);
		  xfree (mi_error_message);
		  mi_error_message = NULL;
		  fputs_unfiltered ("\"\n", raw_stdout);
		}
	      mi_out_rewind (uiout);
	    }
	  else
	    mi_out_rewind (uiout);
	}
      else if (sync_execution)
	{
	  /* Don't print the prompt. We are executing the target in
	     synchronous mode.  */
	  args->action = EXECUTE_COMMAND_SUPRESS_PROMPT;
	  return;
	}
      break;

    case CLI_COMMAND:
      {
	char *argv[2];
	/* A CLI command was read from the input stream.  */
	/* This "feature" will be removed as soon as we have a
	   complete set of mi commands.  */
	/* Echo the command on the console.  */
	fprintf_unfiltered (gdb_stdlog, "%s\n", context->command);
	/* Call the "console" interpreter.  */
	argv[0] = "console";
	argv[1] = context->command;
	args->rc = mi_cmd_interpreter_exec ("-interpreter-exec", argv, 2);

	/* If we changed interpreters, DON'T print out anything.  */
	if (current_interp_named_p (INTERP_MI)
	    || current_interp_named_p (INTERP_MI1)
	    || current_interp_named_p (INTERP_MI2)
	    || current_interp_named_p (INTERP_MI3))
	  {
	    if (args->rc == MI_CMD_DONE)
	      {
		fputs_unfiltered (context->token, raw_stdout);
		fputs_unfiltered ("^done", raw_stdout);
		mi_out_put (uiout, raw_stdout);
		mi_out_rewind (uiout);
		fputs_unfiltered ("\n", raw_stdout);
		args->action = EXECUTE_COMMAND_DISPLAY_PROMPT;
	      }
	    else if (args->rc == MI_CMD_ERROR)
	      {
		if (mi_error_message)
		  {
		    fputs_unfiltered (context->token, raw_stdout);
		    fputs_unfiltered ("^error,msg=\"", raw_stdout);
		    fputstr_unfiltered (mi_error_message, '"', raw_stdout);
		    xfree (mi_error_message);
		    mi_error_message = NULL;
		    fputs_unfiltered ("\"\n", raw_stdout);
		  }
		mi_out_rewind (uiout);
	      }
	    else
	      mi_out_rewind (uiout);
	  }
	break;
      }

    }

  return;
}
Exemple #17
0
/*
 * verify_license -- compare 'license' with 'pattern' and check correctness
 *                  of the copyright line
 */
static int
verify_license(const char *path_to_check, char *pattern, const char *filename)
{
	char buffer[LICENSE_MAX_LEN];
	char *license, *copyright;
	int file_to_check;
	ssize_t ret;
	int year_first, year_last;
	int min_year_first = YEAR_INIT_MIN;
	int max_year_last = YEAR_INIT_MAX;
	char *err_str = NULL;
	const char *name_to_print = filename ? filename : path_to_check;

	if ((file_to_check = open(path_to_check, O_RDONLY)) == -1) {
		ERROR("open(): %s: %s", strerror(errno), path_to_check);
		return -1;
	}

	memset(buffer, 0, sizeof(buffer));
	ret = read(file_to_check, buffer, LICENSE_MAX_LEN);
	close(file_to_check);

	if (ret == -1) {
		ERROR("read(): %s: %s", strerror(errno), name_to_print);
		return -1;
	}

	if (analyze_license(path_to_check, buffer, &license) == -1)
		return -1;

	/* check the copyright notice */
	copyright = buffer;
	while ((copyright = strstr(copyright, COPYRIGHT)) != NULL) {
		copyright += COPYRIGHT_LEN;

		/* skip the copyright symbol '(c)' if any */
		if (strncmp(copyright, COPYRIGHT_SYMBOL,
			COPYRIGHT_SYMBOL_LEN) == 0)
			copyright += COPYRIGHT_SYMBOL_LEN;

		/* look for the first year */
		if (!isdigit(*copyright)) {
			err_str = "no digit just after the 'Copyright ' string";
			break;
		}

		year_first = atoi(copyright);
		if (year_first < YEAR_MIN || year_first > YEAR_MAX) {
			err_str = "the first year is wrong";
			break;
		}
		copyright += YEAR_LEN;

		if (year_first < min_year_first)
			min_year_first = year_first;
		if (year_first > max_year_last)
			max_year_last = year_first;

		/* check if there is the second year */
		if (*copyright == ',')
			continue;
		else if (*copyright != '-') {
			err_str = "'-' or ',' expected after the first year";
			break;
		}
		copyright++;

		/* look for the second year */
		if (!isdigit(*copyright)) {
			err_str = "no digit after '-'";
			break;
		}

		year_last = atoi(copyright);
		if (year_last < YEAR_MIN || year_last > YEAR_MAX) {
			err_str = "the second year is wrong";
			break;
		}
		copyright += YEAR_LEN;

		if (year_last > max_year_last)
			max_year_last = year_last;

		if (*copyright != ',') {
			err_str = "',' expected after the second year";
			break;
		}
	}

	if (!err_str && min_year_first == YEAR_INIT_MIN)
		err_str = "no 'Copyright ' string found";

	if (err_str)
		/* found an error in the copyright notice */
		ERROR2("%s:1: error: incorrect copyright notice: %s",
			name_to_print, err_str);

	/* now check the license */
	if (memcmp(license, pattern, strlen(pattern)) != 0) {
		ERROR2("%s:1: error: incorrect license", name_to_print);
		print_diff(license, pattern, strlen(pattern));
		return -1;
	}

	if (err_str)
		return -1;

	/* all checks passed */
	if (min_year_first != max_year_last && max_year_last != YEAR_INIT_MAX) {
		printf("%i-%i\n", min_year_first, max_year_last);
	} else {
		printf("%i\n", min_year_first);
	}

	return 0;
}
Exemple #18
0
/**
 * This is the customized diff program designed to compare grf files.
 */
int main_GrfDiff(int argc,char* const argv[]) {
if (argc==1) {
    usage();
    return SUCCESS_RETURN_CODE;
}

VersatileEncodingConfig vec=VEC_DEFAULT;
int val,index=-1;
char output[FILENAME_MAX]="";
bool only_verify_arguments = false;
UnitexGetOpt options;
while (EOF!=(val=options.parse_long(argc,argv,optstring_GrfDiff,lopts_GrfDiff,&index))) {
   switch(val) {
   case 'V': only_verify_arguments = true;
             break;
   case 'h': usage();
             return SUCCESS_RETURN_CODE;
   case 1: {
       strcpy(output,options.vars()->optarg);
       break;
   }
   case 'k': if (options.vars()->optarg[0]=='\0') {
                error("Empty input_encoding argument\n");
                return USAGE_ERROR_CODE;
             }
             decode_reading_encoding_parameter(&(vec.mask_encoding_compatibility_input),options.vars()->optarg);
             break;
   case 'q': if (options.vars()->optarg[0]=='\0') {
                error("Empty output_encoding argument\n");
                return USAGE_ERROR_CODE;
             }
             decode_writing_encoding_parameter(&(vec.encoding_output),&(vec.bom_output),options.vars()->optarg);
             break;
   case ':': index==-1 ? error("Missing argument for option -%c\n",options.vars()->optopt) :
                         error("Missing argument for option --%s\n",lopts_GrfDiff[index].name);
             return USAGE_ERROR_CODE;
   case '?': index==-1 ? error("Invalid option -%c\n",options.vars()->optopt) :
                         error("Invalid option --%s\n",options.vars()->optarg);
             return USAGE_ERROR_CODE;
   }
   index=-1;
}

if (options.vars()->optind!=argc-2) {
  error("Invalid arguments: rerun with --help\n");
  return USAGE_ERROR_CODE;
}

if (only_verify_arguments) {
  // freeing all allocated memory
  return SUCCESS_RETURN_CODE;
}

U_FILE* f=U_STDOUT;
if (output[0]!='\0') {
    /* Since the output is supposed to be a diff-like one, there is no point
     * in outputing in a variable encoding, so we force UTF8 */
    f=u_fopen(UTF8,output,U_WRITE);
    if (f==NULL) {
        error("Cannot create file %s\n",output);
    return DEFAULT_ERROR_CODE;
    }
}

Grf* a=load_Grf(&vec,argv[options.vars()->optind]);
if (a==NULL) {
  if (f!=U_STDOUT) {
    u_fclose(f);
  }
  return DEFAULT_ERROR_CODE;
}

Grf* b=load_Grf(&vec,argv[options.vars()->optind+1]);
if (b==NULL) {
    free_Grf(a);
  if (f!=U_STDOUT) {
    u_fclose(f);
  }
  return DEFAULT_ERROR_CODE;
}

GrfDiff* diff=grf_diff(a,b);
free_Grf(a);
free_Grf(b);
print_diff(f,diff);
if (f!=U_STDOUT) {
  u_fclose(f);
}
int different=diff->diff_ops->nbelems!=0;
free_GrfDiff(diff);
return different;
}
Exemple #19
0
int main(int argc, char **argv) {

    int i,j;
    int initial,fixup,spec2k6,legend;

    int num_benchmarks;
    char temp_input[BUFSIZ];

     parse_command_line(argc,argv,
			&num_runs,&initial,
			&legend,&spec2k6,&num_benchmarks);
   

    if (initial) fixup=FIXUP_NONE;
    else fixup=FIXUP_ALL;
   
    machines=spec2k_machines;
   
    printf("\\begin{table*}[tbp]\n");
    printf("\\begin{sf}\n");
    printf("\\begin{scriptsize}\n");
    printf("\\begin{center}\n");
    printf("\\begin{tabular}{|l||r||r|r|r||");
    for(i=0;i<REAL_MACHINES;i++) {
       if (!(!machines[i].is_spec2k6&&spec2k6)) {
          printf("r|");
       }
    }
    printf("}\n");
   
    printf("\\hline\n");
    printf("Benchmark & ");
    printf("\\parbox[b]{1.2cm}{\\flushright Overall\\\\Standard\\\\Deviation\\\\(mean)} & ");
    printf("\\begin{sideways}\\parbox{2cm}{Pin}\\end{sideways} &");   
    printf("\\begin{sideways}\\parbox{2cm}{Qemu}\\end{sideways} &");
    printf("\\begin{sideways}\\parbox{2cm}{Valgrind}\\end{sideways} ");
   
    for(i=0;i<REAL_MACHINES;i++) {
       if (!(!machines[i].is_spec2k6&&spec2k6)) {
          printf("& ");
          printf("\\begin{sideways}\\parbox{2cm}{");

          printf("%s",machines[i].processor2);
          printf("\\\\%s",machines[i].processor1);       	  
          printf("}\\end{sideways} ");
       }
    }
    printf("\\\\\n");
    printf("\\hline\n");

    our_stats=calloc(sizeof(struct stats),num_benchmarks);

    for(j=0;j<num_benchmarks;j++) {   
       load_stats(num_runs,spec2k6,our_stats,argv[(j*2)+BENCH_START],
		     argv[(j*2)+BENCH_START+1],argv[TREE_ARG],j,fixup);
    }
    for(j=0;j<num_benchmarks;j++) {   
	   
       if (!strcmp("makerand",argv[(j*2)+BENCH_START+1])) {
          strcpy(temp_input,"mkrnd");
       }
       else if (!strcmp("default",argv[(j*2)+BENCH_START+1])) {
          strcpy(temp_input," ");
       }
       else if (!strcmp("foreman_baseline",argv[(j*2)+BENCH_START+1])) {
          strcpy(temp_input,"forebase");
       }
       else if (!strcmp("foreman_main",argv[(j*2)+BENCH_START+1])) {
          strcpy(temp_input,"foremain");
       }	   
       else if (!strcmp("sss_main",argv[(j*2)+BENCH_START+1])) {
          strcpy(temp_input,"sss");
       }	   
       else {
          strcpy(temp_input,argv[(j*2)+BENCH_START+1]);
       }
	   
       printf("%s %s &",argv[(j*2)+BENCH_START],temp_input);
       /* mean */
       
       print_diff((long long)(our_stats[j].bench_stdev),LO,MID,HI);
       //print_commas( (long long)(our_stats[j].bench_stdev));

       printf(" & "); 
       
       /* PIN */
       if (!our_stats[j].machine_mean_valid[PIN]) {
          print_blank();
       }
       else {
	  print_diff((long long)(our_stats[j].machine_stdev[PIN]),LO,MID,HI);
	  print_num_points(our_stats[j].num_points[PIN]);       
       }

       printf(" & ");

       /* QEMU */
       if (!our_stats[j].machine_mean_valid[QEMU]) {
          print_blank();
       }
       else {
	  print_diff((long long)(our_stats[j].machine_stdev[QEMU]),LO,MID,HI);
	  print_num_points(our_stats[j].num_points[QEMU]);       
       }
       
       printf(" & ");

       if (!our_stats[j].machine_mean_valid[VALGRIND]) {
          print_blank();
       }
       else {
          print_diff((long long)(our_stats[j].machine_stdev[VALGRIND]),LO,MID,HI);
          print_num_points(our_stats[j].num_points[VALGRIND]);	  
       }

       
       for(i=0;i<REAL_MACHINES;i++) {
          if (!(!machines[i].is_spec2k6&&spec2k6)) {
             printf(" & ");
	     if (!our_stats[j].machine_mean_valid[i]) {
	        print_blank();
	     } else {
                print_diff((long long)(our_stats[j].machine_stdev[i]),LO,MID,HI);
		print_num_points(our_stats[j].num_points[i]);
	     }
	     
	  }
       }
       printf("\\\\\n");
   
       if (j%5==4) printf("\\hline\n");
    }
    printf("\\hline\n");
    printf("\\end{tabular}\n");
    printf("\\end{center}\n");
    
    return 0;
}
Exemple #20
0
static
bool
run_output_check(const output_check oc, const atf::fs::path& path,
                 const std::string& stdxxx)
{
    bool result;

    if (oc.type == oc_empty) {
        const bool is_empty = file_empty(path);
        if (!oc.negated && !is_empty) {
            std::cerr << "Fail: " << stdxxx << " not empty\n";
            print_diff(atf::fs::path("/dev/null"), path);
            result = false;
        } else if (oc.negated && is_empty) {
            std::cerr << "Fail: " << stdxxx << " is empty\n";
            result = false;
        } else
            result = true;
    } else if (oc.type == oc_file) {
        const bool equals = compare_files(path, atf::fs::path(oc.value));
        if (!oc.negated && !equals) {
            std::cerr << "Fail: " << stdxxx << " does not match golden "
                "output\n";
            print_diff(atf::fs::path(oc.value), path);
            result = false;
        } else if (oc.negated && equals) {
            std::cerr << "Fail: " << stdxxx << " matches golden output\n";
            cat_file(atf::fs::path(oc.value));
            result = false;
        } else
            result = true;
    } else if (oc.type == oc_ignore) {
        result = true;
    } else if (oc.type == oc_inline) {
        atf::fs::path path2 = atf::fs::path(atf::config::get("atf_workdir"))
                              / "inline.XXXXXX";
        temp_file temp(path2);
        temp.write(decode(oc.value));
        temp.close();

        const bool equals = compare_files(path, temp.get_path());
        if (!oc.negated && !equals) {
            std::cerr << "Fail: " << stdxxx << " does not match expected "
                "value\n";
            print_diff(temp.get_path(), path);
            result = false;
        } else if (oc.negated && equals) {
            std::cerr << "Fail: " << stdxxx << " matches expected value\n";
            cat_file(temp.get_path());
            result = false;
        } else
            result = true;
    } else if (oc.type == oc_match) {
        const bool matches = grep_file(path, oc.value);
        if (!oc.negated && !matches) {
            std::cerr << "Fail: regexp " + oc.value + " not in " << stdxxx
                      << "\n";
            cat_file(path);
            result = false;
        } else if (oc.negated && matches) {
            std::cerr << "Fail: regexp " + oc.value + " is in " << stdxxx
                      << "\n";
            cat_file(path);
            result = false;
        } else
            result = true;
    } else if (oc.type == oc_save) {
        INV(!oc.negated);
        std::ifstream ifs(path.c_str(), std::fstream::binary);
        ifs >> std::noskipws;
        std::istream_iterator< char > begin(ifs), end;

        std::ofstream ofs(oc.value.c_str(), std::fstream::binary
                                     | std::fstream::trunc);
        std::ostream_iterator <char> obegin(ofs);

        std::copy(begin, end, obegin);
        result = true;
    } else {