*** empty log message ***

This commit is contained in:
hyung-hwan 2007-02-23 06:43:30 +00:00
parent 5708a992c0
commit 6eda269c5c
7 changed files with 280 additions and 37 deletions

View File

@ -1,11 +1,192 @@
/*
* $Id: str.c,v 1.3 2007-02-23 06:31:06 bacon Exp $
* $Id: str.c,v 1.4 2007-02-23 06:43:30 bacon Exp $
*
* {License}
*/
#include <ase/cmn/str.h>
ase_size_t ase_strlen (const ase_char_t* str)
{
const ase_char_t* p = str;
while (*p != ASE_T('\0')) p++;
return p - str;
}
ase_size_t ase_strcpy (ase_char_t* buf, const ase_char_t* str)
{
ase_char_t* org = buf;
while ((*buf++ = *str++) != ASE_T('\0'));
return buf - org - 1;
}
ase_size_t ase_strxcpy (
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str)
{
ase_char_t* p, * p2;
p = buf; p2 = buf + bsz - 1;
while (p < p2)
{
if (*str == ASE_T('\0')) break;
*p++ = *str++;
}
if (bsz > 0) *p = ASE_T('\0');
return p - buf;
}
ase_size_t ase_strncpy (
ase_char_t* buf, const ase_char_t* str, ase_size_t len)
{
const ase_char_t* end = str + len;
while (str < end) *buf++ = *str++;
*buf = ASE_T('\0');
return len;
}
int ase_strcmp (const ase_char_t* s1, const ase_char_t* s2)
{
while (*s1 == *s2)
{
if (*s1 == ASE_C('\0')) return 0;
s1++, s2++;
}
return (*s1 > *s2)? 1: -1;
}
int ase_strxncmp (
const ase_char_t* s1, ase_size_t len1,
const ase_char_t* s2, ase_size_t len2)
{
ase_char_t c1, c2;
const ase_char_t* end1 = s1 + len1;
const ase_char_t* end2 = s2 + len2;
while (s1 < end1)
{
c1 = *s1;
if (s2 < end2)
{
c2 = *s2;
if (c1 > c2) return 1;
if (c1 < c2) return -1;
}
else return 1;
s1++; s2++;
}
return (s2 < end2)? -1: 0;
}
int ase_strcasecmp (
const ase_char_t* s1, const ase_char_t* s2, ase_ccls_t* ccls)
{
while (ASE_TOUPPER(ccls,*s1) == ASE_TOUPPER(ccls,*s2))
{
if (*s1 == ASE_C('\0')) return 0;
s1++, s2++;
}
return (ASE_TOUPPER(ccls,*s1) > ASE_TOUPPER(ccls,*s2))? 1: -1;
}
int ase_strxncasecmp (
const ase_char_t* s1, ase_size_t len1,
const ase_char_t* s2, ase_size_t len2, ase_ccls_t* ccls)
{
ase_char_t c1, c2;
const ase_char_t* end1 = s1 + len1;
const ase_char_t* end2 = s2 + len2;
while (s1 < end1)
{
c1 = ASE_TOUPPER (ccls, *s1);
if (s2 < end2)
{
c2 = ASE_TOUPPER (ccls, *s2);
if (c1 > c2) return 1;
if (c1 < c2) return -1;
}
else return 1;
s1++; s2++;
}
return (s2 < end2)? -1: 0;
}
ase_char_t* ase_strdup (const ase_char_t* str, ase_mmgr_t* mmgr)
{
ase_char_t* tmp;
tmp = (ase_char_t*) ASE_MALLOC (
mmgr, (ase_strlen(str)+1)*ASE_SIZEOF(ase_char_t));
if (tmp == ASE_NULL) return ASE_NULL;
ase_strcpy (tmp, str);
return tmp;
}
ase_char_t* ase_strxdup (
const ase_char_t* str, ase_size_t len, ase_mmgr_t* mmgr)
{
ase_char_t* tmp;
tmp = (ase_char_t*) ASE_MALLOC (
mmgr, (len+1)*ASE_SIZEOF(ase_char_t));
if (tmp == ASE_NULL) return ASE_NULL;
ase_strncpy (tmp, str, len);
return tmp;
}
ase_char_t* ase_strxdup2 (
const ase_char_t* str1, ase_size_t len1,
const ase_char_t* str2, ase_size_t len2, ase_mmgr_t* mmgr)
{
ase_char_t* tmp;
tmp = (ase_char_t*) ASE_MALLOC (
mmgr, (len1+len2+1) * ASE_SIZEOF(ase_char_t));
if (tmp == ASE_NULL) return ASE_NULL;
ase_strncpy (tmp, str1, len1);
ase_strncpy (tmp + len1, str2, len2);
return tmp;
}
ase_char_t* ase_strxnstr (
const ase_char_t* str, ase_size_t strsz,
const ase_char_t* sub, ase_size_t subsz)
{
const ase_char_t* end, * subp;
if (subsz == 0) return (ase_char_t*)str;
if (strsz < subsz) return ASE_NULL;
end = str + strsz - subsz;
subp = sub + subsz;
while (str <= end)
{
const ase_char_t* x = str;
const ase_char_t* y = sub;
while (ase_true)
{
if (y >= subp) return (ase_char_t*)str;
if (*x != *y) break;
x++; y++;
}
str++;
}
return ASE_NULL;
}
ase_str_t* ase_str_open (ase_str_t* str, ase_size_t capa, ase_mmgr_t* mmgr)
{
if (str == ASE_NULL)

View File

@ -1,5 +1,5 @@
/*
* $Id: str.h,v 1.2 2007-02-22 14:46:43 bacon Exp $
* $Id: str.h,v 1.3 2007-02-23 06:43:30 bacon Exp $
*
* {License}
*/
@ -31,6 +31,33 @@ struct ase_str_t
extern "C" {
#endif
ase_size_t ase_strlen (const ase_char_t* str);
ase_size_t ase_strcpy (ase_char_t* buf, const ase_char_t* str);
ase_size_t ase_strxcpy (ase_char_t* buf, ase_size_t bsz, const ase_char_t* str);
ase_size_t ase_strncpy (ase_char_t* buf, const ase_char_t* str, ase_size_t len);
int ase_strcmp (const ase_char_t* s1, const ase_char_t* s2);
int ase_strxncmp (
const ase_char_t* s1, ase_size_t len1,
const ase_char_t* s2, ase_size_t len2);
int ase_strcasecmp (
const ase_char_t* s1, const ase_char_t* s2, ase_ccls_t* ccls);
int ase_strxncasecmp (
const ase_char_t* s1, ase_size_t len1,
const ase_char_t* s2, ase_size_t len2, ase_ccls_t* ccls);
ase_char_t* ase_strdup (const ase_char_t* str, ase_mmgr_t* mmgr);
ase_char_t* ase_strxdup (
const ase_char_t* str, ase_size_t len, ase_mmgr_t* mmgr);
ase_char_t* ase_strxdup2 (
const ase_char_t* str1, ase_size_t len1,
const ase_char_t* str2, ase_size_t len2, ase_mmgr_t* mmgr);
ase_char_t* ase_strxnstr (
const ase_char_t* str, ase_size_t strsz,
const ase_char_t* sub, ase_size_t subsz);
ase_str_t* ase_str_open (ase_str_t* str, ase_size_t capa, ase_mmgr_t* mmgr);
void ase_str_close (ase_str_t* str);
void ase_str_clear (ase_str_t* str);

5
ase/configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.ac Revision: 1.75 .
# From configure.ac Revision: 1.76 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for ase deb-0.1.0.
#
@ -9904,7 +9904,7 @@ then
CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE"
fi
ac_config_files="$ac_config_files makefile awk/makefile lsp/makefile utl/makefile test/awk/makefile test/lsp/makefile"
ac_config_files="$ac_config_files makefile cmn/makefile awk/makefile lsp/makefile utl/makefile test/awk/makefile test/lsp/makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@ -10431,6 +10431,7 @@ do
case "$ac_config_target" in
# Handling of arguments.
"makefile" ) CONFIG_FILES="$CONFIG_FILES makefile" ;;
"cmn/makefile" ) CONFIG_FILES="$CONFIG_FILES cmn/makefile" ;;
"awk/makefile" ) CONFIG_FILES="$CONFIG_FILES awk/makefile" ;;
"lsp/makefile" ) CONFIG_FILES="$CONFIG_FILES lsp/makefile" ;;
"utl/makefile" ) CONFIG_FILES="$CONFIG_FILES utl/makefile" ;;

View File

@ -1,6 +1,6 @@
AC_PREREQ(2.53)
AC_INIT([ase], [deb-0.1.0])
AC_REVISION([$Revision: 1.76 $])
AC_REVISION([$Revision: 1.77 $])
AC_CONFIG_HEADER([conf_unx.h])
# Checks for programs.
@ -76,5 +76,5 @@ then
[CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE"]
fi
AC_CONFIG_FILES([makefile awk/makefile lsp/makefile utl/makefile test/awk/makefile test/lsp/makefile])
AC_CONFIG_FILES([makefile cmn/makefile awk/makefile lsp/makefile utl/makefile test/awk/makefile test/lsp/makefile])
AC_OUTPUT

View File

@ -1,5 +1,5 @@
/*
* $Id: macros.h,v 1.50 2007-02-22 14:46:42 bacon Exp $
* $Id: macros.h,v 1.51 2007-02-23 06:43:30 bacon Exp $
*
* {License}
*/
@ -96,25 +96,35 @@
#define ASE_END_PACKED_STRUCT() };
#endif
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#define ASE_MALLOC(mmgr,size) malloc (size)
#define ASE_MALLOC(mmgr,size) malloc (size)
#define ASE_REALLOC(mmgr,ptr,size) realloc (ptr, size)
#define ASE_FREE(mmgr,ptr) free (ptr)
#define ASE_FREE(mmgr,ptr) free (ptr)
#else
#define ASE_MALLOC(mmgr,size) \
(mmgr)->malloc (size, (mmgr)->custom_data)
#define ASE_REALLOC(mmgr,ptr,size) \
(mmgr)->realloc (ptr, size, (mmgr)->custom_data)
#define ASE_FREE(mmgr,ptr) \
(mmgr)->free (ptr, (mmgr)->custom_data)
#define ASE_MALLOC(mmgr,size) (mmgr)->malloc (mmgr, size)
#define ASE_REALLOC(mmgr,ptr,size) (mmgr)->realloc (mmgr, ptr, size)
#define ASE_FREE(mmgr,ptr) (mmgr)->free (mmgr, ptr)
#endif
#define ASE_MEMCPY(mmgr,dst,src,len) (mmgr)->memcpy (dst, src, len)
#define ASE_MEMSET(mmgr,dst,val,len) (mmgr)->memset (dst, val, len)
#define ASE_MEMCPY(mmgr,dst,src,len) (mmgr)->memcpy (mmgr, dst, src, len)
#define ASE_MEMSET(mmgr,dst,val,len) (mmgr)->memset (mmgr, dst, val, len)
#define ASE_MEMCMP(mmgr,m1,m2,len) (mmgr)->memcmp (mmgr, m1, m2, len)
#define ASE_ISUPPER(ccls,c) (ccls)->is_upper (ccls, c)
#define ASE_ISLOWER(ccls,c) (ccls)->is_lower (ccls, c)
#define ASE_ISALPHA(ccls,c) (ccls)->is_alpha (ccls, c)
#define ASE_ISDIGIT(ccls,c) (ccls)->is_digit (ccls, c)
#define ASE_ISXDIGIT(ccls,c) (ccls)->is_xdigit (ccls, c)
#define ASE_ISALNUM(ccls,c) (ccls)->is_alnum (ccls, c)
#define ASE_ISSPACE(ccls,c) (ccls)->is_space (ccls, c)
#define ASE_ISPRINT(ccls,c) (ccls)->is_print (ccls, c)
#define ASE_ISGRAPH(ccls,c) (ccls)->is_graph (ccls, c)
#define ASE_ISCNTRL(ccls,c) (ccls)->is_cntrl (ccls, c)
#define ASE_ISPUNCT(ccls,c) (ccls)->is_punct (ccls, c)
#define ASE_TOUPPER(ccls,c) (ccls)->to_upper (ccls, c)
#define ASE_TOLOWER(ccls,c) (ccls)->to_lower (ccls, c)
#endif

View File

@ -1,4 +1,4 @@
SUBDIRS=awk lsp utl
SUBDIRS=cmn awk lsp utl
all:
@for i in $(SUBDIRS); \

View File

@ -1,5 +1,5 @@
/*
* $Id: types.h,v 1.70 2007-02-22 14:46:42 bacon Exp $
* $Id: types.h,v 1.71 2007-02-23 06:43:30 bacon Exp $
*
* {License}
*/
@ -230,25 +230,20 @@ typedef int ase_mcint_t;
#endif
#endif
typedef void* (*ase_malloc_t) (ase_size_t n, void* custom_data);
typedef void* (*ase_realloc_t) (void* ptr, ase_size_t n, void* custom_data);
typedef void (*ase_free_t) (void* ptr, void* custom_data);
typedef void* (*ase_memcpy_t) (void* dst, const void* src, ase_size_t n);
typedef void* (*ase_memset_t) (void* dst, int val, ase_size_t n);
typedef struct ase_mmgr_t ase_mmgr_t;
typedef struct ase_cstr_t ase_cstr_t;
typedef struct ase_mmgr_t ase_mmgr_t;
typedef struct ase_ccls_t ase_ccls_t;
struct ase_mmgr_t
{
void* custom_data;
ase_malloc_t malloc;
ase_realloc_t realloc;
ase_free_t free;
ase_memcpy_t memcpy;
ase_memset_t memset;
};
typedef void* (*ase_malloc_t) (ase_mmgr_t* mmgr, ase_size_t n);
typedef void* (*ase_realloc_t) (ase_mmgr_t* mmgr, void* ptr, ase_size_t n);
typedef void (*ase_free_t) (ase_mmgr_t* mmgr, void* ptr);
typedef void* (*ase_memcpy_t) (ase_mmgr_t* mmgr, void* dst, const void* src, ase_size_t n);
typedef void* (*ase_memset_t) (ase_mmgr_t* mmgr, void* dst, int val, ase_size_t n);
typedef void* (*ase_memcmp_t) (ase_mmgr_t* mmgr, const void* m1, const void* m2, ase_size_t n);
typedef ase_bool_t (*ase_isccls_t) (ase_ccls_t* ccls, ase_cint_t c);
typedef ase_cint_t (*ase_toccls_t) (ase_ccls_t* ccls, ase_cint_t c);
struct ase_cstr_t
{
@ -256,4 +251,33 @@ struct ase_cstr_t
ase_size_t len;
};
struct ase_mmgr_t
{
ase_malloc_t malloc;
ase_realloc_t realloc;
ase_free_t free;
ase_memcpy_t memcpy;
ase_memset_t memset;
ase_memcmp_t memcmp;
void* custom_data;
};
struct ase_ccls_t
{
ase_isccls_t is_upper;
ase_isccls_t is_lower;
ase_isccls_t is_alpha;
ase_isccls_t is_digit;
ase_isccls_t is_xdigit;
ase_isccls_t is_alnum;
ase_isccls_t is_space;
ase_isccls_t is_print;
ase_isccls_t is_graph;
ase_isccls_t is_cntrl;
ase_isccls_t is_punct;
ase_toccls_t to_upper;
ase_toccls_t to_lower;
void* custom_data;
};
#endif