コード例 #1
0
ファイル: which.c プロジェクト: tylerberry/newts
static char *
tilde_expand_word (char *filename)
{
  char *dirname, *expansion, *username;
  int user_len;
  struct passwd *user_entry;

  if (filename == 0)
    return ((char *)NULL);

  if (*filename != '~')
    return (savestring (filename));

  /* A leading `~/' or a bare `~' is *always* translated to the value of
     $HOME or the home directory of the current user, regardless of any
     preexpansion hook. */
  if (filename[1] == '\0' || filename[1] == '/')
    {
      /* Prefix $HOME to the rest of the string. */
      expansion = (char *) getenv ("HOME");

      /* If there is no HOME variable, look up the directory in
     the password database. */
      if (expansion == 0)
        expansion = get_home_dir ();

      return (glue_prefix_and_suffix (expansion, filename, 1));
    }

  username = isolate_tilde_prefix (filename, &user_len);

  /* No preexpansion hook, or the preexpansion hook failed.  Look in the
     password database. */
  dirname = (char *)NULL;
  user_entry = getpwnam (username);
  if (user_entry == 0)
    {
      free (username);
      /* If we don't have a failure hook, or if the failure hook did not
     expand the tilde, return a copy of what we were passed. */
      if (dirname == 0)
    dirname = savestring (filename);
    }
  else
    {
      free (username);
      dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len);
    }

#if HAVE_ENDPWENT
  endpwent ();
#endif
  return (dirname);
}
コード例 #2
0
ファイル: rule.c プロジェクト: OS2World/DEV-UTIL-gnumake
static void
convert_suffix_rule (char *target, char *source, struct commands *cmds)
{
  char *targname, *targpercent, *depname;
  char **names, **percents;
  struct dep *deps;
  unsigned int len;

  if (target == 0)
    /* Special case: TARGET being nil means we are defining a
       `.X.a' suffix rule; the target pattern is always `(%.o)'.  */
    {
#ifdef VMS
      targname = savestring ("(%.obj)", 7);
#else
      targname = savestring ("(%.o)", 5);
#endif
      targpercent = targname + 1;
    }
  else
    {
      /* Construct the target name.  */
      len = strlen (target);
      targname = xmalloc (1 + len + 1);
      targname[0] = '%';
      bcopy (target, targname + 1, len + 1);
      targpercent = targname;
    }

  names = (char **) xmalloc (2 * sizeof (char *));
  percents = (char **) alloca (2 * sizeof (char *));
  names[0] = targname;
  percents[0] = targpercent;
  names[1] = percents[1] = 0;

  if (source == 0)
    deps = 0;
  else
    {
      /* Construct the dependency name.  */
      len = strlen (source);
      depname = xmalloc (1 + len + 1);
      depname[0] = '%';
      bcopy (source, depname + 1, len + 1);
      deps = (struct dep *) xmalloc (sizeof (struct dep));
      deps->next = 0;
      deps->name = depname;
      deps->ignore_mtime = 0;
      deps->need_2nd_expansion = 0;
    }

  create_pattern_rule (names, percents, 0, deps, cmds, 0);
}
コード例 #3
0
ファイル: cpp3.c プロジェクト: cjapes/core
void initdefines()
/*
 * Initialize the built-in #define's.  There are two flavors:
 *      #define decus   1               (static definitions)
 *      #define __FILE__ ??             (dynamic, evaluated by magic)
 * Called only on cpp startup.
 *
 * Note: the built-in static definitions are supressed by the -N option.
 * __LINE__, __FILE__, and __DATE__ are always present.
 */
{
        register char           **pp;
        register char           *tp;
        register DEFBUF         *dp;
        int                     i;
        time_t                  tvec;

#if !defined( WNT ) && !defined(G3)
        extern char             *ctime();
#endif

        /*
         * Predefine the built-in symbols.  Allow the
         * implementor to pre-define a symbol as "" to
         * eliminate it.
         */
        if (nflag == 0) {
            for (pp = preset; *pp != NULL; pp++) {
                if (*pp[0] != EOS) {
                    dp = defendel(*pp, FALSE);
                    dp->repl = savestring("1");
                    dp->nargs = DEF_NOARGS;
                }
            }
        }
        /*
         * The magic pre-defines (__FILE__ and __LINE__ are
         * initialized with negative argument counts.  expand()
         * notices this and calls the appropriate routine.
         * DEF_NOARGS is one greater than the first "magic" definition.
         */
        if (nflag < 2) {
            for (pp = magic, i = DEF_NOARGS; *pp != NULL; pp++) {
                dp = defendel(*pp, FALSE);
                dp->nargs = --i;
            }
#if OK_DATE
            /*
             * Define __DATE__ as today's date.
             */
            dp = defendel("__DATE__", FALSE);
            dp->repl = tp = getmem(27);
            dp->nargs = DEF_NOARGS;
            time( &tvec);
            *tp++ = '"';
            strcpy(tp, ctime(&tvec));
            tp[24] = '"';                       /* Overwrite newline    */
#endif
        }
}
コード例 #4
0
ファイル: postmd.c プロジェクト: andreiw/polaris
static void
setwindow(char *list)
    /* corners of window into the matrix */
{
    static char	*templist = NULL;	/* a working copy of the window list */
    char	*ptr;			/* next window coordinate in *templist */
    int		i = 0;			/* assigned to this region in wlist[] */

/*
 *
 * Sets up an optional window into the matrix.
 *
 */


    wlist[0] = wlist[1] = 1;
    wlist[2] = wlist[3] = 0;

    if ( list != NULL )  {
	if ( templist != NULL )
	    free(templist);
	templist = savestring(list);

	ptr = strtok(templist, ",/ \t\n");
	while ( ptr != NULL )  {
	    wlist[i++] = atoi(ptr);
	    ptr = strtok(NULL, ",/ \t\n");
	}   /* End while */
    }	/* End if */

}   /* End of setwindow */
コード例 #5
0
ファイル: scf_client.c プロジェクト: plineo/scf
/* Inicializacion del cliente */
void initialize()
{
    gethostname(my_host,HOSTNAME_SIZE);
    my_host[HOSTNAME_SIZE] = '\0';
    
    if ((local_host = gethostbyname(my_host)) == NULL)
    {
	printf("Local server not found.\n");
    	return;
    }
    
    list.nfiles = 0;
    list.lfiles = 0;
    list.files = (char *)NULL;
    
    
    bzero((char *) &cli_addr, sizeof(cli_addr));

    cli_addr.sin_family = AF_INET;
    bcopy((char *)local_host->h_addr_list[0],(char *)&cli_addr.sin_addr.s_addr,local_host->h_length);
    cli_addr.sin_port = htons(0);

    my_ident = (char *)savestring(getenv("LOGNAME"));

}
コード例 #6
0
ファイル: cli-dump.c プロジェクト: cooljeanius/apple-gdb-1824
/* FIXME: add comment: */
char *
scan_filename_with_cleanup(const char **cmd, const char *defname)
{
  char *filename;
  char *fullname;

  /* FIXME: Need to get the ``/a(ppend)'' flag from somewhere.  */

  /* File: */
  if ((*cmd) == NULL)
    {
      if (defname == NULL)
	error(_("Missing filename."));
      filename = xstrdup(defname);
      make_cleanup(xfree, filename);
    }
  else
    {
      /* FIXME: should parse a possibly quoted string: */
      const char *end;

      (*cmd) = skip_spaces(*cmd);
      end = (*cmd + strcspn(*cmd, " \t"));
      filename = savestring((*cmd), end - (*cmd));
      make_cleanup(xfree, filename);
      (*cmd) = skip_spaces(end);
    }
  gdb_assert(filename != NULL);

  fullname = tilde_expand(filename);
  make_cleanup(xfree, fullname);

  return fullname;
}
コード例 #7
0
ファイル: event-top.c プロジェクト: HoMeCracKeR/gdb-ng
/* Pushes a new prompt on the prompt stack. Each prompt has three
   parts: prefix, prompt, suffix. Usually prefix and suffix are empty
   strings, except when the annotation level is 2. Memory is allocated
   within savestring for the new prompt. */
