Main Page | Class List | Directories | File List | Class Members | File Members

ordchr.c File Reference

#include "awk.h"

Go to the source code of this file.

Functions

static NODEdo_ord (NODE *tree)
static NODEdo_chr (NODE *tree)
NODEdlload (NODE *tree, void *dl)


Function Documentation

NODE* dlload NODE tree,
void *  dl
 

Definition at line 98 of file ordchr.c.

References AWKNUM, do_chr(), do_ord(), and tmp_number.

00101 {
00102         make_builtin("ord", do_ord, 1);
00103         make_builtin("chr", do_chr, 1);
00104 
00105         return tmp_number((AWKNUM) 0);
00106 }

static NODE* do_chr NODE tree  )  [static]
 

Definition at line 63 of file ordchr.c.

References AWKNUM, do_lint, force_number, free_temp, lintwarn, NULL, tmp_number, and tmp_string().

Referenced by dlload().

00065 {
00066         NODE *num;
00067         unsigned int ret = 0;
00068         AWKNUM val = 0.0;
00069         char str[2];
00070 
00071         str[0] = str[1] = '\0';
00072 
00073         if  (do_lint && tree->param_cnt > 1)
00074                 lintwarn("chr: called with too many arguments");
00075 
00076         num = get_argument(tree, 0);
00077         if (num != NULL) {
00078                 val = force_number(num);
00079                 ret = val;      /* convert to int */
00080                 free_temp(num);
00081                 ret &= 0xff;
00082                 str[0] = ret;
00083                 str[1] = '\0';
00084         } else if (do_lint)
00085                 lintwarn("chr: called with no arguments");
00086 
00087 
00088         /* Set the return value */
00089         set_value(tmp_string(str, 1));
00090 
00091         /* Just to make the interpreter happy */
00092         return tmp_number((AWKNUM) 0);
00093 }

static NODE* do_ord NODE tree  )  [static]
 

Definition at line 35 of file ordchr.c.

References AWKNUM, do_lint, force_string, free_temp, lintwarn, NULL, and tmp_number.

Referenced by dlload().

00037 {
00038         NODE *str;
00039         int ret = -1;
00040 
00041         if  (do_lint && tree->param_cnt > 1)
00042                 lintwarn("ord: called with too many arguments");
00043 
00044         str = get_argument(tree, 0);
00045         if (str != NULL) {
00046                 (void) force_string(str);
00047                 ret = str->stptr[0];
00048                 free_temp(str);
00049         } else if (do_lint)
00050                 lintwarn("ord: called with no arguments");
00051 
00052 
00053         /* Set the return value */
00054         set_value(tmp_number((AWKNUM) ret));
00055 
00056         /* Just to make the interpreter happy */
00057         return tmp_number((AWKNUM) 0);
00058 }


© sourcejam.com 2005-2008