*** empty log message ***
This commit is contained in:
parent
af4c825fc4
commit
023d391d86
@ -1,4 +1,4 @@
|
||||
SRCS = awk.c err.c tree.c tab.c map.c parse.c run.c sa.c val.c
|
||||
SRCS = awk.c err.c tree.c tab.c map.c parse.c run.c sa.c val.c misc.c
|
||||
OBJS = $(SRCS:.c=.obj)
|
||||
OUT = xpawk.lib
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
SRCS = awk.c err.c tree.c tab.c map.c parse.c run.c sa.c val.c
|
||||
SRCS = awk.c err.c tree.c tab.c map.c parse.c run.c sa.c val.c misc.c
|
||||
OBJS = $(SRCS:.c=.obj)
|
||||
OUT = xpawk
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
SRCS = awk.c err.c tree.c tab.c map.c parse.c run.c sa.c val.c
|
||||
OBJS = awk.obj err.obj tree.obj tab.obj map.obj parse.obj run.obj sa.obj val.obj
|
||||
SRCS = awk.c err.c tree.c tab.c map.c parse.c run.c sa.c val.c misc.c
|
||||
OBJS = awk.obj err.obj tree.obj tab.obj map.obj parse.obj run.obj sa.obj val.obj misc.obj
|
||||
OUT = xpawk.lib
|
||||
|
||||
CC = lcc
|
||||
|
@ -136,6 +136,10 @@ 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"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h,v 1.40 2006-04-02 12:41:14 bacon Exp $
|
||||
* $Id: awk.h,v 1.41 2006-04-04 16:03:14 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_AWK_H_
|
||||
@ -89,6 +89,10 @@ int xp_awk_detout (xp_awk_t* awk);
|
||||
int xp_awk_parse (xp_awk_t* awk);
|
||||
int xp_awk_run (xp_awk_t* awk);
|
||||
|
||||
/* utility functions exported by awk.h */
|
||||
xp_long_t xp_awk_strtolong (const xp_char_t* str, int base);
|
||||
xp_real_t xp_awk_strtoreal (const xp_char_t* str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
SRCS = awk.c err.c tree.c tab.c map.c parse.c run.c sa.c val.c
|
||||
SRCS = awk.c err.c tree.c tab.c map.c parse.c run.c sa.c val.c misc.c
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
OUT = libxpawk.a
|
||||
|
||||
|
79
ase/awk/misc.c
Normal file
79
ase/awk/misc.c
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* $Id: misc.c,v 1.1 2006-04-04 16:03:14 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef __STAND_ALONE
|
||||
#include <xp/bas/ctype.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#endif
|
||||
|
||||
xp_long_t xp_awk_strtolong (const xp_char_t* str, int base)
|
||||
{
|
||||
xp_long_t n = 0;
|
||||
const xp_char_t* p;
|
||||
int digit, sign = 0;
|
||||
|
||||
xp_assert (base < 37);
|
||||
|
||||
p = str; while (xp_isspace(*p)) p++;
|
||||
|
||||
while (*p != XP_CHAR('\0'))
|
||||
{
|
||||
if (*p == XP_CHAR('-'))
|
||||
{
|
||||
sign = ~sign;
|
||||
p++;
|
||||
}
|
||||
else if (*p == XP_CHAR('+')) p++;
|
||||
else break;
|
||||
}
|
||||
|
||||
if (base == 0)
|
||||
{
|
||||
if (*p == XP_CHAR('0'))
|
||||
{
|
||||
p++;
|
||||
if (*p == XP_CHAR('x'))
|
||||
{
|
||||
p++; base = 16;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
while (*p != XP_CHAR('\0'))
|
||||
{
|
||||
if (*p >= XP_CHAR('0') && *p <= XP_CHAR('9'))
|
||||
digit = *p - XP_CHAR('0');
|
||||
else if (*p >= XP_CHAR('A') && *p <= XP_CHAR('Z'))
|
||||
digit = *p - XP_CHAR('A') + 10;
|
||||
else if (*p >= XP_CHAR('a') && *p <= XP_CHAR('z'))
|
||||
digit = *p - XP_CHAR('a') + 10;
|
||||
else break;
|
||||
|
||||
if (digit >= base) break;
|
||||
n = n * base + digit;
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
return (sign)? -n: n;
|
||||
}
|
||||
|
||||
xp_real_t xp_awk_strtoreal (const xp_char_t* str)
|
||||
{
|
||||
/* TODO: */
|
||||
return (xp_real_t)0.0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: parse.c,v 1.69 2006-04-04 06:26:56 bacon Exp $
|
||||
* $Id: parse.c,v 1.70 2006-04-04 16:03:14 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -1466,7 +1466,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
|
||||
|
||||
nde->type = XP_AWK_NDE_INT;
|
||||
nde->next = XP_NULL;
|
||||
nde->val = xp_strtolong (XP_STR_BUF(&awk->token.name));
|
||||
nde->val = xp_awk_strtolong (XP_STR_BUF(&awk->token.name), 0);
|
||||
|
||||
xp_assert (
|
||||
XP_STR_LEN(&awk->token.name) ==
|
||||
@ -1489,7 +1489,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
|
||||
|
||||
nde->type = XP_AWK_NDE_REAL;
|
||||
nde->next = XP_NULL;
|
||||
nde->val = xp_strtoreal (XP_STR_BUF(&awk->token.name));
|
||||
nde->val = xp_awk_strtoreal (XP_STR_BUF(&awk->token.name));
|
||||
|
||||
xp_assert (
|
||||
XP_STR_LEN(&awk->token.name) ==
|
||||
|
22
ase/awk/sa.c
22
ase/awk/sa.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sa.c,v 1.13 2006-03-31 16:35:37 bacon Exp $
|
||||
* $Id: sa.c,v 1.14 2006-04-04 16:03:14 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -66,26 +66,6 @@ int xp_strcmp (const xp_char_t* s1, const xp_char_t* s2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
xp_long_t xp_strtolong (xp_char_t* str)
|
||||
{
|
||||
xp_long_t n = 0;
|
||||
|
||||
while (xp_isdigit(*str))
|
||||
{
|
||||
n = n * 10 + (*str - XP_CHAR('0'));
|
||||
str++;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
xp_real_t xp_strtoreal (xp_char_t* str)
|
||||
{
|
||||
/* TODO: */
|
||||
return (xp_real_t)0.0;
|
||||
}
|
||||
|
||||
|
||||
int xp_printf (const xp_char_t* fmt, ...)
|
||||
{
|
||||
int n;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sa.h,v 1.18 2006-04-04 06:26:56 bacon Exp $
|
||||
* $Id: sa.h,v 1.19 2006-04-04 16:03:14 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_SA_H_
|
||||
@ -99,12 +99,6 @@ xp_size_t xp_strxncpy (
|
||||
#define xp_strcmp xp_awk_strcmp
|
||||
int xp_strcmp (const xp_char_t* s1, const xp_char_t* s2);
|
||||
|
||||
#define xp_strtolong xp_awk_strtolong
|
||||
xp_long_t xp_strtolong (xp_char_t* str);
|
||||
|
||||
#define xp_strtoreal xp_awk_strtoreal
|
||||
xp_real_t xp_strtoreal (xp_char_t* str);
|
||||
|
||||
#define xp_printf xp_awk_printf
|
||||
int xp_printf (const xp_char_t* fmt, ...);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user