void
push_prompt (char *prefix, char *prompt, char *suffix)
{
  the_prompts.top++;
  PREFIX (0) = savestring (prefix, strlen (prefix));

  /* Note that this function is used by the set annotate 2
     command. This is why we take care of saving the old prompt
     in case a new one is not specified. */
  if (prompt)
    PROMPT (0) = savestring (prompt, strlen (prompt));
  else
    PROMPT (0) = savestring (PROMPT (-1), strlen (PROMPT (-1)));

  SUFFIX (0) = savestring (suffix, strlen (suffix));
}
コード例 #8
0
int
hpux_has_execd (int pid, char **execd_pathname)
{
  /* This request is only available on HPUX 10.0 and later.  */
#if !defined(PT_GET_PROCESS_STATE)
  *execd_pathname = NULL;
  return 0;

#else
  int pt_status;
  ptrace_state_t ptrace_state;

  errno = 0;
  pt_status = call_ptrace (PT_GET_PROCESS_STATE,
			   pid,
			   (PTRACE_ARG3_TYPE) & ptrace_state,
			   sizeof (ptrace_state));
  if (errno)
    perror_with_name ("ptrace");
  if (pt_status < 0)
    return 0;

  if (ptrace_state.pe_report_event & PTRACE_EXEC)
    {
      char *exec_file = target_pid_to_exec_file (pid);
      *execd_pathname = savestring (exec_file, strlen (exec_file));
      return 1;
    }

  return 0;
#endif
}
コード例 #9
0
ファイル: postmd.c プロジェクト: andreiw/polaris
static void
addcolormap(char *list)
    /* use this color map */
{
    static char	*templist = NULL;	/* a working copy of the color list */
    char	*ptr;			/* next color in *templist */
    int		i = 0;			/* assigned to this region in ilist[] */

/*
 *
 * Assigns the integers in *list to the color field for the regions defined in
 * ilist[]. Assumes ilist[] has already been setup.
 *
 */


    if ( list != NULL )  {
	if ( templist != NULL )
	    free(templist);
	templist = savestring(list);

	ptr = strtok(templist, ",/ \t\n");
	while ( ptr != NULL )  {
	    ilist[i++].color = atoi(ptr) % 256;
	    ptr = strtok(NULL, ",/ \t\n");
	}   /* End while */
    }	/* End if */

}   /* End of addcolormap */
コード例 #10
0
ファイル: corefile.c プロジェクト: dougmencken/apple-gdb-1824
/* Set the gnutarget: */
void
set_gnutarget(char *newtarget)
{
  if (gnutarget_string != NULL)
    xfree(gnutarget_string);
  gnutarget_string = savestring(newtarget, strlen(newtarget));
  set_gnutarget_command(NULL, 0, NULL);
}
コード例 #11
0
ファイル: locale.c プロジェクト: BackupTheBerlios/wl530g-svn
/* Set default values for LC_CTYPE, LC_COLLATE, and LC_MESSAGES if they
   are not specified in the environment, but LANG or LC_ALL is.  This
   should be called from main() after parsing the environment. */
