*** empty log message ***
This commit is contained in:
parent
c5ddc5cc9f
commit
40cdec67b4
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h,v 1.111 2006-09-08 14:57:43 bacon Exp $
|
||||
* $Id: awk.h,v 1.112 2006-09-08 15:26:49 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_AWK_H_
|
||||
@ -379,29 +379,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);
|
||||
|
||||
xp_char_t* xp_awk_strtok (
|
||||
xp_awk_t* awk, const xp_char_t* s,
|
||||
const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len);
|
||||
|
||||
xp_char_t* xp_awk_strxtok (
|
||||
xp_awk_t* awk, const xp_char_t* s, xp_size_t len,
|
||||
const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len);
|
||||
|
||||
xp_char_t* xp_awk_strntok (
|
||||
xp_awk_t* awk, const xp_char_t* s,
|
||||
const xp_char_t* delim, xp_size_t delim_len,
|
||||
xp_char_t** tok, xp_size_t* tok_len);
|
||||
|
||||
xp_char_t* xp_awk_strxntok (
|
||||
xp_awk_t* awk, const xp_char_t* s, xp_size_t len,
|
||||
const xp_char_t* delim, xp_size_t delim_len,
|
||||
xp_char_t** tok, xp_size_t* tok_len);
|
||||
|
||||
xp_char_t* xp_awk_strxntokbyrex (
|
||||
xp_awk_t* awk, const xp_char_t* s, xp_size_t len,
|
||||
void* rex, xp_char_t** tok, xp_size_t* tok_len, int* errnum);
|
||||
|
||||
|
||||
int xp_awk_printf (xp_awk_t* awk, const xp_char_t* fmt, ...);
|
||||
|
||||
int xp_awk_sprintf (
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk_i.h,v 1.55 2006-09-05 04:10:23 bacon Exp $
|
||||
* $Id: awk_i.h,v 1.56 2006-09-08 15:26:49 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_AWKI_H_
|
||||
@ -48,6 +48,7 @@ typedef struct xp_awk_tree_t xp_awk_tree_t;
|
||||
#include <xp/awk/parse.h>
|
||||
#include <xp/awk/run.h>
|
||||
#include <xp/awk/extio.h>
|
||||
#include <xp/awk/misc.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable: 4996)
|
||||
@ -247,6 +248,7 @@ struct xp_awk_run_t
|
||||
{
|
||||
void* rs;
|
||||
void* fs;
|
||||
int ignorecase;
|
||||
} rex;
|
||||
|
||||
/* extio chain */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: func.c,v 1.46 2006-09-05 04:10:24 bacon Exp $
|
||||
* $Id: func.c,v 1.47 2006-09-08 15:26:49 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -641,12 +641,12 @@ static int __bfn_split (xp_awk_t* awk, void* run)
|
||||
{
|
||||
if (fs_len <= 1)
|
||||
{
|
||||
p = xp_awk_strxntok (awk,
|
||||
p = xp_awk_strxntok (run,
|
||||
p, str_len, fs_ptr, fs_len, &tok, &tok_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = xp_awk_strxntokbyrex (awk, p, str_len,
|
||||
p = xp_awk_strxntokbyrex (run, p, str_len,
|
||||
fs_rex, &tok, &tok_len, &errnum);
|
||||
if (p == XP_NULL && errnum != XP_AWK_ENOERR)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: misc.c,v 1.16 2006-09-08 14:50:52 bacon Exp $
|
||||
* $Id: misc.c,v 1.17 2006-09-08 15:26:49 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -478,35 +478,35 @@ xp_char_t* xp_awk_strxnstr (
|
||||
}
|
||||
|
||||
xp_char_t* xp_awk_strtok (
|
||||
xp_awk_t* awk, const xp_char_t* s,
|
||||
xp_awk_run_t* run, const xp_char_t* s,
|
||||
const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len)
|
||||
{
|
||||
return xp_awk_strxntok (
|
||||
awk, s, xp_awk_strlen(s),
|
||||
run, s, xp_awk_strlen(s),
|
||||
delim, xp_awk_strlen(delim), tok, tok_len);
|
||||
}
|
||||
|
||||
xp_char_t* xp_awk_strxtok (
|
||||
xp_awk_t* awk, const xp_char_t* s, xp_size_t len,
|
||||
xp_awk_run_t* run, const xp_char_t* s, xp_size_t len,
|
||||
const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len)
|
||||
{
|
||||
return xp_awk_strxntok (
|
||||
awk, s, len,
|
||||
run, s, len,
|
||||
delim, xp_awk_strlen(delim), tok, tok_len);
|
||||
}
|
||||
|
||||
xp_char_t* xp_awk_strntok (
|
||||
xp_awk_t* awk, const xp_char_t* s,
|
||||
xp_awk_run_t* run, const xp_char_t* s,
|
||||
const xp_char_t* delim, xp_size_t delim_len,
|
||||
xp_char_t** tok, xp_size_t* tok_len)
|
||||
{
|
||||
return xp_awk_strxntok (
|
||||
awk, s, xp_awk_strlen(s),
|
||||
run, s, xp_awk_strlen(s),
|
||||
delim, delim_len, tok, tok_len);
|
||||
}
|
||||
|
||||
xp_char_t* xp_awk_strxntok (
|
||||
xp_awk_t* awk, const xp_char_t* s, xp_size_t len,
|
||||
xp_awk_run_t* run, const xp_char_t* s, xp_size_t len,
|
||||
const xp_char_t* delim, xp_size_t delim_len,
|
||||
xp_char_t** tok, xp_size_t* tok_len)
|
||||
{
|
||||
@ -517,6 +517,7 @@ xp_char_t* xp_awk_strxntok (
|
||||
xp_char_t c;
|
||||
int delim_mode;
|
||||
|
||||
xp_printf (XP_T("ignorecase = %d\n"), run->rex.ignorecase);
|
||||
#define __DELIM_NULL 0
|
||||
#define __DELIM_EMPTY 1
|
||||
#define __DELIM_SPACES 2
|
||||
@ -529,7 +530,7 @@ xp_char_t* xp_awk_strxntok (
|
||||
|
||||
for (d = delim; d < delim_end; d++)
|
||||
{
|
||||
if (XP_AWK_ISSPACE(awk,*d))
|
||||
if (XP_AWK_ISSPACE(run->awk,*d))
|
||||
{
|
||||
if (delim_mode == __DELIM_EMPTY)
|
||||
delim_mode = __DELIM_SPACES;
|
||||
@ -558,12 +559,12 @@ xp_char_t* xp_awk_strxntok (
|
||||
* leading and trailing spaces characters off the source
|
||||
* string "s" eventually. */
|
||||
|
||||
while (p < end && XP_AWK_ISSPACE(awk,*p)) p++;
|
||||
while (p < end && XP_AWK_ISSPACE(run->awk,*p)) p++;
|
||||
while (p < end)
|
||||
{
|
||||
c = *p;
|
||||
|
||||
if (!XP_AWK_ISSPACE(awk,c))
|
||||
if (!XP_AWK_ISSPACE(run->awk,c))
|
||||
{
|
||||
if (sp == XP_NULL) sp = p;
|
||||
ep = p;
|
||||
@ -586,15 +587,15 @@ xp_char_t* xp_awk_strxntok (
|
||||
/* each token is delimited by space characters. all leading
|
||||
* and trailing spaces are removed. */
|
||||
|
||||
while (p < end && XP_AWK_ISSPACE(awk,*p)) p++;
|
||||
while (p < end && XP_AWK_ISSPACE(run->awk,*p)) p++;
|
||||
while (p < end)
|
||||
{
|
||||
c = *p;
|
||||
if (XP_AWK_ISSPACE(awk,c)) break;
|
||||
if (XP_AWK_ISSPACE(run->awk,c)) break;
|
||||
if (sp == XP_NULL) sp = p;
|
||||
ep = p++;
|
||||
}
|
||||
while (p < end && XP_AWK_ISSPACE(awk,*p)) p++;
|
||||
while (p < end && XP_AWK_ISSPACE(run->awk,*p)) p++;
|
||||
}
|
||||
else if (delim_mode == __DELIM_NOSPACES)
|
||||
{
|
||||
@ -616,11 +617,11 @@ xp_char_t* xp_awk_strxntok (
|
||||
/* each token is delimited by one of non-space charaters
|
||||
* in the delimeter set "delim". however, all space characters
|
||||
* surrounding the token are removed */
|
||||
while (p < end && XP_AWK_ISSPACE(awk,*p)) p++;
|
||||
while (p < end && XP_AWK_ISSPACE(run->awk,*p)) p++;
|
||||
while (p < end)
|
||||
{
|
||||
c = *p;
|
||||
if (XP_AWK_ISSPACE(awk,c))
|
||||
if (XP_AWK_ISSPACE(run->awk,c))
|
||||
{
|
||||
p++;
|
||||
continue;
|
||||
@ -654,7 +655,7 @@ exit_loop:
|
||||
}
|
||||
|
||||
xp_char_t* xp_awk_strxntokbyrex (
|
||||
xp_awk_t* awk, const xp_char_t* s, xp_size_t len,
|
||||
xp_awk_run_t* run, const xp_char_t* s, xp_size_t len,
|
||||
void* rex, xp_char_t** tok, xp_size_t* tok_len, int* errnum)
|
||||
{
|
||||
int n;
|
||||
@ -665,10 +666,12 @@ xp_char_t* xp_awk_strxntokbyrex (
|
||||
const xp_char_t* str_ptr = s;
|
||||
xp_size_t str_len = len;
|
||||
|
||||
xp_printf (XP_T("ignorecase = %d\n"), run->rex.ignorecase);
|
||||
while (len > 0)
|
||||
{
|
||||
n = xp_awk_matchrex (
|
||||
awk, rex, ptr, left, &match_ptr, &match_len, errnum);
|
||||
run->awk, rex, ptr, left,
|
||||
&match_ptr, &match_len, errnum);
|
||||
if (n == -1) return XP_NULL;
|
||||
if (n == 0)
|
||||
{
|
||||
@ -687,14 +690,14 @@ xp_char_t* xp_awk_strxntokbyrex (
|
||||
ptr++;
|
||||
left--;
|
||||
}
|
||||
else if (awk->option & XP_AWK_STRIPSPACES)
|
||||
else if (run->awk->option & XP_AWK_STRIPSPACES)
|
||||
{
|
||||
/* match at the beginning of the input string */
|
||||
if (match_ptr == s)
|
||||
{
|
||||
for (i = 0; i < match_len; i++)
|
||||
{
|
||||
if (!XP_AWK_ISSPACE(awk, match_ptr[i]))
|
||||
if (!XP_AWK_ISSPACE(run->awk, match_ptr[i]))
|
||||
goto exit_loop;
|
||||
}
|
||||
|
||||
@ -724,7 +727,7 @@ exit_loop:
|
||||
|
||||
for (i = 0; i < match_len; i++)
|
||||
{
|
||||
if (!XP_AWK_ISSPACE(awk, match_ptr[i]))
|
||||
if (!XP_AWK_ISSPACE(run->awk, match_ptr[i]))
|
||||
{
|
||||
*errnum = XP_AWK_ENOERR;
|
||||
return match_ptr+match_len;
|
||||
@ -733,7 +736,7 @@ exit_loop:
|
||||
|
||||
*errnum = XP_AWK_ENOERR;
|
||||
|
||||
if (awk->option & XP_AWK_STRIPSPACES)
|
||||
if (run->awk->option & XP_AWK_STRIPSPACES)
|
||||
{
|
||||
return (match_ptr+match_len >= s+len)?
|
||||
XP_NULL: (match_ptr+match_len);
|
||||
|
43
ase/awk/misc.h
Normal file
43
ase/awk/misc.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* $Id: misc.h,v 1.1 2006-09-08 15:26:49 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_MISC_H_
|
||||
#define _XP_AWK_MISC_H_
|
||||
|
||||
#ifndef _XP_AWK_AWK_H_
|
||||
#error Never include this file directly. Include <xp/awk/awk.h> instead
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
xp_char_t* xp_awk_strtok (
|
||||
xp_awk_run_t* awk, const xp_char_t* s,
|
||||
const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len);
|
||||
|
||||
xp_char_t* xp_awk_strxtok (
|
||||
xp_awk_run_t* awk, const xp_char_t* s, xp_size_t len,
|
||||
const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len);
|
||||
|
||||
xp_char_t* xp_awk_strntok (
|
||||
xp_awk_run_t* awk, const xp_char_t* s,
|
||||
const xp_char_t* delim, xp_size_t delim_len,
|
||||
xp_char_t** tok, xp_size_t* tok_len);
|
||||
|
||||
xp_char_t* xp_awk_strxntok (
|
||||
xp_awk_run_t* awk, const xp_char_t* s, xp_size_t len,
|
||||
const xp_char_t* delim, xp_size_t delim_len,
|
||||
xp_char_t** tok, xp_size_t* tok_len);
|
||||
|
||||
xp_char_t* xp_awk_strxntokbyrex (
|
||||
xp_awk_run_t* awk, const xp_char_t* s, xp_size_t len,
|
||||
void* rex, xp_char_t** tok, xp_size_t* tok_len, int* errnum);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.c,v 1.197 2006-09-05 04:10:24 bacon Exp $
|
||||
* $Id: run.c,v 1.198 2006-09-08 15:26:49 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -332,7 +332,22 @@ int xp_awk_setglobal (void* run, xp_size_t idx, xp_awk_val_t* val)
|
||||
if (val->type != XP_AWK_VAL_STR)
|
||||
XP_AWK_FREE (((xp_awk_run_t*)run)->awk, fs_ptr);
|
||||
}
|
||||
|
||||
else if (idx == XP_AWK_GLOBAL_IGNORECASE)
|
||||
{
|
||||
if ((val->type == XP_AWK_VAL_INT &&
|
||||
((xp_awk_val_int_t*)val)->val == 0) ||
|
||||
(val->type == XP_AWK_VAL_REAL &&
|
||||
((xp_awk_val_real_t*)val)->val == 0.0) ||
|
||||
(val->type == XP_AWK_VAL_STR &&
|
||||
((xp_awk_val_str_t*)val)->len == 0))
|
||||
{
|
||||
((xp_awk_run_t*)run)->rex.ignorecase = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
((xp_awk_run_t*)run)->rex.ignorecase = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: if idx == XP_AWK_GLOBAL_NF recompute $0, etc */
|
||||
|
||||
@ -587,6 +602,7 @@ static int __init_run (
|
||||
|
||||
run->rex.rs = XP_NULL;
|
||||
run->rex.fs = XP_NULL;
|
||||
run->rex.ignorecase = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -4774,12 +4790,12 @@ static int __split_record (xp_awk_run_t* run)
|
||||
{
|
||||
if (fs_len <= 1)
|
||||
{
|
||||
p = xp_awk_strxntok (run->awk,
|
||||
p = xp_awk_strxntok (run,
|
||||
p, len, fs_ptr, fs_len, &tok, &tok_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = xp_awk_strxntokbyrex (run->awk, p, len,
|
||||
p = xp_awk_strxntokbyrex (run, p, len,
|
||||
run->rex.fs, &tok, &tok_len, &errnum);
|
||||
if (p == XP_NULL && errnum != XP_AWK_ENOERR)
|
||||
{
|
||||
@ -4829,12 +4845,12 @@ static int __split_record (xp_awk_run_t* run)
|
||||
{
|
||||
if (fs_len <= 1)
|
||||
{
|
||||
p = xp_awk_strxntok (run->awk,
|
||||
p, len, fs_ptr, fs_len, &tok, &tok_len);
|
||||
p = xp_awk_strxntok (
|
||||
run, p, len, fs_ptr, fs_len, &tok, &tok_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = xp_awk_strxntokbyrex (run->awk, p, len,
|
||||
p = xp_awk_strxntokbyrex (run, p, len,
|
||||
run->rex.fs, &tok, &tok_len, &errnum);
|
||||
if (p == XP_NULL && errnum != XP_AWK_ENOERR)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.h,v 1.16 2006-08-27 15:29:21 bacon Exp $
|
||||
* $Id: run.h,v 1.17 2006-09-08 15:26:49 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_RUN_H_
|
||||
@ -89,7 +89,7 @@ enum
|
||||
XP_AWK_GLOBAL_FILENAME,
|
||||
XP_AWK_GLOBAL_FNR,
|
||||
XP_AWK_GLOBAL_FS,
|
||||
XP_AWK_GLOBAL_INORECASE,
|
||||
XP_AWK_GLOBAL_IGNORECASE,
|
||||
XP_AWK_GLOBAL_NF,
|
||||
XP_AWK_GLOBAL_NR,
|
||||
XP_AWK_GLOBAL_OFMT,
|
||||
|
Loading…
x
Reference in New Issue
Block a user