Lines Matching +refs:po +refs:compose +refs:mail +refs:function

90 @c merge the function and variable indexes into the concept index
350 control using the @code{getline} function.
416 * Function Calls:: A function call is an expression.
489 * Function Example:: An example function definition and what it
492 * Return Statement:: Specifying the value a function returns.
522 function.
523 * Assert Function:: A function for assertions in @command{awk}
525 * Round Function:: A function for rounding if @code{sprintf}
530 * Join Function:: A function to join an array into a string.
531 * Gettimeofday Function:: A function to get formatted times.
534 * Filetrans Function:: A function for handling data file
536 * Rewind Function:: A function for rereading the current file.
540 * Getopt Function:: A function for processing command-line
1553 @c @cindex basic function of @command{awk}
1554 @cindex @command{awk}, function of
1556 The basic function of @command{awk} is to search files for lines (or other
1580 @dfn{rules}. (It may also contain @dfn{function definitions},
2665 be in other languages. This makes @command{awk} programs easy to compose and
3234 using a string constant with a regexp operator or function.}
3702 This example uses the @code{sub} function (which we haven't discussed yet;
3856 The following example uses the @code{sub} function, which
3895 to make several function calls, @emph{per input character} to find the record
3938 using the @code{getline} function.
4521 This also applies to any built-in function that updates @code{$0},
5108 This information is useful when writing a function
5112 for an example of such a function).
5186 function to break up the record manually
5517 @cindex @code{close} function
5518 The @code{close} function is called to ensure that if two identical
5560 @cindex @code{close} function
5561 The @code{close} function is called to ensure that if two identical
5813 and discusses the @code{close} built-in function.
6038 and prints that string. @command{awk} uses the @code{sprintf} function
6042 function accepts a @dfn{format specification} that tells it how to format
6048 @cindex @code{sprintf} function
6121 The format string is very similar to that in the ISO C library function
6611 The next example uses redirection to mail a message to the mailing
6616 report = "mail bug-system"
6624 @code{m}. It's then sent down the pipeline to the @command{mail} program.
6628 The @code{close} function is called here because it's a good idea to close
6716 The @code{tolower} function returns its argument string with all
6845 first be closed with the @code{close} function
7012 @cindex @code{close} function
7015 reading more output from the same command). The @code{close} function
7045 Once this function call is executed, the next @code{getline} from that
7081 output is redirected to the @command{mail} program, the message is not
7088 For example, suppose a program pipes output to the @command{mail} program.
7095 @cindex differences in @command{awk} and @command{gawk}, @code{close} function
7096 @cindex portability, @code{close} function and
7160 @cindex advanced features, @code{close} function
7161 @cindex dark corner, @code{close} function
7162 @cindex @code{close} function, return values
7164 @cindex return values, @code{close} function
7165 @cindex differences in @command{awk} and @command{gawk}, @code{close} function
7166 @cindex Unix @command{awk}, @code{close} function and
7168 In many versions of Unix @command{awk}, the @code{close} function
7179 @command{gawk} treats @code{close} as a function.
7232 @code{pclose} function.
7247 or pass to a function. Additionally, an expression
7254 variables, array references, constants, and function calls, as well as
7278 * Function Calls:: A function call is an expression.
7396 you can use the @code{strtonum} function
7520 @cindex @code{gensub} function (@command{gawk})
7521 @cindex @code{sub} function
7522 @cindex @code{gsub} function
7525 second argument of the @code{match} function
7537 function mysub(pat, repl, str, global)
7557 user-defined function @code{mysub}, which in turn passes it on to
7562 a parameter to a user-defined function, since passing a truth value in
7722 Numbers are converted using the @code{sprintf} function
8209 (Arrays and the @code{rand} function haven't been covered yet.
9013 @cindex function calls
9015 A @dfn{function} is a name for a particular calculation.
9018 example, the function @code{sqrt} computes the square root of a number.
9022 available in every @command{awk} program. The @code{sqrt} function is one
9029 @cindex arguments, in function calls
9030 The way to use a function is with a @dfn{function call} expression,
9031 which consists of the function name followed immediately by a list of
9033 provide the raw materials for the function's calculations.
9035 there are no arguments, just write @samp{()} after the function name.
9036 The following examples show function calls with and without arguments:
9044 @cindex troubleshooting, function call syntax
9046 Do not put any space between the function name and the open-parenthesis!
9047 A user-defined function name looks just like the name of a
9053 with user-defined functions. Each function expects a particular number
9054 of arguments. For example, the @code{sqrt} function must be called with
9070 @cindex side effects, function calls
9071 Like every other expression, the function call has a value, which is
9072 computed by the function based on the arguments you give it. In this
9074 @var{argument}. A function can also have side effects, such as assigning
9785 rules and function definitions interspersed. (Functions are
9796 function @var{name}(@var{args}) @{ @dots{} @}
10374 Contrast this with the effect of the @code{getline} function
10410 @c @cindex @code{next}, inside a user-defined function
10421 statement inside function bodies
10424 function body reads the next record and starts processing it with the
10471 for a user-defined function that simulates the @code{nextfile}
10479 statement inside function bodies
10482 function body reads the next record and starts processing it with the
10637 @code{sprintf} function
10746 as the first argument to the @code{sprintf} function
10752 @cindex @code{sprintf} function, @code{OFMT} variable and
10906 @command{awk} may spawn via redirection or the @code{system} function.
11031 @code{match} function
11033 @code{RLENGTH} is set by invoking the @code{match} function. Its value
11039 @code{match} function
11041 @code{RSTART} is set by invoking the @code{match} function. Its value
11168 @c NEXT ED: Add xref to rewind() function
11403 built-in function),
11594 for more information on the built-in function @code{length}.
11710 @cindex @code{split} function, array elements, deleting
11711 The @code{split} function
11715 function simply clears the array and then returns.
11963 built-in @code{split} function
11986 Then the @code{split} function is called as follows:
12001 @cindex @code{asort} function (@command{gawk})
12003 @cindex @code{asort} function (@command{gawk}), arrays, sorting
12004 @cindex sort function, arrays, sorting
12008 writing a @code{sort} function.
12031 @cindex side effects, @code{asort} function
12051 @code{asorti} function. The interface is identical to that of
12155 the function followed
12157 is a call to the function @code{atan2} and has two arguments.
12162 Whitespace is ignored between the built-in function name and the
12166 convention that always works---no whitespace after a function name.
12169 @cindex troubleshooting, @command{gawk}, fatal errors, function arguments
12170 @cindex @command{gawk}, function arguments and
12171 @cindex differences in @command{awk} and @command{gawk}, function arguments (@command{gawk})
12172 Each built-in function accepts a certain number of arguments.
12174 arguments vary from function to function and are described under the
12177 it is a fatal error to give extra arguments to a built-in function.
12179 When a function is called, expressions that create the function's actual
12194 The order of evaluation of the expressions used for the function's
12219 @cindex @code{int} function
12227 @cindex @code{sqrt} function
12233 @cindex @code{exp} function
12239 @cindex @code{log} function
12244 @cindex @code{sin} function
12248 @cindex @code{cos} function
12252 @cindex @code{atan2} function
12256 @cindex @code{rand} function
12264 In fact, @command{gawk} uses the BSD @code{random} function, which is
12267 Often random integers are needed instead. Following is a user-defined function
12271 function randint(n) @{
12281 The following example uses a similar function to produce random integers
12287 function roll(n) @{ return 1 + int(rand() * n) @}
12311 @cindex @code{srand} function
12312 The function @code{srand} sets the starting point, or seed,
12355 @cindex @code{asort} function (@command{gawk})
12389 The @code{asort} function is described in more detail in
12395 @cindex @code{asorti} function (@command{gawk})
12403 The @code{asorti} function is described in more detail in
12410 @cindex @code{index} function
12426 @cindex @code{length} function
12437 @cindex portability, @code{length} function
12440 In older versions of @command{awk}, the @code{length} function could
12449 @cindex @code{match} function
12450 The @code{match} function searches @var{string} for the
12469 @cindex @code{RSTART} variable, @code{match} function and
12470 @cindex @code{RLENGTH} variable, @code{match} function and
12471 @cindex @code{match} function, @code{RSTART}/@code{RLENGTH} variables
12472 The @code{match} function sets the built-in variable @code{RSTART} to
12520 @cindex differences in @command{awk} and @command{gawk}, @code{match} function
12558 @cindex troubleshooting, @code{match} function
12565 @cindex @code{split} function
12566 This function divides @var{string} into pieces separated by @var{fieldsep}
12575 The @code{split} function splits strings into pieces in a
12596 @cindex differences in @command{awk} and @command{gawk}, @code{split} function
12608 @cindex dark corner, @code{split} function
12630 @cindex @code{sprintf} function
12643 @cindex differences in @command{awk} and @command{gawk}, @code{strtonum} function (@command{gawk})
12644 @cindex @code{strtonum} function (@command{gawk})
12658 Using the @code{strtonum} function is @emph{not} the same as adding zero
12664 @cindex differences in @command{awk} and @command{gawk}, @code{strtonum} function (@command{gawk})
12669 @cindex @code{sub} function
12670 The @code{sub} function alters the value of @var{target}.
12684 This function is peculiar because @var{target} is not simply
12704 The @code{sub} function returns the number of substitutions made (either
12746 @cindex @code{sub} function, arguments of
12747 @cindex @code{gsub} function, arguments of
12772 @cindex @code{gsub} function
12773 This is similar to the @code{sub} function, except @code{gsub} replaces
12786 The @code{gsub} function returns the number of substitutions made. If
12793 @cindex @code{gensub} function (@command{gawk})
12794 @code{gensub} is a general substitution function. Like @code{sub} and
12797 the modified string is returned as the result of the function and the
12854 @cindex @code{substr} function
12861 If @var{length} is not present, this function returns the whole suffix of
12877 @cindex troubleshooting, @code{substr} function
12896 @cindex portability, @code{substr} function
12912 @cindex @code{tolower} function
12919 @cindex @code{toupper} function
12930 @cindex @code{sub} function, escape processing
12931 @cindex @code{gsub} function, escape processing
12932 @cindex @code{gensub} function (@command{gawk}), escape processing
13187 @cindex @code{close} function
13205 @cindex @code{fflush} function
13210 @cindex portability, @code{fflush} function and
13220 This is the purpose of the @code{fflush} function---@command{gawk} also
13221 buffers its output and the @code{fflush} function forces
13229 @cindex @command{gawk}, @code{fflush} function in
13230 @command{gawk} extends the @code{fflush} function in two ways. The first
13238 @cindex troubleshooting, @code{fflush} function
13251 @cindex @code{system} function
13255 function executes the command given by the string @var{command}.
13264 system("date | mail -s 'awk run done' root")
13269 the system administrator is sent mail when the @command{awk} program
13283 @cindex troubleshooting, @code{system} function
13287 Some operating systems cannot implement the @code{system} function.
13342 The @code{fflush} function provides explicit control over output buffering for
13352 @command{gawk} treats this use of the @code{system} function as a special
13433 @cindex @code{systime} function (@command{gawk})
13435 This function returns the current time as the number of seconds since
13442 @cindex @code{mktime} function (@command{gawk})
13443 This function turns @var{datespec} into a timestamp in the same form
13444 as is returned by @code{systime}. It is similar to the function of the
13470 @cindex @code{strftime} function (@command{gawk})
13471 This function returns a string. It is similar to the function of the
13475 @code{systime} function. If no @var{timestamp} argument is supplied,
13483 The @code{systime} function allows you to compare a timestamp from a
13491 The @code{mktime} function allows you to convert a textual representation
13496 The @code{strftime} function allows you to easily turn a timestamp
13498 function
13504 @cindex format specifiers, @code{strftime} function (@command{gawk})
13855 @cindex @code{and} function (@command{gawk})
13859 @cindex @code{or} function (@command{gawk})
13863 @cindex @code{xor} function (@command{gawk})
13867 @cindex @code{compl} function (@command{gawk})
13871 @cindex @code{lshift} function (@command{gawk})
13875 @cindex @code{rshift} function (@command{gawk})
13883 @cindex @code{and} function (@command{gawk})
13887 @cindex @code{or} function (@command{gawk})
13891 @cindex @code{xor} function (@command{gawk})
13895 @cindex @code{compl} function (@command{gawk})
13899 @cindex @code{lshift} function (@command{gawk})
13903 @cindex @code{rshift} function (@command{gawk})
13913 Here is a user-defined function
13917 @cindex @code{bits2str} user-defined function
13924 function bits2str(bits, data, mask)
13946 function bits2str(bits, data, mask)
13993 The @code{bits2str} function turns a binary number into a string.
13996 the function repeatedly checks the rightmost bit.
14034 @cindex @code{dcgettext} function (@command{gawk})
14036 This function returns the translation of @var{string} in
14041 @cindex @code{dcngettext} function (@command{gawk})
14043 This function returns the plural form used for @var{number} of the
14051 @cindex @code{bindtextdomain} function (@command{gawk})
14053 This function allows you to specify the directory in which
14081 * Function Example:: An example function definition and what it
14084 * Return Statement:: Specifying the value a function returns.
14095 extended to include sequences of rules @emph{and} user-defined function
14097 There is no need to put the definition of a function
14098 before all uses of the function. This is because @command{awk} reads the
14101 The definition of a function named @var{name} looks like this:
14105 function @var{name}(@var{parameter-list})
14107 @var{body-of-function}
14115 @var{name} is the name of the function to define. A valid function
14119 used as a variable, array, or function.
14122 @var{parameter-list} is a list of the function's arguments and local
14123 variable names, separated by commas. When the function is called,
14126 A function cannot have two parameters with the same name, nor may it
14127 have a parameter with the same name as the function itself.
14129 The @var{body-of-function} consists of @command{awk} statements. It is the
14130 most important part of the definition, because it says what the function
14136 names. Instead, the number of arguments supplied when the function is
14142 to the function, some of the names in @var{parameter-list} may be
14148 Usually when you write a function, you know how many names you intend to
14151 the local variables, in order to document how your function is supposed to be used.
14154 During execution of the function body, the arguments and local variable
14157 function definition, because there is no way to name them while their
14160 function's body.
14162 The arguments and local variables last only as long as the function body
14164 variables that were shadowed while the function was running.
14168 The function body can contain expressions that call functions. They
14169 can even call this function, either directly or by way of another
14170 function. When this happens, we say the function is @dfn{recursive}.
14171 The act of a function calling itself is called @dfn{recursion}.
14175 @cindex POSIX @command{awk}, @code{function} keyword in
14177 the keyword @code{function} may be
14179 the keyword @code{function}. This actually has some practical implications.
14182 statement does @emph{not} define a function:
14190 of the variable @samp{func} with the return value of the function @samp{foo}.
14200 keyword @code{function} when defining a function.
14205 Here is an example of a user-defined function, called @code{myprint}, that
14209 function myprint(num)
14217 function:
14234 this program, using our function to format the results, prints:
14241 This function deletes all the elements in an array:
14244 function delarray(a, i)
14260 The following is an example of a recursive function. It takes a string
14266 @cindex @code{rev} user-defined function
14268 function rev(str, start)
14277 If this function is in a file named @file{rev.awk}, it can be tested
14286 The C @code{ctime} function takes a timestamp and returns it in a string,
14288 The following example uses the built-in @code{strftime} function
14292 @cindex @code{ctime} user-defined function
14298 # awk version of C ctime(3) function
14300 function ctime(ts, format)
14316 @dfn{Calling a function} means causing the function to run and do its job.
14317 A function call is an expression and its value is the value returned by
14318 the function.
14320 A function call consists of the function name followed by the arguments
14332 between the function name and the open-parenthesis of the argument list.
14335 notices that you used a function name and not a variable name, and reports
14339 When a function is called, it is given a @emph{copy} of the values of
14341 a variable as the expression for the argument, but the called function
14354 If the function @code{myfunc} alters the values of its local variables,
14359 function myfunc(str)
14371 If @code{str} also exists outside of @code{myfunc}, the function body
14380 by the function. This is usually called @dfn{call by reference}.
14381 Changes made to an array parameter inside the body of a function @emph{are}
14382 visible outside that function.
14384 @strong{Note:} Changing an array parameter inside a function
14389 function changeit(array, ind, nvalue)
14408 Some @command{awk} implementations allow you to call a function that
14410 program actually tries to call the function. For example:
14419 function bar() @{ @dots{} @}
14426 problem if a program calls an undefined function.
14437 inside a user-defined function.
14446 The body of a user-defined function can contain a @code{return} statement.
14459 every function definition. So if control reaches the end of the function
14460 body, then the function returns an unpredictable value. @command{awk}
14461 does @emph{not} warn you if you use the return value of such a function.
14463 Sometimes, you want to write a function for what it does, not for
14464 what it returns. Such a function corresponds to a @code{void} function
14467 value of such a function, you do so at your own risk.
14469 The following is an example of a user-defined function that returns a value
14473 function maxelt(vec, i, ret)
14483 @cindex programming conventions, function parameters
14489 @code{i} in the function parameter list indicates that @code{i} and
14493 The following program uses the @code{maxelt} function. It loads an
14498 function maxelt(vec, i, ret)
14541 function foo(a)
14647 @cindex @code{textdomain} function (C library)
14651 by calling the @code{textdomain} function.
14655 collected into a portable object file (@file{guide.po}),
14661 @cindex @code{.po} files
14662 @cindex files, @code{.po}
14666 For each language with a translator, @file{guide.po}
14674 Each language's @file{.po} file is converted into a binary
14684 @cindex @code{bindtextdomain} function (C library)
14688 one by using the @code{bindtextdomain} function.
14706 @cindex @code{gettext} function (C library)
14819 @cindex @code{dcgettext} function (@command{gawk})
14821 This built-in function returns the translation of @var{string} in
14838 of the @code{dcgettext} function is purposely different from the order for
14843 @cindex @code{dcngettext} function (@command{gawk})
14845 This built-in function returns the plural form used for @var{number} of the
14853 The same remarks as for the @code{dcgettext} function apply.
14859 @cindex @code{bindtextdomain} function (@command{gawk})
14861 This built-in function allows you to specify the directory in which
14916 built-in function:
14928 @cindex @code{LC_MESSAGES} locale category, @code{bindtextdomain} function (@command{gawk})
14932 with the @code{bindtextdomain} built-in function:
14956 @cindex @code{.po} files
14957 @cindex files, @code{.po}
14961 be extracted to create the initial @file{.po} file.
14965 @command{gawk}'s @option{--gen-po} command-line option extracts
14982 @cindex @code{--gen-po} option
14988 @cindex @code{--gen-po} option
14992 First, use the @option{--gen-po} command-line option to create
14993 the initial @file{.po} file:
14996 $ gawk --gen-po -f guide.awk > guide.po
15000 When run with @option{--gen-po}, @command{gawk} does not execute your
15150 @cindex @code{bindtextdomain} function (@command{gawk}), portability and
15151 @cindex @code{dcgettext} function (@command{gawk}), portability and
15152 @cindex @code{dcngettext} function (@command{gawk}), portability and
15155 function bindtextdomain(dir, domain)
15160 function dcgettext(string, domain, category)
15165 function dcngettext(string1, string2, number, domain, category)
15177 enough arguments are supplied in the function call. Many versions of
15208 Run @samp{gawk --gen-po} to create the @file{.po} file:
15211 $ gawk --gen-po -f guide.awk > guide.po
15218 @c file eg/data/guide.po
15235 appear in the @file{guide.po} file.
15244 $ cp guide.po guide-mellow.po
15245 @var{Add translations to} guide-mellow.po @dots{}
15253 @c file eg/data/guide-mellow.po
15277 @cindex @code{.po} files, converting to @code{.mo}
15278 @cindex files, @code{.po}, converting to @code{.mo}
15279 @cindex @code{.mo} files, converting from @code{.po}
15280 @cindex files, @code{.mo}, converting from @code{.po}
15287 @file{.po} file to machine-readable @file{.mo} file.
15293 $ msgfmt guide-mellow.po
15442 @cindex @code{--non-decimal-data} option, @code{strtonum} function and
15443 @cindex @code{strtonum} function (@command{gawk}), @code{--non-decimal-data} option and
15447 Instead, use the @code{strtonum} function to convert your data
15564 @cindex @code{close} function, two-way pipes and
15567 function of either @code{"to"} or @code{"from"}
15674 @cindex @code{getservbyname} function (C library)
15680 the predefined port number using the C @code{getservbyname} function.
15810 function sing( dummy)
15868 6 function sing(dummy)
15915 For user-defined functions, the count next to the @code{function}
15916 keyword indicates how many times the function was called.
16023 Each time, the profile and function call trace are appended to the output
16029 @command{pgawk} produces the profile and the function call trace and then exits.
16274 @item -W gen-po
16275 @itemx --gen-po
16276 @cindex @code{--gen-po} option
16364 The synonym @code{func} for the keyword @code{function} is not
16387 @cindex @code{fflush} function, unsupported
16389 The @code{fflush} built-in function is not supported
16413 counts for each statement in the program in the left margin, and function
16414 call counts for each function.
16471 function names must be unique.)
16883 shows you how to write a function that does the same thing.
16911 * Getopt Function:: A function for processing command-line
16927 a specific function). There is no intermediate state analogous to
16934 preserve state information between calls to the function---for example,
16940 When writing a library function, you should try to choose names for your
16942 either another library function or a user's main program. For example, a
16956 indicate what function or set of functions use the variables---for example,
16962 function names as well.@footnote{While all the library routines could have
16967 As a final note on variable naming, if a function makes global variables
16985 function lib_func(x, y, l1, l2)
16998 associative array to hold the values needed by the library function(s), or
17019 function.
17020 * Assert Function:: A function for assertions in @command{awk}
17022 * Round Function:: A function for rounding if @code{sprintf} does
17027 * Join Function:: A function to join an array into a string.
17028 * Gettimeofday Function:: A function to get formatted times.
17046 @code{nextfile} function that you can use to simulate @command{gawk}'s
17049 A first attempt at writing a @code{nextfile} function is as follows:
17055 function nextfile() @{ _abandon_ = FILENAME; next @}
17076 The @code{nextfile} function itself simply sets the value of @code{_abandon_}
17080 @c If the function can't be used on other versions of awk, this whole
17084 execute @code{next} from within a function body. Some other workaround
17088 @cindex @code{nextfile} user-defined function
17114 function nextfile() @{ _abandon_ = FILENAME; next @}
17125 The @code{nextfile} function has not changed. It makes @code{_abandon_}
17136 @code{nextfile} function was executed. In that case, @code{_abandon_}
17149 significant gains in efficiency. If the @code{nextfile} function is executed
17169 @cindex @code{assert} function (C library)
17202 @cindex @code{assert} user-defined function
17205 this @code{assert} function also requires a string version of the condition
17207 Following is the function:
17223 function assert(condition, string)
17242 The @code{assert} function tests the @code{condition} parameter. If it
17257 The function can be used in a program in the following way:
17260 function myfunc(a, b)
17274 @cindex @code{END} pattern, @code{assert} user-defined function and
17284 @cindex @code{BEGIN} pattern, @code{assert} user-defined function and
17301 @cindex @code{print} statement, @code{sprintf} function and
17302 @cindex @code{printf} statement, @code{sprintf} function and
17303 @cindex @code{sprintf} function, @code{print}/@code{printf} statements and
17312 you should check what your system does. The following function does
17316 @cindex @code{round} user-defined function
17330 function round(x, ival, aval, fraction)
17373 @cindex @code{cliff_rand} user-defined function
17389 function cliff_rand()
17401 If the built-in @code{rand} function
17403 isn't random enough, you might try using this function instead.
17412 One commercial implementation of @command{awk} supplies a built-in function,
17417 The inverse of this function is @code{chr} (from the function of the same
17422 @cindex @code{ord} user-defined function
17423 @cindex @code{chr} user-defined function
17430 # _ord_init: function to initialize _ord_
17444 function _ord_init( low, high, i, t)
17492 function ord(str, c)
17499 function chr(c)
17520 @code{@w{_ord_init}} function into the body of the @code{BEGIN} rule. It was
17523 function. It is commented out for production use.
17533 all the strings in an array into one long string. The following function,
17538 Good function design is important; this function needs to be general but it
17545 @cindex @code{join} user-defined function
17559 function join(array, start, end, sep, result, i)
17599 The following function, @code{gettimeofday}, populates a user-supplied array
17603 @cindex @code{gettimeofday} user-defined function
17639 function gettimeofday(time, ret, now, i)
17680 uses this function.
17681 A more general design for the @code{gettimeofday} function would have
17698 * Filetrans Function:: A function for handling data file transitions.
17699 * Rewind Function:: A function for rereading the current file.
17772 @cindex @code{beginfile} user-defined function
17773 @cindex @code{endfile} user-defined function
17808 shows how this library function can be used and
17815 Another request for a new built-in function was for a @code{rewind}
17816 function that would make it possible to reread the current file.
17826 @cindex @code{rewind} user-defined function
17840 function rewind( i)
17872 The @code{rewind} function also relies on the @code{nextfile} keyword
17875 for a function version of @code{nextfile}.
17918 @cindex troubleshooting, @code{getline} function
17940 in @ref{Filetrans Function}, the following library file calls a function named
18058 function disable_assigns(argc, argv, i)
18078 The function works by looping through the arguments.
18115 @cindex @code{getopt} function (C library)
18116 Modern Unix systems provide a C function named @code{getopt} for processing
18203 function to process both normal and GNU-style long options
18208 version of @code{getopt}. This function highlights one of the
18213 function was written before @command{gawk} acquired the ability to
18219 @cindex @code{getopt} user-defined function
18222 # getopt.awk --- do C library getopt(3) function in awk
18251 The function starts out with
18254 are ``private'' to this library function. Such documentation is essential
18257 The @code{getopt} function first checks that it was indeed called with a string of options
18261 @cindex @code{getopt} user-defined function
18264 function getopt(argc, argv, options, thisopt, i)
18466 @cindex @code{getpwent} function (C library)
18467 @cindex @code{getpwent} user-defined function
18476 The primary function is @code{getpwent}, for ``get password entry.''
18494 @c Use old style function header for portability to old systems (SunOS, HP/UX).
18628 @cindex @code{_pw_init} user-defined function
18648 function _pw_init( oldfs, oldrs, olddol0, pwcat, using_fw)
18684 The function @code{_pw_init} keeps three copies of the user information
18691 @cindex @code{getline} command, @code{_pw_init} function
18692 Because this function uses @code{getline} to read information from
18708 The main part of the function uses a loop to read database lines, split
18717 @cindex @code{getpwnam} function (C library)
18718 The @code{getpwnam} function takes a username as a string argument. If that
18722 @cindex @code{getpwnam} user-defined function
18726 function getpwnam(name)
18737 @cindex @code{getpwuid} function (C library)
18739 the @code{getpwuid} function takes a user ID number argument. If that
18743 @cindex @code{getpwuid} user-defined function
18746 function getpwuid(uid)
18756 @cindex @code{getpwent} function (C library)
18757 The @code{getpwent} function simply steps through the database, one entry at
18761 @cindex @code{getpwent} user-defined function
18764 function getpwent()
18774 @cindex @code{endpwent} function (C library)
18775 The @code{@w{endpwent}} function resets @code{@w{_pw_count}} to zero, so that
18778 @cindex @code{endpwent} user-defined function
18781 function endpwent()
18825 @cindex @code{getgrent} function (C library)
18826 @cindex @code{getgrent} user-defined function
18974 @cindex @code{getline} command, @code{_gr_init} user-defined function
18975 @cindex @code{_gr_init} user-defined function
18997 function _gr_init( oldfs, oldrs, olddol0, grcat,
19052 The @code{@w{_gr_init}} function first saves @code{FS}, @code{FIELDWIDTHS}, @code{RS}, and
19083 @cindex @code{getgrnam} function (C library)
19084 The @code{getgrnam} function takes a group name as its argument, and if that
19088 @cindex @code{getgrnam} user-defined function
19091 function getgrnam(group)
19101 @cindex @code{getgrgid} function (C library)
19102 The @code{getgrgid} function is similar, it takes a numeric group ID and
19105 @cindex @code{getgrgid} user-defined function
19108 function getgrgid(gid)
19118 @cindex @code{getgruser} function (C library)
19119 The @code{getgruser} function does not have a C counterpart. It takes a
19122 @cindex @code{getgruser} function, user-defined
19125 function getgruser(user)
19135 @cindex @code{getgrent} function (C library)
19136 The @code{getgrent} function steps through the database one entry at a time.
19139 @cindex @code{getgrent} user-defined function
19142 function getgrent()
19153 @cindex @code{endgrent} function (C library)
19154 The @code{endgrent} function resets @code{_gr_count} to zero so that @code{getgrent} can
19157 @cindex @code{endgrent} user-defined function
19160 function endgrent()
19167 As with the user database routines, each function calls @code{_gr_init} to
19326 function (@pxref{Getopt Function})
19327 and the @code{join} library function
19331 functions needed, and a @code{usage} function that prints out a usage
19359 function usage( e1, e2)
19372 The variables @code{e1} and @code{e2} are used so that the function
19476 function set_fieldlist( n, m, i, j, k, f, g)
19500 The @code{set_charlist} function is more complicated than @code{set_fieldlist}.
19521 function set_charlist( field, i, j, f, g, t,
19662 This version uses the @code{getopt} library function
19767 The @code{beginfile} function is called by the rule in @file{ftrans.awk}
19776 function beginfile(junk)
19783 The @code{endfile} function is called after each file has been processed.
19794 function endfile(file)
19871 The @code{usage} function prints a usage message in case of invalid options,
19876 function usage( e)
19886 The variable @code{e} is used so that the function fits nicely
20160 The @code{usage} function simply prints an error message and exits:
20164 function usage( e)
20174 The variable @code{e} is used so that the function
20362 @code{getopt} library function
20364 and the @code{join} library function
20367 The program begins with a @code{usage} function and then a brief outline of
20403 function usage( e)
20460 The following function, @code{are_equal}, compares the current line,
20480 function are_equal( n, m, clast, cline, alast, aline)
20612 This uses the @code{getopt} library function
20673 The @code{beginfile} function is simple; it just resets the counts of lines,
20680 function beginfile(file)
20688 The @code{endfile} function adds the current file's numbers to the running
20703 function endfile(file)
20872 This program uses the @code{gettimeofday} function from
20889 # Requires gettimeofday library function
20980 Finally, the program uses the @code{system} function
21041 a user proposed that a transliteration function should
21047 function. This program is not as complete as the system @command{tr} utility
21078 The @code{translate} function simply calls @code{stranslate} using @code{$0}
21103 function stranslate(from, to, target, lf, lt, t_ar, i, c)
21120 function translate(from, to)
21147 function, it is not necessarily efficient, and we (the @command{gawk}
21148 authors) started to consider adding a built-in function. However,
21190 Most of the work is done in the @code{printpage} function.
21238 function printpage( i, j)
21553 control line and passing it on to the @code{system} function
21560 @file{extract.awk} uses the @code{join} library function
21637 The variable @code{e} is used so that the function
21656 function. If the line is an ``endfile'' line, then it breaks out of
21666 the array @code{a}, using the @code{split} function
21730 Finally, the function @code{@w{unexpected_eof}} prints an appropriate
21734 @c function lb put on same line for page breaking. sigh
21738 function unexpected_eof() @{
21773 @command{awk}'s @code{gsub} function
21799 function usage()
21854 The @code{usage} function prints an error message and exits.
21915 includes don't accidentally include a library function twice.
22117 The @code{pathto} function does the work of finding the full path to
22143 function pathto(file, i, t, junk)
22300 in the @code{pathto} function when testing for the
22492 third argument to the @code{split} function
22507 Redirection of input for the @code{getline} function
22551 A defined return value for the @code{srand} built-in function
22561 @code{printf} function
22566 in the argument list of the @code{printf} function
22625 The synonym @code{func} for the keyword @code{function} is not
22639 The @code{fflush} built-in function is not supported
22667 The @code{fflush} built-in function for flushing buffered output
22677 The use of @code{func} as an abbreviation for @code{function}
22845 The @code{gensub} function for more powerful text manipulation
22849 The @code{strftime} function acquired a default time format,
22873 The @option{-m} option and the @code{fflush} function from the
22938 The optional third argument to the @code{match} function
22957 The @code{extension} built-in function and the ability to add
22962 The @code{mktime} built-in function for creating timestamps
22988 The @option{--gen-po} command-line option and the use of a leading
23029 The source code now uses new-style function definitions, with
23165 built-in function for dynamically adding new modules.
23192 provided the initial version of the @code{asort} function
23193 as well as the code for the new optional third argument to the @code{match} function.
23232 for the electronic mail addresses of the people who did
23463 @itemx po/*
23465 @command{gawk}'s internationalization features, while the @file{po} library
23669 function prototypes are used to help improve the compile-time checking.
23688 do so by not exiting with an error when a library function is not
23795 @c and Darrel Hankerson <hankedr@mail.auburn.edu>
23994 the @code{extension} function to match the name of the library (for
24008 send electronic mail to @email{ptjm@@interlog.com} if you have problems getting
24443 function is missing from the libraries, which is not true, and an
24444 alternative implementation of this function is provided in
24497 function, which may not support this convention. Whenever it is possible
24586 mail to me. If necessary, I can be reached directly at
24602 mail at the Internet address noted previously.
24605 an electronic mail message to the person who maintains that port. They
24627 Darrel Hankerson, @email{hankedr@@mail.auburn.edu}.
24656 Darrel Hankerson, @email{hankedr@@mail.auburn.edu}.
24748 The @code{fflush} built-in function for flushing buffered output
24758 The use of @code{func} as an abbreviation for @code{function}
24948 Use ANSI/ISO style (prototype) function headers when defining functions.
24951 Put the name of the function at the beginning of its own line.
24954 Put the return type of the function, even if it is @code{int}, on the
24955 line above the line with the name and arguments of the function.
24963 Do not put spaces in front of parentheses used in function calls.
24966 Put spaces around all C operators and after commas in function calls.
24995 Provide one-line descriptive comments for each function.
25001 Do not use the @code{alloca} function for allocating memory off the stack.
25042 (@xref{Bugs}, for the electronic mail
25237 @cindex @code{force_number} internal function
25242 It may end up calling an internal @command{gawk} function.
25244 @cindex @code{force_string} internal function
25247 It may end up calling an internal @command{gawk} function.
25254 The number of parameters actually passed in a function call at runtime.
25262 If you need to pass the string value to a C library function, save
25269 be either @code{Node_var} or @code{Node_var_array} for function
25278 @cindex @code{assoc_clear} internal function
25284 @cindex @code{assoc_lookup} internal function
25294 @cindex @code{make_string} internal function
25301 @cindex @code{make_number} internal function
25307 @cindex @code{tmp_string} internal function
25313 @cindex @code{tmp_number} internal function
25321 @cindex @code{dupnode} internal function
25334 @cindex @code{make_builtin} internal function
25336 Register a C function pointed to by @code{func} as new built-in
25337 function @code{name}. @code{name} is a regular C string. @code{count}
25338 is the maximum number of arguments that the function takes.
25339 The function should be written in the following manner:
25342 /* do_xxx --- do xxx function for gawk */
25352 @cindex @code{get_argument} internal function
25354 This function is called from within a C extension function to get
25355 the @code{i}-th argument from the function call.
25360 @cindex @code{set_value} internal function
25362 This function is called from within a C extension function to set
25363 the return value from the extension function. This value is
25365 new @command{awk} function.
25368 @cindex @code{update_ERRNO} internal function
25370 This function is called from within a C extension function to set
25378 from a function parameter.
25429 @cindex @code{chdir} function, implementing in @command{gawk}
25432 @cindex @code{stat} function, implementing in @command{gawk}
25479 The C @code{stat} function fills in a structure that has a fair
25497 The @code{stat} function always clears the data array, even if
25524 be a function of the file's size if the file has holes.
25627 By convention, for an @command{awk} function @code{foo}, the function that
25628 implements it is called @samp{do_foo}. The function should take
25630 represents the argument list to the function. The @code{newdir}
25652 Finally, the function returns the return value to the @command{awk} level,
25665 The @code{stat} built-in is more involved. First comes a function
25682 Next comes the actual @code{do_stat} function itself. First come the
25690 /* do_stat --- provide a stat() function for gawk */
25773 new function(s) into @command{gawk}. By convention, each library has
25811 @cindex @code{extension} function (@command{gawk})
25813 built-in function.
25814 This function takes two arguments: the name of the
25815 library to load and the name of a function to call when the library
25816 is first loaded. This function adds the new functions to @command{gawk}.
25817 It returns the value returned by the initialization function
26605 @command{awk} programs may also contain function definitions.
26768 @command{awk} for delimiting actions, compound statements, and function
26984 @code{function},
27083 When a function calls itself, either directly or indirectly.
27155 expressions, and function calls have side effects.
27587 Also add information on how to contact you by electronic and paper mail.