void
set_default_locale_vars ()
{
  char *val;

#if defined (HAVE_SETLOCALE)
  val = get_string_value ("LC_CTYPE");
  if (val == 0 && lc_all && *lc_all)
    setlocale (LC_CTYPE, lc_all);

#  if defined (LC_COLLATE)
  val = get_string_value ("LC_COLLATE");
  if (val == 0 && lc_all && *lc_all)
    setlocale (LC_COLLATE, lc_all);
#  endif /* LC_COLLATE */

#  if defined (LC_MESSAGES)
  val = get_string_value ("LC_MESSAGES");
  if (val == 0 && lc_all && *lc_all)
    setlocale (LC_MESSAGES, lc_all);
#  endif /* LC_MESSAGES */

#  if defined (LC_NUMERIC)
  val = get_string_value ("LC_NUMERIC");
  if (val == 0 && lc_all && *lc_all)
    setlocale (LC_NUMERIC, lc_all);
#  endif /* LC_NUMERIC */

#endif /* HAVE_SETLOCALE */

  val = get_string_value ("TEXTDOMAIN");
  if (val && *val)
    {
      FREE (default_domain);
      default_domain = savestring (val);
      textdomain (default_domain);
    }

  val = get_string_value ("TEXTDOMAINDIR");
  if (val && *val)
    {
      FREE (default_dir);
      default_dir = savestring (val);
      bindtextdomain (default_domain, default_dir);
    }
}
コード例 #12
0
ファイル: fea2esig.c プロジェクト: rsprouse/espsfree
static FieldSpec *
AddCommandLine(FieldList    *list,
	       char	    *line)
{
    FieldSpec	*field;


    if (line == NULL)
	return NULL;

    field = FindField(*list, "commandLine");

    if (field == NULL)
    {
	field = NewFieldSpec(ECHAR, 1);
	if (field == NULL)
	{
	    DebugMsg(1, "AddCommandLine: Couldn't create field spec.");
	    return NULL;
	}

	field->dim[0] = strlen(line);
	field->name = savestring("commandLine");
	field->occurrence = GLOBAL;

	if (!AddField(list, field))
	{
	    DebugMsg(1, "AddCommandLine: Couldn't add field spec.");
	    return NULL;
	}
    }
    else			/* field != NULL */
    {
	if (field->occurrence != GLOBAL)
	{
	    DebugMsg(1, "AddCommandLine: non-GLOBAL field \'commandLine\".");
	    return NULL;
	}

	field->type = ECHAR;
	field->rank = 1;
	field->dim = (long *) ((field->dim == NULL)
				? malloc(sizeof(long))
				: realloc(field->dim, sizeof(long)));

	if (field->dim == NULL)
	{
	    DebugMsg(1, "AddCommandLine: couldn't (re)allocate dimension.");
	    return NULL;
	}

	field->dim[0] = 1 + strlen(line);
    }

    field->data = line;

    return field;
}
コード例 #13
0
ファイル: postmd.c プロジェクト: andreiw/polaris
static void
buildilist(char *list)
    /* use this as the interval list */
{
    static char	*templist = NULL;	/* a working copy of the list */
    char	*ptr;			/* next number in *templist */
    int		i;			/* loop index - for checking the list */


/*
 *
 * Reads string *list and builds up the ilist[] that will be used in the next
 * matrix. Since strtok() modifies the string it's parsing we make a copy first.
 * The format of the interval list is described in detail in the comments at the
 * beginning of this program. Basically consists of a comma or space separated
 * list of floating point numbers that must be given in increasing numerical order.
 * The list determines how floating point numbers are mapped into integers in the
 * range 0 to 254.
 *
 */


    if ( templist != NULL )		/* free the space used by the last list */
	free(templist);

    while ( isascii(*list) && isspace(*list) )
	list++;

    for ( ptr = list, regions = 3; *ptr != '\0'; ptr++ )  {
	if ( *ptr == ',' || *ptr == '/' || isspace(*ptr) )
	    regions += 2;
	while ( isascii(*ptr) && isspace(*ptr) ) ptr++;
    }	/* End for */

    next = 0;
    templist = savestring(list);

    ptr = strtok(templist, ",/ \t\n");
    while ( ptr != NULL )  {
	ilist[next].count = 0;
	ilist[next++].color = 254 * (regions - 1 - next) / (regions - 1);
	ilist[next].val = atof(ptr);
	ilist[next].count = 0;
	ilist[next++].color = 254 * (regions - 1 - next) / (regions - 1);
	ptr = strtok(NULL, ",/ \t\n");
    }	/* End while */

    ilist[next].count = 0;
    ilist[next].color = 254 * (regions - 1 - next) / (regions - 1);

    if ( next == 0 )			/* make sure we have a list */
	error(FATAL, "missing interval list");

    for ( i = 3; i < next; i += 2 )	/* that's in increasing numerical order */
	if ( ilist[i].val <= ilist[i-2].val )
	    error(FATAL, "bad interval list");

}   /* End of buildilist */
コード例 #14
0
ファイル: bash.c プロジェクト: Distrotech/which
/* From bash-3.2 */
static void
get_current_user_info ()
{
  struct passwd *entry;

  /* Don't fetch this more than once. */
  if (current_user.user_name == 0)
    {
      entry = getpwuid (current_user.uid);
      if (entry)
        {
          current_user.user_name = savestring (entry->pw_name);
          current_user.shell = (entry->pw_shell && entry->pw_shell[0])
                                ? savestring (entry->pw_shell)
                                : savestring ("/bin/sh");
          current_user.home_dir = savestring (entry->pw_dir);
        }
      else
        {
          current_user.user_name = "I have no name!";
          current_user.user_name = savestring (current_user.user_name);
          current_user.shell = savestring ("/bin/sh");
          current_user.home_dir = savestring ("/");
        }
      endpwent ();
    }
}
コード例 #15
0
ファイル: locale.c プロジェクト: BackupTheBerlios/wl530g-svn
/* Set the value of default_locale and make the current locale the
   system default locale.  This should be called very early in main(). */
