Exemplo n.º 1
0
/* get object file corresponding to src file */
char *
get_object_file (char *src)
{
	// bug 2025
	// Create .o files in /tmp in case the src dir is not writable.
	if (!(keep_flag || (ipa == TRUE) || remember_last_phase == P_any_as)) {
	  char *tmp_file = NULL;
	  char *obj_name = change_suffix(src, "o");
	  string_pair_item_t *p;
	  FOREACH_STRING_PAIR (p, temp_obj_files) {
	    if (strcmp (STRING_PAIR_KEY(p), obj_name) == 0)
	      return STRING_PAIR_VAL(p);
	  }
	  // Create temp file name as in create_temp_file_name.
	  tmp_file = concat_strings(tmpdir, "/cco.XXXXXX");
	  int fd = mkstemp(tmp_file);
      if(fd == -1) {
		error("mkstemp failed for template: %s", tmp_file);
        return NULL;
      }

	  close(fd);
	  add_string_pair (temp_obj_files, obj_name, tmp_file);
	  return tmp_file;
	}
Exemplo n.º 2
0
void read_stringpairs() {
	char *my_string = NULL, *token1, *token2;
	char str1[1024], str2[1024];
	size_t nbytes;
	int bytes_read;
	while ((bytes_read = getline(&my_string, &nbytes, stdin)) != -1) {
		if (g_input_format == INPUT_FORMAT_L2P) {
			if (sscanf(my_string, "%1023s %1023s", &str1[0], &str2[0]) == 2)
				add_string_pair(str1, str2);
		} else if (g_input_format == INPUT_FORMAT_NEWS) {
			token1 = strtok(my_string, "\t\n");
			token2 = strtok(NULL, "\t\n");
			if (token1 != NULL && token2 != NULL)
				add_string_pair(token1, token2);	    
		}
	}
	clear_counts();
	initial_align();
}
Exemplo n.º 3
0
/* get object file corresponding to src file */
char *
get_object_file (char *src)
{
	// bug 2025
	// Create .o files in /tmp in case the src dir is not writable.
	if (!(keep_flag || (ipa == TRUE) || remember_last_phase == P_any_as)) {
	  char *obj_name = change_suffix(src, "o");
	  string_pair_item_t *p;
	  FOREACH_STRING_PAIR (p, temp_obj_files) {
	    if (strcmp (STRING_PAIR_KEY(p), obj_name) == 0)
	      return STRING_PAIR_VAL(p);
	  }
	  // Create temp file name as in create_temp_file_name.
	  buffer_t buf;
	  sprintf(buf, "cco.");
	  char *mapped_name = tempnam (tmpdir, buf);
	  add_string_pair (temp_obj_files, obj_name, mapped_name);
	  return mapped_name;
	}
Exemplo n.º 4
0
/* get object file corresponding to src file */
char *
get_object_file (char *src)
{
#if defined(_WIN32) || defined(TARG_NVISA)
	/* user is responsible for specifying writable dir,
	 * don't write it behind their back. */
#else
	// bug 2025
	// Create .o files in /tmp in case the src dir is not writable.
	if (!(keep_flag || (ipa == TRUE) || remember_last_phase == P_any_as)) {
	  char *obj_name = change_suffix(src, "o");
	  string_pair_item_t *p;
	  buffer_t buf;
	  char *mapped_name;
	  FOREACH_STRING_PAIR (p, temp_obj_files) {
	    if (strcmp (STRING_PAIR_KEY(p), obj_name) == 0)
	      return STRING_PAIR_VAL(p);
	  }
	  // Create temp file name as in create_temp_file_name.
	  sprintf(buf, "cco.");
	  mapped_name = tempnam (tmpdir, buf);
	  add_string_pair (temp_obj_files, obj_name, mapped_name);
	  return mapped_name;
	}