Example #1
0
static void
acls_one_line (const char *prefix, char delim,
               const char *aclstring, size_t len)
{
  /* support both long and short text representation of posix acls */
  struct obstack stk;
  int pref_len = strlen (prefix);
  const char *oldstring = aclstring;
  int pos = 0;

  if (!aclstring || !len)
    return;

  obstack_init (&stk);
  while (pos <= len)
    {
      int move = strcspn (aclstring, ",\n");
      if (!move)
        break;

      if (oldstring != aclstring)
        obstack_1grow (&stk, delim);

      obstack_grow (&stk, prefix, pref_len);
      obstack_grow (&stk, aclstring, move);

      aclstring += move + 1;
    }

  obstack_1grow (&stk, '\0');

  fprintf (stdlis, "%s", (char *) obstack_finish (&stk));

  obstack_free (&stk, NULL);
}
Example #2
0
void
append_gpp_mangled_name (const char *name, int len)
{
  const unsigned char *ptr;
  const unsigned char *limit;
  int encoded_len;
  char buf [6];
  
  MANGLE_CXX_KEYWORDS (name, len);

  limit = (const unsigned char *)name + len;

  /* Compute the length of the string we wish to mangle. */
  for (encoded_len =  0, ptr = (const unsigned char *) name;
       ptr < limit; encoded_len++)
    {
      int ch = UTF8_GET(ptr, limit);

      if (ch < 0)
	error ("internal error - invalid Utf8 name");
    }

  sprintf (buf, "%d", encoded_len);
  obstack_grow (mangle_obstack, buf, strlen (buf));
  obstack_grow (mangle_obstack, name, len);
}
Example #3
0
static char *
hex_format( char *str, int *retlen, int refcon )
{
	int add, len=0, v;
	char *str2;

	if( (str2=strchr( str, '(' )) )         /* compatibility */
		str = str2+1;
	
	for( ;; ) {
		if( sscanf(str, " 0x%x%n\n", &v, &add) <= 0 )
			if( sscanf(str, " %d%n\n", &v, &add) <= 0 )
				break;
		str += add;
		if( refcon == 1 ) {
			unsigned char vch = v;
			obstack_grow( &oftree.stack, &vch, 1 );
		} else {
			obstack_grow( &oftree.stack, &v, 4 );
		}
		len += refcon;
	}
	*retlen = len;
	return len ? obstack_finish( &oftree.stack ) : NULL;
}
Example #4
0
static void
signal_catchpoint_print_one (struct breakpoint *b,
			     struct bp_location **last_loc)
{
  struct signal_catchpoint *c = (void *) b;
  struct value_print_options opts;
  struct ui_out *uiout = current_uiout;

  get_user_print_options (&opts);

  /* Field 4, the address, is omitted (which makes the columns
     not line up too nicely with the headers, but the effect
     is relatively readable).  */
  if (opts.addressprint)
    ui_out_field_skip (uiout, "addr");
  annotate_field (5);

  if (c->signals_to_be_caught
      && VEC_length (gdb_signal_type, c->signals_to_be_caught) > 1)
    ui_out_text (uiout, "signals \"");
  else
    ui_out_text (uiout, "signal \"");

  if (c->signals_to_be_caught)
    {
      int i;
      gdb_signal_type iter;
      struct obstack text;
      struct cleanup *cleanup;

      obstack_init (&text);
      cleanup = make_cleanup_obstack_free (&text);

      for (i = 0;
           VEC_iterate (gdb_signal_type, c->signals_to_be_caught, i, iter);
           i++)
        {
	  const char *name = signal_to_name_or_int (iter);

	  if (i > 0)
	    obstack_grow (&text, " ", 1);
	  obstack_grow (&text, name, strlen (name));
        }
      obstack_grow (&text, "", 1);
      ui_out_field_string (uiout, "what", obstack_base (&text));
      do_cleanups (cleanup);
    }
  else
    ui_out_field_string (uiout, "what",
			 c->catch_all ? "<any signal>" : "<standard signals>");
  ui_out_text (uiout, "\" ");

  if (ui_out_is_mi_like_p (uiout))
    ui_out_field_string (uiout, "catch-type", "signal");
}
Example #5
0
File: tlink.c Project: Fokycnuk/gcc
static int
recompile_files (void)
{
  file *f;

  putenv (xstrdup ("COMPILER_PATH="));
  putenv (xstrdup ("LIBRARY_PATH="));

  while ((f = file_pop ()) != NULL)
    {
      char *line, *command;
      FILE *stream = fopen (f->key, "r");
      const char *const outname = frob_extension (f->key, ".rnw");
      FILE *output = fopen (outname, "w");

      while ((line = tfgets (stream)) != NULL)
	{
	  switch (line[0])
	    {
	    case 'C':
	    case 'O':
	      maybe_tweak (line, f);
	    }
	  fprintf (output, "%s\n", line);
	}
      fclose (stream);
      fclose (output);
      rename (outname, f->key);

      obstack_grow (&temporary_obstack, "cd ", 3);
      obstack_grow (&temporary_obstack, f->dir, strlen (f->dir));
      obstack_grow (&temporary_obstack, "; ", 2);
      obstack_grow (&temporary_obstack, c_file_name, strlen (c_file_name));
      obstack_1grow (&temporary_obstack, ' ');
      obstack_grow (&temporary_obstack, f->args, strlen (f->args));
      obstack_1grow (&temporary_obstack, ' ');
      command = obstack_copy0 (&temporary_obstack, f->main, strlen (f->main));

      if (tlink_verbose)
	fprintf (stderr, _("collect: recompiling %s\n"), f->main);
      if (tlink_verbose >= 3)
	fprintf (stderr, "%s\n", command);

      if (system (command) != 0)
	return 0;

      read_repo_file (f);

      obstack_free (&temporary_obstack, temporary_firstobj);
    }
  return 1;
}
Example #6
0
static void
append_unicode_mangled_name (const char *name, int len)
{
  const unsigned char *ptr;
  const unsigned char *limit = (const unsigned char *)name + len;
  int uuU = 0;
  for (ptr = (const unsigned char *) name;  ptr < limit;  )
    {
      int ch = UTF8_GET(ptr, limit);

      if ((ISALNUM (ch) && ch != 'U') || ch == '$')
        {
	  obstack_1grow (mangle_obstack, ch);
          uuU = 0;
        }
      /* Everything else needs encoding */
      else
	{
	  /* Buffer large enough for UINT_MAX plus the prefix.  */
	  char buf [13];
	  if (ch == '_' || ch == 'U')
	    {
	      /* Prepare to recognize __U */
	      if (ch == '_' && (uuU < 3))
		{
		  uuU++;
		  obstack_1grow (mangle_obstack, ch);
		}
	      /* We recognize __U that we wish to encode
                 __U_. Finish the encoding. */
	      else if (ch == 'U' && (uuU == 2))
		{
		  uuU = 0;
		  obstack_grow (mangle_obstack, "U_", 2);
		}
	      /* Otherwise, just reset uuU and emit the character we
                 have. */
	      else
		{
		  uuU = 0;
		  obstack_1grow (mangle_obstack, ch);
		}
	      continue;
	    }
	  sprintf (buf, "__U%x_", ch);
	  obstack_grow (mangle_obstack, buf, strlen (buf));
	  uuU = 0;
	}
    }
}
Example #7
0
const char *get_output_name(const char *inputname, const char *newext)
{
	if (inputname == NULL)
		inputname = "a";

	char const       *filename;
	char const *const name_end = find_extension(inputname, &filename);

	assert(obstack_object_size(&file_obst) == 0);
	obstack_grow(&file_obst, filename, name_end-filename);
	size_t extlen = strlen(newext);
	obstack_grow(&file_obst, newext, extlen);
	return obstack_nul_finish(&file_obst);
}
Example #8
0
static void
obstack_code_rename (struct obstack *stk, char *from, char *to)
{
  char *s;

  s = from[0] == 0 ? from :
                     safer_name_suffix (from, false, absolute_names_option);
  obstack_1grow (stk, 'R');
  obstack_grow (stk, s, strlen (s) + 1);

  s = to[0] == 0 ? to:
                   safer_name_suffix (to, false, absolute_names_option);
  obstack_1grow (stk, 'T');
  obstack_grow (stk, s, strlen (s) + 1);
}
Example #9
0
void
append_gpp_mangled_name (const char *name, int len)
{
  int encoded_len = unicode_mangling_length (name, len);
  int needs_escapes = encoded_len > 0;
  char buf[6];

  sprintf (buf, "%d", (needs_escapes ? encoded_len : len));
  obstack_grow (mangle_obstack, buf, strlen (buf));

  if (needs_escapes)
    append_unicode_mangled_name (name, len);
  else
    obstack_grow (mangle_obstack, name, len);
}
Example #10
0
static int write_extent_block(struct defrag_ctx *c, blk64_t block,
                              struct ext3_extent *data,
                              e2_blkcnt_t max_extents, int depth,
                              struct obstack *index_mempool)
{
	struct ext3_extent_header *header = malloc(EXT2_BLOCK_SIZE(&c->sb));
	struct ext3_extent_idx *extents = (void *)(header + 1);
	int ret;