void
set_default_locale ()
{
#if defined (HAVE_SETLOCALE)
  default_locale = setlocale (LC_ALL, "");
  if (default_locale)
    default_locale = savestring (default_locale);
#endif /* HAVE_SETLOCALE */
}
コード例 #16
0
ファイル: misc.c プロジェクト: bminor/bash
/* Process and free undo lists attached to each history entry prior to the
   current entry, inclusive, reverting each line to its saved state.  This 
   is destructive, and state about the current line is lost.  This is not
   intended to be called while actively editing, and the current line is
   not assumed to have been added to the history list. */
void
_rl_revert_all_lines (void)
{
  int hpos;
  HIST_ENTRY *entry;
  UNDO_LIST *ul, *saved_undo_list;
  char *lbuf;

  lbuf = savestring (rl_line_buffer);
  saved_undo_list = rl_undo_list;
  hpos = where_history ();

  entry = (hpos == history_length) ? previous_history () : current_history ();
  while (entry)
    {
      if (ul = (UNDO_LIST *)entry->data)
	{
	  if (ul == saved_undo_list)
	    saved_undo_list = 0;
	  /* Set up rl_line_buffer and other variables from history entry */
	  rl_replace_from_history (entry, 0);	/* entry->line is now current */
	  entry->data = 0;			/* entry->data is now current undo list */
	  /* Undo all changes to this history entry */
	  while (rl_undo_list)
	    rl_do_undo ();
	  /* And copy the reverted line back to the history entry, preserving
	     the timestamp. */
	  FREE (entry->line);
	  entry->line = savestring (rl_line_buffer);
	}
      entry = previous_history ();
    }

  /* Restore history state */
  rl_undo_list = saved_undo_list;	/* may have been set to null */
  history_set_pos (hpos);
  
  /* reset the line buffer */
  rl_replace_line (lbuf, 0);
  _rl_set_the_line ();

  /* and clean up */
  xfree (lbuf);
}  
コード例 #17
0
ファイル: history.c プロジェクト: pyer/forth
HIST_ENTRY * alloc_history_entry ( char *string )
{
  HIST_ENTRY *temp;

  temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));

  temp->line = string ? savestring (string) : string;
  temp->data = (char *)NULL;
  return temp;
}
コード例 #18
0
ファイル: demangle.c プロジェクト: DonCN/haiku
void
set_demangling_style (char *style)
{
  if (current_demangling_style_string != NULL)
    {
      xfree (current_demangling_style_string);
    }
  current_demangling_style_string = savestring (style, strlen (style));
  set_demangling_command ((char *) NULL, 0, (struct cmd_list_element *) NULL);
}
コード例 #19
0
ファイル: event-top.c プロジェクト: HoMeCracKeR/gdb-ng
/* Called by do_setshow_command.  */
void
set_async_prompt (char *args, int from_tty, struct cmd_list_element *c)
{
  /* APPLE LOCAL begin Inform user about debugging optimized code  */
  if (currently_inside_optimized_code
      && the_prompts.top > 0
      && (strstr (PROMPT (0), "[opt> ") != 0))
    {
      char *new_str;
      pop_prompt ();
      PROMPT (0) = savestring (new_async_prompt, strlen (new_async_prompt));
      new_str = (char *) xmalloc (strlen (new_async_prompt) + 7);
      sprintf (new_str, "%s[opt> ", new_async_prompt);
      push_prompt ("", new_str, "");
      xfree (new_str);
    }
  else
  /* APPLE LOCAL end Inform user about debugging optimized code  */
    PROMPT (0) = savestring (new_async_prompt, strlen (new_async_prompt));
}
コード例 #20
0
ファイル: locale.c プロジェクト: WndSks/msys
/* Set the value of default_locale and make the current locale the
   system default locale.  This should be called very early in main(). */
