1N/A/*********************************************************************** 1N/A* This software is part of the ast package * 1N/A* Copyright (c) 1982-2011 AT&T Intellectual Property * 1N/A* and is licensed under the * 1N/A* Common Public License, Version 1.0 * 1N/A* by AT&T Intellectual Property * 1N/A* A copy of the License is available at * 1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 1N/A* Information and Software Systems Research * 1N/A* David Korn <dgk@research.att.com> * 1N/A***********************************************************************/ 1N/A#
endif /* _lib_pathnative */ 1N/A#
endif /*SHOPT_TYPEDEF */ 1N/A#
endif /* SHOPT_MULTIBYTE */ 1N/A/* ======== name value pair routines ======== */ 1N/A * output variable name in format for re-input 1N/A /* could be an redefine */ 1N/A /* check for a redefine */ 1N/A#
endif /* SHOPT_TYPEDEF */ 1N/A * given a list of assignments, determine <name> is on the list 1N/A returns a pointer to the argnod on the list or NULL 1N/A * Perform parameter assignment for a linked list of parameters 1N/A * <flags> contains attributes for the parameters 1N/A#
endif /* SHOPT_TYPEDEF*/ 1N/A#
endif /* SHOPT_NAMESPACE */ 1N/A#
endif /* SHOPT_TYPEDEF */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_TYPEDEF */ 1N/A /* check for array assignment */ 1N/A#
endif /* SHOPT_TYPEDEF */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_TYPEDEF */ 1N/A#
endif /* SHOPT_TYPEDEF */ 1N/A#
endif /* SHOPT_TYPEDEF */ 1N/A#
endif /* SHOPT_TYPEDEF */ 1N/A * copy the subscript onto the stack 1N/A if(c==
'[' || c==
']' || c==
'\\')
1N/A * construct a new name from a prefix and base name on the stack 1N/A * grow this stack string <name> by <n> bytes and move from cp-1 to end 1N/A * right by <n>. Returns beginning of string on the stack 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A switch(c = *(
unsigned char*)(
sp =
cp))
1N/A#
endif /* SHOPT_NAMESPACE */ 1N/A#
endif /* SHOPT_NAMESPACE */ 1N/A#
endif /* SHOPT_NAMESPACE */ 1N/A#
endif /* SHOPT_NAMESPACE */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A if(c==
'.')
/* don't optimize */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A if(c==
'.' && (
cp[
1]==0 ||
cp[
1]==
'=' ||
cp[
1]==
'+'))
1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A * for backward compatibility 1N/A * evaluate subscript for 1N/A * possible side effects 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A /* not implemented yet */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A /* subscript must be 0*/ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A * delete the node <np> from the dictionary <root> and clear from the cache 1N/A * if <root> is NULL, only the cache is cleared 1N/A * if flags does not contain NV_NOFREE, the node is freed 1N/A * Put <arg> into associative memory. 1N/A * If <flags> & NV_ARRAY then follow array to next subscript 1N/A * If <flags> & NV_NOARRAY then subscript is not allowed 1N/A * If <flags> & NV_NOSCOPE then use the current scope only 1N/A * If <flags> & NV_ASSIGN then assignment is allowed 1N/A * If <flags> & NV_IDENT then name must be an identifier 1N/A * If <flags> & NV_VARNAME then name must be a valid variable name 1N/A * If <flags> & NV_NOADD then node will not be added if not found 1N/A * If <flags> & NV_NOREF then don't follow reference 1N/A * If <flags> & NV_NOFAIL then don't generate an error message on failure 1N/A * If <flags> & NV_STATIC then unset before an assignment 1N/A * If <flags> & NV_UNJUST then unset attributes before assignment 1N/A * SH_INIT is only set while initializing the environment 1N/A while((c= *(
unsigned char*)
cp++) && (c!=
'=') && (c!=
'/') &&
1N/A#
endif /* SHOPT_TYPEDEF */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_MULTIBYTE */ 1N/A * put value <string> into name-value node <np>. 1N/A * If <np> is an array, then the element given by the 1N/A * current index is assigned to. 1N/A * If <flags> contains NV_RDONLY, readonly attribute is ignored 1N/A * If <flags> contains NV_INTEGER, string is a pointer to a number 1N/A * If <flags> contains NV_NOFREE, previous value is freed, and <string> 1N/A * becomes value of node and <flags> becomes attributes 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A /* The following could cause the shell to fork if assignment 1N/A * would cause a side effect 1N/A /* This function contains disc */ 1N/A /* called from disc, assign the actual value */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A d = (
double)(*(
float*)
sp);
1N/A#
endif /* _lib_pathnative */ 1N/A * return the host file name given the UNIX name 1N/A#
endif /* _lib_pathnative */ 1N/A#
endif /* SHOPT_MULTIBYTE */ 1N/A /* delay free in case <sp> points into free region */ 1N/A /* restore original string */ 1N/A#
endif /* SHOPT_MULTIBYTE */ 1N/A * Right-justify <str> so that it contains no more than 1N/A * <size> characters. If <str> contains fewer than <size> 1N/A * characters, left-pad with <fill>. Trailing blanks 1N/A * in <str> will be ignored. 1N/A * If the leftmost digit in <str> is not a digit, <fill> 1N/A * will default to a blank. 1N/A /* ignore trailing blanks */ 1N/A * handle left and right justified fields for multi-byte chars 1N/A * given physical size, return a logical size which reflects the 1N/A * screen width of multi-byte characters 1N/A * Multi-width characters replaced by spaces if they cross the boundary 1N/A * <type> is non-zero for right justified fields 1N/A /* check for right justified fields that need truncating */ 1N/A /* left justified and character crosses field boundary */ 1N/A /* save boundary char and replace with spaces */ 1N/A#
endif /* SHOPT_MULTIBYTE */ 1N/A register char *p,*q;
1N/A * put the name and attribute into value of attributes variable 1N/A /* export doubles as integers for ksh88 compatibility */ 1N/A /* export doubles as integers for ksh88 compatibility */ 1N/A * Generate the environment list for the child. 1N/A /* L_ARGNOD gets generated automatically as full path name of command */ 1N/A#
endif /*SHOPT_TYPEDEF */ 1N/A * Walk through the name-value pairs 1N/A * if <mask> is non-zero, then only nodes with (nvflags&mask)==flags 1N/A * If <mask> is zero, and <flags> non-zero, then nodes with one or 1N/A * more of <flags> is visited 1N/A * If <mask> and <flags> are zero, then all nodes are visted 1N/A * create a new environment scope 1N/A#
endif /* SHOPT_NAMESPACE */ 1N/A * Remove freeable local space associated with the nvalue field 1N/A * of nnod. This includes any strings representing the value(s) of the 1N/A * node, as well as its dope vector, if it is an array. 1N/A * Currently this is a dummy, but someday will be needed 1N/A * for reference counting 1N/A * Set the value of <np> to 0, and nullify any attributes 1N/A * that <np> may have had. Free any freeable space occupied 1N/A * by the value of <np>. If <np> denotes an array member, it 1N/A * will retain its attributes. 1N/A * <flags> can contain NV_RDONLY to override the readonly attribute 1N/A * <flags> can contain NV_EXPORT to override preserve nvenv 1N/A /* free function definition */ 1N/A /* This function contains disc */ 1N/A /* called from disc, assign the actual value */ 1N/A * return the node pointer in the highest level scope 1N/A * return space separated list of names of variables in given tree 1N/A#
endif /* SHOPT_OPTIMIZE */ 1N/A * Return a pointer to a character string that denotes the value 1N/A * of <np>. If <np> refers to an array, return a pointer to 1N/A * the value associated with the current index. 1N/A * If the value of <np> is an integer, the string returned will 1N/A * be overwritten by the next call to nv_getval. 1N/A * If <np> has no value, 0 is returned. 1N/A#
endif /* SHOPT_OPTIMIZE */ 1N/A * if NV_RAW flag is on, return pointer to binary data 1N/A * otherwise, base64 encode the data and return this string 1N/A#
endif /* SHOPT_OPTIMIZE */ 1N/A * Give <np> the attributes <newatts,> and change its current 1N/A * value to conform to <newatts>. The <size> of left and right 1N/A * justified fields may be given. 1N/A register unsigned int n;
1N/A /* check for restrictions */ 1N/A /* handle attributes that do not change data separately */ 1N/A /* record changes to the environment */ 1N/A /* for an array, change all the elements */ 1N/A if(
ap)
/* add element to prevent array deletion */ 1N/A#
endif /* SHOPT_TYPEDEF */ 1N/A#
endif /* SHOPT_TYPEDEF */ 1N/A * This version of getenv uses the hash storage to access environment values 1N/A * Some dynamic linkers will make this file see the libc getenv(), 1N/A * so sh_getenv() is used for the astintercept() callback. Plain 1N/A * getenv() is provided for static links. 1N/A#
endif /* _NEXT_SOURCE */ 1N/A * This version of putenv uses the hash storage to assign environment values 1N/A * Override libast setenviron(). 1N/A * Same linker dance as with getenv() above. 1N/A * normalize <cp> and return pointer to subscript if any 1N/A * if <eq> is specified, return pointer to first = not in a subscript 1N/A#
endif /* SHOPT_NAMESPACE */ 1N/A /* create a virtual node */ 1N/A * Create a reference node from <np> to $np in dictionary <hp> 1N/A /* bind to earlier scope, or add to global scope */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A /* cause subscript evaluation and return result */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A * get the scope corresponding to <index> 1N/A * whence uses the same values as lseeek() 1N/A * make <scoped> the top scope and return previous scope 1N/A * The inverse of creating a reference node 1N/A * These following are for binary compatibility with the old hash library 1N/A * They will be removed someday 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_NAMESPACE */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A#
endif /* SHOPT_FIXEDARRAY */ 1N/A * returns the data context for a builtin