	assert(depth < 3);
	if (header == NULL)
		return -1;
	header->eh_magic = EXT3_EXT_MAGIC;
	header->eh_entries = EXT_PER_BLOCK(&c->sb);
	if (header->eh_entries > max_extents)
		header->eh_entries = max_extents;
	header->eh_max = EXT_PER_BLOCK(&c->sb);
	header->eh_generation = 0;
	header->eh_depth = depth;
	memcpy(extents, data, header->eh_entries * sizeof(struct ext3_extent));
	ret = write_block(c, header, block);
	if (ret >= 0) {
		EI_LEAF_SET(extents, block);
		extents->ei_block = data->ee_block;
		extents->ei_unused = 0;
		obstack_grow(index_mempool, extents, sizeof(*extents));
	}
	if (ret >= 0)
		ret = header->eh_entries;
	free(header);
	return ret;
}
Example #11
0
static _IO_size_t
_IO_obstack_xsputn (_IO_FILE *fp, const void *data, _IO_size_t n)
{
  struct obstack *obstack = ((struct _IO_obstack_file *) fp)->obstack;

  if (fp->_IO_write_ptr + n > fp->_IO_write_end)
    {
      int size;

      /* We need some more memory.  First shrink the buffer to the
	 space we really currently need.  */
      obstack_blank_fast (obstack, fp->_IO_write_ptr - fp->_IO_write_end);

      /* Now grow for N bytes, and put the data there.  */
      obstack_grow (obstack, data, n);

      /* Setup the buffer pointers again.  */
      fp->_IO_write_base = obstack_base (obstack);
      fp->_IO_write_ptr = obstack_next_free (obstack);
      size = obstack_room (obstack);
      fp->_IO_write_end = fp->_IO_write_ptr + size;
      /* Now allocate the rest of the current chunk.  */
      obstack_blank_fast (obstack, size);
    }
  else
    fp->_IO_write_ptr = __mempcpy (fp->_IO_write_ptr, data, n);

  return n;
}
Example #12
0
void
append_incremental_renames (struct directory *dir)
{
  struct obstack stk;
  size_t size;
  struct directory *dp;
  const char *dump;
  
  if (dirhead == NULL)
    return;

  obstack_init (&stk);
  dump = directory_contents (dir);
  if (dump)
    {
      size = dumpdir_size (dump) - 1;
      obstack_grow (&stk, dump, size);
    }
  else
    size = 0;

  for (dp = dirhead; dp; dp = dp->next)
    store_rename (dp, &stk);

  if (obstack_object_size (&stk) != size)
    {
      obstack_1grow (&stk, 0);
      dumpdir_free (dir->dump);
      dir->dump = dumpdir_create (obstack_finish (&stk));
    }
  obstack_free (&stk, NULL);
}
Example #13
0
static void
do_ui_file_obsavestring (void *context, const char *buffer, long length)
{
  struct obstack *obstack = (struct obstack *) context;

  obstack_grow (obstack, buffer, length);
}
Example #14
0
File: input.c Project: WndSks/msys
static int
match_input (const char *s)
{
  int n;			/* number of characters matched */
  int ch;			/* input character */
  const char *t;

  ch = peek_input ();
  if (ch != *s)
    return 0;			/* fail */
  (void) next_char ();

  if (s[1] == '\0')
    return 1;			/* short match */

  for (n = 1, t = s++; (ch = peek_input ()) == *s++; n++)
    {
      (void) next_char ();
      if (*s == '\0')		/* long match */
	return 1;
    }

  /* Failed, push back input.  */
  obstack_grow (push_string_init (), t, n);
  push_string_finish ();
  return 0;
}
Example #15
0
File: input.c Project: thewml/wml
static boolean
match_comment (const unsigned char *s)
{
  int n;                        /* number of characters matched */
  int ch;                       /* input character */
  const unsigned char *t;
  struct obstack *st;

  ch = peek_input ();
  if (ch != *s)
    return FALSE;               /* fail */

  (void) next_char ();
  if (s[1] == '\0')
    return TRUE;                /* short match */

  for (n = 1, t = s++; (ch = peek_input ()) == *s++; n++)
    {
      (void) next_char ();
      if (*s == '\0')           /* long match */
        return TRUE;
    }

  /* Push back input.  */
  st = push_string_init ();
  obstack_grow (st, t, n);
  push_string_finish (READ_NORMAL);
  return FALSE;
}
Example #16
0
static int obst_snadd(lc_appendable_t *obj, const char *str, size_t n)
{
	struct obstack *obst = (struct obstack*)obj->obj;
	obj->written += n;
	obstack_grow(obst, str, n);
	return n;
}
Example #17
0
File: devel.c Project: thewml/wml
void
shipout_long (struct obstack *obs, long val)
{
  char buf[128];

  sprintf (buf, "%ld", val);
  obstack_grow (obs, buf, strlen (buf));
}
Example #18
0
File: devel.c Project: thewml/wml
void
shipout_int (struct obstack *obs, int val)
{
  char buf[128];

  sprintf (buf, "%d", val);
  obstack_grow (obs, buf, strlen (buf));
}
Example #19
0
void mem_grow( mem_String info, const char *string, int len )
{
   stringInfo i = (stringInfo)info;
   
   _mem_magic_strings( i, __FUNCTION__ );
   
   i->bytes += len;
   obstack_grow( i->obstack, string, len );
}
static void
append_string_as_wide (const char *string, struct obstack *output)
{
  for (; *string; ++string)
    {
      gdb_wchar_t w = gdb_btowc (*string);
      obstack_grow (output, &w, sizeof (gdb_wchar_t));
    }
}
Example #21
0
static void
emit_numeric_character (struct type *type, unsigned long value,
			struct obstack *output)
{
  gdb_byte *buffer;