void
set_default_locale ()
{
#if defined (HAVE_SETLOCALE)
  default_locale = setlocale (LC_ALL, "");
  if (default_locale)
    default_locale = savestring (default_locale);
#endif /* HAVE_SETLOCALE */
  bindtextdomain (PACKAGE, LOCALEDIR);
  textdomain (PACKAGE);
}
コード例 #21
0
ファイル: cp-namespace.c プロジェクト: eepp/binutils-gdb
static struct block_symbol
cp_search_static_and_baseclasses (const char *name,
				  const struct block *block,
				  const domain_enum domain,
				  unsigned int prefix_len,
				  int is_in_anonymous)
{
  struct block_symbol sym;
  char *klass, *nested;
  struct cleanup *cleanup;
  struct block_symbol klass_sym;
  struct type *klass_type;

  /* The test here uses <= instead of < because Fortran also uses this,
     and the module.exp testcase will pass "modmany::" for NAME here.  */
  gdb_assert (prefix_len + 2 <= strlen (name));
  gdb_assert (name[prefix_len + 1] == ':');

  /* Find the name of the class and the name of the method, variable, etc.  */

  /* The class name is everything up to and including PREFIX_LEN.  */
  klass = savestring (name, prefix_len);

  /* The rest of the name is everything else past the initial scope
     operator.  */
  nested = xstrdup (name + prefix_len + 2);

  /* Add cleanups to free memory for these strings.  */
  cleanup = make_cleanup (xfree, klass);
  make_cleanup (xfree, nested);

  /* Lookup a class named KLASS.  If none is found, there is nothing
     more that can be done.  KLASS could be a namespace, so always look
     in VAR_DOMAIN.  This works for classes too because of
     symbol_matches_domain (which should be replaced with something else,
     but it's what we have today).  */
  klass_sym = lookup_global_symbol (klass, block, VAR_DOMAIN);
  if (klass_sym.symbol == NULL)
    {
      do_cleanups (cleanup);
      return null_block_symbol;
    }
  klass_type = SYMBOL_TYPE (klass_sym.symbol);

  /* Look for a symbol named NESTED in this class.
     The caller is assumed to have already have done a basic lookup of NAME.
     So we pass zero for BASIC_LOOKUP to cp_lookup_nested_symbol_1 here.  */
  sym = cp_lookup_nested_symbol_1 (klass_type, nested, name, block, domain,
				   0, is_in_anonymous);

  do_cleanups (cleanup);
  return sym;
}
コード例 #22
0
ファイル: cpp3.c プロジェクト: StefanBruens/core
/*
 * Initialize the built-in #define's.  There are two flavors:
 *      #define decus   1               (static definitions)
 *      #define __FILE__ ??             (dynamic, evaluated by magic)
 * Called only on cpp startup.
 *
 * Note: the built-in static definitions are suppressed by the -N option.
 * __LINE__, __FILE__, and __DATE__ are always present.
 */
void initdefines()
{
    char** pp;
    char* tp;
    DEFBUF* dp;
    int i;
    time_t tvec;

    /*
     * Predefine the built-in symbols.  Allow the
     * implementor to pre-define a symbol as "" to
     * eliminate it.
     */
    if (nflag == 0)
    {
        for (pp = preset; *pp != NULL; pp++)
        {
            if (*pp[0] != EOS)
            {
                dp = defendel(*pp, FALSE);
                dp->repl = savestring("1");
                dp->nargs = DEF_NOARGS;
            }
        }
    }
    /*
     * The magic pre-defines (__FILE__ and __LINE__ are
     * initialized with negative argument counts.  expand()
     * notices this and calls the appropriate routine.
     * DEF_NOARGS is one greater than the first "magic" definition.
     */
    if (nflag < 2)
    {
        for (pp = magic, i = DEF_NOARGS; *pp != NULL; pp++)
        {
            dp = defendel(*pp, FALSE);
            dp->nargs = --i;
        }
#if OK_DATE
        /*
         * Define __DATE__ as today's date.
         */
        dp = defendel("__DATE__", FALSE);
        dp->repl = tp = getmem(27);
        dp->nargs = DEF_NOARGS;
        time( &tvec);
        *tp++ = '"';
        strcpy(tp, ctime(&tvec));
        tp[24] = '"';                       /* Overwrite newline    */
#endif
    }
}
コード例 #23
0
ファイル: misc.c プロジェクト: bminor/bash
/* Save the current line in _rl_saved_line_for_history. */
int
rl_maybe_save_line (void)
{
  if (_rl_saved_line_for_history == 0)
    {
      _rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
      _rl_saved_line_for_history->line = savestring (rl_line_buffer);
      _rl_saved_line_for_history->timestamp = (char *)NULL;
      _rl_saved_line_for_history->data = (char *)rl_undo_list;
    }

  return 0;
}
コード例 #24
0
ファイル: cpp3.c プロジェクト: cjapes/core
int AddInclude( char* pIncStr )
{
    char     *pIncEnv    = NULL;    /* Kopie des INCLUDE     */
    char     *pIncPos;              /* wandert zum naechsten */

    pIncEnv = savestring( pIncStr );
    pIncPos = strtok( pIncEnv, ";" );

    while( pIncPos != NULL )
    {
        if (incend >= &incdir[MAXINCLUDE])
            cfatal("Too many include directories", NULLST);
        *incend++ = pIncPos;
        pIncPos   = strtok( NULL, ";" );
    }
    return( 1 );
}
コード例 #25
0
ファイル: macro.c プロジェクト: bminor/bash
/* Execute the most recently defined keyboard macro.
   COUNT says how many times to execute it. */
