moved the xma mmgr to std.c with the new function hawk_init_xma_mmgr() and hawk_fini_xma_mmgr()
This commit is contained in:
parent
2a03c6f061
commit
715085c778
138
bin/hawk.c
138
bin/hawk.c
@ -30,8 +30,8 @@
|
|||||||
#include <hawk-utl.h>
|
#include <hawk-utl.h>
|
||||||
#include <hawk-fmt.h>
|
#include <hawk-fmt.h>
|
||||||
#include <hawk-cli.h>
|
#include <hawk-cli.h>
|
||||||
#include <hawk-xma.h>
|
|
||||||
#include <hawk-glob.h>
|
#include <hawk-glob.h>
|
||||||
|
#include <hawk-xma.h>
|
||||||
|
|
||||||
#if !defined(_GNU_SOURCE)
|
#if !defined(_GNU_SOURCE)
|
||||||
# define _GNU_SOURCE
|
# define _GNU_SOURCE
|
||||||
@ -75,7 +75,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static hawk_rtx_t* app_rtx = HAWK_NULL;
|
static hawk_rtx_t* app_rtx = HAWK_NULL;
|
||||||
static int app_debug = 0;
|
|
||||||
|
|
||||||
typedef struct gv_t gv_t;
|
typedef struct gv_t gv_t;
|
||||||
typedef struct gvm_t gvm_t;
|
typedef struct gvm_t gvm_t;
|
||||||
@ -123,11 +122,9 @@ struct arg_t
|
|||||||
unsigned int classic: 1;
|
unsigned int classic: 1;
|
||||||
int opton;
|
int opton;
|
||||||
int optoff;
|
int optoff;
|
||||||
|
int debug;
|
||||||
|
|
||||||
hawk_uintptr_t memlimit;
|
hawk_uintptr_t memlimit;
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
hawk_uintptr_t failmalloc;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -547,9 +544,6 @@ static void print_usage (FILE* out, const hawk_bch_t* argv0, const hawk_bch_t* r
|
|||||||
fprintf (out, " -m/--memory-limit number limit the memory usage (bytes)\n");
|
fprintf (out, " -m/--memory-limit number limit the memory usage (bytes)\n");
|
||||||
fprintf (out, " -w expand datafile wildcards\n");
|
fprintf (out, " -w expand datafile wildcards\n");
|
||||||
|
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
fprintf (out, " -X number fail the number'th memory allocation\n");
|
|
||||||
#endif
|
|
||||||
#if defined(HAWK_OOCH_IS_UCH)
|
#if defined(HAWK_OOCH_IS_UCH)
|
||||||
fprintf (out, " --script-encoding string specify script file encoding name\n");
|
fprintf (out, " --script-encoding string specify script file encoding name\n");
|
||||||
fprintf (out, " --console-encoding string specify console encoding name\n");
|
fprintf (out, " --console-encoding string specify console encoding name\n");
|
||||||
@ -674,7 +668,6 @@ static int process_argv (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_ar
|
|||||||
{ ":field-separator", 'F' },
|
{ ":field-separator", 'F' },
|
||||||
{ ":assign", 'v' },
|
{ ":assign", 'v' },
|
||||||
{ ":memory-limit", 'm' },
|
{ ":memory-limit", 'm' },
|
||||||
{ ":mode", 'M' },
|
|
||||||
|
|
||||||
{ ":script-encoding", '\0' },
|
{ ":script-encoding", '\0' },
|
||||||
{ ":console-encoding", '\0' },
|
{ ":console-encoding", '\0' },
|
||||||
@ -690,11 +683,7 @@ static int process_argv (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_ar
|
|||||||
|
|
||||||
static hawk_bcli_t opt =
|
static hawk_bcli_t opt =
|
||||||
{
|
{
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
"hDc:f:d:t:F:v:m:I:wX:",
|
|
||||||
#else
|
|
||||||
"hDc:f:d:t:F:v:m:I:w",
|
"hDc:f:d:t:F:v:m:I:w",
|
||||||
#endif
|
|
||||||
lng
|
lng
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -726,7 +715,7 @@ static int process_argv (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_ar
|
|||||||
goto oops;
|
goto oops;
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
app_debug = 1;
|
arg->debug = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
@ -843,15 +832,6 @@ static int process_argv (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_ar
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
case 'X':
|
|
||||||
{
|
|
||||||
arg->failmalloc = strtoul(opt.arg, HAWK_NULL, 10);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case '\0':
|
case '\0':
|
||||||
{
|
{
|
||||||
/* a long option with no corresponding short option */
|
/* a long option with no corresponding short option */
|
||||||
@ -1033,89 +1013,12 @@ static void print_hawk_rtx_error (hawk_rtx_t* rtx)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* xma_alloc (hawk_mmgr_t* mmgr, hawk_oow_t size)
|
|
||||||
{
|
|
||||||
return hawk_xma_alloc(mmgr->ctx, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void* xma_realloc (hawk_mmgr_t* mmgr, void* ptr, hawk_oow_t size)
|
|
||||||
{
|
|
||||||
return hawk_xma_realloc(mmgr->ctx, ptr, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void xma_free (hawk_mmgr_t* mmgr, void* ptr)
|
|
||||||
{
|
|
||||||
hawk_xma_free (mmgr->ctx, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static hawk_mmgr_t xma_mmgr =
|
|
||||||
{
|
|
||||||
xma_alloc,
|
|
||||||
xma_realloc,
|
|
||||||
xma_free,
|
|
||||||
HAWK_NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
static void xma_dumper_without_hawk (void* ctx, const hawk_bch_t* fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
va_start (ap, fmt);
|
|
||||||
vfprintf (stderr, fmt, ap);
|
|
||||||
va_end (ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
static hawk_uintptr_t debug_mmgr_count = 0;
|
|
||||||
static hawk_uintptr_t debug_mmgr_alloc_count = 0;
|
|
||||||
static hawk_uintptr_t debug_mmgr_realloc_count = 0;
|
|
||||||
static hawk_uintptr_t debug_mmgr_free_count = 0;
|
|
||||||
|
|
||||||
static void* debug_mmgr_alloc (hawk_mmgr_t* mmgr, hawk_oow_t size)
|
|
||||||
{
|
|
||||||
void* ptr;
|
|
||||||
struct arg_t* arg = (struct arg_t*)mmgr->ctx;
|
|
||||||
debug_mmgr_count++;
|
|
||||||
if (debug_mmgr_count % arg->failmalloc == 0) return HAWK_NULL;
|
|
||||||
ptr = malloc (size);
|
|
||||||
if (ptr) debug_mmgr_alloc_count++;
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void* debug_mmgr_realloc (hawk_mmgr_t* mmgr, void* ptr, hawk_oow_t size)
|
|
||||||
{
|
|
||||||
void* rptr;
|
|
||||||
struct arg_t* arg = (struct arg_t*)mmgr->ctx;
|
|
||||||
debug_mmgr_count++;
|
|
||||||
if (debug_mmgr_count % arg->failmalloc == 0) return HAWK_NULL;
|
|
||||||
rptr = realloc (ptr, size);
|
|
||||||
if (rptr)
|
|
||||||
{
|
|
||||||
if (ptr) debug_mmgr_realloc_count++;
|
|
||||||
else debug_mmgr_alloc_count++;
|
|
||||||
}
|
|
||||||
return rptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void debug_mmgr_free (hawk_mmgr_t* mmgr, void* ptr)
|
|
||||||
{
|
|
||||||
debug_mmgr_free_count++;
|
|
||||||
free (ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static hawk_mmgr_t debug_mmgr =
|
|
||||||
{
|
|
||||||
debug_mmgr_alloc,
|
|
||||||
debug_mmgr_realloc,
|
|
||||||
debug_mmgr_free,
|
|
||||||
HAWK_NULL
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_argv0)
|
static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_argv0)
|
||||||
{
|
{
|
||||||
hawk_t* hawk = HAWK_NULL;
|
hawk_t* hawk = HAWK_NULL;
|
||||||
hawk_rtx_t* rtx = HAWK_NULL;
|
hawk_rtx_t* rtx = HAWK_NULL;
|
||||||
hawk_val_t* retv;
|
hawk_val_t* retv;
|
||||||
|
hawk_mmgr_t xma_mmgr;
|
||||||
int i;
|
int i;
|
||||||
struct arg_t arg;
|
struct arg_t arg;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -1150,18 +1053,9 @@ static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[], const hawk_bc
|
|||||||
psout.u.fileb.cmgr = arg.script_cmgr;
|
psout.u.fileb.cmgr = arg.script_cmgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
if (arg.failmalloc > 0)
|
|
||||||
{
|
|
||||||
debug_mmgr.ctx = &arg;
|
|
||||||
mmgr = &debug_mmgr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if (arg.memlimit > 0)
|
if (arg.memlimit > 0)
|
||||||
{
|
{
|
||||||
xma_mmgr.ctx = hawk_xma_open(hawk_get_sys_mmgr(), 0, HAWK_NULL, arg.memlimit);
|
if (hawk_init_xma_mmgr(&xma_mmgr, arg.memlimit) <= -1)
|
||||||
if (xma_mmgr.ctx == HAWK_NULL)
|
|
||||||
{
|
{
|
||||||
print_error ("cannot open memory heap\n");
|
print_error ("cannot open memory heap\n");
|
||||||
goto oops;
|
goto oops;
|
||||||
@ -1293,7 +1187,7 @@ static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[], const hawk_bc
|
|||||||
hawk_int_t tmp;
|
hawk_int_t tmp;
|
||||||
|
|
||||||
hawk_rtx_refdownval (rtx, retv);
|
hawk_rtx_refdownval (rtx, retv);
|
||||||
if (app_debug) dprint_return (rtx, retv);
|
if (arg.debug) dprint_return (rtx, retv);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if (hawk_rtx_valtoint(rtx, retv, &tmp) >= 0) ret = tmp;
|
if (hawk_rtx_valtoint(rtx, retv, &tmp) >= 0) ret = tmp;
|
||||||
@ -1310,27 +1204,13 @@ oops:
|
|||||||
|
|
||||||
unset_intr_pipe ();
|
unset_intr_pipe ();
|
||||||
|
|
||||||
if (xma_mmgr.ctx)
|
if (arg.memlimit > 0)
|
||||||
{
|
{
|
||||||
if (app_debug) hawk_xma_dump (xma_mmgr.ctx, xma_dumper_without_hawk, HAWK_NULL);
|
if (arg.debug) hawk_xma_dump (xma_mmgr.ctx, main_xma_dumper_without_hawk, HAWK_NULL);
|
||||||
hawk_xma_close (xma_mmgr.ctx);
|
hawk_fini_xma_mmgr (&xma_mmgr);
|
||||||
}
|
}
|
||||||
freearg (&arg);
|
freearg (&arg);
|
||||||
|
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
/*
|
|
||||||
if (arg.failmalloc > 0)
|
|
||||||
{
|
|
||||||
hawk_fprintf (HAWK_STDERR, HAWK_T("\n"));
|
|
||||||
hawk_fprintf (HAWK_STDERR, HAWK_T("-[MALLOC COUNTS]---------------------------------------\n"));
|
|
||||||
hawk_fprintf (HAWK_STDERR, HAWK_T("ALLOC: %lu FREE: %lu: REALLOC: %lu\n"),
|
|
||||||
(unsigned long)debug_mmgr_alloc_count,
|
|
||||||
(unsigned long)debug_mmgr_free_count,
|
|
||||||
(unsigned long)debug_mmgr_realloc_count);
|
|
||||||
hawk_fprintf (HAWK_STDERR, HAWK_T("-------------------------------------------------------\n"));
|
|
||||||
}*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
bin/main.c
11
bin/main.c
@ -26,8 +26,19 @@
|
|||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <hawk.h>
|
#include <hawk.h>
|
||||||
|
#include <hawk-xma.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void main_xma_dumper_without_hawk (void* ctx, const hawk_bch_t* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start (ap, fmt);
|
||||||
|
vfprintf (stderr, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------- */
|
||||||
|
|
||||||
static int main_version(int argc, hawk_bch_t* argv[], const hawk_bch_t* real_argv0)
|
static int main_version(int argc, hawk_bch_t* argv[], const hawk_bch_t* real_argv0)
|
||||||
{
|
{
|
||||||
printf ("%s %s\n", hawk_get_base_name_bcstr(real_argv0), HAWK_PACKAGE_VERSION);
|
printf ("%s %s\n", hawk_get_base_name_bcstr(real_argv0), HAWK_PACKAGE_VERSION);
|
||||||
|
@ -36,6 +36,8 @@ extern "C" {
|
|||||||
int main_hawk(int argc, hawk_bch_t* argv[], const hawk_bch_t* real_argv0);
|
int main_hawk(int argc, hawk_bch_t* argv[], const hawk_bch_t* real_argv0);
|
||||||
int main_sed(int argc, hawk_bch_t* argv[], const hawk_bch_t* real_argv0);
|
int main_sed(int argc, hawk_bch_t* argv[], const hawk_bch_t* real_argv0);
|
||||||
|
|
||||||
|
void main_xma_dumper_without_hawk (void* ctx, const hawk_bch_t* fmt, ...);
|
||||||
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
134
bin/sed.c
134
bin/sed.c
@ -23,13 +23,14 @@
|
|||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
#include <hawk-sed.h>
|
#include <hawk-sed.h>
|
||||||
#include <hawk-xma.h>
|
|
||||||
#include <hawk-cli.h>
|
#include <hawk-cli.h>
|
||||||
#include <hawk-fmt.h>
|
#include <hawk-fmt.h>
|
||||||
#include <hawk-utl.h>
|
#include <hawk-utl.h>
|
||||||
#include <hawk-std.h>
|
#include <hawk-std.h>
|
||||||
|
#include <hawk-xma.h>
|
||||||
|
|
||||||
#if !defined(_GNU_SOURCE)
|
#if !defined(_GNU_SOURCE)
|
||||||
# define _GNU_SOURCE
|
# define _GNU_SOURCE
|
||||||
@ -87,89 +88,14 @@ struct arg_t
|
|||||||
int inplace;
|
int inplace;
|
||||||
int wildcard;
|
int wildcard;
|
||||||
|
|
||||||
|
int debug;
|
||||||
#if defined(HAWK_ENABLE_SEDTRACER)
|
#if defined(HAWK_ENABLE_SEDTRACER)
|
||||||
int trace;
|
int trace;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hawk_uintptr_t memlimit;
|
hawk_uintptr_t memlimit;
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
hawk_uintptr_t failmalloc;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------- */
|
|
||||||
static void* xma_alloc (hawk_mmgr_t* mmgr, hawk_oow_t size)
|
|
||||||
{
|
|
||||||
return hawk_xma_alloc (mmgr->ctx, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void* xma_realloc (hawk_mmgr_t* mmgr, void* ptr, hawk_oow_t size)
|
|
||||||
{
|
|
||||||
return hawk_xma_realloc (mmgr->ctx, ptr, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void xma_free (hawk_mmgr_t* mmgr, void* ptr)
|
|
||||||
{
|
|
||||||
hawk_xma_free (mmgr->ctx, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static hawk_mmgr_t xma_mmgr =
|
|
||||||
{
|
|
||||||
xma_alloc,
|
|
||||||
xma_realloc,
|
|
||||||
xma_free,
|
|
||||||
HAWK_NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
static hawk_uintptr_t debug_mmgr_count = 0;
|
|
||||||
static hawk_uintptr_t debug_mmgr_alloc_count = 0;
|
|
||||||
static hawk_uintptr_t debug_mmgr_realloc_count = 0;
|
|
||||||
static hawk_uintptr_t debug_mmgr_free_count = 0;
|
|
||||||
|
|
||||||
static void* debug_mmgr_alloc (hawk_mmgr_t* mmgr, hawk_oow_t size)
|
|
||||||
{
|
|
||||||
void* ptr;
|
|
||||||
struct arg_t* arg = (struct arg_t*)mmgr->ctx;
|
|
||||||
debug_mmgr_count++;
|
|
||||||
if (debug_mmgr_count % arg->failmalloc == 0) return HAWK_NULL;
|
|
||||||
ptr = malloc(size);
|
|
||||||
if (ptr) debug_mmgr_alloc_count++;
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void* debug_mmgr_realloc (hawk_mmgr_t* mmgr, void* ptr, hawk_oow_t size)
|
|
||||||
{
|
|
||||||
void* rptr;
|
|
||||||
struct arg_t* arg = (struct arg_t*)mmgr->ctx;
|
|
||||||
debug_mmgr_count++;
|
|
||||||
if (debug_mmgr_count % arg->failmalloc == 0) return HAWK_NULL;
|
|
||||||
rptr = realloc(ptr, size);
|
|
||||||
if (rptr)
|
|
||||||
{
|
|
||||||
if (ptr) debug_mmgr_realloc_count++;
|
|
||||||
else debug_mmgr_alloc_count++;
|
|
||||||
}
|
|
||||||
return rptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void debug_mmgr_free (hawk_mmgr_t* mmgr, void* ptr)
|
|
||||||
{
|
|
||||||
debug_mmgr_free_count++;
|
|
||||||
free (ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static hawk_mmgr_t debug_mmgr =
|
|
||||||
{
|
|
||||||
debug_mmgr_alloc,
|
|
||||||
debug_mmgr_realloc,
|
|
||||||
debug_mmgr_free,
|
|
||||||
HAWK_NULL
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void print_error (const hawk_bch_t* fmt, ...)
|
static void print_error (const hawk_bch_t* fmt, ...)
|
||||||
@ -202,6 +128,7 @@ static void print_usage (FILE* out, const hawk_bch_t* argv0, const hawk_bch_t* r
|
|||||||
|
|
||||||
fprintf (out, "Options as follows:\n");
|
fprintf (out, "Options as follows:\n");
|
||||||
fprintf (out, " -h/--help show this message\n");
|
fprintf (out, " -h/--help show this message\n");
|
||||||
|
fprintf (out, " -D show extra information\n");
|
||||||
fprintf (out, " -n disable auto-print\n");
|
fprintf (out, " -n disable auto-print\n");
|
||||||
fprintf (out, " -e script specify a script\n");
|
fprintf (out, " -e script specify a script\n");
|
||||||
fprintf (out, " -f file specify a script file\n");
|
fprintf (out, " -f file specify a script file\n");
|
||||||
@ -216,14 +143,11 @@ static void print_usage (FILE* out, const hawk_bch_t* argv0, const hawk_bch_t* r
|
|||||||
fprintf (out, " <start~step>,<start,+line>,<start,~line>,<0,/regex/>\n");
|
fprintf (out, " <start~step>,<start,+line>,<start,~line>,<0,/regex/>\n");
|
||||||
fprintf (out, " -x allow text on the same line as c, a, i\n");
|
fprintf (out, " -x allow text on the same line as c, a, i\n");
|
||||||
fprintf (out, " -y ensure a newline at text end\n");
|
fprintf (out, " -y ensure a newline at text end\n");
|
||||||
fprintf (out, " -m number specify the maximum amount of memory to use in bytes\n");
|
fprintf (out, " -m/--memory-limit number specify the maximum amount of memory to use in bytes\n");
|
||||||
fprintf (out, " -w expand file wildcards\n");
|
fprintf (out, " -w expand file wildcards\n");
|
||||||
#if defined(HAWK_ENABLE_SEDTRACER)
|
#if defined(HAWK_ENABLE_SEDTRACER)
|
||||||
fprintf (out, " -t print command traces\n");
|
fprintf (out, " -t print command traces\n");
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
fprintf (out, " -X number fail the number'th memory allocation\n");
|
|
||||||
#endif
|
|
||||||
#if defined(HAWK_OOCH_IS_UCH)
|
#if defined(HAWK_OOCH_IS_UCH)
|
||||||
fprintf (out, " --script-encoding string specify script file encoding name\n");
|
fprintf (out, " --script-encoding string specify script file encoding name\n");
|
||||||
fprintf (out, " --infile-encoding string specify input file encoding name\n");
|
fprintf (out, " --infile-encoding string specify input file encoding name\n");
|
||||||
@ -288,17 +212,13 @@ static int handle_args (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_arg
|
|||||||
{ ":infile-encoding", '\0' },
|
{ ":infile-encoding", '\0' },
|
||||||
{ ":outfile-encoding", '\0' },
|
{ ":outfile-encoding", '\0' },
|
||||||
#endif
|
#endif
|
||||||
|
{ ":memory-limit", 'm' },
|
||||||
{ "help", 'h' },
|
{ "help", 'h' },
|
||||||
{ HAWK_NULL, '\0' }
|
{ HAWK_NULL, '\0' }
|
||||||
};
|
};
|
||||||
static hawk_bcli_t opt =
|
static hawk_bcli_t opt =
|
||||||
{
|
{
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
"hDne:f:o:rRisabxytm:w",
|
||||||
"hne:f:o:rRisabxytm:wX:",
|
|
||||||
#else
|
|
||||||
"hne:f:o:rRisabxytm:w",
|
|
||||||
#endif
|
|
||||||
lng
|
lng
|
||||||
};
|
};
|
||||||
hawk_bci_t c;
|
hawk_bci_t c;
|
||||||
@ -325,6 +245,10 @@ static int handle_args (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_arg
|
|||||||
print_usage (stdout, argv[0], real_argv0);
|
print_usage (stdout, argv[0], real_argv0);
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
case 'D':
|
||||||
|
arg->debug = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
arg->option |= HAWK_SED_QUIET;
|
arg->option |= HAWK_SED_QUIET;
|
||||||
break;
|
break;
|
||||||
@ -390,12 +314,6 @@ static int handle_args (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_arg
|
|||||||
arg->wildcard = 1;
|
arg->wildcard = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
case 'X':
|
|
||||||
arg->failmalloc = strtoul(opt.arg, HAWK_NULL, 10);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case '\0':
|
case '\0':
|
||||||
{
|
{
|
||||||
if (hawk_comp_bcstr(opt.lngopt, "script-encoding", 0) == 0)
|
if (hawk_comp_bcstr(opt.lngopt, "script-encoding", 0) == 0)
|
||||||
@ -790,6 +708,7 @@ static HAWK_INLINE int execute_sed (int argc, hawk_bch_t* argv[], const hawk_bch
|
|||||||
int xarg_inited = 0;
|
int xarg_inited = 0;
|
||||||
hawk_mmgr_t* mmgr = hawk_get_sys_mmgr();
|
hawk_mmgr_t* mmgr = hawk_get_sys_mmgr();
|
||||||
hawk_cmgr_t* cmgr = hawk_get_cmgr_by_id(HAWK_CMGR_UTF8);
|
hawk_cmgr_t* cmgr = hawk_get_cmgr_by_id(HAWK_CMGR_UTF8);
|
||||||
|
hawk_mmgr_t xma_mmgr;
|
||||||
|
|
||||||
memset (&arg, 0, HAWK_SIZEOF(arg));
|
memset (&arg, 0, HAWK_SIZEOF(arg));
|
||||||
ret = handle_args(argc, argv, real_argv0, &arg);
|
ret = handle_args(argc, argv, real_argv0, &arg);
|
||||||
@ -798,18 +717,9 @@ static HAWK_INLINE int execute_sed (int argc, hawk_bch_t* argv[], const hawk_bch
|
|||||||
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
if (arg.failmalloc > 0)
|
|
||||||
{
|
|
||||||
debug_mmgr.ctx = &arg;
|
|
||||||
mmgr = &debug_mmgr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if (arg.memlimit > 0)
|
if (arg.memlimit > 0)
|
||||||
{
|
{
|
||||||
xma_mmgr.ctx = hawk_xma_open(hawk_get_sys_mmgr(), 0, HAWK_NULL, arg.memlimit);
|
if (hawk_init_xma_mmgr(&xma_mmgr, arg.memlimit) <= -1)
|
||||||
if (xma_mmgr.ctx == HAWK_NULL)
|
|
||||||
{
|
{
|
||||||
print_error ("cannot open memory heap\n");
|
print_error ("cannot open memory heap\n");
|
||||||
goto oops;
|
goto oops;
|
||||||
@ -1085,21 +995,13 @@ static HAWK_INLINE int execute_sed (int argc, hawk_bch_t* argv[], const hawk_bch
|
|||||||
oops:
|
oops:
|
||||||
if (xarg_inited) purge_xarg (&xarg);
|
if (xarg_inited) purge_xarg (&xarg);
|
||||||
if (sed) hawk_sed_close (sed);
|
if (sed) hawk_sed_close (sed);
|
||||||
if (xma_mmgr.ctx) hawk_xma_close (xma_mmgr.ctx);
|
if (arg.memlimit > 0)
|
||||||
|
{
|
||||||
|
if (arg.debug) hawk_xma_dump (xma_mmgr.ctx, main_xma_dumper_without_hawk, HAWK_NULL);
|
||||||
|
hawk_fini_xma_mmgr (&xma_mmgr);
|
||||||
|
}
|
||||||
free_scripts ();
|
free_scripts ();
|
||||||
|
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
|
||||||
if (arg.failmalloc > 0)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "\n");
|
|
||||||
fprintf (stderr, "-[MALLOC COUNTS]---------------------------------------\n");
|
|
||||||
fprintf (stderr, "ALLOC: %lu FREE: %lu: REALLOC: %lu\n",
|
|
||||||
(unsigned long)debug_mmgr_alloc_count,
|
|
||||||
(unsigned long)debug_mmgr_free_count,
|
|
||||||
(unsigned long)debug_mmgr_realloc_count);
|
|
||||||
fprintf (stderr, "-------------------------------------------------------\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ public:
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// The getErrorNumber() function gets the number of the last
|
/// The getErrorNumber() function gets the number of the last
|
||||||
/// error occurred. It returns HAWK_SED_ENOERR if the stream editor
|
/// error occurred. It returns HAWK_ENOERR if the stream editor
|
||||||
/// has not been initialized with the open() function.
|
/// has not been initialized with the open() function.
|
||||||
///
|
///
|
||||||
hawk_errnum_t getErrorNumber () const;
|
hawk_errnum_t getErrorNumber () const;
|
||||||
|
@ -55,6 +55,7 @@ pkginclude_HEADERS = \
|
|||||||
hawk-chr.h \
|
hawk-chr.h \
|
||||||
hawk-cli.h \
|
hawk-cli.h \
|
||||||
hawk-cmn.h \
|
hawk-cmn.h \
|
||||||
|
hawk-cut.h \
|
||||||
hawk-dir.h \
|
hawk-dir.h \
|
||||||
hawk-ecs.h \
|
hawk-ecs.h \
|
||||||
hawk-fio.h \
|
hawk-fio.h \
|
||||||
@ -90,6 +91,8 @@ libhawk_la_SOURCES = \
|
|||||||
$(pkginclude_HEADERS) \
|
$(pkginclude_HEADERS) \
|
||||||
arr.c \
|
arr.c \
|
||||||
chr.c \
|
chr.c \
|
||||||
|
cut-prv.h \
|
||||||
|
cut.c \
|
||||||
dir.c \
|
dir.c \
|
||||||
ecs-imp.h \
|
ecs-imp.h \
|
||||||
ecs.c \
|
ecs.c \
|
||||||
@ -169,6 +172,7 @@ libhawk_la_SOURCES += \
|
|||||||
syscall.h \
|
syscall.h \
|
||||||
tio.c \
|
tio.c \
|
||||||
std.c \
|
std.c \
|
||||||
|
std-cut.c \
|
||||||
std-json.c \
|
std-json.c \
|
||||||
std-sed.c
|
std-sed.c
|
||||||
|
|
||||||
|
161
lib/Makefile.in
161
lib/Makefile.in
@ -247,30 +247,30 @@ libhawk_la_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
|
|||||||
$(am__DEPENDENCIES_6) $(am__DEPENDENCIES_7) \
|
$(am__DEPENDENCIES_6) $(am__DEPENDENCIES_7) \
|
||||||
$(am__DEPENDENCIES_8) $(am__DEPENDENCIES_9)
|
$(am__DEPENDENCIES_8) $(am__DEPENDENCIES_9)
|
||||||
am__libhawk_la_SOURCES_DIST = hawk.h hawk-arr.h hawk-chr.h hawk-cli.h \
|
am__libhawk_la_SOURCES_DIST = hawk.h hawk-arr.h hawk-chr.h hawk-cli.h \
|
||||||
hawk-cmn.h hawk-dir.h hawk-ecs.h hawk-fio.h hawk-fmt.h \
|
hawk-cmn.h hawk-cut.h hawk-dir.h hawk-ecs.h hawk-fio.h \
|
||||||
hawk-gem.h hawk-glob.h hawk-htb.h hawk-json.h hawk-map.h \
|
hawk-fmt.h hawk-gem.h hawk-glob.h hawk-htb.h hawk-json.h \
|
||||||
hawk-mtx.h hawk-rbt.h hawk-pac1.h hawk-pio.h hawk-skad.h \
|
hawk-map.h hawk-mtx.h hawk-rbt.h hawk-pac1.h hawk-pio.h \
|
||||||
hawk-utl.h hawk-sed.h hawk-sio.h hawk-std.h hawk-str.h \
|
hawk-skad.h hawk-utl.h hawk-sed.h hawk-sio.h hawk-std.h \
|
||||||
hawk-tio.h hawk-tre.h hawk-upac.h hawk-xma.h Hawk.hpp \
|
hawk-str.h hawk-tio.h hawk-tre.h hawk-upac.h hawk-xma.h \
|
||||||
Hawk-Sed.hpp arr.c chr.c dir.c ecs-imp.h ecs.c err-prv.h err.c \
|
Hawk.hpp Hawk-Sed.hpp arr.c chr.c cut-prv.h cut.c dir.c \
|
||||||
err-sys.c fmt-imp.h fmt.c fnc-prv.h fnc.c gem.c gem-glob.c \
|
ecs-imp.h ecs.c err-prv.h err.c err-sys.c fmt-imp.h fmt.c \
|
||||||
gem-nwif.c gem-nwif2.c hawk-prv.h hawk.c htb.c idmap-imp.h \
|
fnc-prv.h fnc.c gem.c gem-glob.c gem-nwif.c gem-nwif2.c \
|
||||||
json.c json-prv.h mb8.c misc-imp.h misc-prv.h misc.c \
|
hawk-prv.h hawk.c htb.c idmap-imp.h json.c json-prv.h mb8.c \
|
||||||
parse-prv.h parse.c rbt.c rec.c rio-prv.h rio.c run-prv.h \
|
misc-imp.h misc-prv.h misc.c parse-prv.h parse.c rbt.c rec.c \
|
||||||
run.c sed-prv.h sed.c skad-prv.h skad.c tre-prv.h tre-ast.c \
|
rio-prv.h rio.c run-prv.h run.c sed-prv.h sed.c skad-prv.h \
|
||||||
tre-ast.h tre-compile.c tre-compile.h tre-match-bt.c \
|
skad.c tre-prv.h tre-ast.c tre-ast.h tre-compile.c \
|
||||||
tre-match-pa.c tre-match-ut.h tre-mem.c tre-mem.h tre-parse.c \
|
tre-compile.h tre-match-bt.c tre-match-pa.c tre-match-ut.h \
|
||||||
tre-parse.h tre-stack.h tre-stack.c tre.c tree-prv.h tree.c \
|
tre-mem.c tre-mem.h tre-parse.c tre-parse.h tre-stack.h \
|
||||||
uch-prop.h uch-case.h utf16.c utf8.c utl-ass.c utl-cmgr.c \
|
tre-stack.c tre.c tree-prv.h tree.c uch-prop.h uch-case.h \
|
||||||
utl-rnd.c utl-sort.c utl-str.c utl-sys.c utl-xstr.c utl.c \
|
utf16.c utf8.c utl-ass.c utl-cmgr.c utl-rnd.c utl-sort.c \
|
||||||
val-prv.h val.c xma.c cli-imp.h cli.c fio.c mtx.c pio.c sio.c \
|
utl-str.c utl-sys.c utl-xstr.c utl.c val-prv.h val.c xma.c \
|
||||||
syscall.h tio.c std.c std-json.c std-sed.c Hawk.cpp Std.cpp \
|
cli-imp.h cli.c fio.c mtx.c pio.c sio.c syscall.h tio.c std.c \
|
||||||
Sed.cpp Std-Sed.cpp mod-hawk.c mod-hawk.h mod-math.c \
|
std-cut.c std-json.c std-sed.c Hawk.cpp Std.cpp Sed.cpp \
|
||||||
mod-math.h mod-str.c mod-str.h mod-sys.c mod-sys.h \
|
Std-Sed.cpp mod-hawk.c mod-hawk.h mod-math.c mod-math.h \
|
||||||
../mod/mod-ffi.c ../mod/mod-ffi.h ../mod/mod-memc.c \
|
mod-str.c mod-str.h mod-sys.c mod-sys.h ../mod/mod-ffi.c \
|
||||||
../mod/mod-memc.h ../mod/mod-mysql.c ../mod/mod-mysql.h \
|
../mod/mod-ffi.h ../mod/mod-memc.c ../mod/mod-memc.h \
|
||||||
../mod/mod-sed.c ../mod/mod-sed.h ../mod/mod-uci.c \
|
../mod/mod-mysql.c ../mod/mod-mysql.h ../mod/mod-sed.c \
|
||||||
../mod/mod-uci.h
|
../mod/mod-sed.h ../mod/mod-uci.c ../mod/mod-uci.h
|
||||||
am__objects_1 =
|
am__objects_1 =
|
||||||
am__objects_2 = $(am__objects_1)
|
am__objects_2 = $(am__objects_1)
|
||||||
@ENABLE_CXX_TRUE@am__objects_3 = libhawk_la-Hawk.lo libhawk_la-Std.lo \
|
@ENABLE_CXX_TRUE@am__objects_3 = libhawk_la-Hawk.lo libhawk_la-Std.lo \
|
||||||
@ -291,28 +291,30 @@ am__dirstamp = $(am__leading_dot)dirstamp
|
|||||||
@ENABLE_MOD_UCI_STATIC_TRUE@am__objects_9 = \
|
@ENABLE_MOD_UCI_STATIC_TRUE@am__objects_9 = \
|
||||||
@ENABLE_MOD_UCI_STATIC_TRUE@ ../mod/libhawk_la-mod-uci.lo
|
@ENABLE_MOD_UCI_STATIC_TRUE@ ../mod/libhawk_la-mod-uci.lo
|
||||||
am_libhawk_la_OBJECTS = $(am__objects_2) libhawk_la-arr.lo \
|
am_libhawk_la_OBJECTS = $(am__objects_2) libhawk_la-arr.lo \
|
||||||
libhawk_la-chr.lo libhawk_la-dir.lo libhawk_la-ecs.lo \
|
libhawk_la-chr.lo libhawk_la-cut.lo libhawk_la-dir.lo \
|
||||||
libhawk_la-err.lo libhawk_la-err-sys.lo libhawk_la-fmt.lo \
|
libhawk_la-ecs.lo libhawk_la-err.lo libhawk_la-err-sys.lo \
|
||||||
libhawk_la-fnc.lo libhawk_la-gem.lo libhawk_la-gem-glob.lo \
|
libhawk_la-fmt.lo libhawk_la-fnc.lo libhawk_la-gem.lo \
|
||||||
libhawk_la-gem-nwif.lo libhawk_la-gem-nwif2.lo \
|
libhawk_la-gem-glob.lo libhawk_la-gem-nwif.lo \
|
||||||
libhawk_la-hawk.lo libhawk_la-htb.lo libhawk_la-json.lo \
|
libhawk_la-gem-nwif2.lo libhawk_la-hawk.lo libhawk_la-htb.lo \
|
||||||
libhawk_la-mb8.lo libhawk_la-misc.lo libhawk_la-parse.lo \
|
libhawk_la-json.lo libhawk_la-mb8.lo libhawk_la-misc.lo \
|
||||||
libhawk_la-rbt.lo libhawk_la-rec.lo libhawk_la-rio.lo \
|
libhawk_la-parse.lo libhawk_la-rbt.lo libhawk_la-rec.lo \
|
||||||
libhawk_la-run.lo libhawk_la-sed.lo libhawk_la-skad.lo \
|
libhawk_la-rio.lo libhawk_la-run.lo libhawk_la-sed.lo \
|
||||||
libhawk_la-tre-ast.lo libhawk_la-tre-compile.lo \
|
libhawk_la-skad.lo libhawk_la-tre-ast.lo \
|
||||||
libhawk_la-tre-match-bt.lo libhawk_la-tre-match-pa.lo \
|
libhawk_la-tre-compile.lo libhawk_la-tre-match-bt.lo \
|
||||||
libhawk_la-tre-mem.lo libhawk_la-tre-parse.lo \
|
libhawk_la-tre-match-pa.lo libhawk_la-tre-mem.lo \
|
||||||
libhawk_la-tre-stack.lo libhawk_la-tre.lo libhawk_la-tree.lo \
|
libhawk_la-tre-parse.lo libhawk_la-tre-stack.lo \
|
||||||
libhawk_la-utf16.lo libhawk_la-utf8.lo libhawk_la-utl-ass.lo \
|
libhawk_la-tre.lo libhawk_la-tree.lo libhawk_la-utf16.lo \
|
||||||
|
libhawk_la-utf8.lo libhawk_la-utl-ass.lo \
|
||||||
libhawk_la-utl-cmgr.lo libhawk_la-utl-rnd.lo \
|
libhawk_la-utl-cmgr.lo libhawk_la-utl-rnd.lo \
|
||||||
libhawk_la-utl-sort.lo libhawk_la-utl-str.lo \
|
libhawk_la-utl-sort.lo libhawk_la-utl-str.lo \
|
||||||
libhawk_la-utl-sys.lo libhawk_la-utl-xstr.lo libhawk_la-utl.lo \
|
libhawk_la-utl-sys.lo libhawk_la-utl-xstr.lo libhawk_la-utl.lo \
|
||||||
libhawk_la-val.lo libhawk_la-xma.lo libhawk_la-cli.lo \
|
libhawk_la-val.lo libhawk_la-xma.lo libhawk_la-cli.lo \
|
||||||
libhawk_la-fio.lo libhawk_la-mtx.lo libhawk_la-pio.lo \
|
libhawk_la-fio.lo libhawk_la-mtx.lo libhawk_la-pio.lo \
|
||||||
libhawk_la-sio.lo libhawk_la-tio.lo libhawk_la-std.lo \
|
libhawk_la-sio.lo libhawk_la-tio.lo libhawk_la-std.lo \
|
||||||
libhawk_la-std-json.lo libhawk_la-std-sed.lo $(am__objects_3) \
|
libhawk_la-std-cut.lo libhawk_la-std-json.lo \
|
||||||
$(am__objects_4) $(am__objects_5) $(am__objects_6) \
|
libhawk_la-std-sed.lo $(am__objects_3) $(am__objects_4) \
|
||||||
$(am__objects_7) $(am__objects_8) $(am__objects_9)
|
$(am__objects_5) $(am__objects_6) $(am__objects_7) \
|
||||||
|
$(am__objects_8) $(am__objects_9)
|
||||||
libhawk_la_OBJECTS = $(am_libhawk_la_OBJECTS)
|
libhawk_la_OBJECTS = $(am_libhawk_la_OBJECTS)
|
||||||
AM_V_P = $(am__v_P_@AM_V@)
|
AM_V_P = $(am__v_P_@AM_V@)
|
||||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||||
@ -339,7 +341,8 @@ am__depfiles_remade = ../mod/$(DEPDIR)/libhawk_la-mod-ffi.Plo \
|
|||||||
./$(DEPDIR)/libhawk_la-Std-Sed.Plo \
|
./$(DEPDIR)/libhawk_la-Std-Sed.Plo \
|
||||||
./$(DEPDIR)/libhawk_la-Std.Plo ./$(DEPDIR)/libhawk_la-arr.Plo \
|
./$(DEPDIR)/libhawk_la-Std.Plo ./$(DEPDIR)/libhawk_la-arr.Plo \
|
||||||
./$(DEPDIR)/libhawk_la-chr.Plo ./$(DEPDIR)/libhawk_la-cli.Plo \
|
./$(DEPDIR)/libhawk_la-chr.Plo ./$(DEPDIR)/libhawk_la-cli.Plo \
|
||||||
./$(DEPDIR)/libhawk_la-dir.Plo ./$(DEPDIR)/libhawk_la-ecs.Plo \
|
./$(DEPDIR)/libhawk_la-cut.Plo ./$(DEPDIR)/libhawk_la-dir.Plo \
|
||||||
|
./$(DEPDIR)/libhawk_la-ecs.Plo \
|
||||||
./$(DEPDIR)/libhawk_la-err-sys.Plo \
|
./$(DEPDIR)/libhawk_la-err-sys.Plo \
|
||||||
./$(DEPDIR)/libhawk_la-err.Plo ./$(DEPDIR)/libhawk_la-fio.Plo \
|
./$(DEPDIR)/libhawk_la-err.Plo ./$(DEPDIR)/libhawk_la-fio.Plo \
|
||||||
./$(DEPDIR)/libhawk_la-fmt.Plo ./$(DEPDIR)/libhawk_la-fnc.Plo \
|
./$(DEPDIR)/libhawk_la-fmt.Plo ./$(DEPDIR)/libhawk_la-fnc.Plo \
|
||||||
@ -359,6 +362,7 @@ am__depfiles_remade = ../mod/$(DEPDIR)/libhawk_la-mod-ffi.Plo \
|
|||||||
./$(DEPDIR)/libhawk_la-rec.Plo ./$(DEPDIR)/libhawk_la-rio.Plo \
|
./$(DEPDIR)/libhawk_la-rec.Plo ./$(DEPDIR)/libhawk_la-rio.Plo \
|
||||||
./$(DEPDIR)/libhawk_la-run.Plo ./$(DEPDIR)/libhawk_la-sed.Plo \
|
./$(DEPDIR)/libhawk_la-run.Plo ./$(DEPDIR)/libhawk_la-sed.Plo \
|
||||||
./$(DEPDIR)/libhawk_la-sio.Plo ./$(DEPDIR)/libhawk_la-skad.Plo \
|
./$(DEPDIR)/libhawk_la-sio.Plo ./$(DEPDIR)/libhawk_la-skad.Plo \
|
||||||
|
./$(DEPDIR)/libhawk_la-std-cut.Plo \
|
||||||
./$(DEPDIR)/libhawk_la-std-json.Plo \
|
./$(DEPDIR)/libhawk_la-std-json.Plo \
|
||||||
./$(DEPDIR)/libhawk_la-std-sed.Plo \
|
./$(DEPDIR)/libhawk_la-std-sed.Plo \
|
||||||
./$(DEPDIR)/libhawk_la-std.Plo ./$(DEPDIR)/libhawk_la-tio.Plo \
|
./$(DEPDIR)/libhawk_la-std.Plo ./$(DEPDIR)/libhawk_la-tio.Plo \
|
||||||
@ -435,12 +439,12 @@ am__can_run_installinfo = \
|
|||||||
*) (install-info --version) >/dev/null 2>&1;; \
|
*) (install-info --version) >/dev/null 2>&1;; \
|
||||||
esac
|
esac
|
||||||
am__pkginclude_HEADERS_DIST = hawk.h hawk-arr.h hawk-chr.h hawk-cli.h \
|
am__pkginclude_HEADERS_DIST = hawk.h hawk-arr.h hawk-chr.h hawk-cli.h \
|
||||||
hawk-cmn.h hawk-dir.h hawk-ecs.h hawk-fio.h hawk-fmt.h \
|
hawk-cmn.h hawk-cut.h hawk-dir.h hawk-ecs.h hawk-fio.h \
|
||||||
hawk-gem.h hawk-glob.h hawk-htb.h hawk-json.h hawk-map.h \
|
hawk-fmt.h hawk-gem.h hawk-glob.h hawk-htb.h hawk-json.h \
|
||||||
hawk-mtx.h hawk-rbt.h hawk-pac1.h hawk-pio.h hawk-skad.h \
|
hawk-map.h hawk-mtx.h hawk-rbt.h hawk-pac1.h hawk-pio.h \
|
||||||
hawk-utl.h hawk-sed.h hawk-sio.h hawk-std.h hawk-str.h \
|
hawk-skad.h hawk-utl.h hawk-sed.h hawk-sio.h hawk-std.h \
|
||||||
hawk-tio.h hawk-tre.h hawk-upac.h hawk-xma.h Hawk.hpp \
|
hawk-str.h hawk-tio.h hawk-tre.h hawk-upac.h hawk-xma.h \
|
||||||
Hawk-Sed.hpp
|
Hawk.hpp Hawk-Sed.hpp
|
||||||
HEADERS = $(pkginclude_HEADERS)
|
HEADERS = $(pkginclude_HEADERS)
|
||||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
|
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
|
||||||
hawk-cfg.h.in
|
hawk-cfg.h.in
|
||||||
@ -666,28 +670,29 @@ BUILT_SOURCES = \
|
|||||||
utl-str.c
|
utl-str.c
|
||||||
|
|
||||||
pkginclude_HEADERS = hawk.h hawk-arr.h hawk-chr.h hawk-cli.h \
|
pkginclude_HEADERS = hawk.h hawk-arr.h hawk-chr.h hawk-cli.h \
|
||||||
hawk-cmn.h hawk-dir.h hawk-ecs.h hawk-fio.h hawk-fmt.h \
|
hawk-cmn.h hawk-cut.h hawk-dir.h hawk-ecs.h hawk-fio.h \
|
||||||
hawk-gem.h hawk-glob.h hawk-htb.h hawk-json.h hawk-map.h \
|
hawk-fmt.h hawk-gem.h hawk-glob.h hawk-htb.h hawk-json.h \
|
||||||
hawk-mtx.h hawk-rbt.h hawk-pac1.h hawk-pio.h hawk-skad.h \
|
hawk-map.h hawk-mtx.h hawk-rbt.h hawk-pac1.h hawk-pio.h \
|
||||||
hawk-utl.h hawk-sed.h hawk-sio.h hawk-std.h hawk-str.h \
|
hawk-skad.h hawk-utl.h hawk-sed.h hawk-sio.h hawk-std.h \
|
||||||
hawk-tio.h hawk-tre.h hawk-upac.h hawk-xma.h $(am__append_7)
|
hawk-str.h hawk-tio.h hawk-tre.h hawk-upac.h hawk-xma.h \
|
||||||
|
$(am__append_7)
|
||||||
pkglib_LTLIBRARIES = libhawk.la $(am__append_11)
|
pkglib_LTLIBRARIES = libhawk.la $(am__append_11)
|
||||||
libhawk_la_SOURCES = $(pkginclude_HEADERS) arr.c chr.c dir.c ecs-imp.h \
|
libhawk_la_SOURCES = $(pkginclude_HEADERS) arr.c chr.c cut-prv.h cut.c \
|
||||||
ecs.c err-prv.h err.c err-sys.c fmt-imp.h fmt.c fnc-prv.h \
|
dir.c ecs-imp.h ecs.c err-prv.h err.c err-sys.c fmt-imp.h \
|
||||||
fnc.c gem.c gem-glob.c gem-nwif.c gem-nwif2.c hawk-prv.h \
|
fmt.c fnc-prv.h fnc.c gem.c gem-glob.c gem-nwif.c gem-nwif2.c \
|
||||||
hawk.c htb.c idmap-imp.h json.c json-prv.h mb8.c misc-imp.h \
|
hawk-prv.h hawk.c htb.c idmap-imp.h json.c json-prv.h mb8.c \
|
||||||
misc-prv.h misc.c parse-prv.h parse.c rbt.c rec.c rio-prv.h \
|
misc-imp.h misc-prv.h misc.c parse-prv.h parse.c rbt.c rec.c \
|
||||||
rio.c run-prv.h run.c sed-prv.h sed.c skad-prv.h skad.c \
|
rio-prv.h rio.c run-prv.h run.c sed-prv.h sed.c skad-prv.h \
|
||||||
tre-prv.h tre-ast.c tre-ast.h tre-compile.c tre-compile.h \
|
skad.c tre-prv.h tre-ast.c tre-ast.h tre-compile.c \
|
||||||
tre-match-bt.c tre-match-pa.c tre-match-ut.h tre-mem.c \
|
tre-compile.h tre-match-bt.c tre-match-pa.c tre-match-ut.h \
|
||||||
tre-mem.h tre-parse.c tre-parse.h tre-stack.h tre-stack.c \
|
tre-mem.c tre-mem.h tre-parse.c tre-parse.h tre-stack.h \
|
||||||
tre.c tree-prv.h tree.c uch-prop.h uch-case.h utf16.c utf8.c \
|
tre-stack.c tre.c tree-prv.h tree.c uch-prop.h uch-case.h \
|
||||||
utl-ass.c utl-cmgr.c utl-rnd.c utl-sort.c utl-str.c utl-sys.c \
|
utf16.c utf8.c utl-ass.c utl-cmgr.c utl-rnd.c utl-sort.c \
|
||||||
utl-xstr.c utl.c val-prv.h val.c xma.c cli-imp.h cli.c fio.c \
|
utl-str.c utl-sys.c utl-xstr.c utl.c val-prv.h val.c xma.c \
|
||||||
mtx.c pio.c sio.c syscall.h tio.c std.c std-json.c std-sed.c \
|
cli-imp.h cli.c fio.c mtx.c pio.c sio.c syscall.h tio.c std.c \
|
||||||
$(am__append_8) $(am__append_9) $(am__append_12) \
|
std-cut.c std-json.c std-sed.c $(am__append_8) $(am__append_9) \
|
||||||
$(am__append_14) $(am__append_16) $(am__append_20) \
|
$(am__append_12) $(am__append_14) $(am__append_16) \
|
||||||
$(am__append_21)
|
$(am__append_20) $(am__append_21)
|
||||||
libhawk_la_CPPFLAGS = $(CPPFLAGS_ALL_COMMON) $(CPPFLAGS_PFMOD) \
|
libhawk_la_CPPFLAGS = $(CPPFLAGS_ALL_COMMON) $(CPPFLAGS_PFMOD) \
|
||||||
$(am__append_3) $(am__append_17)
|
$(am__append_3) $(am__append_17)
|
||||||
libhawk_la_CFLAGS = $(CFLAGS_ALL_COMMON)
|
libhawk_la_CFLAGS = $(CFLAGS_ALL_COMMON)
|
||||||
@ -876,6 +881,7 @@ distclean-compile:
|
|||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-arr.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-arr.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-chr.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-chr.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-cli.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-cli.Plo@am__quote@ # am--include-marker
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-cut.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-dir.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-dir.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-ecs.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-ecs.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-err-sys.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-err-sys.Plo@am__quote@ # am--include-marker
|
||||||
@ -906,6 +912,7 @@ distclean-compile:
|
|||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-sed.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-sed.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-sio.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-sio.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-skad.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-skad.Plo@am__quote@ # am--include-marker
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-std-cut.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-std-json.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-std-json.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-std-sed.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-std-sed.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-std.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-std.Plo@am__quote@ # am--include-marker
|
||||||
@ -1007,6 +1014,13 @@ libhawk_la-chr.lo: chr.c
|
|||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -c -o libhawk_la-chr.lo `test -f 'chr.c' || echo '$(srcdir)/'`chr.c
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -c -o libhawk_la-chr.lo `test -f 'chr.c' || echo '$(srcdir)/'`chr.c
|
||||||
|
|
||||||
|
libhawk_la-cut.lo: cut.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -MT libhawk_la-cut.lo -MD -MP -MF $(DEPDIR)/libhawk_la-cut.Tpo -c -o libhawk_la-cut.lo `test -f 'cut.c' || echo '$(srcdir)/'`cut.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-cut.Tpo $(DEPDIR)/libhawk_la-cut.Plo
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cut.c' object='libhawk_la-cut.lo' libtool=yes @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -c -o libhawk_la-cut.lo `test -f 'cut.c' || echo '$(srcdir)/'`cut.c
|
||||||
|
|
||||||
libhawk_la-dir.lo: dir.c
|
libhawk_la-dir.lo: dir.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -MT libhawk_la-dir.lo -MD -MP -MF $(DEPDIR)/libhawk_la-dir.Tpo -c -o libhawk_la-dir.lo `test -f 'dir.c' || echo '$(srcdir)/'`dir.c
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -MT libhawk_la-dir.lo -MD -MP -MF $(DEPDIR)/libhawk_la-dir.Tpo -c -o libhawk_la-dir.lo `test -f 'dir.c' || echo '$(srcdir)/'`dir.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-dir.Tpo $(DEPDIR)/libhawk_la-dir.Plo
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-dir.Tpo $(DEPDIR)/libhawk_la-dir.Plo
|
||||||
@ -1357,6 +1371,13 @@ libhawk_la-std.lo: std.c
|
|||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -c -o libhawk_la-std.lo `test -f 'std.c' || echo '$(srcdir)/'`std.c
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -c -o libhawk_la-std.lo `test -f 'std.c' || echo '$(srcdir)/'`std.c
|
||||||
|
|
||||||
|
libhawk_la-std-cut.lo: std-cut.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -MT libhawk_la-std-cut.lo -MD -MP -MF $(DEPDIR)/libhawk_la-std-cut.Tpo -c -o libhawk_la-std-cut.lo `test -f 'std-cut.c' || echo '$(srcdir)/'`std-cut.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-std-cut.Tpo $(DEPDIR)/libhawk_la-std-cut.Plo
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='std-cut.c' object='libhawk_la-std-cut.lo' libtool=yes @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -c -o libhawk_la-std-cut.lo `test -f 'std-cut.c' || echo '$(srcdir)/'`std-cut.c
|
||||||
|
|
||||||
libhawk_la-std-json.lo: std-json.c
|
libhawk_la-std-json.lo: std-json.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -MT libhawk_la-std-json.lo -MD -MP -MF $(DEPDIR)/libhawk_la-std-json.Tpo -c -o libhawk_la-std-json.lo `test -f 'std-json.c' || echo '$(srcdir)/'`std-json.c
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -MT libhawk_la-std-json.lo -MD -MP -MF $(DEPDIR)/libhawk_la-std-json.Tpo -c -o libhawk_la-std-json.lo `test -f 'std-json.c' || echo '$(srcdir)/'`std-json.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-std-json.Tpo $(DEPDIR)/libhawk_la-std-json.Plo
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-std-json.Tpo $(DEPDIR)/libhawk_la-std-json.Plo
|
||||||
@ -1660,6 +1681,7 @@ distclean: distclean-am
|
|||||||
-rm -f ./$(DEPDIR)/libhawk_la-arr.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-arr.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-chr.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-chr.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-cli.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-cli.Plo
|
||||||
|
-rm -f ./$(DEPDIR)/libhawk_la-cut.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-dir.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-dir.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-ecs.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-ecs.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-err-sys.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-err-sys.Plo
|
||||||
@ -1690,6 +1712,7 @@ distclean: distclean-am
|
|||||||
-rm -f ./$(DEPDIR)/libhawk_la-sed.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-sed.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-sio.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-sio.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-skad.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-skad.Plo
|
||||||
|
-rm -f ./$(DEPDIR)/libhawk_la-std-cut.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-std-json.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-std-json.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-std-sed.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-std-sed.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-std.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-std.Plo
|
||||||
@ -1777,6 +1800,7 @@ maintainer-clean: maintainer-clean-am
|
|||||||
-rm -f ./$(DEPDIR)/libhawk_la-arr.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-arr.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-chr.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-chr.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-cli.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-cli.Plo
|
||||||
|
-rm -f ./$(DEPDIR)/libhawk_la-cut.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-dir.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-dir.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-ecs.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-ecs.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-err-sys.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-err-sys.Plo
|
||||||
@ -1807,6 +1831,7 @@ maintainer-clean: maintainer-clean-am
|
|||||||
-rm -f ./$(DEPDIR)/libhawk_la-sed.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-sed.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-sio.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-sio.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-skad.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-skad.Plo
|
||||||
|
-rm -f ./$(DEPDIR)/libhawk_la-std-cut.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-std-json.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-std-json.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-std-sed.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-std-sed.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhawk_la-std.Plo
|
-rm -f ./$(DEPDIR)/libhawk_la-std.Plo
|
||||||
|
124
lib/cut-prv.h
Normal file
124
lib/cut-prv.h
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2006-2020 Chung, Hyung-Hwan. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _HAWK_CUT_PRV_H_
|
||||||
|
#define _HAWK_CUT_PRV_H_
|
||||||
|
|
||||||
|
#include <hawk-cut.h>
|
||||||
|
#include <hawk-ecs.h>
|
||||||
|
|
||||||
|
typedef struct hawk_cut_sel_blk_t hawk_cut_sel_blk_t;
|
||||||
|
|
||||||
|
struct hawk_cut_sel_blk_t
|
||||||
|
{
|
||||||
|
hawk_oow_t len;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
HAWK_SED_SEL_CHAR = HAWK_T('c'),
|
||||||
|
HAWK_SED_SEL_FIELD = HAWK_T('f')
|
||||||
|
} id;
|
||||||
|
hawk_oow_t start;
|
||||||
|
hawk_oow_t end;
|
||||||
|
} range[128];
|
||||||
|
hawk_cut_sel_blk_t* next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct hawk_cut_t
|
||||||
|
{
|
||||||
|
HAWK_CUT_HDR;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
hawk_cut_errstr_t errstr; /**< error string getter */
|
||||||
|
hawk_cut_errnum_t errnum; /**< stores an error number */
|
||||||
|
hawk_ooch_t errmsg[128]; /**< error message holder */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int option; /**< stores options */
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
hawk_cut_sel_blk_t fb; /**< the first block is static */
|
||||||
|
hawk_cut_sel_blk_t* lb; /**< points to the last block */
|
||||||
|
|
||||||
|
hawk_ooch_t din; /**< input field delimiter */
|
||||||
|
hawk_ooch_t dout; /**< output field delimiter */
|
||||||
|
|
||||||
|
hawk_oow_t count;
|
||||||
|
hawk_oow_t fcount;
|
||||||
|
hawk_oow_t ccount;
|
||||||
|
} sel;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
/** data needed for output streams */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
hawk_cut_io_impl_t fun; /**< an output handler */
|
||||||
|
hawk_cut_io_arg_t arg; /**< output handling data */
|
||||||
|
|
||||||
|
hawk_ooch_t buf[2048];
|
||||||
|
hawk_oow_t len;
|
||||||
|
int eof;
|
||||||
|
} out;
|
||||||
|
|
||||||
|
/** data needed for input streams */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
hawk_cut_io_impl_t fun; /**< an input handler */
|
||||||
|
hawk_cut_io_arg_t arg; /**< input handling data */
|
||||||
|
|
||||||
|
hawk_ooch_t xbuf[1]; /**< a read-ahead buffer */
|
||||||
|
int xbuf_len; /**< data length in the buffer */
|
||||||
|
|
||||||
|
hawk_ooch_t buf[2048]; /**< input buffer */
|
||||||
|
hawk_oow_t len; /**< data length in the buffer */
|
||||||
|
hawk_oow_t pos; /**< current position in the buffer */
|
||||||
|
int eof; /**< EOF indicator */
|
||||||
|
|
||||||
|
hawk_ooecs_t line; /**< pattern space */
|
||||||
|
hawk_oow_t num; /**< current line number */
|
||||||
|
|
||||||
|
hawk_oow_t nflds; /**< the number of fields */
|
||||||
|
hawk_oow_t cflds; /**< capacity of flds field */
|
||||||
|
hawk_oocs_t sflds[128]; /**< static field buffer */
|
||||||
|
hawk_oocs_t* flds;
|
||||||
|
int delimited;
|
||||||
|
} in;
|
||||||
|
} e;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* NOTHING */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
745
lib/cut.c
Normal file
745
lib/cut.c
Normal file
@ -0,0 +1,745 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2006-2020 Chung, Hyung-Hwan. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cut-prv.h"
|
||||||
|
#include "hawk-prv.h"
|
||||||
|
#include <hawk-chr.h>
|
||||||
|
|
||||||
|
static int hawk_cut_init (hawk_cut_t* cut, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr);
|
||||||
|
static void hawk_cut_fini (hawk_cut_t* cut);
|
||||||
|
|
||||||
|
#define SETERR0(cut,num) \
|
||||||
|
do { hawk_cut_seterrnum (cut, HAWK_NULL, num); } while (0)
|
||||||
|
|
||||||
|
#define DFL_LINE_CAPA 256
|
||||||
|
|
||||||
|
static int add_selector_block (hawk_cut_t* cut)
|
||||||
|
{
|
||||||
|
hawk_cut_sel_blk_t* b;
|
||||||
|
|
||||||
|
b = (hawk_cut_sel_blk_t*)hawk_cut_allocmem(cut, HAWK_SIZEOF(*b));
|
||||||
|
if (HAWK_UNLIKELY(!b)) return -1;
|
||||||
|
|
||||||
|
HAWK_MEMSET(b, 0, HAWK_SIZEOF(*b));
|
||||||
|
b->next = HAWK_NULL;
|
||||||
|
b->len = 0;
|
||||||
|
|
||||||
|
cut->sel.lb->next = b;
|
||||||
|
cut->sel.lb = b;
|
||||||
|
cut->sel.count = 0;
|
||||||
|
cut->sel.fcount = 0;
|
||||||
|
cut->sel.ccount = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void free_all_selector_blocks (hawk_cut_t* cut)
|
||||||
|
{
|
||||||
|
hawk_cut_sel_blk_t* b;
|
||||||
|
|
||||||
|
for (b = cut->sel.fb.next; b != HAWK_NULL; )
|
||||||
|
{
|
||||||
|
hawk_cut_sel_blk_t* nxt = b->next;
|
||||||
|
hawk_cut_freemem(cut, b);
|
||||||
|
b = nxt;
|
||||||
|
}
|
||||||
|
|
||||||
|
cut->sel.lb = &cut->sel.fb;
|
||||||
|
cut->sel.lb->len = 0;
|
||||||
|
cut->sel.lb->next = HAWK_NULL;
|
||||||
|
cut->sel.count = 0;
|
||||||
|
cut->sel.fcount = 0;
|
||||||
|
cut->sel.ccount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hawk_cut_t* hawk_cut_open (hawk_mmgr_t* mmgr, hawk_oow_t xtnsize, hawk_cmgr_t* cmgr, hawk_errnum_t* errnum)
|
||||||
|
{
|
||||||
|
hawk_cut_t* cut;
|
||||||
|
|
||||||
|
cut = (hawk_cut_t*)HAWK_MMGR_ALLOC(mmgr, HAWK_SIZEOF(hawk_cut_t) + xtnsize);
|
||||||
|
if (HAWK_LIKELY(cut))
|
||||||
|
{
|
||||||
|
if (hawk_cut_init(cut, mmgr, cmgr) <= -1)
|
||||||
|
{
|
||||||
|
if (errnum) *errnum = hawk_cut_geterrnum(cut);
|
||||||
|
HAWK_MMGR_FREE (mmgr, cut);
|
||||||
|
cut = HAWK_NULL;
|
||||||
|
}
|
||||||
|
else HAWK_MEMSET(cut + 1, 0, xtnsize);
|
||||||
|
}
|
||||||
|
else if (errnum) *errnum = HAWK_ENOMEM;
|
||||||
|
|
||||||
|
return cut;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hawk_cut_close (hawk_cut_t* cut)
|
||||||
|
{
|
||||||
|
hawk_cut_fini (cut);
|
||||||
|
HAWK_MMGR_FREE (hawk_cut_getmmgr(cut), cut);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int hawk_cut_init (hawk_cut_t* cut, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr)
|
||||||
|
{
|
||||||
|
HAWK_MEMSET (cut, 0, HAWK_SIZEOF(*cut));
|
||||||
|
|
||||||
|
cut->_instsize = HAWK_SIZEOF(*cut);
|
||||||
|
cut->_gem.mmgr = mmgr;
|
||||||
|
cut->_gem.cmgr = cmgr;
|
||||||
|
|
||||||
|
/* initialize error handling fields */
|
||||||
|
cut->_gem.errnum = HAWK_ENOERR;
|
||||||
|
cut->_gem.errmsg[0] = '\0';
|
||||||
|
cut->_gem.errloc.line = 0;
|
||||||
|
cut->_gem.errloc.colm = 0;
|
||||||
|
cut->_gem.errloc.file = HAWK_NULL;
|
||||||
|
cut->_gem.errstr = hawk_dfl_errstr;
|
||||||
|
|
||||||
|
|
||||||
|
/* on init, the last points to the first */
|
||||||
|
cut->sel.lb = &cut->sel.fb;
|
||||||
|
/* the block has no data yet */
|
||||||
|
cut->sel.fb.len = 0;
|
||||||
|
|
||||||
|
cut->e.in.cflds = HAWK_COUNTOF(cut->e.in.sflds);
|
||||||
|
cut->e.in.flds = cut->e.in.sflds;
|
||||||
|
|
||||||
|
if (hawk_ooecs_init(&cut->e.in.line, hawk_cut_getgem(cut), DFL_LINE_CAPA) <= -1) return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hawk_cut_fini (hawk_cut_t* cut)
|
||||||
|
{
|
||||||
|
free_all_selector_blocks (cut);
|
||||||
|
if (cut->e.in.flds != cut->e.in.sflds) hawk_cut_freemem(cut, cut->e.in.flds);
|
||||||
|
hawk_ooecs_fini(&cut->e.in.line);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hawk_cut_setoption (hawk_cut_t* cut, int option)
|
||||||
|
{
|
||||||
|
cut->option = option;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hawk_cut_getoption (hawk_cut_t* cut)
|
||||||
|
{
|
||||||
|
return cut->option;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hawk_cut_clear (hawk_cut_t* cut)
|
||||||
|
{
|
||||||
|
free_all_selector_blocks (cut);
|
||||||
|
if (cut->e.in.flds != cut->e.in.sflds) hawk_cut_freemem(cut, cut->e.in.flds);
|
||||||
|
cut->e.in.cflds = HAWK_COUNTOF(cut->e.in.sflds);
|
||||||
|
cut->e.in.flds = cut->e.in.sflds;
|
||||||
|
|
||||||
|
hawk_ooecs_clear(&cut->e.in.line);
|
||||||
|
hawk_ooecs_setcapa(&cut->e.in.line, DFL_LINE_CAPA);
|
||||||
|
}
|
||||||
|
|
||||||
|
int hawk_cut_comp (hawk_cut_t* cut, const hawk_ooch_t* str, hawk_oow_t len)
|
||||||
|
{
|
||||||
|
const hawk_ooch_t* p = str;
|
||||||
|
const hawk_ooch_t* xnd = str + len;
|
||||||
|
hawk_ooci_t c;
|
||||||
|
int sel = HAWK_SED_SEL_CHAR;
|
||||||
|
|
||||||
|
#define CC(x,y) (((x) <= (y))? ((hawk_ooci_t)*(x)): HAWK_OOCI_EOF)
|
||||||
|
#define NC(x,y) (((x) < (y))? ((hawk_ooci_t)*(++(x))): HAWK_OOCI_EOF)
|
||||||
|
#define EOF(x) ((x) == HAWK_OOCI_EOF)
|
||||||
|
#define MASK_START (1 << 1)
|
||||||
|
#define MASK_END (1 << 2)
|
||||||
|
#define MAX HAWK_TYPE_MAX(hawk_oow_t)
|
||||||
|
|
||||||
|
/* free selector blocks compiled previously */
|
||||||
|
free_all_selector_blocks (cut);
|
||||||
|
|
||||||
|
/* set the default delimiters */
|
||||||
|
cut->sel.din = HAWK_T(' ');
|
||||||
|
cut->sel.dout = HAWK_T(' ');
|
||||||
|
|
||||||
|
/* if the selector string is empty, don't need to proceed */
|
||||||
|
if (len <= 0) return 0;
|
||||||
|
|
||||||
|
/* compile the selector string */
|
||||||
|
xnd--; c = CC (p, xnd);
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
hawk_oow_t start = 0, end = 0;
|
||||||
|
int mask = 0;
|
||||||
|
|
||||||
|
while (hawk_is_ooch_space(c)) c = NC(p, xnd);
|
||||||
|
if (EOF(c))
|
||||||
|
{
|
||||||
|
if (cut->sel.count > 0)
|
||||||
|
{
|
||||||
|
SETERR0 (cut, HAWK_CUT_ESELNV);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == HAWK_T('d'))
|
||||||
|
{
|
||||||
|
/* the next character is the input delimiter.
|
||||||
|
* the output delimiter defaults to the input
|
||||||
|
* delimiter. */
|
||||||
|
c = NC(p, xnd);
|
||||||
|
if (EOF(c))
|
||||||
|
{
|
||||||
|
SETERR0 (cut, HAWK_CUT_ESELNV);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
cut->sel.din = c;
|
||||||
|
cut->sel.dout = c;
|
||||||
|
|
||||||
|
c = NC(p, xnd);
|
||||||
|
}
|
||||||
|
else if (c == HAWK_T('D'))
|
||||||
|
{
|
||||||
|
/* the next two characters are the input and
|
||||||
|
* the output delimiter each. */
|
||||||
|
c = NC(p, xnd);
|
||||||
|
if (EOF(c))
|
||||||
|
{
|
||||||
|
SETERR0 (cut, HAWK_CUT_ESELNV);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
cut->sel.din = c;
|
||||||
|
|
||||||
|
c = NC(p, xnd);
|
||||||
|
if (EOF(c))
|
||||||
|
{
|
||||||
|
SETERR0 (cut, HAWK_CUT_ESELNV);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
cut->sel.dout = c;
|
||||||
|
|
||||||
|
c = NC(p, xnd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (c == HAWK_T('c') || c == HAWK_T('f'))
|
||||||
|
{
|
||||||
|
sel = c;
|
||||||
|
c = NC(p, xnd);
|
||||||
|
while (hawk_is_ooch_space(c)) c = NC(p, xnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hawk_is_ooch_digit(c))
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
start = start * 10 + (c - HAWK_T('0'));
|
||||||
|
c = NC(p, xnd);
|
||||||
|
}
|
||||||
|
while (hawk_is_ooch_digit(c));
|
||||||
|
|
||||||
|
while (hawk_is_ooch_space(c)) c = NC(p, xnd);
|
||||||
|
mask |= MASK_START;
|
||||||
|
}
|
||||||
|
else start++;
|
||||||
|
|
||||||
|
if (c == HAWK_T('-'))
|
||||||
|
{
|
||||||
|
c = NC(p, xnd);
|
||||||
|
while (hawk_is_ooch_space(c)) c = NC(p, xnd);
|
||||||
|
|
||||||
|
if (hawk_is_ooch_digit(c))
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
end = end * 10 + (c - HAWK_T('0'));
|
||||||
|
c = NC(p, xnd);
|
||||||
|
}
|
||||||
|
while (hawk_is_ooch_digit(c));
|
||||||
|
mask |= MASK_END;
|
||||||
|
}
|
||||||
|
else end = MAX;
|
||||||
|
|
||||||
|
while (hawk_is_ooch_space(c)) c = NC(p, xnd);
|
||||||
|
}
|
||||||
|
else end = start;
|
||||||
|
|
||||||
|
if (!(mask & (MASK_START | MASK_END)))
|
||||||
|
{
|
||||||
|
SETERR0 (cut, HAWK_CUT_ESELNV);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cut->sel.lb->len >= HAWK_COUNTOF(cut->sel.lb->range))
|
||||||
|
{
|
||||||
|
if (add_selector_block (cut) <= -1)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cut->sel.lb->range[cut->sel.lb->len].id = sel;
|
||||||
|
cut->sel.lb->range[cut->sel.lb->len].start = start;
|
||||||
|
cut->sel.lb->range[cut->sel.lb->len].end = end;
|
||||||
|
cut->sel.lb->len++;
|
||||||
|
cut->sel.count++;
|
||||||
|
if (sel == HAWK_SED_SEL_FIELD) cut->sel.fcount++;
|
||||||
|
else cut->sel.ccount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EOF(c)) break;
|
||||||
|
if (c == HAWK_T(',')) c = NC(p, xnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int read_char (hawk_cut_t* cut, hawk_ooch_t* c)
|
||||||
|
{
|
||||||
|
hawk_ooi_t n;
|
||||||
|
|
||||||
|
if (cut->e.in.pos >= cut->e.in.len)
|
||||||
|
{
|
||||||
|
n = cut->e.in.fun(cut, HAWK_CUT_IO_READ, &cut->e.in.arg, cut->e.in.buf, HAWK_COUNTOF(cut->e.in.buf));
|
||||||
|
if (n <= -1) return -1;
|
||||||
|
if (n == 0) return 0; /* end of file */
|
||||||
|
|
||||||
|
cut->e.in.len = n;
|
||||||
|
cut->e.in.pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*c = cut->e.in.buf[cut->e.in.pos++];
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int read_line (hawk_cut_t* cut)
|
||||||
|
{
|
||||||
|
hawk_oow_t len = 0;
|
||||||
|
hawk_ooch_t c;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
hawk_ooecs_clear(&cut->e.in.line);
|
||||||
|
if (cut->e.in.eof) return 0;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
n = read_char(cut, &c);
|
||||||
|
if (n <= -1) return -1;
|
||||||
|
if (n == 0)
|
||||||
|
{
|
||||||
|
cut->e.in.eof = 1;
|
||||||
|
if (len == 0) return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == HAWK_T('\n'))
|
||||||
|
{
|
||||||
|
/* don't include the line terminater to a line */
|
||||||
|
/* TODO: support different line end convension */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hawk_ooecs_ccat(&cut->e.in.line, c) == (hawk_oow_t)-1) return -1;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cut->e.in.num++;
|
||||||
|
|
||||||
|
if (cut->option & HAWK_CUT_TRIMSPACE) hawk_ooecs_trim(&cut->e.in.line, HAWK_TRIM_LEFT | HAWK_TRIM_RIGHT);
|
||||||
|
if (cut->option & HAWK_CUT_NORMSPACE) hawk_ooecs_compact(&cut->e.in.line);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flush (hawk_cut_t* cut)
|
||||||
|
{
|
||||||
|
hawk_oow_t pos = 0;
|
||||||
|
hawk_ooi_t n;
|
||||||
|
|
||||||
|
while (cut->e.out.len > 0)
|
||||||
|
{
|
||||||
|
n = cut->e.out.fun(cut, HAWK_CUT_IO_WRITE, &cut->e.out.arg, &cut->e.out.buf[pos], cut->e.out.len);
|
||||||
|
if (n <= -1) return -1;
|
||||||
|
if (n == 0) return -1; /* reached the end of file - this is also an error */
|
||||||
|
|
||||||
|
pos += n;
|
||||||
|
cut->e.out.len -= n;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int write_char (hawk_cut_t* cut, hawk_ooch_t c)
|
||||||
|
{
|
||||||
|
cut->e.out.buf[cut->e.out.len++] = c;
|
||||||
|
if (c == HAWK_T('\n') || cut->e.out.len >= HAWK_COUNTOF(cut->e.out.buf)) return flush(cut);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int write_linebreak (hawk_cut_t* cut)
|
||||||
|
{
|
||||||
|
/* TODO: different line termination convention */
|
||||||
|
return write_char(cut, HAWK_T('\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int write_str (hawk_cut_t* cut, const hawk_ooch_t* str, hawk_oow_t len)
|
||||||
|
{
|
||||||
|
hawk_oow_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
if (write_char(cut, str[i]) <= -1) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cut_chars (hawk_cut_t* cut, hawk_oow_t start, hawk_oow_t end, int delim)
|
||||||
|
{
|
||||||
|
const hawk_ooch_t* ptr = HAWK_OOECS_PTR(&cut->e.in.line);
|
||||||
|
hawk_oow_t len = HAWK_OOECS_LEN(&cut->e.in.line);
|
||||||
|
|
||||||
|
if (len <= 0) return 0;
|
||||||
|
|
||||||
|
if (start <= end)
|
||||||
|
{
|
||||||
|
if (start <= len && end > 0)
|
||||||
|
{
|
||||||
|
if (start >= 1) start--;
|
||||||
|
if (end >= 1) end--;
|
||||||
|
|
||||||
|
if (end >= len) end = len - 1;
|
||||||
|
|
||||||
|
if (delim && write_char(cut, cut->sel.dout) <= -1) return -1;
|
||||||
|
if (write_str(cut, &ptr[start], end-start+1) <= -1) return -1;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (start > 0 && end <= len)
|
||||||
|
{
|
||||||
|
hawk_oow_t i;
|
||||||
|
|
||||||
|
if (start >= 1) start--;
|
||||||
|
if (end >= 1) end--;
|
||||||
|
|
||||||
|
if (start >= len) start = len - 1;
|
||||||
|
|
||||||
|
if (delim && write_char (cut, cut->sel.dout) <= -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = start; i >= end; i--)
|
||||||
|
{
|
||||||
|
if (write_char (cut, ptr[i]) <= -1)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int isdelim (hawk_cut_t* cut, hawk_ooch_t c)
|
||||||
|
{
|
||||||
|
return ((cut->option & HAWK_CUT_WHITESPACE) && hawk_is_ooch_space(c)) ||
|
||||||
|
(!(cut->option & HAWK_CUT_WHITESPACE) && c == cut->sel.din);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int split_line (hawk_cut_t* cut)
|
||||||
|
{
|
||||||
|
const hawk_ooch_t* ptr = HAWK_OOECS_PTR(&cut->e.in.line);
|
||||||
|
hawk_oow_t len = HAWK_OOECS_LEN(&cut->e.in.line);
|
||||||
|
hawk_oow_t i, x = 0, xl = 0;
|
||||||
|
|
||||||
|
cut->e.in.delimited = 0;
|
||||||
|
cut->e.in.flds[x].ptr = ptr;
|
||||||
|
for (i = 0; i < len; )
|
||||||
|
{
|
||||||
|
hawk_ooch_t c = ptr[i++];
|
||||||
|
if (isdelim(cut,c))
|
||||||
|
{
|
||||||
|
if (cut->option & HAWK_CUT_FOLDDELIMS)
|
||||||
|
{
|
||||||
|
while (i < len && isdelim(cut,ptr[i])) i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cut->e.in.flds[x++].len = xl;
|
||||||
|
|
||||||
|
if (x >= cut->e.in.cflds)
|
||||||
|
{
|
||||||
|
hawk_oocs_t* tmp;
|
||||||
|
hawk_oow_t nsz;
|
||||||
|
|
||||||
|
nsz = cut->e.in.cflds;
|
||||||
|
if (nsz > 100000) nsz += 100000;
|
||||||
|
else nsz *= 2;
|
||||||
|
|
||||||
|
tmp = hawk_cut_allocmem(cut, HAWK_SIZEOF(*tmp) * nsz);
|
||||||
|
if (HAWK_UNLIKELY(!tmp)) return -1;
|
||||||
|
|
||||||
|
HAWK_MEMCPY (tmp, cut->e.in.flds, HAWK_SIZEOF(*tmp) * cut->e.in.cflds);
|
||||||
|
|
||||||
|
if (cut->e.in.flds != cut->e.in.sflds) hawk_cut_freemem(cut, cut->e.in.flds);
|
||||||
|
cut->e.in.flds = tmp;
|
||||||
|
cut->e.in.cflds = nsz;
|
||||||
|
}
|
||||||
|
|
||||||
|
xl = 0;
|
||||||
|
cut->e.in.flds[x].ptr = &ptr[i];
|
||||||
|
cut->e.in.delimited = 1;
|
||||||
|
}
|
||||||
|
else xl++;
|
||||||
|
}
|
||||||
|
cut->e.in.flds[x].len = xl;
|
||||||
|
cut->e.in.nflds = ++x;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cut_fields (hawk_cut_t* cut, hawk_oow_t start, hawk_oow_t end, int delim)
|
||||||
|
{
|
||||||
|
hawk_oow_t len = cut->e.in.nflds;
|
||||||
|
|
||||||
|
if (!cut->e.in.delimited /*|| len <= 0*/) return 0;
|
||||||
|
|
||||||
|
HAWK_ASSERT (len > 0);
|
||||||
|
if (start <= end)
|
||||||
|
{
|
||||||
|
if (start <= len && end > 0)
|
||||||
|
{
|
||||||
|
hawk_oow_t i;
|
||||||
|
|
||||||
|
if (start >= 1) start--;
|
||||||
|
if (end >= 1) end--;
|
||||||
|
|
||||||
|
if (end >= len) end = len - 1;
|
||||||
|
|
||||||
|
if (delim && write_char(cut, cut->sel.dout) <= -1) return -1;
|
||||||
|
|
||||||
|
for (i = start; i <= end; i++)
|
||||||
|
{
|
||||||
|
if (write_str(cut, cut->e.in.flds[i].ptr, cut->e.in.flds[i].len) <= -1) return -1;
|
||||||
|
if (i < end && write_char(cut, cut->sel.dout) <= -1) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (start > 0 && end <= len)
|
||||||
|
{
|
||||||
|
hawk_oow_t i;
|
||||||
|
|
||||||
|
if (start >= 1) start--;
|
||||||
|
if (end >= 1) end--;
|
||||||
|
|
||||||
|
if (start >= len) start = len - 1;
|
||||||
|
|
||||||
|
if (delim && write_char (cut, cut->sel.dout) <= -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = start; i >= end; i--)
|
||||||
|
{
|
||||||
|
if (write_str(cut, cut->e.in.flds[i].ptr, cut->e.in.flds[i].len) <= -1) return -1;
|
||||||
|
if (i > end && write_char (cut, cut->sel.dout) <= -1) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hawk_cut_exec (hawk_cut_t* cut, hawk_cut_io_impl_t inf, hawk_cut_io_impl_t outf)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
hawk_ooi_t n;
|
||||||
|
|
||||||
|
cut->e.out.fun = outf;
|
||||||
|
cut->e.out.eof = 0;
|
||||||
|
cut->e.out.len = 0;
|
||||||
|
|
||||||
|
cut->e.in.fun = inf;
|
||||||
|
cut->e.in.eof = 0;
|
||||||
|
cut->e.in.len = 0;
|
||||||
|
cut->e.in.pos = 0;
|
||||||
|
cut->e.in.num = 0;
|
||||||
|
|
||||||
|
n = cut->e.in.fun(cut, HAWK_CUT_IO_OPEN, &cut->e.in.arg, HAWK_NULL, 0);
|
||||||
|
if (n <= -1)
|
||||||
|
{
|
||||||
|
ret = -1;
|
||||||
|
goto done3;
|
||||||
|
}
|
||||||
|
if (n == 0)
|
||||||
|
{
|
||||||
|
/* EOF reached upon opening an input stream.
|
||||||
|
* no data to process. this is success */
|
||||||
|
goto done2;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = cut->e.out.fun (cut, HAWK_CUT_IO_OPEN, &cut->e.out.arg, HAWK_NULL, 0);
|
||||||
|
if (n <= -1)
|
||||||
|
{
|
||||||
|
ret = -1;
|
||||||
|
goto done2;
|
||||||
|
}
|
||||||
|
if (n == 0)
|
||||||
|
{
|
||||||
|
/* still don't know if we will write something.
|
||||||
|
* just mark EOF on the output stream and continue */
|
||||||
|
cut->e.out.eof = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
hawk_cut_sel_blk_t* b;
|
||||||
|
int id = 0; /* mark 'no output' so far */
|
||||||
|
int delimited = 0;
|
||||||
|
int linebreak = 0;
|
||||||
|
|
||||||
|
n = read_line (cut);
|
||||||
|
if (n <= -1) { ret = -1; goto done; }
|
||||||
|
if (n == 0) goto done;
|
||||||
|
|
||||||
|
if (cut->sel.fcount > 0)
|
||||||
|
{
|
||||||
|
if (split_line (cut) <= -1) { ret = -1; goto done; }
|
||||||
|
delimited = cut->e.in.delimited;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (b = &cut->sel.fb; b != HAWK_NULL; b = b->next)
|
||||||
|
{
|
||||||
|
hawk_oow_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < b->len; i++)
|
||||||
|
{
|
||||||
|
if (b->range[i].id == HAWK_SED_SEL_CHAR)
|
||||||
|
{
|
||||||
|
n = cut_chars (
|
||||||
|
cut,
|
||||||
|
b->range[i].start,
|
||||||
|
b->range[i].end,
|
||||||
|
id == 2
|
||||||
|
);
|
||||||
|
if (n >= 1)
|
||||||
|
{
|
||||||
|
/* mark a char's been output */
|
||||||
|
id = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
n = cut_fields (
|
||||||
|
cut,
|
||||||
|
b->range[i].start,
|
||||||
|
b->range[i].end,
|
||||||
|
id > 0
|
||||||
|
);
|
||||||
|
if (n >= 1)
|
||||||
|
{
|
||||||
|
/* mark a field's been output */
|
||||||
|
id = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n <= -1) { ret = -1; goto done; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cut->sel.ccount > 0)
|
||||||
|
{
|
||||||
|
/* so long as there is a character selector,
|
||||||
|
* a newline must be printed */
|
||||||
|
linebreak = 1;
|
||||||
|
}
|
||||||
|
else if (cut->sel.fcount > 0)
|
||||||
|
{
|
||||||
|
/* if only field selectors are specified */
|
||||||
|
|
||||||
|
if (delimited)
|
||||||
|
{
|
||||||
|
/* and if the input line is delimited,
|
||||||
|
* write a line break */
|
||||||
|
linebreak = 1;
|
||||||
|
}
|
||||||
|
else if (!(cut->option & HAWK_CUT_DELIMONLY))
|
||||||
|
{
|
||||||
|
/* if not delimited, write the
|
||||||
|
* entire undelimited input line depending
|
||||||
|
* on the option set. */
|
||||||
|
if (write_str(cut, HAWK_OOECS_PTR(&cut->e.in.line), HAWK_OOECS_LEN(&cut->e.in.line)) <= -1)
|
||||||
|
{
|
||||||
|
ret = -1; goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a line break is needed in this case */
|
||||||
|
linebreak = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linebreak && write_linebreak(cut) <= -1)
|
||||||
|
{
|
||||||
|
ret = -1; goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
cut->e.out.fun (cut, HAWK_CUT_IO_CLOSE, &cut->e.out.arg, HAWK_NULL, 0);
|
||||||
|
done2:
|
||||||
|
cut->e.in.fun (cut, HAWK_CUT_IO_CLOSE, &cut->e.in.arg, HAWK_NULL, 0);
|
||||||
|
done3:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -------------------------------------- */
|
||||||
|
|
||||||
|
void* hawk_cut_allocmem (hawk_cut_t* cut, hawk_oow_t size)
|
||||||
|
{
|
||||||
|
void* ptr = HAWK_MMGR_ALLOC(hawk_cut_getmmgr(cut), size);
|
||||||
|
if (HAWK_UNLIKELY(!ptr)) hawk_cut_seterrnum(cut, HAWK_NULL, HAWK_ENOMEM);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* hawk_cut_callocmem (hawk_cut_t* cut, hawk_oow_t size)
|
||||||
|
{
|
||||||
|
void* ptr = HAWK_MMGR_ALLOC(hawk_cut_getmmgr(cut), size);
|
||||||
|
if (HAWK_LIKELY(ptr)) HAWK_MEMSET(ptr, 0, size);
|
||||||
|
else hawk_cut_seterrnum(cut, HAWK_NULL, HAWK_ENOMEM);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* hawk_cut_reallocmem (hawk_cut_t* cut, void* ptr, hawk_oow_t size)
|
||||||
|
{
|
||||||
|
void* nptr = HAWK_MMGR_REALLOC(hawk_cut_getmmgr(cut), ptr, size);
|
||||||
|
if (HAWK_UNLIKELY(!nptr)) hawk_cut_seterrnum(cut, HAWK_NULL, HAWK_ENOMEM);
|
||||||
|
return nptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hawk_cut_freemem (hawk_cut_t* cut, void* ptr)
|
||||||
|
{
|
||||||
|
HAWK_MMGR_FREE(hawk_cut_getmmgr(cut), ptr);
|
||||||
|
}
|
@ -447,3 +447,26 @@ hawk_oow_t FN(fmt) (str_t* str, const char_t* fmt, ...)
|
|||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hawk_oow_t FN(compact) (str_t* str)
|
||||||
|
{
|
||||||
|
if (str->val.ptr)
|
||||||
|
{
|
||||||
|
str->val.len = compact_chars(str->val.ptr, str->val.len);
|
||||||
|
str->val.ptr[str->val.len] = '\0';
|
||||||
|
}
|
||||||
|
return str->val.len;
|
||||||
|
}
|
||||||
|
|
||||||
|
hawk_oow_t FN(trim) (str_t* str, int flags)
|
||||||
|
{
|
||||||
|
if (str->val.ptr)
|
||||||
|
{
|
||||||
|
const char_t* ptr;
|
||||||
|
hawk_oow_t len = str->val.len;
|
||||||
|
ptr = trim_chars(str->val.ptr, &len, flags);
|
||||||
|
copy_chars(str->val.ptr, ptr, len);
|
||||||
|
str->val.ptr[len] = '\0';
|
||||||
|
}
|
||||||
|
return str->val.len;
|
||||||
|
}
|
||||||
|
12
lib/ecs.c
12
lib/ecs.c
@ -34,12 +34,18 @@
|
|||||||
#undef char_t
|
#undef char_t
|
||||||
#undef cstr_t
|
#undef cstr_t
|
||||||
#undef count_chars
|
#undef count_chars
|
||||||
|
#undef compact_chars
|
||||||
|
#undef copy_chars
|
||||||
|
#undef trim_chars
|
||||||
#define FN(verb) _FN(becs,verb)
|
#define FN(verb) _FN(becs,verb)
|
||||||
#define T(x) HAWK_BT(x)
|
#define T(x) HAWK_BT(x)
|
||||||
#define str_t hawk_becs_t
|
#define str_t hawk_becs_t
|
||||||
#define char_t hawk_bch_t
|
#define char_t hawk_bch_t
|
||||||
#define cstr_t hawk_bcs_t
|
#define cstr_t hawk_bcs_t
|
||||||
#define count_chars(x) hawk_count_bcstr(x)
|
#define count_chars(x) hawk_count_bcstr(x)
|
||||||
|
#define compact_chars(x,l) hawk_compact_bchars(x,l)
|
||||||
|
#define copy_chars(x,y,l) hawk_copy_bchars(x,y,l)
|
||||||
|
#define trim_chars(x,l,f) hawk_trim_bchars(x,l,f)
|
||||||
#define BUILD_BECS
|
#define BUILD_BECS
|
||||||
#include "ecs-imp.h"
|
#include "ecs-imp.h"
|
||||||
|
|
||||||
@ -51,12 +57,18 @@
|
|||||||
#undef char_t
|
#undef char_t
|
||||||
#undef cstr_t
|
#undef cstr_t
|
||||||
#undef count_chars
|
#undef count_chars
|
||||||
|
#undef compact_chars
|
||||||
|
#undef copy_chars
|
||||||
|
#undef trim_chars
|
||||||
#define FN(verb) _FN(uecs,verb)
|
#define FN(verb) _FN(uecs,verb)
|
||||||
#define T(x) HAWK_UT(x)
|
#define T(x) HAWK_UT(x)
|
||||||
#define str_t hawk_uecs_t
|
#define str_t hawk_uecs_t
|
||||||
#define char_t hawk_uch_t
|
#define char_t hawk_uch_t
|
||||||
#define cstr_t hawk_ucs_t
|
#define cstr_t hawk_ucs_t
|
||||||
#define count_chars(x) hawk_count_ucstr(x)
|
#define count_chars(x) hawk_count_ucstr(x)
|
||||||
|
#define compact_chars(x,l) hawk_compact_uchars(x,l)
|
||||||
|
#define copy_chars(x,y,l) hawk_copy_uchars(x,y,l)
|
||||||
|
#define trim_chars(x,l,f) hawk_trim_uchars(x,l,f)
|
||||||
#define BUILD_UECS
|
#define BUILD_UECS
|
||||||
#include "ecs-imp.h"
|
#include "ecs-imp.h"
|
||||||
|
|
||||||
|
@ -209,6 +209,10 @@ const hawk_ooch_t* hawk_dfl_errstr (hawk_errnum_t errnum)
|
|||||||
HAWK_T("occurrence specifier too large"),
|
HAWK_T("occurrence specifier too large"),
|
||||||
HAWK_T("no previous regular expression"),
|
HAWK_T("no previous regular expression"),
|
||||||
HAWK_T("cut selector not valid"),
|
HAWK_T("cut selector not valid"),
|
||||||
|
HAWK_T("I/O error with file '${0}'"),
|
||||||
|
|
||||||
|
/* cut error messages */
|
||||||
|
HAWK_T("selector not valid"),
|
||||||
HAWK_T("I/O error with file '${0}'")
|
HAWK_T("I/O error with file '${0}'")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1079,6 +1079,10 @@ enum hawk_errnum_t
|
|||||||
HAWK_SED_ECSLNV, /**< cut selector not valid */
|
HAWK_SED_ECSLNV, /**< cut selector not valid */
|
||||||
HAWK_SED_EIOFIL, /**< io error with file '${0}' */
|
HAWK_SED_EIOFIL, /**< io error with file '${0}' */
|
||||||
|
|
||||||
|
/* cut errors */
|
||||||
|
HAWK_CUT_ESELNV, /**< selector not valid */
|
||||||
|
HAWK_CUT_EIOFIL, /**< io error with file '${0}'*/
|
||||||
|
|
||||||
/* the number of error numbers, internal use only */
|
/* the number of error numbers, internal use only */
|
||||||
HAWK_NUMERRNUMS
|
HAWK_NUMERRNUMS
|
||||||
};
|
};
|
||||||
|
481
lib/hawk-cut.h
Normal file
481
lib/hawk-cut.h
Normal file
@ -0,0 +1,481 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2006-2020 Chung, Hyung-Hwan. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _HAWK_CUT_H_
|
||||||
|
#define _HAWK_CUT_H_
|
||||||
|
|
||||||
|
#include <hawk-cmn.h>
|
||||||
|
#include <hawk-gem.h>
|
||||||
|
#include <hawk-sio.h>
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
* This file defines a text cutter utility.
|
||||||
|
*
|
||||||
|
* @todo HAWK_CUT_ORDEREDSEL - A selector 5,3,1 is ordered to 1,3,5
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @example cut.c
|
||||||
|
* This example implements a simple cut utility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @struct hawk_cut_t
|
||||||
|
* The hawk_cut_t type defines a text cutter. The details are hidden as it is
|
||||||
|
* a large complex structure vulnerable to unintended changes.
|
||||||
|
*/
|
||||||
|
typedef struct hawk_cut_t hawk_cut_t;
|
||||||
|
|
||||||
|
#define HAWK_CUT_HDR \
|
||||||
|
hawk_oow_t _instsize; \
|
||||||
|
hawk_gem_t _gem
|
||||||
|
|
||||||
|
typedef struct hawk_cut_alt_t hawk_cut_alt_t;
|
||||||
|
struct hawk_cut_alt_t
|
||||||
|
{
|
||||||
|
/* ensure that hawk_cut_alt_t matches the beginning part of hawk_cut_t */
|
||||||
|
HAWK_CUT_HDR;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_option_t type defines various option codes for a text cutter.
|
||||||
|
* Options can be OR'ed with each other and be passed to a text cutter with
|
||||||
|
* the hawk_cut_setoption() function.
|
||||||
|
*/
|
||||||
|
enum hawk_cut_option_t
|
||||||
|
{
|
||||||
|
/** show delimited line only. if not set, undelimited lines are
|
||||||
|
* shown in its entirety */
|
||||||
|
HAWK_CUT_DELIMONLY = (1 << 0),
|
||||||
|
|
||||||
|
/** treat any whitespaces as an input delimiter */
|
||||||
|
HAWK_CUT_WHITESPACE = (1 << 2),
|
||||||
|
|
||||||
|
/** fold adjacent delimiters */
|
||||||
|
HAWK_CUT_FOLDDELIMS = (1 << 3),
|
||||||
|
|
||||||
|
/** trim leading and trailing whitespaces off the input line */
|
||||||
|
HAWK_CUT_TRIMSPACE = (1 << 4),
|
||||||
|
|
||||||
|
/** normalize whitespaces in the input line */
|
||||||
|
HAWK_CUT_NORMSPACE = (1 << 5)
|
||||||
|
};
|
||||||
|
typedef enum hawk_cut_option_t hawk_cut_option_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_io_cmd_t type defines I/O command codes. The code indicates
|
||||||
|
* the action to take in an I/O handler.
|
||||||
|
*/
|
||||||
|
enum hawk_cut_io_cmd_t
|
||||||
|
{
|
||||||
|
HAWK_CUT_IO_OPEN = 0,
|
||||||
|
HAWK_CUT_IO_CLOSE = 1,
|
||||||
|
HAWK_CUT_IO_READ = 2,
|
||||||
|
HAWK_CUT_IO_WRITE = 3
|
||||||
|
};
|
||||||
|
typedef enum hawk_cut_io_cmd_t hawk_cut_io_cmd_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_io_arg_t type defines a data structure required by
|
||||||
|
* an I/O handler.
|
||||||
|
*/
|
||||||
|
struct hawk_cut_io_arg_t
|
||||||
|
{
|
||||||
|
void* handle; /**< I/O handle */
|
||||||
|
const hawk_ooch_t* path; /**< file path. HAWK_NULL for a console */
|
||||||
|
};
|
||||||
|
typedef struct hawk_cut_io_arg_t hawk_cut_io_arg_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_io_impl_t type defines an I/O handler. hawk_cut_exec() calls
|
||||||
|
* I/O handlers to read from and write to a text stream.
|
||||||
|
*/
|
||||||
|
typedef hawk_ooi_t (*hawk_cut_io_impl_t) (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
hawk_cut_io_cmd_t cmd,
|
||||||
|
hawk_cut_io_arg_t* arg,
|
||||||
|
hawk_ooch_t* data,
|
||||||
|
hawk_oow_t count
|
||||||
|
);
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_iostd_type_t type defines types of standard
|
||||||
|
* I/O resources.
|
||||||
|
*/
|
||||||
|
enum hawk_cut_iostd_type_t
|
||||||
|
{
|
||||||
|
HAWK_CUT_IOSTD_NULL, /**< null resource type */
|
||||||
|
HAWK_CUT_IOSTD_FILE, /**< file */
|
||||||
|
HAWK_CUT_IOSTD_FILEB, /**< file */
|
||||||
|
HAWK_CUT_IOSTD_FILEU, /**< file */
|
||||||
|
HAWK_CUT_IOSTD_OOCS, /**< string */
|
||||||
|
HAWK_CUT_IOSTD_BCS,
|
||||||
|
HAWK_CUT_IOSTD_UCS,
|
||||||
|
HAWK_CUT_IOSTD_SIO /**< sio */
|
||||||
|
};
|
||||||
|
typedef enum hawk_cut_iostd_type_t hawk_cut_iostd_type_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_iostd_t type defines a standard I/O resource.
|
||||||
|
*/
|
||||||
|
struct hawk_cut_iostd_t
|
||||||
|
{
|
||||||
|
/** resource type */
|
||||||
|
hawk_cut_iostd_type_t type;
|
||||||
|
|
||||||
|
/** union describing the resource of the specified type */
|
||||||
|
union
|
||||||
|
{
|
||||||
|
/** file path with character encoding */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
/** file path to open. #HAWK_NULL or '-' for stdin/stdout. */
|
||||||
|
const hawk_ooch_t* path;
|
||||||
|
/** a stream created with the file path is set with this
|
||||||
|
* cmgr if it is not #HAWK_NULL. */
|
||||||
|
hawk_cmgr_t* cmgr;
|
||||||
|
} file;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
const hawk_bch_t* path;
|
||||||
|
hawk_cmgr_t* cmgr;
|
||||||
|
} fileb;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
const hawk_uch_t* path;
|
||||||
|
hawk_cmgr_t* cmgr;
|
||||||
|
} fileu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* input string or dynamically allocated output string
|
||||||
|
*
|
||||||
|
* For input, the ptr and the len field of str indicates the
|
||||||
|
* pointer and the length of a string to read. You must set
|
||||||
|
* these two fields before calling hawk_cut_execstd().
|
||||||
|
*
|
||||||
|
* For output, the ptr and the len field of str indicates the
|
||||||
|
* pointer and the length of produced output. The output
|
||||||
|
* string is dynamically allocated. You don't need to set these
|
||||||
|
* fields before calling hawk_cut_execstd() because they are
|
||||||
|
* set by hawk_cut_execstd() and valid while the relevant cut
|
||||||
|
* object is alive. You must free the memory chunk pointed to by
|
||||||
|
* the ptr field with hawk_cut_freemem() once you're done with it
|
||||||
|
* to avoid memory leaks.
|
||||||
|
*/
|
||||||
|
hawk_oocs_t oocs;
|
||||||
|
hawk_bcs_t bcs;
|
||||||
|
hawk_ucs_t ucs;
|
||||||
|
|
||||||
|
/** pre-opened sio stream */
|
||||||
|
hawk_sio_t* sio;
|
||||||
|
} u;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct hawk_cut_iostd_t hawk_cut_iostd_t;
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_open() function creates a text cutter.
|
||||||
|
* @return A pointer to a text cutter on success, #HAWK_NULL on failure
|
||||||
|
*/
|
||||||
|
|
||||||
|
HAWK_EXPORT hawk_cut_t* hawk_cut_open (
|
||||||
|
hawk_mmgr_t* mmgr, /**< memory manager */
|
||||||
|
hawk_oow_t xtnsize, /**< extension size in bytes */
|
||||||
|
hawk_cmgr_t* cmgr,
|
||||||
|
hawk_errnum_t* errnum
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_close() function destroys a text cutter.
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT void hawk_cut_close (
|
||||||
|
hawk_cut_t* cut /**< text cutter */
|
||||||
|
);
|
||||||
|
|
||||||
|
#if defined(HAWK_HAVE_INLINE)
|
||||||
|
/**
|
||||||
|
* The hawk_cut_getxtn() function returns the pointer to the extension area
|
||||||
|
* placed behind the actual cut object.
|
||||||
|
*/
|
||||||
|
static HAWK_INLINE void* hawk_cut_getxtn (hawk_cut_t* cut) { return (void*)((hawk_uint8_t*)cut + ((hawk_cut_alt_t*)cut)->_instsize); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_getgem() function gets the pointer to the gem structure of the
|
||||||
|
* cut object.
|
||||||
|
*/
|
||||||
|
static HAWK_INLINE hawk_gem_t* hawk_cut_getgem (hawk_cut_t* cut) { return &((hawk_cut_alt_t*)cut)->_gem; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_getmmgr() function gets the memory manager ucut in
|
||||||
|
* hawk_cut_open().
|
||||||
|
*/
|
||||||
|
static HAWK_INLINE hawk_mmgr_t* hawk_cut_getmmgr (hawk_cut_t* cut) { return ((hawk_cut_alt_t*)cut)->_gem.mmgr; }
|
||||||
|
static HAWK_INLINE hawk_cmgr_t* hawk_cut_getcmgr (hawk_cut_t* cut) { return ((hawk_cut_alt_t*)cut)->_gem.cmgr; }
|
||||||
|
static HAWK_INLINE void hawk_cut_setcmgr (hawk_cut_t* cut, hawk_cmgr_t* cmgr) { ((hawk_cut_alt_t*)cut)->_gem.cmgr = cmgr; }
|
||||||
|
#else
|
||||||
|
#define hawk_cut_getxtn(cut) ((void*)((hawk_uint8_t*)cut + ((hawk_cut_alt_t*)cut)->_instsize))
|
||||||
|
#define hawk_cut_getgem(cut) (&((hawk_cut_alt_t*)(cut))->_gem)
|
||||||
|
#define hawk_cut_getmmgr(cut) (((hawk_cut_alt_t*)(cut))->_gem.mmgr)
|
||||||
|
#define hawk_cut_getcmgr(cut) (((hawk_cut_alt_t*)(cut))->_gem.cmgr)
|
||||||
|
#define hawk_cut_setcmgr(cut,_cmgr) (((hawk_cut_alt_t*)(cut))->_gem.cmgr = (_cmgr))
|
||||||
|
#endif /* HAWK_HAVE_INLINE */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_getoption() function retrieves the current options set in
|
||||||
|
* a text cutter.
|
||||||
|
* @return 0 or a number OR'ed of #hawk_cut_option_t values
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT int hawk_cut_getoption (
|
||||||
|
hawk_cut_t* cut /**< text cutter */
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_setoption() function sets the option code.
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT void hawk_cut_setoption (
|
||||||
|
hawk_cut_t* cut, /**< text cutter */
|
||||||
|
int opt /**< 0 or a number OR'ed of #hawk_cut_option_t values */
|
||||||
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT hawk_errstr_t hawk_cut_geterrstr (
|
||||||
|
hawk_cut_t* cut
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_geterrnum() function returns the number of the last error
|
||||||
|
* occurred.
|
||||||
|
* \return error number
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_geterror() function gets an error number, an error location,
|
||||||
|
* and an error message. The information is set to the memory area pointed
|
||||||
|
* to by each parameter.
|
||||||
|
*/
|
||||||
|
#if defined(HAWK_HAVE_INLINE)
|
||||||
|
static HAWK_INLINE hawk_errnum_t hawk_cut_geterrnum (hawk_cut_t* cut) { return hawk_gem_geterrnum(hawk_cut_getgem(cut)); }
|
||||||
|
static HAWK_INLINE const hawk_loc_t* hawk_cut_geterrloc (hawk_cut_t* cut) { return hawk_gem_geterrloc(hawk_cut_getgem(cut)); }
|
||||||
|
static HAWK_INLINE const hawk_bch_t* hawk_cut_geterrbmsg (hawk_cut_t* cut) { return hawk_gem_geterrbmsg(hawk_cut_getgem(cut)); }
|
||||||
|
static HAWK_INLINE const hawk_uch_t* hawk_cut_geterrumsg (hawk_cut_t* cut) { return hawk_gem_geterrumsg(hawk_cut_getgem(cut)); }
|
||||||
|
static HAWK_INLINE void hawk_cut_geterrbinf (hawk_cut_t* cut, hawk_errbinf_t* errinf) { return hawk_gem_geterrbinf(hawk_cut_getgem(cut), errinf); }
|
||||||
|
static HAWK_INLINE void hawk_cut_geterruinf (hawk_cut_t* cut, hawk_erruinf_t* errinf) { return hawk_gem_geterruinf(hawk_cut_getgem(cut), errinf); }
|
||||||
|
static HAWK_INLINE void hawk_cut_geterror (hawk_cut_t* cut, hawk_errnum_t* errnum, const hawk_ooch_t** errmsg, hawk_loc_t* errloc) { return hawk_gem_geterror(hawk_cut_getgem(cut), errnum, errmsg, errloc); }
|
||||||
|
#else
|
||||||
|
#define hawk_cut_geterrnum(cut) hawk_gem_geterrnum(hawk_cut_getgem(cut))
|
||||||
|
#define hawk_cut_geterrloc(cut) hawk_gem_geterrloc(hawk_cut_getgem(cut))
|
||||||
|
#define hawk_cut_geterrbmsg(cut) hawk_gem_geterrbmsg(hawk_cut_getgem(cut))
|
||||||
|
#define hawk_cut_geterrumsg(cut) hawk_gem_geterrumsg(hawk_cut_getgem(cut))
|
||||||
|
#define hawk_cut_geterrbinf(cut, errinf) (hawk_gem_geterrbinf(hawk_cut_getgem(cut), errinf))
|
||||||
|
#define hawk_cut_geterruinf(cut, errinf) (hawk_gem_geterruinf(hawk_cut_getgem(cut), errinf))
|
||||||
|
#define hawk_cut_geterror(cut, errnum, errmsg, errloc) (hawk_gem_geterror(hawk_cut_getgem(cut), errnum, errmsg, errloc))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAWK_OOCH_IS_BCH)
|
||||||
|
# define hawk_cut_geterrmsg hawk_cut_geterrbmsg
|
||||||
|
# define hawk_cut_geterrinf hawk_cut_geterrbinf
|
||||||
|
#else
|
||||||
|
# define hawk_cut_geterrmsg hawk_cut_geterrumsg
|
||||||
|
# define hawk_cut_geterrinf hawk_cut_geterruinf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_seterrnum() function sets the error information omitting
|
||||||
|
* error location. You must pass a non-NULL for \a errarg if the specified
|
||||||
|
* error number \a errnum requires one or more arguments to format an
|
||||||
|
* error message.
|
||||||
|
*/
|
||||||
|
#if defined(HAWK_HAVE_INLINE)
|
||||||
|
static HAWK_INLINE void hawk_cut_seterrnum (hawk_cut_t* cut, const hawk_loc_t* errloc, hawk_errnum_t errnum) { hawk_gem_seterrnum (hawk_cut_getgem(cut), errloc, errnum); }
|
||||||
|
static HAWK_INLINE void hawk_cut_seterrinf (hawk_cut_t* cut, const hawk_errinf_t* errinf) { hawk_gem_seterrinf (hawk_cut_getgem(cut), errinf); }
|
||||||
|
static HAWK_INLINE void hawk_cut_seterror (hawk_cut_t* cut, const hawk_loc_t* errloc, hawk_errnum_t errnum, const hawk_oocs_t* errarg) { hawk_gem_seterror(hawk_cut_getgem(cut), errloc, errnum, errarg); }
|
||||||
|
static HAWK_INLINE const hawk_ooch_t* hawk_cut_backuperrmsg (hawk_cut_t* cut) { return hawk_gem_backuperrmsg(hawk_cut_getgem(cut)); }
|
||||||
|
#else
|
||||||
|
#define hawk_cut_seterrnum(cut, errloc, errnum) hawk_gem_seterrnum(hawk_cut_getgem(cut), errloc, errnum)
|
||||||
|
#define hawk_cut_seterrinf(cut, errinf) hawk_gem_seterrinf(hawk_cut_getgem(cut), errinf)
|
||||||
|
#define hawk_cut_seterror(cut, errloc, errnum, errarg) hawk_gem_seterror(hawk_cut_getgem(cut), errloc, errnum, errarg)
|
||||||
|
#define hawk_cut_backuperrmsg(cut) hawk_gem_backuperrmsg(hawk_cut_getgem(cut))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
HAWK_EXPORT void hawk_cut_seterrbfmt (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
const hawk_loc_t* errloc,
|
||||||
|
hawk_errnum_t errnum,
|
||||||
|
const hawk_bch_t* fmt,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT void hawk_cut_seterrufmt (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
const hawk_loc_t* errloc,
|
||||||
|
hawk_errnum_t errnum,
|
||||||
|
const hawk_uch_t* fmt,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
HAWK_EXPORT void hawk_cut_seterrbvfmt (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
const hawk_loc_t* errloc,
|
||||||
|
hawk_errnum_t errnum,
|
||||||
|
const hawk_bch_t* errfmt,
|
||||||
|
va_list ap
|
||||||
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT void hawk_cut_seterruvfmt (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
const hawk_loc_t* errloc,
|
||||||
|
hawk_errnum_t errnum,
|
||||||
|
const hawk_uch_t* errfmt,
|
||||||
|
va_list ap
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_clear() function clears memory buffers internally allocated.
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT void hawk_cut_clear (
|
||||||
|
hawk_cut_t* cut /**< text cutter */
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_comp() function compiles a selector into an internal form.
|
||||||
|
* @return 0 on success, -1 on error
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT int hawk_cut_comp (
|
||||||
|
hawk_cut_t* cut, /**< text cutter */
|
||||||
|
const hawk_ooch_t* str, /**< selector pointer */
|
||||||
|
hawk_oow_t len /**< selector length */
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_exec() function executes the compiled commands.
|
||||||
|
* @return 0 on success, -1 on error
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT int hawk_cut_exec (
|
||||||
|
hawk_cut_t* cut, /**< text cutter */
|
||||||
|
hawk_cut_io_impl_t inf, /**< input text stream */
|
||||||
|
hawk_cut_io_impl_t outf /**< output text stream */
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_allocmem() function allocates a chunk of memory using
|
||||||
|
* the memory manager of \a cut.
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT void* hawk_cut_allocmem (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
hawk_oow_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_callocmem() function allocates a chunk of memory using
|
||||||
|
* the memory manager of \a cut and clears it to zeros.
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT void* hawk_cut_callocmem (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
hawk_oow_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_reallocmem() function reallocates a chunk of memory using
|
||||||
|
* the memory manager of \a cut.
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT void* hawk_cut_reallocmem (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
void* ptr,
|
||||||
|
hawk_oow_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_freemem() function frees a chunk of memory using
|
||||||
|
* the memory manager of \a cut.
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT void hawk_cut_freemem (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
void* ptr
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_openstd() function creates a text cutter with the default
|
||||||
|
* memory manager and initialized it for other hawk_cut_xxxxstd functions.
|
||||||
|
* @return pointer to a text cutter on success, QSE_NULL on failure.
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT hawk_cut_t* hawk_cut_openstd (
|
||||||
|
hawk_oow_t xtnsize, /**< extension size in bytes */
|
||||||
|
hawk_errnum_t* errnum
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_openstdwithmmgr() function creates a text cutter with a
|
||||||
|
* user-defined memory manager. It is equivalent to hawk_cut_openstd(),
|
||||||
|
* except that you can specify your own memory manager.
|
||||||
|
* @return pointer to a text cutter on success, QSE_NULL on failure.
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT hawk_cut_t* hawk_cut_openstdwithmmgr (
|
||||||
|
hawk_mmgr_t* mmgr, /**< memory manager */
|
||||||
|
hawk_oow_t xtnsize, /**< extension size in bytes */
|
||||||
|
hawk_cmgr_t* cmgr,
|
||||||
|
hawk_errnum_t* errnum
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_compstd() function compiles a null-terminated selector.
|
||||||
|
* Call hawk_cut_comp() for a length delimited selector.
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT int hawk_cut_compstd (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
const hawk_ooch_t* str
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_cut_execstd() function executes the compiled script
|
||||||
|
* over an input file @a infile and an output file @a outfile.
|
||||||
|
* If @a infile is QSE_NULL, the standard console input is used.
|
||||||
|
* If @a outfile is QSE_NULL, the standard console output is used..
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT int hawk_cut_execstd (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
hawk_cut_iostd_t in[],
|
||||||
|
hawk_cut_iostd_t* out
|
||||||
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT int hawk_cut_execstdfile (
|
||||||
|
hawk_cut_t* cut,
|
||||||
|
const hawk_ooch_t* infile,
|
||||||
|
const hawk_ooch_t* outfile,
|
||||||
|
hawk_cmgr_t* cmgr
|
||||||
|
);
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -335,6 +335,15 @@ HAWK_EXPORT hawk_oow_t hawk_becs_fmt (
|
|||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT hawk_oow_t hawk_becs_compact (
|
||||||
|
hawk_becs_t* str
|
||||||
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT hawk_oow_t hawk_becs_trim (
|
||||||
|
hawk_becs_t* str,
|
||||||
|
int flags
|
||||||
|
);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -550,6 +559,15 @@ HAWK_EXPORT hawk_oow_t hawk_uecs_fmt (
|
|||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT hawk_oow_t hawk_uecs_compact (
|
||||||
|
hawk_uecs_t* str
|
||||||
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT hawk_oow_t hawk_uecs_trim (
|
||||||
|
hawk_uecs_t* str,
|
||||||
|
int flags
|
||||||
|
);
|
||||||
|
|
||||||
#if defined(HAWK_OOCH_IS_UCH)
|
#if defined(HAWK_OOCH_IS_UCH)
|
||||||
# define hawk_ooecs_open hawk_uecs_open
|
# define hawk_ooecs_open hawk_uecs_open
|
||||||
# define hawk_ooecs_close hawk_uecs_close
|
# define hawk_ooecs_close hawk_uecs_close
|
||||||
@ -579,6 +597,8 @@ HAWK_EXPORT hawk_oow_t hawk_uecs_fmt (
|
|||||||
# define hawk_ooecs_fcat hawk_uecs_fcat
|
# define hawk_ooecs_fcat hawk_uecs_fcat
|
||||||
# define hawk_ooecs_vfmt hawk_uecs_vfmt
|
# define hawk_ooecs_vfmt hawk_uecs_vfmt
|
||||||
# define hawk_ooecs_fmt hawk_uecs_fmt
|
# define hawk_ooecs_fmt hawk_uecs_fmt
|
||||||
|
# define hawk_ooecs_compact hawk_uecs_compact
|
||||||
|
# define hawk_ooecs_trim hawk_uecs_trim
|
||||||
#else
|
#else
|
||||||
# define hawk_ooecs_open hawk_becs_open
|
# define hawk_ooecs_open hawk_becs_open
|
||||||
# define hawk_ooecs_close hawk_becs_close
|
# define hawk_ooecs_close hawk_becs_close
|
||||||
@ -608,6 +628,8 @@ HAWK_EXPORT hawk_oow_t hawk_uecs_fmt (
|
|||||||
# define hawk_ooecs_fcat hawk_becs_fcat
|
# define hawk_ooecs_fcat hawk_becs_fcat
|
||||||
# define hawk_ooecs_vfmt hawk_becs_vfmt
|
# define hawk_ooecs_vfmt hawk_becs_vfmt
|
||||||
# define hawk_ooecs_fmt hawk_becs_fmt
|
# define hawk_ooecs_fmt hawk_becs_fmt
|
||||||
|
# define hawk_ooecs_compact hawk_becs_compact
|
||||||
|
# define hawk_ooecs_trim hawk_becs_trim
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HAWK_EXPORT hawk_oow_t hawk_becs_ncatuchars (
|
HAWK_EXPORT hawk_oow_t hawk_becs_ncatuchars (
|
||||||
|
@ -499,7 +499,7 @@ HAWK_EXPORT hawk_htb_pair_t* hawk_htb_update (
|
|||||||
* hawk_htb_t* htb, hawk_htb_pair_t* pair,
|
* hawk_htb_t* htb, hawk_htb_pair_t* pair,
|
||||||
* void* kptr, hawk_oow_t klen, void* ctx)
|
* void* kptr, hawk_oow_t klen, void* ctx)
|
||||||
* {
|
* {
|
||||||
* hawk_cstr_t* v = (hawk_cstr_t*)ctx;
|
* hawk_oocs_t* v = (hawk_oocs_t*)ctx;
|
||||||
* if (pair == HAWK_NULL)
|
* if (pair == HAWK_NULL)
|
||||||
* {
|
* {
|
||||||
* // no existing key for the key
|
* // no existing key for the key
|
||||||
@ -552,7 +552,7 @@ HAWK_EXPORT hawk_htb_pair_t* hawk_htb_update (
|
|||||||
*
|
*
|
||||||
* for (i = 0; i < HAWK_COUNTOF(vals); i++)
|
* for (i = 0; i < HAWK_COUNTOF(vals); i++)
|
||||||
* {
|
* {
|
||||||
* hawk_cstr_t ctx;
|
* hawk_oocs_t ctx;
|
||||||
* ctx.ptr = vals[i]; ctx.len = hawk_count_oocstr(vals[i]);
|
* ctx.ptr = vals[i]; ctx.len = hawk_count_oocstr(vals[i]);
|
||||||
* hawk_htb_cbsert (s1,
|
* hawk_htb_cbsert (s1,
|
||||||
* keys[i%HAWK_COUNTOF(keys)], hawk_count_oocstr(keys[i%HAWK_COUNTOF(keys)]),
|
* keys[i%HAWK_COUNTOF(keys)], hawk_count_oocstr(keys[i%HAWK_COUNTOF(keys)]),
|
||||||
|
@ -463,7 +463,7 @@ HAWK_EXPORT hawk_rbt_pair_t* hawk_rbt_update (
|
|||||||
* hawk_rbt_t* rbt, hawk_rbt_pair_t* pair,
|
* hawk_rbt_t* rbt, hawk_rbt_pair_t* pair,
|
||||||
* void* kptr, hawk_oow_t klen, void* ctx)
|
* void* kptr, hawk_oow_t klen, void* ctx)
|
||||||
* {
|
* {
|
||||||
* hawk_cstr_t* v = (hawk_cstr_t*)ctx;
|
* hawk_oocs_t* v = (hawk_oocs_t*)ctx;
|
||||||
* if (pair == HAWK_NULL)
|
* if (pair == HAWK_NULL)
|
||||||
* {
|
* {
|
||||||
* // no existing key for the key
|
* // no existing key for the key
|
||||||
@ -515,7 +515,7 @@ HAWK_EXPORT hawk_rbt_pair_t* hawk_rbt_update (
|
|||||||
*
|
*
|
||||||
* for (i = 0; i < HAWK_COUNTOF(vals); i++)
|
* for (i = 0; i < HAWK_COUNTOF(vals); i++)
|
||||||
* {
|
* {
|
||||||
* hawk_cstr_t ctx;
|
* hawk_oocs_t ctx;
|
||||||
* ctx.ptr = vals[i]; ctx.len = hawk_count_oocstr(vals[i]);
|
* ctx.ptr = vals[i]; ctx.len = hawk_count_oocstr(vals[i]);
|
||||||
* hawk_rbt_cbsert (s1,
|
* hawk_rbt_cbsert (s1,
|
||||||
* keys[i%HAWK_COUNTOF(keys)], hawk_count_oocstr(keys[i%HAWK_COUNTOF(keys)]),
|
* keys[i%HAWK_COUNTOF(keys)], hawk_count_oocstr(keys[i%HAWK_COUNTOF(keys)]),
|
||||||
|
@ -735,6 +735,15 @@ HAWK_EXPORT void hawk_sed_setlinenum (
|
|||||||
hawk_oow_t num /**< a line number */
|
hawk_oow_t num /**< a line number */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_sed_getspace() function gets the pointer and the length
|
||||||
|
* to a buffer space specfied by \a space.
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT void hawk_sed_getspace (
|
||||||
|
hawk_sed_t* sed,
|
||||||
|
hawk_sed_space_t space,
|
||||||
|
hawk_oocs_t* str
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The hawk_sed_allocmem() function allocates a chunk of memory using
|
* The hawk_sed_allocmem() function allocates a chunk of memory using
|
||||||
@ -746,7 +755,7 @@ HAWK_EXPORT void* hawk_sed_allocmem (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The hawk_sed_allocmem() function allocates a chunk of memory using
|
* The hawk_sed_callocmem() function allocates a chunk of memory using
|
||||||
* the memory manager of \a sed and clears it to zeros.
|
* the memory manager of \a sed and clears it to zeros.
|
||||||
*/
|
*/
|
||||||
HAWK_EXPORT void* hawk_sed_callocmem (
|
HAWK_EXPORT void* hawk_sed_callocmem (
|
||||||
@ -755,7 +764,7 @@ HAWK_EXPORT void* hawk_sed_callocmem (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The hawk_sed_allocmem() function reallocates a chunk of memory using
|
* The hawk_sed_reallocmem() function reallocates a chunk of memory using
|
||||||
* the memory manager of \a sed.
|
* the memory manager of \a sed.
|
||||||
*/
|
*/
|
||||||
HAWK_EXPORT void* hawk_sed_reallocmem (
|
HAWK_EXPORT void* hawk_sed_reallocmem (
|
||||||
@ -765,7 +774,7 @@ HAWK_EXPORT void* hawk_sed_reallocmem (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The hawk_sed_allocmem() function frees a chunk of memory using
|
* The hawk_sed_freemem() function frees a chunk of memory using
|
||||||
* the memory manager of \a sed.
|
* the memory manager of \a sed.
|
||||||
*/
|
*/
|
||||||
HAWK_EXPORT void hawk_sed_freemem (
|
HAWK_EXPORT void hawk_sed_freemem (
|
||||||
@ -773,16 +782,6 @@ HAWK_EXPORT void hawk_sed_freemem (
|
|||||||
void* ptr
|
void* ptr
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* The hawk_sed_getspace() function gets the pointer and the length
|
|
||||||
* to a buffer space specfied by \a space.
|
|
||||||
*/
|
|
||||||
HAWK_EXPORT void hawk_sed_getspace (
|
|
||||||
hawk_sed_t* sed,
|
|
||||||
hawk_sed_space_t space,
|
|
||||||
hawk_oocs_t* str
|
|
||||||
);
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,10 +272,39 @@ HAWK_EXPORT const hawk_ooch_t* hawk_stdgetfileindirs (
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_get_sys_mmgr() function returns a pointer to a stock memory manager structure
|
||||||
|
* that can be used where a custom memory manager is not required. The returned structure
|
||||||
|
* is managed internally and should not be modified or finalized by the caller.
|
||||||
|
*
|
||||||
|
* \return Pointer to the system-wide default memory manager.
|
||||||
|
*/
|
||||||
HAWK_EXPORT hawk_mmgr_t* hawk_get_sys_mmgr (
|
HAWK_EXPORT hawk_mmgr_t* hawk_get_sys_mmgr (
|
||||||
void
|
void
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This hawk_init_xma_mmgr() function initializes the memory manager structure pointed
|
||||||
|
* to by `mmgr` with the specified memory limit `memlimit`. The caller is responsible for
|
||||||
|
* allocating the memory for `mmgr` prior to calling this function.
|
||||||
|
*
|
||||||
|
* \return 0 on success, or a negative value on failure
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT int hawk_init_xma_mmgr (
|
||||||
|
hawk_mmgr_t* mmgr,
|
||||||
|
hawk_oow_t memlimit
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hawk_fini_xma_mmgr() function cleans up resources associated with the memory
|
||||||
|
* manager structure previously initialized by `hawk_init_xma_mmgr()`. After this call,
|
||||||
|
* the `mmgr` structure should not be used unless it is re-initialized.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
HAWK_EXPORT void hawk_fini_xma_mmgr (
|
||||||
|
hawk_mmgr_t* mmgr
|
||||||
|
);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -72,9 +72,8 @@
|
|||||||
*/
|
*/
|
||||||
#include <hawk-cmn.h>
|
#include <hawk-cmn.h>
|
||||||
|
|
||||||
#if defined(HAWK_BUILD_DEBUG)
|
/*#define HAWK_XMA_ENABLE_STAT*/
|
||||||
#define HAWK_XMA_ENABLE_STAT
|
#define HAWK_XMA_ENABLE_STAT
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @struct hawk_xma_t
|
/** @struct hawk_xma_t
|
||||||
* The hawk_xma_t type defines a simple memory allocator over a memory zone.
|
* The hawk_xma_t type defines a simple memory allocator over a memory zone.
|
||||||
@ -109,10 +108,19 @@ struct hawk_xma_t
|
|||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
hawk_oow_t total;
|
hawk_oow_t total;
|
||||||
hawk_oow_t alloc;
|
hawk_oow_t alloc; /* allocated size */
|
||||||
hawk_oow_t avail;
|
hawk_oow_t avail; /* available size */
|
||||||
hawk_oow_t nused;
|
hawk_oow_t nused; /* nubmer of used blocks */
|
||||||
hawk_oow_t nfree;
|
hawk_oow_t nfree; /* number of free blocks */
|
||||||
|
hawk_oow_t alloc_hwmark; /* high watermark - highest total memory ever allocated */
|
||||||
|
|
||||||
|
hawk_oow_t nallocops; /* number of alloc operations */
|
||||||
|
hawk_oow_t nallocgoodops; /* number of successful alloc operations */
|
||||||
|
hawk_oow_t nallocbadops; /* number of failed alloc operations */
|
||||||
|
hawk_oow_t nreallocops; /* number of realloc operations */
|
||||||
|
hawk_oow_t nreallocgoodops; /* number of good realloc operations */
|
||||||
|
hawk_oow_t nreallocbadops; /* number of failed realloc operations - could fall back to normal alloc*/
|
||||||
|
hawk_oow_t nfreeops; /* number of free operations */
|
||||||
} stat;
|
} stat;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -2423,7 +2423,6 @@ static int run_while (hawk_rtx_t* rtx, hawk_nde_while_t* nde)
|
|||||||
rtx->exit_level = EXIT_NONE;
|
rtx->exit_level = EXIT_NONE;
|
||||||
}
|
}
|
||||||
else if (rtx->exit_level != EXIT_NONE) break;
|
else if (rtx->exit_level != EXIT_NONE) break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (nde->type == HAWK_NDE_DOWHILE)
|
else if (nde->type == HAWK_NDE_DOWHILE)
|
||||||
|
48
lib/sed.c
48
lib/sed.c
@ -2050,10 +2050,7 @@ static int read_char (hawk_sed_t* sed, hawk_ooch_t* c)
|
|||||||
{
|
{
|
||||||
if (sed->e.in.pos >= sed->e.in.len)
|
if (sed->e.in.pos >= sed->e.in.len)
|
||||||
{
|
{
|
||||||
n = sed->e.in.fun (
|
n = sed->e.in.fun(sed, HAWK_SED_IO_READ, &sed->e.in.arg, sed->e.in.buf, HAWK_COUNTOF(sed->e.in.buf));
|
||||||
sed, HAWK_SED_IO_READ, &sed->e.in.arg,
|
|
||||||
sed->e.in.buf, HAWK_COUNTOF(sed->e.in.buf)
|
|
||||||
);
|
|
||||||
if (n <= -1) return -1;
|
if (n <= -1) return -1;
|
||||||
if (n == 0) return 0; /* end of file */
|
if (n == 0) return 0; /* end of file */
|
||||||
|
|
||||||
@ -2127,10 +2124,7 @@ static int flush (hawk_sed_t* sed)
|
|||||||
|
|
||||||
while (sed->e.out.len > 0)
|
while (sed->e.out.len > 0)
|
||||||
{
|
{
|
||||||
n = sed->e.out.fun (
|
n = sed->e.out.fun(sed, HAWK_SED_IO_WRITE, &sed->e.out.arg, &sed->e.out.buf[pos], sed->e.out.len);
|
||||||
sed, HAWK_SED_IO_WRITE, &sed->e.out.arg,
|
|
||||||
&sed->e.out.buf[pos], sed->e.out.len);
|
|
||||||
|
|
||||||
if (n <= -1) return -1;
|
if (n <= -1) return -1;
|
||||||
if (n == 0) return -1; /* reached the end of file - this is also an error */
|
if (n == 0) return -1; /* reached the end of file - this is also an error */
|
||||||
|
|
||||||
@ -2144,12 +2138,7 @@ static int flush (hawk_sed_t* sed)
|
|||||||
static int write_char (hawk_sed_t* sed, hawk_ooch_t c)
|
static int write_char (hawk_sed_t* sed, hawk_ooch_t c)
|
||||||
{
|
{
|
||||||
sed->e.out.buf[sed->e.out.len++] = c;
|
sed->e.out.buf[sed->e.out.len++] = c;
|
||||||
if (c == HAWK_T('\n') ||
|
if (c == HAWK_T('\n') || sed->e.out.len >= HAWK_COUNTOF(sed->e.out.buf)) return flush (sed);
|
||||||
sed->e.out.len >= HAWK_COUNTOF(sed->e.out.buf))
|
|
||||||
{
|
|
||||||
return flush (sed);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3949,6 +3938,21 @@ void hawk_sed_pushecb (hawk_sed_t* sed, hawk_sed_ecb_t* ecb)
|
|||||||
sed->ecb = ecb;
|
sed->ecb = ecb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hawk_sed_getspace (hawk_sed_t* sed, hawk_sed_space_t space, hawk_oocs_t* str)
|
||||||
|
{
|
||||||
|
switch (space)
|
||||||
|
{
|
||||||
|
case HAWK_SED_SPACE_HOLD:
|
||||||
|
str->ptr = HAWK_OOECS_PTR(&sed->e.txt.hold);
|
||||||
|
str->len = HAWK_OOECS_LEN(&sed->e.txt.hold);
|
||||||
|
break;
|
||||||
|
case HAWK_SED_SPACE_PATTERN:
|
||||||
|
str->ptr = HAWK_OOECS_PTR(&sed->e.in.line);
|
||||||
|
str->len = HAWK_OOECS_LEN(&sed->e.in.line);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void* hawk_sed_allocmem (hawk_sed_t* sed, hawk_oow_t size)
|
void* hawk_sed_allocmem (hawk_sed_t* sed, hawk_oow_t size)
|
||||||
{
|
{
|
||||||
void* ptr = HAWK_MMGR_ALLOC(hawk_sed_getmmgr(sed), size);
|
void* ptr = HAWK_MMGR_ALLOC(hawk_sed_getmmgr(sed), size);
|
||||||
@ -3975,19 +3979,3 @@ void hawk_sed_freemem (hawk_sed_t* sed, void* ptr)
|
|||||||
{
|
{
|
||||||
HAWK_MMGR_FREE (hawk_sed_getmmgr(sed), ptr);
|
HAWK_MMGR_FREE (hawk_sed_getmmgr(sed), ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void hawk_sed_getspace (hawk_sed_t* sed, hawk_sed_space_t space, hawk_oocs_t* str)
|
|
||||||
{
|
|
||||||
switch (space)
|
|
||||||
{
|
|
||||||
case HAWK_SED_SPACE_HOLD:
|
|
||||||
str->ptr = HAWK_OOECS_PTR(&sed->e.txt.hold);
|
|
||||||
str->len = HAWK_OOECS_LEN(&sed->e.txt.hold);
|
|
||||||
break;
|
|
||||||
case HAWK_SED_SPACE_PATTERN:
|
|
||||||
str->ptr = HAWK_OOECS_PTR(&sed->e.in.line);
|
|
||||||
str->len = HAWK_OOECS_LEN(&sed->e.in.line);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
1217
lib/std-cut.c
Normal file
1217
lib/std-cut.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -120,13 +120,14 @@ hawk_sed_t* hawk_sed_openstdwithmmgr (hawk_mmgr_t* mmgr, hawk_oow_t xtnsize, haw
|
|||||||
if (!cmgr) cmgr = hawk_get_cmgr_by_id(HAWK_CMGR_UTF8);
|
if (!cmgr) cmgr = hawk_get_cmgr_by_id(HAWK_CMGR_UTF8);
|
||||||
|
|
||||||
sed = hawk_sed_open(mmgr, HAWK_SIZEOF(xtn_t) + xtnsize, cmgr, errnum);
|
sed = hawk_sed_open(mmgr, HAWK_SIZEOF(xtn_t) + xtnsize, cmgr, errnum);
|
||||||
if (!sed) return HAWK_NULL;
|
if (HAWK_UNLIKELY(!sed)) return HAWK_NULL;
|
||||||
|
|
||||||
sed->_instsize += HAWK_SIZEOF(xtn_t);
|
sed->_instsize += HAWK_SIZEOF(xtn_t);
|
||||||
|
|
||||||
return sed;
|
return sed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
static int verify_iostd_in (hawk_sed_t* sed, hawk_sed_iostd_t in[])
|
static int verify_iostd_in (hawk_sed_t* sed, hawk_sed_iostd_t in[])
|
||||||
{
|
{
|
||||||
hawk_oow_t i;
|
hawk_oow_t i;
|
||||||
@ -990,6 +991,8 @@ static hawk_ooi_t x_out (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
int hawk_sed_compstd (hawk_sed_t* sed, hawk_sed_iostd_t in[], hawk_oow_t* count)
|
int hawk_sed_compstd (hawk_sed_t* sed, hawk_sed_iostd_t in[], hawk_oow_t* count)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = GET_XTN(sed);
|
xtn_t* xtn = GET_XTN(sed);
|
||||||
|
43
lib/std.c
43
lib/std.c
@ -26,6 +26,7 @@
|
|||||||
#include <hawk-std.h>
|
#include <hawk-std.h>
|
||||||
#include <hawk-pio.h>
|
#include <hawk-pio.h>
|
||||||
#include <hawk-sio.h>
|
#include <hawk-sio.h>
|
||||||
|
#include <hawk-xma.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -233,6 +234,47 @@ hawk_mmgr_t* hawk_get_sys_mmgr (void)
|
|||||||
{
|
{
|
||||||
return &sys_mmgr;
|
return &sys_mmgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
static void* xma_alloc (hawk_mmgr_t* mmgr, hawk_oow_t size)
|
||||||
|
{
|
||||||
|
return hawk_xma_alloc(mmgr->ctx, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void* xma_realloc (hawk_mmgr_t* mmgr, void* ptr, hawk_oow_t size)
|
||||||
|
{
|
||||||
|
return hawk_xma_realloc(mmgr->ctx, ptr, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xma_free (hawk_mmgr_t* mmgr, void* ptr)
|
||||||
|
{
|
||||||
|
hawk_xma_free (mmgr->ctx, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int hawk_init_xma_mmgr (hawk_mmgr_t* mmgr, hawk_oow_t memlimit)
|
||||||
|
{
|
||||||
|
hawk_xma_t* xma;
|
||||||
|
|
||||||
|
xma = hawk_xma_open(hawk_get_sys_mmgr(), 0, HAWK_NULL, memlimit);
|
||||||
|
if (HAWK_UNLIKELY(!xma)) return -1;
|
||||||
|
|
||||||
|
HAWK_MEMSET(mmgr, 0, HAWK_SIZEOF(*mmgr));
|
||||||
|
mmgr->alloc = xma_alloc;
|
||||||
|
mmgr->realloc = xma_realloc;
|
||||||
|
mmgr->free = xma_free;
|
||||||
|
mmgr->ctx = xma;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hawk_fini_xma_mmgr (hawk_mmgr_t* mmgr)
|
||||||
|
{
|
||||||
|
if (mmgr->ctx) hawk_xma_close(mmgr->ctx);
|
||||||
|
mmgr->ctx = HAWK_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
@ -2497,7 +2539,6 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod)
|
|||||||
if (sio == HAWK_NULL) return -1;
|
if (sio == HAWK_NULL) return -1;
|
||||||
|
|
||||||
if (rxtn->c.cmgr) hawk_sio_setcmgr (sio, rxtn->c.cmgr);
|
if (rxtn->c.cmgr) hawk_sio_setcmgr (sio, rxtn->c.cmgr);
|
||||||
|
|
||||||
riod->handle = sio;
|
riod->handle = sio;
|
||||||
rxtn->c.out.count++;
|
rxtn->c.out.count++;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -720,7 +720,7 @@ hawk_flt_t hawk_uchars_to_flt (const hawk_uch_t* str, hawk_oow_t len, const hawk
|
|||||||
end = str + len;
|
end = str + len;
|
||||||
|
|
||||||
/* Strip off leading blanks and check for a sign */
|
/* Strip off leading blanks and check for a sign */
|
||||||
/*while (AWK_IS_SPACE(*p)) p++;*/
|
/*while (hawk_is_uch_space(*p)) p++;*/
|
||||||
if (stripspc)
|
if (stripspc)
|
||||||
{
|
{
|
||||||
/* strip off leading spaces */
|
/* strip off leading spaces */
|
||||||
@ -929,7 +929,7 @@ hawk_flt_t hawk_bchars_to_flt (const hawk_bch_t* str, hawk_oow_t len, const hawk
|
|||||||
end = str + len;
|
end = str + len;
|
||||||
|
|
||||||
/* Strip off leading blanks and check for a sign */
|
/* Strip off leading blanks and check for a sign */
|
||||||
/*while (AWK_IS_SPACE(*p)) p++;*/
|
/*while (hawk_is_bch_space(*p)) p++;*/
|
||||||
if (stripspc)
|
if (stripspc)
|
||||||
{
|
{
|
||||||
/* strip off leading spaces */
|
/* strip off leading spaces */
|
||||||
|
64
lib/xma.c
64
lib/xma.c
@ -268,6 +268,15 @@ int hawk_xma_init (hawk_xma_t* xma, hawk_mmgr_t* mmgr, void* zoneptr, hawk_oow_t
|
|||||||
xma->stat.avail = zonesize - MBLKHDRSIZE;
|
xma->stat.avail = zonesize - MBLKHDRSIZE;
|
||||||
xma->stat.nfree = 1;
|
xma->stat.nfree = 1;
|
||||||
xma->stat.nused = 0;
|
xma->stat.nused = 0;
|
||||||
|
xma->stat.alloc_hwmark = 0;
|
||||||
|
|
||||||
|
xma->stat.nallocops = 0;
|
||||||
|
xma->stat.nallocgoodops = 0;
|
||||||
|
xma->stat.nallocbadops = 0;
|
||||||
|
xma->stat.nreallocops = 0;
|
||||||
|
xma->stat.nreallocgoodops = 0;
|
||||||
|
xma->stat.nreallocbadops = 0;
|
||||||
|
xma->stat.nfreeops = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -390,6 +399,7 @@ static hawk_xma_fblk_t* alloc_from_freelist (hawk_xma_t* xma, hawk_oow_t xfi, ha
|
|||||||
xma->stat.nused++;
|
xma->stat.nused++;
|
||||||
xma->stat.alloc += cand->size;
|
xma->stat.alloc += cand->size;
|
||||||
xma->stat.avail -= cand->size;
|
xma->stat.avail -= cand->size;
|
||||||
|
if (xma->stat.alloc > xma->stat.alloc_hwmark) xma->stat.alloc_hwmark = xma->stat.alloc;
|
||||||
#endif
|
#endif
|
||||||
return cand;
|
return cand;
|
||||||
}
|
}
|
||||||
@ -406,6 +416,9 @@ void* hawk_xma_alloc (hawk_xma_t* xma, hawk_oow_t size)
|
|||||||
|
|
||||||
DBG_VERIFY (xma, "alloc start");
|
DBG_VERIFY (xma, "alloc start");
|
||||||
|
|
||||||
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
|
xma->stat.nallocops++;
|
||||||
|
#endif
|
||||||
/* round up 'size' to the multiples of ALIGN */
|
/* round up 'size' to the multiples of ALIGN */
|
||||||
if (size < MINALLOCSIZE) size = MINALLOCSIZE;
|
if (size < MINALLOCSIZE) size = MINALLOCSIZE;
|
||||||
size = HAWK_ALIGN_POW2(size, ALIGN);
|
size = HAWK_ALIGN_POW2(size, ALIGN);
|
||||||
@ -430,13 +443,20 @@ void* hawk_xma_alloc (hawk_xma_t* xma, hawk_oow_t size)
|
|||||||
xma->stat.nused++;
|
xma->stat.nused++;
|
||||||
xma->stat.alloc += cand->size;
|
xma->stat.alloc += cand->size;
|
||||||
xma->stat.avail -= cand->size;
|
xma->stat.avail -= cand->size;
|
||||||
|
if (xma->stat.alloc > xma->stat.alloc_hwmark) xma->stat.alloc_hwmark = xma->stat.alloc;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (xfi == XFIMAX(xma))
|
else if (xfi == XFIMAX(xma))
|
||||||
{
|
{
|
||||||
/* huge block */
|
/* huge block */
|
||||||
cand = alloc_from_freelist(xma, XFIMAX(xma), size);
|
cand = alloc_from_freelist(xma, XFIMAX(xma), size);
|
||||||
if (!cand) return HAWK_NULL;
|
if (HAWK_UNLIKELY(!cand))
|
||||||
|
{
|
||||||
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
|
xma->stat.nallocbadops++;
|
||||||
|
#endif
|
||||||
|
return HAWK_NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -465,10 +485,19 @@ void* hawk_xma_alloc (hawk_xma_t* xma, hawk_oow_t size)
|
|||||||
cand = alloc_from_freelist(xma, xfi, size);
|
cand = alloc_from_freelist(xma, xfi, size);
|
||||||
if (cand) break;
|
if (cand) break;
|
||||||
}
|
}
|
||||||
if (!cand) return HAWK_NULL;
|
if (!cand)
|
||||||
|
{
|
||||||
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
|
xma->stat.nallocbadops++;
|
||||||
|
#endif
|
||||||
|
return HAWK_NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
|
xma->stat.nallocgoodops++;
|
||||||
|
#endif
|
||||||
DBG_VERIFY (xma, "alloc end");
|
DBG_VERIFY (xma, "alloc end");
|
||||||
return SYS_TO_USR(cand);
|
return SYS_TO_USR(cand);
|
||||||
}
|
}
|
||||||
@ -525,6 +554,7 @@ static void* _realloc_merge (hawk_xma_t* xma, void* b, hawk_oow_t size)
|
|||||||
#if defined(HAWK_XMA_ENABLE_STAT)
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
xma->stat.alloc += req;
|
xma->stat.alloc += req;
|
||||||
xma->stat.avail -= req; /* req + MBLKHDRSIZE(tmp) - MBLKHDRSIZE(n) */
|
xma->stat.avail -= req; /* req + MBLKHDRSIZE(tmp) - MBLKHDRSIZE(n) */
|
||||||
|
if (xma->stat.alloc > xma->stat.alloc_hwmark) xma->stat.alloc_hwmark = xma->stat.alloc;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -542,6 +572,7 @@ static void* _realloc_merge (hawk_xma_t* xma, void* b, hawk_oow_t size)
|
|||||||
xma->stat.nfree--;
|
xma->stat.nfree--;
|
||||||
xma->stat.alloc += MBLKHDRSIZE + n->size;
|
xma->stat.alloc += MBLKHDRSIZE + n->size;
|
||||||
xma->stat.avail -= n->size;
|
xma->stat.avail -= n->size;
|
||||||
|
if (xma->stat.alloc > xma->stat.alloc_hwmark) xma->stat.alloc_hwmark = xma->stat.alloc;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -614,7 +645,7 @@ static void* _realloc_merge (hawk_xma_t* xma, void* b, hawk_oow_t size)
|
|||||||
void* hawk_xma_calloc (hawk_xma_t* xma, hawk_oow_t size)
|
void* hawk_xma_calloc (hawk_xma_t* xma, hawk_oow_t size)
|
||||||
{
|
{
|
||||||
void* ptr = hawk_xma_alloc(xma, size);
|
void* ptr = hawk_xma_alloc(xma, size);
|
||||||
if (ptr) HAWK_MEMSET (ptr, 0, size);
|
if (HAWK_LIKELY(ptr)) HAWK_MEMSET(ptr, 0, size);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,9 +661,15 @@ void* hawk_xma_realloc (hawk_xma_t* xma, void* b, hawk_oow_t size)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* try reallocation by merging the adjacent continuous blocks */
|
/* try reallocation by merging the adjacent continuous blocks */
|
||||||
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
|
xma->stat.nreallocops++;
|
||||||
|
#endif
|
||||||
n = _realloc_merge (xma, b, size);
|
n = _realloc_merge (xma, b, size);
|
||||||
if (!n)
|
if (!n)
|
||||||
{
|
{
|
||||||
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
|
xma->stat.nreallocbadops++;
|
||||||
|
#endif
|
||||||
/* reallocation by merging failed. fall back to the slow
|
/* reallocation by merging failed. fall back to the slow
|
||||||
* allocation-copy-free scheme */
|
* allocation-copy-free scheme */
|
||||||
n = hawk_xma_alloc(xma, size);
|
n = hawk_xma_alloc(xma, size);
|
||||||
@ -642,6 +679,12 @@ void* hawk_xma_realloc (hawk_xma_t* xma, void* b, hawk_oow_t size)
|
|||||||
hawk_xma_free (xma, b);
|
hawk_xma_free (xma, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
|
xma->stat.nreallocgoodops++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
@ -661,6 +704,7 @@ void hawk_xma_free (hawk_xma_t* xma, void* b)
|
|||||||
/* update statistical variables */
|
/* update statistical variables */
|
||||||
xma->stat.nused--;
|
xma->stat.nused--;
|
||||||
xma->stat.alloc -= org_blk_size;
|
xma->stat.alloc -= org_blk_size;
|
||||||
|
xma->stat.nfreeops++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
x = prev_mblk(blk);
|
x = prev_mblk(blk);
|
||||||
@ -800,9 +844,10 @@ void hawk_xma_dump (hawk_xma_t* xma, hawk_xma_dumper_t dumper, void* ctx)
|
|||||||
|
|
||||||
#if defined(HAWK_XMA_ENABLE_STAT)
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
dumper (ctx, "== statistics ==\n");
|
dumper (ctx, "== statistics ==\n");
|
||||||
dumper (ctx, "total = %zu\n", xma->stat.total);
|
dumper (ctx, "Total = %zu\n", xma->stat.total);
|
||||||
dumper (ctx, "alloc = %zu\n", xma->stat.alloc);
|
dumper (ctx, "Alloc = %zu\n", xma->stat.alloc);
|
||||||
dumper (ctx, "avail = %zu\n", xma->stat.avail);
|
dumper (ctx, "Avail = %zu\n", xma->stat.avail);
|
||||||
|
dumper (ctx, "Alloc High Watermark = %zu\n", xma->stat.alloc_hwmark);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dumper (ctx, "== blocks ==\n");
|
dumper (ctx, "== blocks ==\n");
|
||||||
@ -826,6 +871,13 @@ void hawk_xma_dump (hawk_xma_t* xma, hawk_xma_dumper_t dumper, void* ctx)
|
|||||||
#if defined(HAWK_XMA_ENABLE_STAT)
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
dumper (ctx, "Internal use : %18zu bytes\n", isum);
|
dumper (ctx, "Internal use : %18zu bytes\n", isum);
|
||||||
dumper (ctx, "Total : %18zu bytes\n", (asum + fsum + isum));
|
dumper (ctx, "Total : %18zu bytes\n", (asum + fsum + isum));
|
||||||
|
dumper (ctx, "Alloc operations : %18zu\n", xma->stat.nallocops);
|
||||||
|
dumper (ctx, "Good alloc operations : %18zu\n", xma->stat.nallocgoodops);
|
||||||
|
dumper (ctx, "Bad alloc operations : %18zu\n", xma->stat.nallocbadops);
|
||||||
|
dumper (ctx, "Realloc operations : %18zu\n", xma->stat.nreallocops);
|
||||||
|
dumper (ctx, "Good realloc operations: %18zu\n", xma->stat.nreallocgoodops);
|
||||||
|
dumper (ctx, "Bad realloc operations : %18zu\n", xma->stat.nreallocbadops);
|
||||||
|
dumper (ctx, "Free operations : %18zu\n", xma->stat.nfreeops);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAWK_XMA_ENABLE_STAT)
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
|
@ -13,6 +13,7 @@ int main ()
|
|||||||
{
|
{
|
||||||
hawk_json_t* json;
|
hawk_json_t* json;
|
||||||
hawk_json_prim_t prim;
|
hawk_json_prim_t prim;
|
||||||
|
/* const hawk_ooch_t* TODO */
|
||||||
|
|
||||||
no_plan();
|
no_plan();
|
||||||
prim.instcb = on_json_element;
|
prim.instcb = on_json_element;
|
||||||
@ -20,6 +21,8 @@ int main ()
|
|||||||
json = hawk_json_openstd(0, &prim, HAWK_NULL);
|
json = hawk_json_openstd(0, &prim, HAWK_NULL);
|
||||||
OK (json != HAWK_NULL, "instantiation must be successful");
|
OK (json != HAWK_NULL, "instantiation must be successful");
|
||||||
|
|
||||||
|
/* hawk_json_feed(json, "{\"hello\": \"world\"}", & TODO */
|
||||||
|
|
||||||
hawk_json_close(json);
|
hawk_json_close(json);
|
||||||
return exit_status();
|
return exit_status();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user