  buffer = alloca (TYPE_LENGTH (type));
  pack_long (buffer, type, value);
  obstack_grow (output, buffer, TYPE_LENGTH (type));
}
Example #22
0
/* Add name a file offset of a symbol.  */
void
arlib_add_symref (const char *symname, off_t symoff)
{
  /* For all supported platforms the following is true.  */
  assert (sizeof (uint32_t) == sizeof (int));
  obstack_int_grow (&symtab.symsoffob, (int) le_bswap_32 (symoff));

  size_t symname_len = strlen (symname) + 1;
  obstack_grow (&symtab.symsnameob, symname, symname_len);
}
Example #23
0
/* Finalize (in the obstack_finish sense) the current token
   and record its pointer and length.  */
static void
save_token (struct Tokens *t)
{
  /* Don't count the trailing NUL byte in the length.  */
  size_t len = obstack_object_size (&t->o_data) - 1;
  char const *s = obstack_finish (&t->o_data);
  obstack_ptr_grow (&t->o_tok, s);
  obstack_grow (&t->o_tok_len, &len, sizeof len);
  t->n_tok++;
}
static void
mangle_array_type (tree p_type)
{
  tree type, elt_type;
  int match;

  type = TREE_TYPE (p_type);
  gcc_assert (type);

  elt_type = TYPE_ARRAY_ELEMENT (type);

  /* We cache a bit of the Jarray <> mangle. */
  if (!atms)
    {
      atms = get_identifier ("6JArray");
    }

  /* Maybe we have what we're looking for in the compression table. */
  if ((match = find_compression_array_match (p_type)) >= 0)
    {
      emit_compression_string (match);
      return;
    }

  /* We know for a fact that all arrays are pointers */
  obstack_1grow (mangle_obstack, 'P');
  /* Maybe we already have a Jarray<t> somewhere. PSx_ will be enough. */
  if ((match = find_compression_record_match (type, NULL)) > 0)
    {
      emit_compression_string (match);
      return;
    }

  /* Maybe we already have just JArray somewhere */
  if ((match = find_compression_array_template_match (atms)) > 0)
    emit_compression_string (match);
  else
    {
      /* Start the template mangled name */
      obstack_grow (mangle_obstack, 
		    IDENTIFIER_POINTER (atms), IDENTIFIER_LENGTH (atms));
      /* Insert in the compression table */
      compression_table_add (atms);
    } 

  /* Mangle Jarray <elt_type> */
  obstack_1grow (mangle_obstack, 'I');
  mangle_type (elt_type);
  obstack_1grow (mangle_obstack, 'E');

  /* Add `Jarray <elt_type>' and `Jarray <elt_type> *' to the table */
  compression_table_add (type);
  compression_table_add (p_type);
}
Example #25
0
File: devel.c Project: thewml/wml
void
dump_args (struct obstack *obs, int argc, token_data **argv, const char *sep)
{
  int i;

  for (i = 1; i < argc; i++)
    {
      if (i > 1 && sep)
        obstack_grow (obs, sep, strlen (sep));

      obstack_1grow (obs, CHAR_BGROUP);
      /*   Remove surrounding double quotes  */
      if (*ARG (i) == '"' && LAST_CHAR (ARG (i)) == '"')
        obstack_grow (obs, ARG (i) + 1, strlen (ARG (i)) - 2);
      else
        obstack_grow (obs, ARG (i), strlen (ARG (i)));

      obstack_1grow (obs, CHAR_EGROUP);
    }
}
Example #26
0
void
append_gpp_mangled_name (const char *name, int len)
{
  int encoded_len, needs_escapes;
  /* Buffer large enough for INT_MIN.  */
  char buf[9];

  MANGLE_CXX_KEYWORDS (name, len);

  encoded_len = unicode_mangling_length (name, len);
  needs_escapes = encoded_len > 0;

  sprintf (buf, "%d", (needs_escapes ? encoded_len : len));
  obstack_grow (mangle_obstack, buf, strlen (buf));

  if (needs_escapes)
    append_unicode_mangled_name (name, len);
  else
    obstack_grow (mangle_obstack, name, len);
}
Example #27
0
File: devel.c Project: thewml/wml
void
shipout_string (struct obstack *obs, const char *s, int len)
{
  if (s == NULL)
    s = "";

  if (len == 0)
    len = strlen (s);

  obstack_grow (obs, s, len);
}
Example #28
0
int
main( int argc, char **argv )
{
    char *s = "Hello world";
    char *s2 = "**Helsssssssssssssssssssssssssssslo world**";
    char *p, *p2;

    obstack_init( &os );
    p = (char*)obstack_copy0( &os, s, strlen(s) );
    p2 = (char*)obstack_copy0( &os, s2, strlen(s2) );
    //printf("%s - %s %08lX %08lX\n", p, p2, p, p2 );
    obstack_free( &os, p );
    p = (char*)obstack_copy0( &os, s, strlen(s) );
    p = (char*)obstack_copy0( &os, s, strlen(s) );
    p2 = (char*)obstack_copy0( &os, s2, strlen(s2) );
    //printf("%s - %s %08lX %08lX\n", p, p2, p, p2 );

    obstack_grow( &os, s, strlen(s) );
    obstack_grow( &os, s, strlen(s) );
    obstack_grow( &os, s, strlen(s) );
    obstack_grow( &os, s, strlen(s) );
    obstack_grow( &os, s, strlen(s) );
    obstack_grow( &os, s, strlen(s) );
    obstack_grow0( &os, s, strlen(s) );
    p = obstack_finish( &os );
    obstack_grow0( &os, s, strlen(s) );
    p = obstack_finish( &os );
    printf("XXXXXX %s XXXXXX\n", p );

    obstack_free( &os, NULL );
    return 0;
}
Example #29
0
/*
 *			symbol_new()
 *
 * Return a pointer to a new symbol.
 * Die if we can't make a new symbol.
 * Fill in the symbol's values.
 * Add symbol to end of symbol chain.
 *
 *
 * Please always call this to create a new symbol.
 *
 * Changes since 1985: Symbol names may not contain '\0'. Sigh.
 */
symbolS *
symbol_new(
char	       *name,	/* We copy this: OK to alter your copy. */
unsigned char	type,	/* As in <nlist.h>. */
char		other,	/* As in <nlist.h>. */
short		desc,	/* As in <nlist.h>. */
valueT		value,	/* As in <nlist.h>, often an address. */
			/* Often used as offset from frag address. */
struct frag    *frag)	/* For sy_frag. */
{
  register symbolS *		symbolP;
  register char *		preserved_copy_of_name;
  register unsigned int		name_length;
           char *		p;

  name_length = strlen(name) + 1;
  obstack_grow(&notes,name,name_length);
  p=obstack_finish(&notes);
  /* obstack_1done( &notes, name, name_length, &p ); */
  preserved_copy_of_name = p;
  p=obstack_alloc(&notes,sizeof(struct symbol));
  /* obstack_1blank( &notes, sizeof(struct symbol), &p ); */
  symbolP			= (symbolS *) p;
  symbolP -> sy_name		= preserved_copy_of_name;
  symbolP -> sy_type		= type;
  symbolP -> sy_other		= other;
  symbolP -> sy_desc		= desc;
  symbolP -> sy_value		= value;
  symbolP -> sy_frag		= frag;
  symbolP -> sy_prev_by_index	= NULL; /* Don't know what this is yet. */
  symbolP -> sy_next		= NULL;	/* End of chain. */
  symbolP -> sy_forward		= NULL; /* JF */
  symbolP -> expression		= NULL;
#ifdef SUSPECT
  symbolP -> sy_name_offset	= ~ 0; /* Impossible offset catches errors. */
  symbolP -> sy_number		= ~ 0; /* Ditto. */
#endif
  /*
   * Link to end of symbol chain.
   */
  if (symbol_lastP)
    {
      symbol_lastP -> sy_next = symbolP;
    }
  else
    {
      symbol_rootP = symbolP;
    }
  symbol_lastP = symbolP;

  return (symbolP);
}
Example #30
0
File: tlink.c Project: aosm/gcc_40
static char *
frob_extension (const char *s, const char *ext)
{
  const char *p = strrchr (s, '/');
  if (! p)
    p = s;
  p = strrchr (p, '.');
  if (! p)
    p = s + strlen (s);

  obstack_grow (&temporary_obstack, s, p - s);
  return obstack_copy0 (&temporary_obstack, ext, strlen (ext));
}