int
rl_call_last_kbd_macro (int count, int ignore)
{
  if (current_macro == 0)
    _rl_abort_internal ();

  if (RL_ISSTATE (RL_STATE_MACRODEF))
    {
      rl_ding ();		/* no recursive macros */
      current_macro[--current_macro_index] = '\0';	/* erase this char */
      return 0;
    }

  while (count--)
    _rl_with_macro_input (savestring (current_macro));
  return 0;
}
コード例 #26
0
ファイル: scf_client.c プロジェクト: plineo/scf
/* Rutina para cambiar o visualizar el identificador */
void set_ident(char *ident)
{
    if (srv_socket > 0)
    {
	printf("You can't change your nick connected to server. Logout first.\n");
	return;
    }

    if (ident == NULL)
	printf("Your nick is %s.\n", my_ident);
    else
    {
	free(my_ident);
	my_ident = (char *)savestring(ident);
	printf("Your nick is now %s.\n", my_ident);
    }
}
コード例 #27
0
ファイル: bash.c プロジェクト: Distrotech/which
/* Return the next element from PATH_LIST, a colon separated list of
   paths.  PATH_INDEX_POINTER is the address of an index into PATH_LIST;
   the index is modified by this function.
   Return the next element of PATH_LIST or NULL if there are no more. */
char*
get_next_path_element (char const* path_list, int* path_index_pointer)
{
  char* path;

  path = extract_colon_unit (path_list, path_index_pointer);

  if (path == 0)
    return (path);

  if (*path == '\0')
    {
      free (path);
      path = savestring (".");
    }

  return (path);
}
コード例 #28
0
ファイル: which.c プロジェクト: tylerberry/newts
static char *
get_next_path_element (const char *path_list, int *path_index_pointer)
{
  char *path;

  path = extract_colon_unit (path_list, path_index_pointer);

  if (!path)
    return (path);

  if (!*path)
    {
      free (path);
      path = savestring (".");
    }

  return (path);
}
コード例 #29
0
ファイル: cpp3.c プロジェクト: StefanBruens/core
int AddInclude( char* pIncStr )
{
    char* pIncEnv    = NULL;    /* Kopie des INCLUDE     */
    char* pIncPos;              /* wandert zum naechsten */

    pIncEnv = savestring( pIncStr );
    pIncPos = strtok( pIncEnv, ";" );

    while( pIncPos != NULL )
    {
        if (incend >= &incdir[MAXINCLUDE])
            cfatal("Too many include directories", NULLST);
        *incend++ = pIncPos;
        pIncPos   = strtok( NULL, ";" );
    }
    /* coverity[leaked_storage] - we know this leaks, but it doesn't matter in this short lived utility */
    return( 1 );
}
コード例 #30
0
ファイル: location.c プロジェクト: Winter3un/ctf_task
event_location_up
new_linespec_location (char **linespec)
{
  struct event_location *location;

  location = XCNEW (struct event_location);
  EL_TYPE (location) = LINESPEC_LOCATION;
  if (*linespec != NULL)
    {
      char *p;
      char *orig = *linespec;

      linespec_lex_to_end (linespec);
      p = remove_trailing_whitespace (orig, *linespec);
      if ((p - orig) > 0)
	EL_LINESPEC (location) = savestring (orig, p - orig);
    }
  return event_location_up (location);
}