*** empty log message ***

This commit is contained in:
hyung-hwan 2006-04-04 16:22:01 +00:00
parent 023d391d86
commit 050196400e
4 changed files with 35 additions and 15 deletions

View File

@ -15,3 +15,6 @@ EXPORTS
xp_awk_parse
xp_awk_run
xp_awk_strtolong
xp_awk_strtoreal

View File

@ -113,6 +113,10 @@ SOURCE=.\map.c
# End Source File
# Begin Source File
SOURCE=.\misc.c
# End Source File
# Begin Source File
SOURCE=.\parse.c
# End Source File
# Begin Source File
@ -136,10 +140,6 @@ SOURCE=.\tree.c
SOURCE=.\val.c
# End Source File
# End Group
#
SOURCE=.\misc.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.c,v 1.1 2006-04-04 16:03:14 bacon Exp $
* $Id: misc.c,v 1.2 2006-04-04 16:22:01 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -35,21 +35,27 @@ xp_long_t xp_awk_strtolong (const xp_char_t* str, int base)
if (*p == XP_CHAR('0'))
{
p++;
if (*p == XP_CHAR('x'))
if (*p == XP_CHAR('x') || *p == XP_CHAR('X'))
{
p++; base = 16;
}
else if (*p == XP_CHAR('b') || *p == XP_CHAR('B'))
{
p++; base = 2;
}
else base = 8;
}
else base = 10;
}
else if (base == 16)
{
// skip a leading "0x" from hex numbers.
if ((*p == XP_CHAR('0')) && (*(p+1) == XP_CHAR('x')))
{
p += 2;
}
if (*p == XP_CHAR('0') &&
(*(p+1) == XP_CHAR('x') || *(p+1) == XP_CHAR('X'))) p += 2;
}
else if (base == 2)
{
if (*p == XP_CHAR('0') &&
(*(p+1) == XP_CHAR('b') || *(p+1) == XP_CHAR('B'))) p += 2;
}
while (*p != XP_CHAR('\0'))

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c,v 1.70 2006-04-04 16:03:14 bacon Exp $
* $Id: parse.c,v 1.71 2006-04-04 16:22:01 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -2460,7 +2460,18 @@ static int __get_number (xp_awk_t* awk)
GET_CHAR_TO (awk, c);
} while (xp_isxdigit(c));
// TODO: return hexadecimal number...
return 0;
}
else if (c == XP_CHAR('b') || c == XP_CHAR('B'))
{
/* binary number */
do
{
ADD_TOKEN_CHAR (awk, c);
GET_CHAR_TO (awk, c);
} while (c == XP_CHAR('0') || c == XP_CHAR('1'));
return 0;
}
else if (c != '.')
{
@ -2469,9 +2480,9 @@ static int __get_number (xp_awk_t* awk)
{
ADD_TOKEN_CHAR (awk, c);
GET_CHAR_TO (awk, c);
} while (c >= XP_CHAR('0') || c <= XP_CHAR('7'));
} while (c >= XP_CHAR('0') && c <= XP_CHAR('7'));
// TOOD: return octal number
return 0;
}
}