![]() |
![]()
| ![]() |
![]()
NAMEmawk-code - dumping mawk's byte-code SYNOPSISAt startup, mawk compiles the script into byte-code. After that, it interprets the compiled byte-code. Use the -Wdump option to show the byte-code. PROGRAM CODESAs mawk executes the program, it maintains a reference to the command to execute in cdp. After that there may be data and/or references in cdp[0], cdp[1], etc. When an operation requires operands, mawk pushes the values (or array/string references) onto the stack, which updates the stack pointer sp. When the operation completes, mawk consumes those entries on the stack, pushing the result (if any) onto the stack. While executing user-defined functions, mawk maintains a frame pointer fp to address the function's local variables. a_catConcatenate array-indices. Usage: Forms a multiple array index by concatenating the
elements of sp[1-cnt..0], with each element separated by
SUBSEP.
Parameters:
a_delDelete an array item. Usage: delete array[expr]
Parameters: a_lengthFind the length of an array. Usage: length(array)
Parameters:
Returns the length of the array in sp[0]. a_pushaPush array address onto stack. Usage: This is used to set up a calling argument for a
function.
Parameters:
Returns the array in sp[0]. a_testTest if an expression is present in an array. Usage: (expression in array)
Parameters: Returns 1 in sp[0] if the expression is found, 0 otherwise. addAdd two numbers. Usage: first + second
Parameters: Returns the sum in sp[0]. add_asgCombined addition/assignment. Usage: target += source
Parameters: Stores the sum in the target, leaving sp[0] pointing to the target. ae_pushaPush reference to array cell, given expression for its index. Usage: arrayname[expression]
Parameters: Returns a reference to the addressed cell in sp[0]. ae_pushiPush contents of array cell, given expression for its index. Usage: arrayname[expression]
Parameters:
Returns contents of the addressed cell in sp[0]. aloopUpdate reference to next cell for array loop. Usage: for ( i in arrayname )
statement
Parameters: Mawk maintains a stack of array-loop state. It updates the array/cell references in the current loop's state. assignAssigns a value. Usage: target = source
Parameters: atan2Compute arc-tangent of two values. Usage: atan2( first, second )
Parameters: Returns the result in sp[0]. callCall a function. Usage: function()
Parameters: Returns function value in sp[0]. catConcatenate two strings. Usage: first second
Parameters: Returns the result in sp[0]. closeClose the file or pipe associated with an expression. Usage: close( expression )
Parameters:
Returns the status from closing the file, 0 on success or -1 on failure. cosCompute the cosine of a value in radians. Usage: cos( value )
Parameters:
Returns the result in sp[0]. del_aDelete an array. Usage: delete(array)
Parameters:
divDivide one number by another. Usage: first / second
Parameters: Returns the quotient in sp[0]. div_asgCombined division/assignment. Usage: target /= source
Parameters: Stores the quotient in the target, leaving sp[0] pointing to the target. eqCompare two values. Usage: first == second
Parameters: Returns 1 in sp[0] if the values are equal, otherwise 0. exitExits mawk with a specific exit-code. Usage: exit(exit_code)
Parameters:
exit0Exits mawk with success Usage: exit
Parameters: none
expCompute base-e exponential function of a value. Usage: exp( value )
Parameters:
Returns the result in sp[0]. f_add_asgCombination addition/assignment to NF. Usage: NF += expression
Parameters:
f_assignAssign an expression to NF. Usage: NF = expression
Parameters:
f_div_asgCombination division/assignment to NF. Usage: NF /= expression
Parameters:
f_mod_asgCombination modulus/assignment to NF. Usage: NF %= expression
Parameters:
f_mul_asgCombination multiplication/assignment to NF. Usage: NF *= expression
Parameters:
f_post_decPost-decrement using NF. Usage: NF--
Parameters: holds a reference to the field to use
f_post_incPost-increment using NF. Usage: NF++
Parameters: holds a reference to the field to use
f_pow_asgExponentiation using NF. Usage: NF ^= expression
Parameters:
f_pre_decPredecrement using NF. Usage: --NF
Parameters:
f_pre_incPreincrement using NF. Usage: ++NF
Parameters:
f_pushaPush array reference to data split-up as fields.. Usage: $0 = expression
getline Parameters:
Returns the resulting array reference in sp[0]. f_pushiPush contents of numbered field. Usage: $expression
Parameters: Returns the field's value in sp[0]. f_sub_asgCombination subtraction/assignment to NF. Usage: NF -= expression
Parameters:
fe_pushaPush reference to numbered field. Usage: $number
Parameters:
Returns a reference to the field in sp[0]. fe_pushiPush content of numbered field. Usage: $number
Parameters:
Returns the field's content in sp[0]. fflushFlush the output file or pipe associated with an expression. Usage: fflush( expression )
Parameters:
Returns the result in sp[0]. gtTest if first value is greater than the second. Usage: first > second
Parameters: Returns 1 in sp[0] if the first value is greater than, otherwise 0. gteTest if first value is greater than or equal to the second. Usage: first >= second
Parameters: Returns 1 in sp[0] if the first value is greater than or equal, otherwise 0. indexFind the position of the second string in the first. Usage: index( first, second )
Parameters: Returns the position in sp[0] starting at 1 if found, 0 if not found. intReturns a value truncated towards zero.. Usage: int( value )
Parameters:
Returns the result in sp[0]. jmainGo from BEGIN code to MAIN code. Usage: (internal state)
Parameters: jmpJump to a new byte-code position, by a given number of bytes. Usage: (internal state)
Parameters:
jnzJump to a new byte-code position if sp[0] is nonzero, by a given number of bytes. Usage: (internal state)
Parameters: jzJump to a new byte-code position if sp[0] is zero, by a given number of bytes. Usage: (internal state)
Parameters: l_pushaPush a local address onto the evaluation stack. Usage: (internal state)
Parameters:
Returns the address in sp[0]. l_pushiPush contents of a local variable onto the evaluation stack. Usage: (internal state)
Parameters:
Returns the contents of the local variable in sp[0]. la_pushaPushes a reference to an array onto the evaluation stack. Usage: arrayname
Parameters:
Returns a reference to the array in sp[0]. lae_pushaPushes a reference to a given array cell onto the evaluation stack. Usage: arrayname[expression]
Parameters: Returns a reference to the specified array cell in sp[0]. lae_pushiPushes the contents of a given array cell onto the evaluation stack. Usage: arrayname[expression]
Parameters: Returns the contents of the specified array cell in sp[0]. lengthReturns the length of a string or array value. Usage: length( value )
Parameters:
Returns the length in sp[0]. ljnzSpecial jump for logical-OR, always preceded by test. Usage: (internal state)
Parameters: ljzSpecial jump for logical-OR, always preceded by test. Usage: (internal state)
Parameters: logCompute the natural logarithm of a value. Usage: log( value )
Parameters:
Returns the result in sp[0]. ltTest if first value is less than the second. Usage: first < second
Parameters: Returns 1 in sp[0] if the first value is less than, otherwise 0. lteTest if first value is less than or equal to the second. Usage: first <= second
Parameters: Returns 1 in sp[0] if the first value is less than or equal, otherwise 0. match0Test if $0 matches a given regular expression. Usage: $0 ~ regex
Parameters:
Returns 1 in sp[0] if $0 matches the regular expression, 0 otherwise. match1Test if a given expression matches a given regular expression. Usage: expression ~ regex
Parameters: Returns 1 in sp[0] if the expression matches the regular expression, 0 otherwise. match2Test if an expression in sp[-1] matches the regular expression in sp[0]. Usage: expression ~ regex
Parameters: Returns 1 in sp[0] if the expression matches the regular expression, 0 otherwise. mktimeConverts a date specification in systime format to a timestamp. Usage: mktime( string )
Parameters:
Returns the result in sp[0]. modCompute modulus/remainder with two operands. Usage: first % second
Parameters: Returns the remainder in sp[0]. mod_asgAssign modulus/remainder with two operands. Usage: first %= second
Parameters: Returns the remainder in sp[0] as well as replacing the first value. mulCompute product with two operands. Usage: first * second
Parameters: Returns the product in sp[0]. mul_asgAssign product with two operands. Usage: first *= second
Parameters: Returns the product in sp[0] as well as replacing the first value. neqCompare two values. Usage: first != second
Parameters: Returns 1 in sp[0] if the values are not equal, otherwise 0. nextRead the next record, restart pattern testing. Usage: next
Parameters: nextfileBegin processing the next file listed on the command line. Usage: nextfile
Parameters: nf_pushiPush the number of fields (NF) onto the evaluation stack. Usage: (internal state)
Parameters: notCompute a logical negation. Usage: ! value
Parameters:
Returns the result on the evaluation stack, i.e., 0 if the value is nonzero and 1 otherwise. ol_glRead into $0 using getline. Usage: getline
Parameters: ol_gl_nrRead into $0 using getline, updating NR and FNR. Usage: getline < file
Parameters: omainStart executing the main section of the script (between BEGIN and END). Usage: (internal state)
Parameters: popPop the evaluation stack, discarding the value. Usage: (internal state)
Parameters: pop_alFinish an array “in” loop, deallocating the state information. Usage: (internal state)
Parameters: post_decPost-decrement a value. Usage: value --
Parameters:
Returns the updated value in sp[0]. post_incPost-increment a value. Usage: value ++
Parameters:
Returns the updated value in sp[0]. powCompute the first value raised to the power of the second value. Usage: first ^ second
Parameters: Returns the result in sp[0]. pow_asgAssign the first value raised to the power of the second value. Usage: variable = first ^ second
Parameters: pre_decPre-decrement a value. Usage: -- value
Parameters:
Returns the updated value in sp[0];. pre_incPre-increment a value. Usage: ++ value
Parameters:
Returns the updated value in sp[0];. pushaPush array address onto stack. Usage: (internal state)
Parameters:
Returns the array in sp[0]. pushcPush a data cell onto the evaluation stack. Usage: (internal state)
Parameters:
Returns a reference to the result in sp[0]. pushdPush a double floating value onto the evaluation stack. Usage: (internal state)
Parameters:
Returns a reference to the result in sp[0]. pushiPush contents of next referenced variable onto the evaluation stack. Usage: (internal state)
Parameters:
Returns a reference to the result in sp[0]. pushintReserve the next slot on the evaluation stack, setting its type. Usage: (internal state)
Parameters:
Returns a reference to the result in sp[0]. pushsPush a reference to a string value onto the evaluation stack. Usage: (internal state)
Parameters:
Returns a reference to the result in sp[0]. randReturns a random number between zero and one.. Usage: rand()
Parameters: Returns the result in sp[0]. rangeTest a range pattern: pat1, pat2 { action }. Usage: (internal state)
Parameters: retReturn a function value. Usage: return value
Parameters:
When calling a function, mawk saves the current stack, creating a new one. On return, mawk restores the previous stack and returns the function value in sp[0]. ret0Return from a function without providing a return-value. Usage: return
Parameters:
As in the ret operation, mawk restores the previous stack. After the return, sp[0] is an uninitialized value. set_alBegin an array “in” loop. Usage: for ( iterator in arrayname )
statement
Parameters: Mawk pushes a new entry onto the array loop stack, and updates cdp to point to the statement to execute. sinCompute the sine of a value in radians. Usage: sin( value )
Parameters:
Returns the result in sp[0]. sprintfReturns a string constructed from expression-list according to format. Usage: sprintf( format [, value1 [,... ] ] )
Parameters:
sqrtReturns the square root of a value. Usage: sqrt( value 0
Parameters:
Returns the result in sp[0]. srandSeeds the random number generator. Usage: srand( value )
srand( ) Parameters:
Returns the previous seed value in sp[0]. stopFinish a range pattern. Usage: (internal state)
Parameters: strftimeFormats the given timestamp using the given format. Usage: strftime( format , timestamp , utc )
strftime( format , timestamp ) strftime( format ) strftime( ) Parameters: Zero to three parameters may be on the stack. If all three are used, they are as follows: Returns the result in sp[0]. subSubtract the second value from the first. Usage: first - second
Parameters: sub_asgAssign the difference of two values to a variable. Usage: target = first - second
Parameters: Stores the difference in the target, leaving sp[0] pointing to the target. substreturns the substring of string s, starting at index i, of length n. Usage: substr(s,i,n)
substr(s,i) Parameters: systemExecutes a command, returning the wait-status. Usage: status = system( command )
Parameters:
Returns the wait-status in sp[0]. systimeReturns the current time of day as the number of seconds since the Epoch. Usage: systime( )
Parameters: Returns the result in sp[0]. testTest a logical expression. Usage: value
Parameters:
Returns the result on the evaluation stack, i.e., 1 if the value is nonzero and 0 otherwise. tolowerCopy a string, converting to lowercase. Usage: tolower( value )
Parameters:
Returns the result in sp[0]. toupperCopy a string, converting to uppercase. Usage: toupper( value )
Parameters:
Returns the result in sp[0]. uminusUnitary minus. Usage: - value
Parameters:
Returns the result in sp[0]. uplusUnitary plus. Usage: + value
Parameters:
Returns the result in sp[0]. REGULAR EXPRESSIONSM_1Jmandatory jump M_2JAoptional (undesirable) jump M_2JBoptional (desirable) jump M_2JCpop position, optional jump (to continue looping) if advanced M_ACCEPTend of match M_ANYarbitrary character (.) M_CLASScharacter class M_ENDend of string ($) M_ENTERprepare an iteration by resetting the counter. This precedes a M_SAVE_POS. M_LOOPLike M_2JC, this is the last part of a conditional loop. It is used where one or both of the minimum and maximum iterations are known. M_SAVE_POSpush position onto stack, at the beginning of a loop M_STARTstart of string (^) M_STRmatching a literal string M_Uarbitrary string (.*)
|