*** empty log message ***
This commit is contained in:
parent
d44d550ff8
commit
5754c542db
@ -1,14 +1,9 @@
|
||||
/*
|
||||
* $Id: awk.c,v 1.76 2006-09-01 04:03:28 bacon Exp $
|
||||
* $Id: awk.c,v 1.77 2006-09-22 14:04:25 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#endif
|
||||
|
||||
static void __free_afn (void* awk, void* afn);
|
||||
|
||||
xp_awk_t* xp_awk_open (xp_awk_syscas_t* syscas)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h,v 1.116 2006-09-14 06:40:06 bacon Exp $
|
||||
* $Id: awk.h,v 1.117 2006-09-22 14:04:25 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_AWK_H_
|
||||
@ -74,6 +74,8 @@ struct xp_awk_syscas_t
|
||||
xp_cint_t (*to_upper) (xp_cint_t c);
|
||||
xp_cint_t (*to_lower) (xp_cint_t c);
|
||||
|
||||
int (*sprintf) (xp_char_t* buf, xp_size_t size, xp_char_t* fmt, ...);
|
||||
|
||||
void* custom_data;
|
||||
};
|
||||
|
||||
@ -386,12 +388,6 @@ xp_char_t* xp_awk_strxnstr (
|
||||
const xp_char_t* str, xp_size_t strsz,
|
||||
const xp_char_t* sub, xp_size_t subsz);
|
||||
|
||||
int xp_awk_printf (xp_awk_t* awk, const xp_char_t* fmt, ...);
|
||||
|
||||
int xp_awk_sprintf (
|
||||
xp_awk_t* awk, xp_char_t* buf,
|
||||
xp_size_t size, const xp_char_t* fmt, ...);
|
||||
|
||||
/* utility functions to convert an error number ot a string */
|
||||
const xp_char_t* xp_awk_geterrstr (int errnum);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk_i.h,v 1.57 2006-09-09 04:52:40 bacon Exp $
|
||||
* $Id: awk_i.h,v 1.58 2006-09-22 14:04:25 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_AWKI_H_
|
||||
@ -18,7 +18,6 @@ typedef struct xp_awk_tree_t xp_awk_tree_t;
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define xp_assert assert
|
||||
@ -28,12 +27,9 @@ typedef struct xp_awk_tree_t xp_awk_tree_t;
|
||||
#define xp_memmove(dst,src,len) memmove(dst,src,len)
|
||||
#define xp_memcmp(src1,src2,len) memcmp(src1,src2,len)
|
||||
#define xp_memzero(dst,len) memset(dst,0,len)
|
||||
|
||||
#define xp_va_start(pvar,param) va_start(pvar,param)
|
||||
#define xp_va_list va_list
|
||||
#define xp_va_end(pvar) va_end(pvar)
|
||||
#define xp_va_arg(pvar,type) va_arg(pvar,type)
|
||||
|
||||
#else
|
||||
#include <xp/bas/memory.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#endif
|
||||
|
||||
#include <xp/awk/str.h>
|
||||
@ -247,7 +243,18 @@ struct xp_awk_run_t
|
||||
void* rs;
|
||||
void* fs;
|
||||
int ignorecase;
|
||||
} rex;
|
||||
|
||||
struct
|
||||
{
|
||||
xp_char_t* ptr;
|
||||
xp_size_t len;
|
||||
} ofs;
|
||||
struct
|
||||
{
|
||||
xp_char_t* ptr;
|
||||
xp_size_t len;
|
||||
} subsep;
|
||||
} global;
|
||||
|
||||
/* extio chain */
|
||||
struct
|
||||
|
@ -1,13 +1,9 @@
|
||||
/*
|
||||
* $Id: extio.c,v 1.47 2006-09-10 15:50:34 bacon Exp $
|
||||
* $Id: extio.c,v 1.48 2006-09-22 14:04:25 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/assert.h>
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
__MASK_READ = 0x0100,
|
||||
@ -287,12 +283,12 @@ int xp_awk_readextio (
|
||||
const xp_char_t* match_ptr;
|
||||
xp_size_t match_len;
|
||||
|
||||
xp_assert (run->rex.rs != XP_NULL);
|
||||
xp_assert (run->global.rs != XP_NULL);
|
||||
|
||||
/* TODO: safematchrex */
|
||||
n = xp_awk_matchrex (
|
||||
run->awk, run->rex.rs,
|
||||
((run->rex.ignorecase)? XP_AWK_REX_IGNORECASE: 0),
|
||||
run->awk, run->global.rs,
|
||||
((run->global.ignorecase)? XP_AWK_REX_IGNORECASE: 0),
|
||||
XP_AWK_STR_BUF(buf), XP_AWK_STR_LEN(buf),
|
||||
&match_ptr, &match_len, &run->errnum);
|
||||
if (n == -1)
|
||||
|
@ -1,13 +1,9 @@
|
||||
/*
|
||||
* $Id: func.c,v 1.52 2006-09-16 12:58:38 bacon Exp $
|
||||
* $Id: func.c,v 1.53 2006-09-22 14:04:25 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/assert.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <tchar.h>
|
||||
#include <math.h>
|
||||
@ -586,7 +582,7 @@ static int __bfn_split (xp_awk_t* awk, void* run)
|
||||
|
||||
if (fs_len > 1)
|
||||
{
|
||||
fs_rex = ((xp_awk_run_t*)run)->rex.fs;
|
||||
fs_rex = ((xp_awk_run_t*)run)->global.fs;
|
||||
fs_rex_free = XP_NULL;
|
||||
}
|
||||
}
|
||||
@ -938,7 +934,7 @@ static int __substitute (xp_awk_t* awk, void* run, xp_long_t max_count)
|
||||
}
|
||||
}
|
||||
|
||||
opt = (((xp_awk_run_t*)run)->rex.ignorecase)? XP_AWK_REX_IGNORECASE: 0;
|
||||
opt = (((xp_awk_run_t*)run)->global.ignorecase)? XP_AWK_REX_IGNORECASE: 0;
|
||||
cur_ptr = a2_ptr;
|
||||
cur_len = a2_len;
|
||||
sub_count = 0;
|
||||
|
@ -1,13 +1,9 @@
|
||||
/*
|
||||
* $Id: map.c,v 1.24 2006-09-01 07:18:39 bacon Exp $
|
||||
* $Id: map.c,v 1.25 2006-09-22 14:04:25 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/assert.h>
|
||||
#endif
|
||||
|
||||
/* TODO: improve the entire map routines.
|
||||
support automatic bucket resizing and remaping, etc. */
|
||||
|
||||
|
232
ase/awk/misc.c
232
ase/awk/misc.c
@ -1,22 +1,9 @@
|
||||
/*
|
||||
* $Id: misc.c,v 1.20 2006-09-10 16:04:34 bacon Exp $
|
||||
* $Id: misc.c,v 1.21 2006-09-22 14:04:25 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/assert.h>
|
||||
#include <xp/bas/stdarg.h>
|
||||
#endif
|
||||
|
||||
static int __vprintf (
|
||||
xp_awk_t* awk, const xp_char_t* fmt, xp_va_list ap);
|
||||
static int __vsprintf (
|
||||
xp_awk_t* awk, xp_char_t* buf, xp_size_t size,
|
||||
const xp_char_t* fmt, xp_va_list ap);
|
||||
|
||||
static xp_char_t* __adjust_format (xp_awk_t* awk, const xp_char_t* format);
|
||||
|
||||
xp_long_t xp_awk_strtolong (
|
||||
xp_awk_t* awk, const xp_char_t* str,
|
||||
int base, const xp_char_t** endptr)
|
||||
@ -622,7 +609,7 @@ xp_char_t* xp_awk_strxntok (
|
||||
{
|
||||
/* each token is delimited by one of charaters
|
||||
* in the delimeter set "delim". */
|
||||
if (run->rex.ignorecase)
|
||||
if (run->global.ignorecase)
|
||||
{
|
||||
while (p < end)
|
||||
{
|
||||
@ -657,7 +644,7 @@ xp_char_t* xp_awk_strxntok (
|
||||
* in the delimeter set "delim". however, all space characters
|
||||
* surrounding the token are removed */
|
||||
while (p < end && XP_AWK_ISSPACE(run->awk,*p)) p++;
|
||||
if (run->rex.ignorecase)
|
||||
if (run->global.ignorecase)
|
||||
{
|
||||
while (p < end)
|
||||
{
|
||||
@ -730,7 +717,7 @@ xp_char_t* xp_awk_strxntokbyrex (
|
||||
{
|
||||
n = xp_awk_matchrex (
|
||||
run->awk, rex,
|
||||
((run->rex.ignorecase)? XP_AWK_REX_IGNORECASE: 0),
|
||||
((run->global.ignorecase)? XP_AWK_REX_IGNORECASE: 0),
|
||||
ptr, left, (const xp_char_t**)&match_ptr, &match_len,
|
||||
errnum);
|
||||
if (n == -1) return XP_NULL;
|
||||
@ -809,215 +796,4 @@ exit_loop:
|
||||
}
|
||||
}
|
||||
|
||||
int xp_awk_printf (xp_awk_t* awk, const xp_char_t* fmt, ...)
|
||||
{
|
||||
int n;
|
||||
xp_va_list ap;
|
||||
|
||||
xp_va_start (ap, fmt);
|
||||
n = __vprintf (awk, fmt, ap);
|
||||
xp_va_end (ap);
|
||||
return n;
|
||||
}
|
||||
|
||||
static int __vprintf (xp_awk_t* awk, const xp_char_t* fmt, xp_va_list ap)
|
||||
{
|
||||
int n;
|
||||
xp_char_t* nf = __adjust_format (awk, fmt);
|
||||
if (nf == XP_NULL) return -1;
|
||||
|
||||
#ifdef XP_CHAR_IS_MCHAR
|
||||
n = vprintf (nf, ap);
|
||||
#else
|
||||
n = vwprintf (nf, ap);
|
||||
#endif
|
||||
|
||||
XP_AWK_FREE (awk, nf);
|
||||
return n;
|
||||
}
|
||||
|
||||
int xp_awk_sprintf (
|
||||
xp_awk_t* awk, xp_char_t* buf, xp_size_t size,
|
||||
const xp_char_t* fmt, ...)
|
||||
{
|
||||
int n;
|
||||
xp_va_list ap;
|
||||
|
||||
xp_va_start (ap, fmt);
|
||||
n = __vsprintf (awk, buf, size, fmt, ap);
|
||||
xp_va_end (ap);
|
||||
return n;
|
||||
}
|
||||
|
||||
static int __vsprintf (
|
||||
xp_awk_t* awk, xp_char_t* buf, xp_size_t size,
|
||||
const xp_char_t* fmt, xp_va_list ap)
|
||||
{
|
||||
int n;
|
||||
xp_char_t* nf = __adjust_format (awk, fmt);
|
||||
if (nf == XP_NULL) return -1;
|
||||
|
||||
#if defined(dos) || defined(__dos)
|
||||
n = vsprintf (buf, nf, ap); /* TODO: write your own vsnprintf */
|
||||
#elif defined(XP_CHAR_IS_MCHAR)
|
||||
n = vsnprintf (buf, size, nf, ap);
|
||||
#elif defined(_WIN32)
|
||||
n = _vsnwprintf (buf, size, nf, ap);
|
||||
#else
|
||||
n = vswprintf (buf, size, nf, ap);
|
||||
#endif
|
||||
XP_AWK_FREE (awk, nf);
|
||||
return n;
|
||||
}
|
||||
|
||||
#define MOD_SHORT 1
|
||||
#define MOD_LONG 2
|
||||
#define MOD_LONGLONG 3
|
||||
|
||||
#define ADDC(str,c) \
|
||||
do { \
|
||||
if (xp_awk_str_ccat(&str, c) == (xp_size_t)-1) { \
|
||||
xp_awk_str_close (&str); \
|
||||
return XP_NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static xp_char_t* __adjust_format (xp_awk_t* awk, const xp_char_t* format)
|
||||
{
|
||||
const xp_char_t* fp = format;
|
||||
xp_char_t* tmp;
|
||||
xp_awk_str_t str;
|
||||
xp_char_t ch;
|
||||
int modifier;
|
||||
|
||||
if (xp_awk_str_open (&str, 256, awk) == XP_NULL) return XP_NULL;
|
||||
|
||||
while (*fp != XP_T('\0'))
|
||||
{
|
||||
while (*fp != XP_T('\0') && *fp != XP_T('%'))
|
||||
{
|
||||
ADDC (str, *fp++);
|
||||
}
|
||||
|
||||
if (*fp == XP_T('\0')) break;
|
||||
xp_assert (*fp == XP_T('%'));
|
||||
|
||||
ch = *fp++;
|
||||
ADDC (str, ch); /* add % */
|
||||
|
||||
ch = *fp++;
|
||||
|
||||
/* flags */
|
||||
for (;;)
|
||||
{
|
||||
if (ch == XP_T(' ') || ch == XP_T('+') ||
|
||||
ch == XP_T('-') || ch == XP_T('#'))
|
||||
{
|
||||
ADDC (str, ch);
|
||||
}
|
||||
else if (ch == XP_T('0'))
|
||||
{
|
||||
ADDC (str, ch);
|
||||
ch = *fp++;
|
||||
break;
|
||||
}
|
||||
else break;
|
||||
|
||||
ch = *fp++;
|
||||
}
|
||||
|
||||
/* check the width */
|
||||
if (ch == XP_T('*')) ADDC (str, ch);
|
||||
else
|
||||
{
|
||||
while (XP_AWK_ISDIGIT (awk, ch))
|
||||
{
|
||||
ADDC (str, ch);
|
||||
ch = *fp++;
|
||||
}
|
||||
}
|
||||
|
||||
/* precision */
|
||||
if (ch == XP_T('.'))
|
||||
{
|
||||
ADDC (str, ch);
|
||||
ch = *fp++;
|
||||
|
||||
if (ch == XP_T('*')) ADDC (str, ch);
|
||||
else
|
||||
{
|
||||
while (XP_AWK_ISDIGIT (awk, ch))
|
||||
{
|
||||
ADDC (str, ch);
|
||||
ch = *fp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* modifier */
|
||||
for (modifier = 0;;)
|
||||
{
|
||||
if (ch == XP_T('h')) modifier = MOD_SHORT;
|
||||
else if (ch == XP_T('l'))
|
||||
{
|
||||
modifier = (modifier == MOD_LONG)? MOD_LONGLONG: MOD_LONG;
|
||||
}
|
||||
else break;
|
||||
ch = *fp++;
|
||||
}
|
||||
|
||||
|
||||
/* type */
|
||||
if (ch == XP_T('%')) ADDC (str, ch);
|
||||
else if (ch == XP_T('c') || ch == XP_T('s'))
|
||||
{
|
||||
#if !defined(XP_CHAR_IS_MCHAR) && !defined(_WIN32)
|
||||
ADDC (str, 'l');
|
||||
#endif
|
||||
ADDC (str, ch);
|
||||
}
|
||||
else if (ch == XP_T('C') || ch == XP_T('S'))
|
||||
{
|
||||
#ifdef _WIN32
|
||||
ADDC (str, ch);
|
||||
#else
|
||||
#ifdef XP_CHAR_IS_MCHAR
|
||||
ADDC (str, 'l');
|
||||
#endif
|
||||
ADDC (str, XP_AWK_TOLOWER(awk,ch));
|
||||
#endif
|
||||
}
|
||||
else if (ch == XP_T('d') || ch == XP_T('i') ||
|
||||
ch == XP_T('o') || ch == XP_T('u') ||
|
||||
ch == XP_T('x') || ch == XP_T('X'))
|
||||
{
|
||||
if (modifier == MOD_SHORT)
|
||||
{
|
||||
ADDC (str, 'h');
|
||||
}
|
||||
else if (modifier == MOD_LONG)
|
||||
{
|
||||
ADDC (str, 'l');
|
||||
}
|
||||
else if (modifier == MOD_LONGLONG)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__LCC__)
|
||||
ADDC (str, 'I');
|
||||
ADDC (str, '6');
|
||||
ADDC (str, '4');
|
||||
#else
|
||||
ADDC (str, 'l');
|
||||
ADDC (str, 'l');
|
||||
#endif
|
||||
}
|
||||
ADDC (str, ch);
|
||||
}
|
||||
else if (ch == XP_T('\0')) break;
|
||||
else ADDC (str, ch);
|
||||
}
|
||||
|
||||
tmp = XP_AWK_STR_BUF(&str);
|
||||
xp_awk_str_forfeit (&str);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,9 @@
|
||||
/*
|
||||
* $Id: parse.c,v 1.180 2006-09-11 14:29:22 bacon Exp $
|
||||
* $Id: parse.c,v 1.181 2006-09-22 14:04:25 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
TOKEN_EOF,
|
||||
|
@ -1,13 +1,11 @@
|
||||
/*
|
||||
* $Id: rex.c,v 1.29 2006-09-10 15:50:34 bacon Exp $
|
||||
* $Id: rex.c,v 1.30 2006-09-22 14:04:26 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#include <xp/bas/ctype.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
168
ase/awk/run.c
168
ase/awk/run.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.c,v 1.203 2006-09-13 14:16:13 bacon Exp $
|
||||
* $Id: run.c,v 1.204 2006-09-22 14:04:26 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -9,7 +9,6 @@
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/assert.h>
|
||||
#include <xp/bas/memory.h>
|
||||
#endif
|
||||
|
||||
#define DEF_BUF_CAPA 256
|
||||
@ -41,6 +40,9 @@ enum
|
||||
#define PANIC_I(run,code) \
|
||||
do { (run)->errnum = (code); return -1; } while (0)
|
||||
|
||||
#define DEFAULT_OFS XP_T(" ")
|
||||
#define DEFAULT_SUBSEP XP_T("\034")
|
||||
|
||||
static void __add_run (xp_awk_t* awk, xp_awk_run_t* run);
|
||||
static void __del_run (xp_awk_t* awk, xp_awk_run_t* run);
|
||||
|
||||
@ -272,13 +274,13 @@ int xp_awk_setglobal (void* run, xp_size_t idx, xp_awk_val_t* val)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (r->rex.rs != XP_NULL)
|
||||
if (r->global.rs != XP_NULL)
|
||||
{
|
||||
xp_awk_freerex (
|
||||
((xp_awk_run_t*)run)->awk,
|
||||
r->rex.rs);
|
||||
r->global.rs);
|
||||
}
|
||||
r->rex.rs = rex;
|
||||
r->global.rs = rex;
|
||||
}
|
||||
|
||||
if (val->type != XP_AWK_VAL_STR)
|
||||
@ -321,13 +323,13 @@ int xp_awk_setglobal (void* run, xp_size_t idx, xp_awk_val_t* val)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (r->rex.fs != XP_NULL)
|
||||
if (r->global.fs != XP_NULL)
|
||||
{
|
||||
xp_awk_freerex (
|
||||
((xp_awk_run_t*)run)->awk,
|
||||
r->rex.fs);
|
||||
r->global.fs);
|
||||
}
|
||||
r->rex.fs = rex;
|
||||
r->global.fs = rex;
|
||||
}
|
||||
|
||||
if (val->type != XP_AWK_VAL_STR)
|
||||
@ -342,11 +344,11 @@ int xp_awk_setglobal (void* run, xp_size_t idx, xp_awk_val_t* val)
|
||||
(val->type == XP_AWK_VAL_STR &&
|
||||
((xp_awk_val_str_t*)val)->len == 0))
|
||||
{
|
||||
((xp_awk_run_t*)run)->rex.ignorecase = 0;
|
||||
((xp_awk_run_t*)run)->global.ignorecase = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
((xp_awk_run_t*)run)->rex.ignorecase = 1;
|
||||
((xp_awk_run_t*)run)->global.ignorecase = 1;
|
||||
}
|
||||
}
|
||||
else if (idx == XP_AWK_GLOBAL_NF)
|
||||
@ -355,7 +357,6 @@ int xp_awk_setglobal (void* run, xp_size_t idx, xp_awk_val_t* val)
|
||||
xp_long_t lv;
|
||||
xp_real_t rv;
|
||||
|
||||
/* TODO: need to recompute $0, etc */
|
||||
n = xp_awk_valtonum (run, val, &lv, &rv);
|
||||
if (n == -1) return -1;
|
||||
if (n == 1) lv = (xp_long_t)rv;
|
||||
@ -365,9 +366,33 @@ int xp_awk_setglobal (void* run, xp_size_t idx, xp_awk_val_t* val)
|
||||
if (__shorten_record (r, (xp_size_t)lv) == -1) return -1;
|
||||
}
|
||||
}
|
||||
else if (idx == XP_AWK_GLOBAL_OFS)
|
||||
{
|
||||
xp_char_t* ofs_ptr;
|
||||
xp_size_t ofs_len;
|
||||
|
||||
xp_awk_refdownval (run, old);
|
||||
STACK_GLOBAL((xp_awk_run_t*)run,idx) = val;
|
||||
ofs_ptr = xp_awk_valtostr (
|
||||
run, val, xp_true, XP_NULL, &ofs_len);
|
||||
if (ofs_ptr == XP_NULL) return -1;
|
||||
|
||||
r->global.ofs.ptr = ofs_ptr;
|
||||
r->global.ofs.len = ofs_len;
|
||||
}
|
||||
else if (idx == XP_AWK_GLOBAL_SUBSEP)
|
||||
{
|
||||
xp_char_t* subsep_ptr;
|
||||
xp_size_t subsep_len;
|
||||
|
||||
subsep_ptr = xp_awk_valtostr (
|
||||
run, val, xp_true, XP_NULL, &subsep_len);
|
||||
if (subsep_ptr == XP_NULL) return -1;
|
||||
|
||||
r->global.subsep.ptr = subsep_ptr;
|
||||
r->global.subsep.len = subsep_len;
|
||||
}
|
||||
|
||||
xp_awk_refdownval (r, old);
|
||||
STACK_GLOBAL(r,idx) = val;
|
||||
xp_awk_refupval (val);
|
||||
|
||||
return 0;
|
||||
@ -615,9 +640,13 @@ static int __init_run (
|
||||
run->extio.handler[XP_AWK_EXTIO_CONSOLE] = runios->console;
|
||||
run->extio.chain = XP_NULL;
|
||||
|
||||
run->rex.rs = XP_NULL;
|
||||
run->rex.fs = XP_NULL;
|
||||
run->rex.ignorecase = 0;
|
||||
run->global.rs = XP_NULL;
|
||||
run->global.fs = XP_NULL;
|
||||
run->global.ignorecase = 0;
|
||||
run->global.ofs.ptr = DEFAULT_OFS;
|
||||
run->global.ofs.len = xp_awk_strlen(DEFAULT_OFS);
|
||||
run->global.subsep.ptr = DEFAULT_SUBSEP;
|
||||
run->global.subsep.len = xp_awk_strlen(DEFAULT_SUBSEP);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -631,15 +660,31 @@ static void __deinit_run (xp_awk_run_t* run)
|
||||
xp_awk_clearextio (run);
|
||||
xp_assert (run->extio.chain == XP_NULL);
|
||||
|
||||
if (run->rex.rs != XP_NULL)
|
||||
if (run->global.rs != XP_NULL)
|
||||
{
|
||||
XP_AWK_FREE (run->awk, run->rex.rs);
|
||||
run->rex.rs = XP_NULL;
|
||||
XP_AWK_FREE (run->awk, run->global.rs);
|
||||
run->global.rs = XP_NULL;
|
||||
}
|
||||
if (run->rex.fs != XP_NULL)
|
||||
if (run->global.fs != XP_NULL)
|
||||
{
|
||||
XP_AWK_FREE (run->awk, run->rex.fs);
|
||||
run->rex.fs = XP_NULL;
|
||||
XP_AWK_FREE (run->awk, run->global.fs);
|
||||
run->global.fs = XP_NULL;
|
||||
}
|
||||
|
||||
if (run->global.ofs.ptr != XP_NULL &&
|
||||
run->global.ofs.ptr != DEFAULT_SUBSEP)
|
||||
{
|
||||
XP_AWK_FREE (run->awk, run->global.ofs.ptr);
|
||||
run->global.ofs.ptr = XP_NULL;
|
||||
run->global.ofs.len = 0;
|
||||
}
|
||||
|
||||
if (run->global.subsep.ptr != XP_NULL &&
|
||||
run->global.subsep.ptr != DEFAULT_SUBSEP)
|
||||
{
|
||||
XP_AWK_FREE (run->awk, run->global.subsep.ptr);
|
||||
run->global.subsep.ptr = XP_NULL;
|
||||
run->global.subsep.len = 0;
|
||||
}
|
||||
|
||||
/* destroy input record. __clear_record should be called
|
||||
@ -1947,7 +1992,7 @@ static xp_awk_val_t* __eval_expression (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
||||
n = xp_awk_matchrex (
|
||||
((xp_awk_run_t*)run)->awk,
|
||||
((xp_awk_val_rex_t*)v)->code,
|
||||
((((xp_awk_run_t*)run)->rex.ignorecase)? XP_AWK_REX_IGNORECASE: 0),
|
||||
((((xp_awk_run_t*)run)->global.ignorecase)? XP_AWK_REX_IGNORECASE: 0),
|
||||
((xp_awk_val_str_t*)run->inrec.d0)->buf,
|
||||
((xp_awk_val_str_t*)run->inrec.d0)->len,
|
||||
XP_NULL, XP_NULL, &errnum);
|
||||
@ -2778,7 +2823,7 @@ static xp_awk_val_t* __eval_binop_eq (
|
||||
else if (left->type == XP_AWK_VAL_STR &&
|
||||
right->type == XP_AWK_VAL_STR)
|
||||
{
|
||||
if (run->rex.ignorecase)
|
||||
if (run->global.ignorecase)
|
||||
{
|
||||
r = xp_awk_strxncasecmp (
|
||||
run->awk,
|
||||
@ -2845,7 +2890,7 @@ static xp_awk_val_t* __eval_binop_ne (
|
||||
else if (left->type == XP_AWK_VAL_STR &&
|
||||
right->type == XP_AWK_VAL_STR)
|
||||
{
|
||||
if (run->rex.ignorecase)
|
||||
if (run->global.ignorecase)
|
||||
{
|
||||
r = xp_awk_strxncasecmp (
|
||||
run->awk,
|
||||
@ -2906,7 +2951,7 @@ static xp_awk_val_t* __eval_binop_gt (
|
||||
else if (left->type == XP_AWK_VAL_STR &&
|
||||
right->type == XP_AWK_VAL_STR)
|
||||
{
|
||||
if (run->rex.ignorecase)
|
||||
if (run->global.ignorecase)
|
||||
{
|
||||
r = xp_awk_strxncasecmp (
|
||||
run->awk,
|
||||
@ -2967,7 +3012,7 @@ static xp_awk_val_t* __eval_binop_ge (
|
||||
else if (left->type == XP_AWK_VAL_STR &&
|
||||
right->type == XP_AWK_VAL_STR)
|
||||
{
|
||||
if (run->rex.ignorecase)
|
||||
if (run->global.ignorecase)
|
||||
{
|
||||
r = xp_awk_strxncasecmp (
|
||||
run->awk,
|
||||
@ -3028,7 +3073,7 @@ static xp_awk_val_t* __eval_binop_lt (
|
||||
else if (left->type == XP_AWK_VAL_STR &&
|
||||
right->type == XP_AWK_VAL_STR)
|
||||
{
|
||||
if (run->rex.ignorecase)
|
||||
if (run->global.ignorecase)
|
||||
{
|
||||
r = xp_awk_strxncasecmp (
|
||||
run->awk,
|
||||
@ -3089,7 +3134,7 @@ static xp_awk_val_t* __eval_binop_le (
|
||||
else if (left->type == XP_AWK_VAL_STR &&
|
||||
right->type == XP_AWK_VAL_STR)
|
||||
{
|
||||
if (run->rex.ignorecase)
|
||||
if (run->global.ignorecase)
|
||||
{
|
||||
r = xp_awk_strxncasecmp (
|
||||
run->awk,
|
||||
@ -3486,7 +3531,7 @@ static xp_awk_val_t* __eval_binop_match0 (
|
||||
{
|
||||
n = xp_awk_matchrex (
|
||||
run->awk, rex_code,
|
||||
((run->rex.ignorecase)? XP_AWK_REX_IGNORECASE: 0),
|
||||
((run->global.ignorecase)? XP_AWK_REX_IGNORECASE: 0),
|
||||
((xp_awk_val_str_t*)left)->buf,
|
||||
((xp_awk_val_str_t*)left)->len,
|
||||
XP_NULL, XP_NULL, &errnum);
|
||||
@ -3517,7 +3562,7 @@ static xp_awk_val_t* __eval_binop_match0 (
|
||||
|
||||
n = xp_awk_matchrex (
|
||||
run->awk, rex_code,
|
||||
((run->rex.ignorecase)? XP_AWK_REX_IGNORECASE: 0),
|
||||
((run->global.ignorecase)? XP_AWK_REX_IGNORECASE: 0),
|
||||
str, len, XP_NULL, XP_NULL, &errnum);
|
||||
if (n == -1)
|
||||
{
|
||||
@ -4908,7 +4953,7 @@ static int __split_record (xp_awk_run_t* run)
|
||||
else
|
||||
{
|
||||
p = xp_awk_strxntokbyrex (run, p, len,
|
||||
run->rex.fs, &tok, &tok_len, &errnum);
|
||||
run->global.fs, &tok, &tok_len, &errnum);
|
||||
if (p == XP_NULL && errnum != XP_AWK_ENOERR)
|
||||
{
|
||||
if (fs_free != XP_NULL)
|
||||
@ -4963,7 +5008,7 @@ static int __split_record (xp_awk_run_t* run)
|
||||
else
|
||||
{
|
||||
p = xp_awk_strxntokbyrex (run, p, len,
|
||||
run->rex.fs, &tok, &tok_len, &errnum);
|
||||
run->global.fs, &tok, &tok_len, &errnum);
|
||||
if (p == XP_NULL && errnum != XP_AWK_ENOERR)
|
||||
{
|
||||
if (fs_free != XP_NULL)
|
||||
@ -5042,8 +5087,6 @@ static int __recomp_record_fields (
|
||||
xp_awk_run_t* run, xp_size_t lv, xp_char_t* str, xp_size_t len)
|
||||
{
|
||||
xp_awk_val_t* v;
|
||||
xp_char_t* ofs_free = XP_NULL, * ofs;
|
||||
xp_size_t ofs_len;
|
||||
xp_size_t max, i, nflds;
|
||||
|
||||
/* recomposes the record and the fields when $N has been assigned
|
||||
@ -5097,45 +5140,15 @@ static int __recomp_record_fields (
|
||||
|
||||
xp_awk_str_clear (&run->inrec.line);
|
||||
|
||||
if (max > 1)
|
||||
{
|
||||
/* gets the value of OFS to use it as a field separator */
|
||||
|
||||
v = STACK_GLOBAL(run, XP_AWK_GLOBAL_OFS);
|
||||
xp_awk_refupval (v);
|
||||
|
||||
if (v->type == XP_AWK_VAL_NIL)
|
||||
{
|
||||
/* OFS not set */
|
||||
ofs = XP_T(" ");
|
||||
ofs_len = 1;
|
||||
}
|
||||
else if (v->type == XP_AWK_VAL_STR)
|
||||
{
|
||||
ofs = ((xp_awk_val_str_t*)v)->buf;
|
||||
ofs_len = ((xp_awk_val_str_t*)v)->len;
|
||||
}
|
||||
else
|
||||
{
|
||||
ofs = xp_awk_valtostr (
|
||||
run, v, xp_true, XP_NULL, &ofs_len);
|
||||
if (ofs == XP_NULL) return -1;
|
||||
|
||||
ofs_free = ofs;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < max; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
if (xp_awk_str_ncat (
|
||||
&run->inrec.line,
|
||||
ofs, ofs_len) == (xp_size_t)-1)
|
||||
run->global.ofs.ptr,
|
||||
run->global.ofs.len) == (xp_size_t)-1)
|
||||
{
|
||||
if (ofs_free != XP_NULL)
|
||||
XP_AWK_FREE (run->awk, ofs_free);
|
||||
if (max > 1) xp_awk_refdownval (run, v);
|
||||
run->errnum = XP_AWK_ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
@ -5153,9 +5166,6 @@ static int __recomp_record_fields (
|
||||
if (xp_awk_str_ncat (
|
||||
&run->inrec.line, str, len) == (xp_size_t)-1)
|
||||
{
|
||||
if (ofs_free != XP_NULL)
|
||||
XP_AWK_FREE (run->awk, ofs_free);
|
||||
if (max > 1) xp_awk_refdownval (run, v);
|
||||
run->errnum = XP_AWK_ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
@ -5163,9 +5173,6 @@ static int __recomp_record_fields (
|
||||
tmp = xp_awk_makestrval (run, str,len);
|
||||
if (tmp == XP_NULL)
|
||||
{
|
||||
if (ofs_free != XP_NULL)
|
||||
XP_AWK_FREE (run->awk, ofs_free);
|
||||
if (max > 1) xp_awk_refdownval (run, v);
|
||||
run->errnum = XP_AWK_ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
@ -5187,9 +5194,6 @@ static int __recomp_record_fields (
|
||||
if (xp_awk_str_cat (
|
||||
&run->inrec.line, XP_T("")) == (xp_size_t)-1)
|
||||
{
|
||||
if (ofs_free != XP_NULL)
|
||||
XP_AWK_FREE (run->awk, ofs_free);
|
||||
if (max > 1) xp_awk_refdownval (run, v);
|
||||
run->errnum = XP_AWK_ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
@ -5216,18 +5220,12 @@ static int __recomp_record_fields (
|
||||
if (xp_awk_str_ncat (&run->inrec.line,
|
||||
tmp->buf, tmp->len) == (xp_size_t)-1)
|
||||
{
|
||||
if (ofs_free != XP_NULL)
|
||||
XP_AWK_FREE (run->awk, ofs_free);
|
||||
if (max > 1) xp_awk_refdownval (run, v);
|
||||
run->errnum = XP_AWK_ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ofs_free != XP_NULL) XP_AWK_FREE (run->awk, ofs_free);
|
||||
if (max > 1) xp_awk_refdownval (run, v);
|
||||
|
||||
v = STACK_GLOBAL(run, XP_AWK_GLOBAL_NF);
|
||||
xp_assert (v->type == XP_AWK_VAL_INT);
|
||||
if (((xp_awk_val_int_t*)v)->val != max)
|
||||
@ -5385,9 +5383,10 @@ static xp_char_t* __idxnde_to_str (
|
||||
|
||||
xp_awk_refupval (idx);
|
||||
|
||||
/* TODO: configurable index seperator, not just a comma */
|
||||
if (XP_AWK_STR_LEN(&idxstr) > 0 &&
|
||||
xp_awk_str_cat (&idxstr, XP_T(",")) == (xp_size_t)-1)
|
||||
xp_awk_str_ncat (&idxstr,
|
||||
run->global.subsep.ptr,
|
||||
run->global.subsep.len) == (xp_size_t)-1)
|
||||
{
|
||||
xp_awk_refdownval (run, idx);
|
||||
xp_awk_str_close (&idxstr);
|
||||
@ -5413,4 +5412,3 @@ static xp_char_t* __idxnde_to_str (
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* $Id: str.c,v 1.4 2006-09-10 15:50:34 bacon Exp $
|
||||
* $Id: str.c,v 1.5 2006-09-22 14:04:26 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#endif
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
/*
|
||||
* $Id: tab.c,v 1.16 2006-09-01 07:18:40 bacon Exp $
|
||||
* $Id: tab.c,v 1.17 2006-09-22 14:04:26 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#endif
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
/*
|
||||
* $Id: tree.c,v 1.74 2006-09-11 14:29:22 bacon Exp $
|
||||
* $Id: tree.c,v 1.75 2006-09-22 14:04:26 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#include <xp/bas/stdio.h>
|
||||
#endif
|
||||
|
||||
static const xp_char_t* __assop_str[] =
|
||||
@ -242,9 +240,17 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
||||
case XP_AWK_NDE_REAL:
|
||||
{
|
||||
xp_char_t tmp[128];
|
||||
xp_awk_sprintf (
|
||||
awk, tmp, xp_countof(tmp), XP_T("%Lf"),
|
||||
#if (XP_SIZEOF_LONG_DOUBLE != 0)
|
||||
awk->syscas->sprintf (
|
||||
tmp, xp_countof(tmp), XP_T("%Lf"),
|
||||
(long double)((xp_awk_nde_real_t*)nde)->val);
|
||||
#elif (XP_SIZEOF_DOUBLE != 0)
|
||||
awk->syscas->sprintf (
|
||||
tmp, xp_countof(tmp), XP_T("%f"),
|
||||
(double)((xp_awk_nde_real_t*)nde)->val);
|
||||
#else
|
||||
#error unsupported floating-point data type
|
||||
#endif
|
||||
PUT_SRCSTR (awk, tmp);
|
||||
break;
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
/*
|
||||
* $Id: val.c,v 1.59 2006-09-01 07:18:40 bacon Exp $
|
||||
* $Id: val.c,v 1.60 2006-09-22 14:04:26 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef XP_AWK_STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
#include <xp/bas/assert.h>
|
||||
#include <xp/bas/stdio.h>
|
||||
#endif
|
||||
|
||||
static xp_awk_val_nil_t __awk_nil = { XP_AWK_VAL_NIL, 0 };
|
||||
@ -491,12 +489,12 @@ xp_char_t* xp_awk_valtostr (
|
||||
xp_char_t tbuf[256], * tmp;
|
||||
|
||||
#if (XP_SIZEOF_LONG_DOUBLE != 0)
|
||||
xp_awk_sprintf (
|
||||
run->awk, tbuf, xp_countof(tbuf), XP_T("%Lf"),
|
||||
run->awk->syscas->sprintf (
|
||||
tbuf, xp_countof(tbuf), XP_T("%Lf"),
|
||||
(long double)((xp_awk_val_real_t*)v)->val);
|
||||
#elif (XP_SIZEOF_DOUBLE != 0)
|
||||
xp_awk_sprintf (
|
||||
run->awk, tbuf, xp_countof(tbuf), XP_T("%f"),
|
||||
run->awk->syscas->sprintf (
|
||||
tbuf, xp_countof(tbuf), XP_T("%f"),
|
||||
(double)((xp_awk_val_real_t*)v)->val);
|
||||
#else
|
||||
#error unsupported floating-point data type
|
||||
|
@ -1,8 +1,9 @@
|
||||
/*
|
||||
* $Id: awk.c,v 1.89 2006-09-08 14:51:15 bacon Exp $
|
||||
* $Id: awk.c,v 1.90 2006-09-22 14:05:30 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/bas/stdio.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
@ -670,6 +671,7 @@ static int __main (int argc, xp_char_t* argv[])
|
||||
syscas.to_upper = towupper;
|
||||
syscas.to_lower = towlower;
|
||||
#endif
|
||||
syscas.sprintf = xp_sprintf;
|
||||
|
||||
#ifdef _WIN32
|
||||
syscas_data.heap = HeapCreate (0, 1000000, 1000000);
|
||||
@ -754,6 +756,170 @@ static int __main (int argc, xp_char_t* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
NTSYSAPI PTEB NTAPI NtCurrentTeb();
|
||||
Function NtCurrentTeb returns address of TEB (Thread Environment Block) for calling thread.
|
||||
NtCurrentTeb isn't typical NT CALL realised via INT 2E, becouse TEB is accessable at address fs:[0018h].
|
||||
Microsoft declare NtCurrentTeb as __cdecl, but ntdll.dll export it as __stdcall (it don't have metter, becouse function don't have any parameters), so you cannot use ntdll.dll export. In this case the better way is write NtCurrentTeb manually, declaring it as __cdecl.
|
||||
|
||||
typedef UCHAR BOOLEAN;
|
||||
|
||||
typedef struct _TEB {
|
||||
|
||||
NT_TIB Tib;
|
||||
PVOID EnvironmentPointer;
|
||||
CLIENT_ID Cid;
|
||||
PVOID ActiveRpcInfo;
|
||||
PVOID ThreadLocalStoragePointer;
|
||||
PPEB Peb;
|
||||
ULONG LastErrorValue;
|
||||
ULONG CountOfOwnedCriticalSections;
|
||||
PVOID CsrClientThread;
|
||||
PVOID Win32ThreadInfo;
|
||||
ULONG Win32ClientInfo[0x1F];
|
||||
PVOID WOW32Reserved;
|
||||
ULONG CurrentLocale;
|
||||
ULONG FpSoftwareStatusRegister;
|
||||
PVOID SystemReserved1[0x36];
|
||||
PVOID Spare1;
|
||||
ULONG ExceptionCode;
|
||||
ULONG SpareBytes1[0x28];
|
||||
PVOID SystemReserved2[0xA];
|
||||
ULONG GdiRgn;
|
||||
ULONG GdiPen;
|
||||
ULONG GdiBrush;
|
||||
CLIENT_ID RealClientId;
|
||||
PVOID GdiCachedProcessHandle;
|
||||
ULONG GdiClientPID;
|
||||
ULONG GdiClientTID;
|
||||
PVOID GdiThreadLocaleInfo;
|
||||
PVOID UserReserved[5];
|
||||
PVOID GlDispatchTable[0x118];
|
||||
ULONG GlReserved1[0x1A];
|
||||
PVOID GlReserved2;
|
||||
PVOID GlSectionInfo;
|
||||
PVOID GlSection;
|
||||
PVOID GlTable;
|
||||
PVOID GlCurrentRC;
|
||||
PVOID GlContext;
|
||||
NTSTATUS LastStatusValue;
|
||||
UNICODE_STRING StaticUnicodeString;
|
||||
WCHAR StaticUnicodeBuffer[0x105];
|
||||
PVOID DeallocationStack;
|
||||
PVOID TlsSlots[0x40];
|
||||
LIST_ENTRY TlsLinks;
|
||||
PVOID Vdm;
|
||||
PVOID ReservedForNtRpc;
|
||||
PVOID DbgSsReserved[0x2];
|
||||
ULONG HardErrorDisabled;
|
||||
PVOID Instrumentation[0x10];
|
||||
PVOID WinSockData;
|
||||
ULONG GdiBatchCount;
|
||||
ULONG Spare2;
|
||||
ULONG Spare3;
|
||||
ULONG Spare4;
|
||||
PVOID ReservedForOle;
|
||||
ULONG WaitingOnLoaderLock;
|
||||
PVOID StackCommit;
|
||||
PVOID StackCommitMax;
|
||||
PVOID StackReserved;
|
||||
|
||||
} TEB, *PTEB;
|
||||
|
||||
typedef struct _PEB {
|
||||
BOOLEAN InheritedAddressSpace;
|
||||
BOOLEAN ReadImageFileExecOptions;
|
||||
BOOLEAN BeingDebugged;
|
||||
BOOLEAN Spare;
|
||||
HANDLE Mutant;
|
||||
PVOID ImageBaseAddress;
|
||||
PPEB_LDR_DATA LoaderData;
|
||||
PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
|
||||
PVOID SubSystemData;
|
||||
PVOID ProcessHeap;
|
||||
PVOID FastPebLock;
|
||||
PPEBLOCKROUTINE FastPebLockRoutine;
|
||||
PPEBLOCKROUTINE FastPebUnlockRoutine;
|
||||
ULONG EnvironmentUpdateCount;
|
||||
PPVOID KernelCallbackTable;
|
||||
PVOID EventLogSection;
|
||||
PVOID EventLog;
|
||||
PPEB_FREE_BLOCK FreeList;
|
||||
ULONG TlsExpansionCounter;
|
||||
PVOID TlsBitmap;
|
||||
ULONG TlsBitmapBits[0x2];
|
||||
PVOID ReadOnlySharedMemoryBase;
|
||||
PVOID ReadOnlySharedMemoryHeap;
|
||||
PPVOID ReadOnlyStaticServerData;
|
||||
PVOID AnsiCodePageData;
|
||||
PVOID OemCodePageData;
|
||||
PVOID UnicodeCaseTableData;
|
||||
ULONG NumberOfProcessors;
|
||||
ULONG NtGlobalFlag;
|
||||
BYTE Spare2[0x4];
|
||||
LARGE_INTEGER CriticalSectionTimeout;
|
||||
ULONG HeapSegmentReserve;
|
||||
ULONG HeapSegmentCommit;
|
||||
ULONG HeapDeCommitTotalFreeThreshold;
|
||||
ULONG HeapDeCommitFreeBlockThreshold;
|
||||
ULONG NumberOfHeaps;
|
||||
ULONG MaximumNumberOfHeaps;
|
||||
PPVOID *ProcessHeaps;
|
||||
PVOID GdiSharedHandleTable;
|
||||
PVOID ProcessStarterHelper;
|
||||
PVOID GdiDCAttributeList;
|
||||
PVOID LoaderLock;
|
||||
ULONG OSMajorVersion;
|
||||
ULONG OSMinorVersion;
|
||||
ULONG OSBuildNumber;
|
||||
ULONG OSPlatformId;
|
||||
ULONG ImageSubSystem;
|
||||
ULONG ImageSubSystemMajorVersion;
|
||||
ULONG ImageSubSystemMinorVersion;
|
||||
ULONG GdiHandleBuffer[0x22];
|
||||
ULONG PostProcessInitRoutine;
|
||||
ULONG TlsExpansionBitmap;
|
||||
BYTE TlsExpansionBitmapBits[0x80];
|
||||
ULONG SessionId;
|
||||
|
||||
} PEB, *PPEB;
|
||||
|
||||
|
||||
*/
|
||||
void* get_current_teb ()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
mov eax, fs:[0x18]
|
||||
}
|
||||
}
|
||||
|
||||
void* get_current_peb ()
|
||||
{
|
||||
void* teb = get_current_teb ();
|
||||
return *(void**)((char*)teb + 0x30);
|
||||
}
|
||||
|
||||
int is_debugger_present ()
|
||||
{
|
||||
void *peb = get_current_peb ();
|
||||
return *((char*)peb+0x02);
|
||||
}
|
||||
|
||||
|
||||
int is_debugger_present2 ()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
mov eax, fs:[0x18]
|
||||
mov ebx, [eax+0x30]
|
||||
xor eax, eax
|
||||
mov al, byte ptr[ebx+0x02]
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__STAND_ALONE) && !defined(_WIN32)
|
||||
int main (int argc, char* argv[])
|
||||
#else
|
||||
@ -779,6 +945,19 @@ if (n == (xp_size_t)-1)
|
||||
}
|
||||
else xp_printf (XP_T("%d, %s\n"), n, buf);
|
||||
}
|
||||
|
||||
if (IsDebuggerPresent ())
|
||||
{
|
||||
xp_printf (XP_T("Running application in a debugger....\n"));
|
||||
}
|
||||
if (is_debugger_present ())
|
||||
{
|
||||
xp_printf (XP_T("Running application in a debugger by is_debugger_present...\n"));
|
||||
}
|
||||
if (is_debugger_present2 ())
|
||||
{
|
||||
xp_printf (XP_T("Running application in a debugger by is_debugger_present2...\n"));
|
||||
}
|
||||
#endif
|
||||
|
||||
n = __main (argc, argv);
|
||||
|
19
ase/test/awk/t47.awk
Normal file
19
ase/test/awk/t47.awk
Normal file
@ -0,0 +1,19 @@
|
||||
BEGIN {
|
||||
|
||||
a[1] = 20;
|
||||
a[2] = 40;
|
||||
a[3,5,6] = 40;
|
||||
a["abc"] = 20;
|
||||
|
||||
for (i in a) print "a[" i "]=" a[i];
|
||||
#SUBSEP=",,,";
|
||||
#SUBSEP=4.5;
|
||||
SUBSEP=555;
|
||||
|
||||
print "------------------------";
|
||||
|
||||
a[9,x,3] = 40;
|
||||
for (i in a) print "a[" i "]=" a[i];
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "__STAND_ALONE" /FR /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D _WIN32_WINNT=0x0400 /D "__STAND_ALONE" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
Loading…
Reference in New Issue
Block a user