⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 declare.def

📁 android-w.song.android.widget
💻 DEF
📖 第 1 页 / 共 2 页
字号:
This file is declare.def, from which is created declare.c.It implements the builtins "declare" and "local" in Bash.Copyright (C) 1987-2010 Free Software Foundation, Inc.This file is part of GNU Bash, the Bourne Again SHell.Bash is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.Bash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with Bash.  If not, see <http://www.gnu.org/licenses/>.$PRODUCES declare.c$BUILTIN declare$FUNCTION declare_builtin$SHORT_DOC declare [-aAfFgilrtux] [-p] [name[=value] ...]Set variable values and attributes.Declare variables and give them attributes.  If no NAMEs are given,display the attributes and values of all variables.Options:  -f	restrict action or display to function names and definitions  -F	restrict display to function names only (plus line number and	source file when debugging)  -g	create global variables when used in a shell function; otherwise	ignored  -p	display the attributes and value of each NAMEOptions which set attributes:  -a	to make NAMEs indexed arrays (if supported)  -A	to make NAMEs associative arrays (if supported)  -i	to make NAMEs have the `integer' attribute  -l	to convert NAMEs to lower case on assignment  -r	to make NAMEs readonly  -t	to make NAMEs have the `trace' attribute  -u	to convert NAMEs to upper case on assignment  -x	to make NAMEs exportUsing `+' instead of `-' turns off the given attribute.Variables with the integer attribute have arithmetic evaluation (seethe `let' command) performed when the variable is assigned a value.When used in a function, `declare' makes NAMEs local, as with the `local'command.  The `-g' option suppresses this behavior.Exit Status:Returns success unless an invalid option is supplied or an error occurs.$END$BUILTIN typeset$FUNCTION declare_builtin$SHORT_DOC typeset [-aAfFgilrtux] [-p] name[=value] ...Set variable values and attributes.Obsolete.  See `help declare'.$END#include <config.h>#if defined (HAVE_UNISTD_H)#  ifdef _MINIX#    include <sys/types.h>#  endif#  include <unistd.h>#endif#include <stdio.h>#include "../bashansi.h"#include "../bashintl.h"#include "../shell.h"#include "common.h"#include "builtext.h"#include "bashgetopt.h"extern int array_needs_making;extern int posixly_correct;static int declare_internal __P((register WORD_LIST *, int));/* Declare or change variable attributes. */intdeclare_builtin (list)     register WORD_LIST *list;{  return (declare_internal (list, 0));}$BUILTIN local$FUNCTION local_builtin$SHORT_DOC local [option] name[=value] ...Define local variables.Create a local variable called NAME, and give it VALUE.  OPTION canbe any option accepted by `declare'.Local variables can only be used within a function; they are visibleonly to the function where they are defined and its children.Exit Status:Returns success unless an invalid option is supplied, an error occurs,or the shell is not executing a function.$ENDintlocal_builtin (list)     register WORD_LIST *list;{  if (variable_context)    return (declare_internal (list, 1));  else    {      builtin_error (_("can only be used in a function"));      return (EXECUTION_FAILURE);    }}#if defined (ARRAY_VARS)#  define DECLARE_OPTS	"+acfgilprtuxAF"#else#  define DECLARE_OPTS	"+cfgilprtuxF"#endif/* The workhorse function. */static intdeclare_internal (list, local_var)     register WORD_LIST *list;     int local_var;{  int flags_on, flags_off, *flags;  int any_failed, assign_error, pflag, nodefs, opt, mkglobal;  char *t, *subscript_start;  SHELL_VAR *var;  FUNCTION_DEF *shell_fn;  flags_on = flags_off = any_failed = assign_error = pflag = nodefs = mkglobal = 0;  reset_internal_getopt ();  while ((opt = internal_getopt (list, DECLARE_OPTS)) != EOF)    {      flags = list_opttype == '+' ? &flags_off : &flags_on;      switch (opt)	{	case 'a':#if defined (ARRAY_VARS)	  *flags |= att_array;	  break;#else	  builtin_usage ();	  return (EX_USAGE);#endif	case 'A':#if defined (ARRAY_VARS)	  *flags |= att_assoc;	  break;#else	  builtin_usage ();	  return (EX_USAGE);#endif	case 'p':	  if (local_var == 0)	    pflag++;	  break;        case 'F':	  nodefs++;	  *flags |= att_function;	  break;	case 'f':	  *flags |= att_function;	  break;	case 'g':	  if (flags == &flags_on)	    mkglobal = 1;	  break;	case 'i':	  *flags |= att_integer;	  break;	case 'r':	  *flags |= att_readonly;	  break;	case 't':	  *flags |= att_trace;	  break;	case 'x':	  *flags |= att_exported;	  array_needs_making = 1;	  break;#if defined (CASEMOD_ATTRS)#  if defined (CASEMOD_CAPCASE)	 case 'c':	  *flags |= att_capcase;	  if (flags == &flags_on)	    flags_off |= att_uppercase|att_lowercase;	  break;#  endif	case 'l':	  *flags |= att_lowercase;	  if (flags == &flags_on)	    flags_off |= att_capcase|att_uppercase;	  break;	case 'u':	  *flags |= att_uppercase;	  if (flags == &flags_on)	    flags_off |= att_capcase|att_lowercase;	  break;#endif /* CASEMOD_ATTRS */	default:	  builtin_usage ();	  return (EX_USAGE);	}    }  list = loptend;  /* If there are no more arguments left, then we just want to show     some variables. */  if (list == 0)	/* declare -[aAfFirtx] */    {      /* Show local variables defined at this context level if this is	 the `local' builtin. */      if (local_var)	{	  register SHELL_VAR **vlist;	  register int i;	  vlist = all_local_variables ();	  if (vlist)	    {	      for (i = 0; vlist[i]; i++)		print_assignment (vlist[i]);	      free (vlist);	    }	}      else if (pflag && (flags_on == 0 || flags_on == att_function))	show_all_var_attributes (flags_on == 0, nodefs);      else if (flags_on == 0)	return (set_builtin ((WORD_LIST *)NULL));      else	set_or_show_attributes ((WORD_LIST *)NULL, flags_on, nodefs);      return (sh_chkwrite (EXECUTION_SUCCESS));    }  if (pflag)	/* declare -p [-aAfFirtx] name [name...] */    {      for (any_failed = 0; list; list = list->next)	{	  pflag = show_name_attributes (list->word->word, nodefs);	  if (pflag)	    {	      sh_notfound (list->word->word);	      any_failed++;	    }	}      return (sh_chkwrite (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS));    }#define NEXT_VARIABLE() free (name); list = list->next; continue  /* There are arguments left, so we are making variables. */  while (list)		/* declare [-aAfFirx] name [name ...] */    {      char *value, *name;      int offset, aflags;#if defined (ARRAY_VARS)      int making_array_special, compound_array_assign, simple_array_assign;#endif      name = savestring (list->word->word);      offset = assignment (name, 0);      aflags = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -