*** empty log message ***
This commit is contained in:
parent
364cf51537
commit
375c3f19c3
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: func.c,v 1.5 2006-06-21 15:37:51 bacon Exp $
|
* $Id: func.c,v 1.6 2006-06-30 04:25:53 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -7,6 +7,7 @@
|
|||||||
#ifndef XP_AWK_STAND_ALONE
|
#ifndef XP_AWK_STAND_ALONE
|
||||||
#include <xp/bas/memory.h>
|
#include <xp/bas/memory.h>
|
||||||
#include <xp/bas/string.h>
|
#include <xp/bas/string.h>
|
||||||
|
#include <xp/bas/assert.h>
|
||||||
#include <xp/bas/str.h>
|
#include <xp/bas/str.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.c,v 1.47 2006-06-30 04:18:29 bacon Exp $
|
* $Id: awk.c,v 1.48 2006-06-30 04:25:53 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk.h>
|
#include <xp/awk/awk.h>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
#ifndef __STAND_ALONE
|
#ifndef __STAND_ALONE
|
||||||
#include <xp/bas/stdio.h>
|
#include <xp/bas/stdio.h>
|
||||||
#include <xp/bas/string.h>
|
#include <xp/bas/string.h>
|
||||||
|
#include <xp/bas/sysapi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -67,16 +68,44 @@ static FILE* fopen_t (const xp_char_t* path, const xp_char_t* mode)
|
|||||||
mode_mb = mode;
|
mode_mb = mode;
|
||||||
#else
|
#else
|
||||||
if (xp_wcstomcs_strict (
|
if (xp_wcstomcs_strict (
|
||||||
path, path_mb, xp_countof(path_mb)) == -1) return -1;
|
path, path_mb, xp_countof(path_mb)) == -1) return XP_NULL;
|
||||||
if (xp_wcstomcs_strict (
|
if (xp_wcstomcs_strict (
|
||||||
mode, mode_mb, xp_countof(mode_mb)) == -1) return -1;
|
mode, mode_mb, xp_countof(mode_mb)) == -1) return XP_NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return fopen (path_mb, mode_mb);
|
return fopen (path_mb, mode_mb);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FILE* popen_t (const xp_char_t* cmd, const xp_char_t* mode)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
return _tpopen (cmd, mode);
|
||||||
|
#else
|
||||||
|
#ifdef XP_CHAR_IS_MCHAR
|
||||||
|
const xp_mchar_t* cmd_mb;
|
||||||
|
const xp_mchar_t* mode_mb;
|
||||||
|
#else
|
||||||
|
xp_mchar_t cmd_mb[2048];
|
||||||
|
xp_mchar_t mode_mb[32];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef XP_CHAR_IS_MCHAR
|
||||||
|
cmd_mb = cmd;
|
||||||
|
mode_mb = mode;
|
||||||
|
#else
|
||||||
|
if (xp_wcstomcs_strict (
|
||||||
|
cmd, cmd_mb, xp_countof(cmd_mb)) == -1) return XP_NULL;
|
||||||
|
if (xp_wcstomcs_strict (
|
||||||
|
mode, mode_mb, xp_countof(mode_mb)) == -1) return XP_NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return popen (cmd_mb, mode_mb);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
{
|
||||||
#define fgets_t _fgetts
|
#define fgets_t _fgetts
|
||||||
#define fputs_t _fputts
|
#define fputs_t _fputts
|
||||||
#else
|
#else
|
||||||
@ -100,7 +129,7 @@ static xp_ssize_t process_source (
|
|||||||
case XP_AWK_IO_OPEN:
|
case XP_AWK_IO_OPEN:
|
||||||
{
|
{
|
||||||
if (src_io->input_file == XP_NULL) return 0;
|
if (src_io->input_file == XP_NULL) return 0;
|
||||||
src_io->input_handle = fopen_t (src_io->input_file, _T("r"));
|
src_io->input_handle = fopen_t (src_io->input_file, XP_T("r"));
|
||||||
if (src_io->input_handle == NULL) return -1;
|
if (src_io->input_handle == NULL) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -211,7 +240,7 @@ static xp_ssize_t process_extio_pipe (
|
|||||||
mode = XP_T("w");
|
mode = XP_T("w");
|
||||||
else return -1; /* TODO: any way to set the error number? */
|
else return -1; /* TODO: any way to set the error number? */
|
||||||
xp_printf (XP_TEXT("opending %s of type %d (pipe)\n"), epa->name, epa->type);
|
xp_printf (XP_TEXT("opending %s of type %d (pipe)\n"), epa->name, epa->type);
|
||||||
handle = _tpopen (epa->name, mode);
|
handle = popen_t (epa->name, mode);
|
||||||
if (handle == NULL) return -1;
|
if (handle == NULL) return -1;
|
||||||
epa->handle = (void*)handle;
|
epa->handle = (void*)handle;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user