home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / exec / funascii.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  942 b   |  42 lines

  1. /*
  2. \fucref{fun\_ascii}{void fun\_ascii ()}
  3.     {}
  4.     {}
  5.     {}
  6.     {}
  7.     {funstrel.c}
  8.     {
  9.  
  10.         This function is called when a call to the built-in function {\em
  11.         ascii} is to be processed.
  12.  
  13.         If the last pushed value is a string, then the return register
  14.         is set to the integer (ASCII number) representation of the first
  15.         character in the string. Otherwise, the stacked argument is taken
  16.         as an {\em int} and the return register is set to the
  17.         character-to-string representation.
  18.  
  19.     }
  20. */
  21.  
  22. #include "icm-exec.h"
  23.  
  24. void fun_ascii ()
  25. {
  26.     char
  27.         buf [2];
  28.  
  29.     if (stack [sp].type == e_str)
  30.     {
  31.         reg.type = e_int;
  32.         reg.vu.intval = * (stack [sp].vu.i->ls.str);
  33.     }
  34.     else
  35.     {
  36.         buf [1] = '\0';
  37.         buf [0] = (char) stack [sp].vu.intval;
  38.         reg = newvar (e_str);
  39.         reg.vu.i->ls.str = xstrdup (buf);
  40.     }
  41. }
  42.