added qse_sed_getspace(), qse_sed_allocmem(), qse_sed_reallocmem(), qse_sed_callocmem(), qse_sed_freemem()
This commit is contained in:
@ -15,20 +15,27 @@ LDADD += $(UNICOWS_LIBS)
|
||||
endif
|
||||
endif
|
||||
|
||||
bin_PROGRAMS = sed01
|
||||
CMNFILES = sed00.c sed00.h
|
||||
bin_PROGRAMS = sed01 sed02 sed03
|
||||
|
||||
sed01_SOURCES = sed01.c
|
||||
sed01_SOURCES = sed01.c $(CMNFILES)
|
||||
sed01_LDADD = $(LDADD)
|
||||
|
||||
sed02_SOURCES = sed02.c $(CMNFILES)
|
||||
sed02_LDADD = $(LDADD)
|
||||
|
||||
sed03_SOURCES = sed03.c $(CMNFILES)
|
||||
sed03_LDADD = $(LDADD)
|
||||
|
||||
if ENABLE_CXX
|
||||
|
||||
CXXLIB = -lqsesedxx -lqsecmnxx
|
||||
bin_PROGRAMS += sed21 sed22
|
||||
|
||||
sed21_SOURCES = sed21.cpp
|
||||
sed21_SOURCES = sed21.cpp $(CMNFILES)
|
||||
sed21_LDADD = $(CXXLIB) $(LDADD)
|
||||
|
||||
sed22_SOURCES = sed22.cpp
|
||||
sed22_SOURCES = sed22.cpp $(CMNFILES)
|
||||
sed22_LDADD = $(CXXLIB) $(LDADD)
|
||||
|
||||
endif
|
||||
|
@ -35,7 +35,8 @@ POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
@WCHAR_TRUE@@WIN32_TRUE@am__append_1 = $(UNICOWS_LIBS)
|
||||
bin_PROGRAMS = sed01$(EXEEXT) $(am__EXEEXT_1)
|
||||
bin_PROGRAMS = sed01$(EXEEXT) sed02$(EXEEXT) sed03$(EXEEXT) \
|
||||
$(am__EXEEXT_1)
|
||||
@ENABLE_CXX_TRUE@am__append_2 = sed21 sed22
|
||||
subdir = samples/sed
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
@ -55,19 +56,26 @@ CONFIG_CLEAN_VPATH_FILES =
|
||||
@ENABLE_CXX_TRUE@am__EXEEXT_1 = sed21$(EXEEXT) sed22$(EXEEXT)
|
||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_sed01_OBJECTS = sed01.$(OBJEXT)
|
||||
am__objects_1 = sed00.$(OBJEXT)
|
||||
am_sed01_OBJECTS = sed01.$(OBJEXT) $(am__objects_1)
|
||||
sed01_OBJECTS = $(am_sed01_OBJECTS)
|
||||
am__DEPENDENCIES_1 =
|
||||
@WCHAR_TRUE@@WIN32_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
|
||||
am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2)
|
||||
sed01_DEPENDENCIES = $(am__DEPENDENCIES_3)
|
||||
am__sed21_SOURCES_DIST = sed21.cpp
|
||||
@ENABLE_CXX_TRUE@am_sed21_OBJECTS = sed21.$(OBJEXT)
|
||||
am_sed02_OBJECTS = sed02.$(OBJEXT) $(am__objects_1)
|
||||
sed02_OBJECTS = $(am_sed02_OBJECTS)
|
||||
sed02_DEPENDENCIES = $(am__DEPENDENCIES_3)
|
||||
am_sed03_OBJECTS = sed03.$(OBJEXT) $(am__objects_1)
|
||||
sed03_OBJECTS = $(am_sed03_OBJECTS)
|
||||
sed03_DEPENDENCIES = $(am__DEPENDENCIES_3)
|
||||
am__sed21_SOURCES_DIST = sed21.cpp sed00.c sed00.h
|
||||
@ENABLE_CXX_TRUE@am_sed21_OBJECTS = sed21.$(OBJEXT) $(am__objects_1)
|
||||
sed21_OBJECTS = $(am_sed21_OBJECTS)
|
||||
@ENABLE_CXX_TRUE@sed21_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
||||
am__sed22_SOURCES_DIST = sed22.cpp
|
||||
@ENABLE_CXX_TRUE@am_sed22_OBJECTS = sed22.$(OBJEXT)
|
||||
am__sed22_SOURCES_DIST = sed22.cpp sed00.c sed00.h
|
||||
@ENABLE_CXX_TRUE@am_sed22_OBJECTS = sed22.$(OBJEXT) $(am__objects_1)
|
||||
sed22_OBJECTS = $(am_sed22_OBJECTS)
|
||||
@ENABLE_CXX_TRUE@sed22_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||
@ENABLE_CXX_TRUE@ $(am__DEPENDENCIES_3)
|
||||
@ -93,9 +101,10 @@ CXXLD = $(CXX)
|
||||
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
SOURCES = $(sed01_SOURCES) $(sed21_SOURCES) $(sed22_SOURCES)
|
||||
DIST_SOURCES = $(sed01_SOURCES) $(am__sed21_SOURCES_DIST) \
|
||||
$(am__sed22_SOURCES_DIST)
|
||||
SOURCES = $(sed01_SOURCES) $(sed02_SOURCES) $(sed03_SOURCES) \
|
||||
$(sed21_SOURCES) $(sed22_SOURCES)
|
||||
DIST_SOURCES = $(sed01_SOURCES) $(sed02_SOURCES) $(sed03_SOURCES) \
|
||||
$(am__sed21_SOURCES_DIST) $(am__sed22_SOURCES_DIST)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
@ -279,12 +288,17 @@ AM_CPPFLAGS = \
|
||||
-I$(includedir)
|
||||
|
||||
LDADD = -lqsesed -lqsecmn $(am__append_1)
|
||||
sed01_SOURCES = sed01.c
|
||||
CMNFILES = sed00.c sed00.h
|
||||
sed01_SOURCES = sed01.c $(CMNFILES)
|
||||
sed01_LDADD = $(LDADD)
|
||||
sed02_SOURCES = sed02.c $(CMNFILES)
|
||||
sed02_LDADD = $(LDADD)
|
||||
sed03_SOURCES = sed03.c $(CMNFILES)
|
||||
sed03_LDADD = $(LDADD)
|
||||
@ENABLE_CXX_TRUE@CXXLIB = -lqsesedxx -lqsecmnxx
|
||||
@ENABLE_CXX_TRUE@sed21_SOURCES = sed21.cpp
|
||||
@ENABLE_CXX_TRUE@sed21_SOURCES = sed21.cpp $(CMNFILES)
|
||||
@ENABLE_CXX_TRUE@sed21_LDADD = $(CXXLIB) $(LDADD)
|
||||
@ENABLE_CXX_TRUE@sed22_SOURCES = sed22.cpp
|
||||
@ENABLE_CXX_TRUE@sed22_SOURCES = sed22.cpp $(CMNFILES)
|
||||
@ENABLE_CXX_TRUE@sed22_LDADD = $(CXXLIB) $(LDADD)
|
||||
all: all-am
|
||||
|
||||
@ -366,6 +380,12 @@ clean-binPROGRAMS:
|
||||
sed01$(EXEEXT): $(sed01_OBJECTS) $(sed01_DEPENDENCIES) $(EXTRA_sed01_DEPENDENCIES)
|
||||
@rm -f sed01$(EXEEXT)
|
||||
$(LINK) $(sed01_OBJECTS) $(sed01_LDADD) $(LIBS)
|
||||
sed02$(EXEEXT): $(sed02_OBJECTS) $(sed02_DEPENDENCIES) $(EXTRA_sed02_DEPENDENCIES)
|
||||
@rm -f sed02$(EXEEXT)
|
||||
$(LINK) $(sed02_OBJECTS) $(sed02_LDADD) $(LIBS)
|
||||
sed03$(EXEEXT): $(sed03_OBJECTS) $(sed03_DEPENDENCIES) $(EXTRA_sed03_DEPENDENCIES)
|
||||
@rm -f sed03$(EXEEXT)
|
||||
$(LINK) $(sed03_OBJECTS) $(sed03_LDADD) $(LIBS)
|
||||
sed21$(EXEEXT): $(sed21_OBJECTS) $(sed21_DEPENDENCIES) $(EXTRA_sed21_DEPENDENCIES)
|
||||
@rm -f sed21$(EXEEXT)
|
||||
$(CXXLINK) $(sed21_OBJECTS) $(sed21_LDADD) $(LIBS)
|
||||
@ -379,7 +399,10 @@ mostlyclean-compile:
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sed00.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sed01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sed02.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sed03.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sed21.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sed22.Po@am__quote@
|
||||
|
||||
|
31
qse/samples/sed/sed00.c
Normal file
31
qse/samples/sed/sed00.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* sed00.c */
|
||||
|
||||
#include "sed00.h"
|
||||
#include <qse/cmn/mbwc.h>
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
void init_sed_sample_locale (void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOutputCP (CP_UTF8);*/
|
||||
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
}
|
16
qse/samples/sed/sed00.h
Normal file
16
qse/samples/sed/sed00.h
Normal file
@ -0,0 +1,16 @@
|
||||
/* sed00.h */
|
||||
|
||||
#ifndef _SED00_H_
|
||||
#define _SED00_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void init_sed_sample_locale (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,14 +1,9 @@
|
||||
#include <qse/sed/std.h>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include "sed00.h"
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
int sed_main (int argc, qse_char_t* argv[])
|
||||
static int sed_main (int argc, qse_char_t* argv[])
|
||||
{
|
||||
qse_sed_t* sed = QSE_NULL;
|
||||
qse_char_t* infile;
|
||||
@ -21,6 +16,7 @@ int sed_main (int argc, qse_char_t* argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* create a sed object */
|
||||
sed = qse_sed_openstd (0);
|
||||
if (sed == QSE_NULL)
|
||||
{
|
||||
@ -28,6 +24,7 @@ int sed_main (int argc, qse_char_t* argv[])
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* compile commands */
|
||||
if (qse_sed_compstdstr (sed, argv[1]) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: %s\n"), qse_sed_geterrmsg(sed));
|
||||
@ -37,6 +34,7 @@ int sed_main (int argc, qse_char_t* argv[])
|
||||
infile = (argc >= 3)? argv[2]: QSE_NULL;
|
||||
outfile = (argc >= 4)? argv[3]: QSE_NULL;
|
||||
|
||||
/* executes the compiled commands over the intput and output files specified */
|
||||
if (qse_sed_execstdfile (sed, infile, outfile, QSE_NULL) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: %s\n"), qse_sed_geterrmsg(sed));
|
||||
@ -44,30 +42,14 @@ int sed_main (int argc, qse_char_t* argv[])
|
||||
}
|
||||
|
||||
oops:
|
||||
if (sed != QSE_NULL) qse_sed_close (sed);
|
||||
/* destroy the sed object */
|
||||
if (sed) qse_sed_close (sed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOutputCP (CP_UTF8);*/
|
||||
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
init_sed_sample_locale ();
|
||||
return qse_runmain (argc, argv, sed_main);
|
||||
}
|
||||
|
||||
|
68
qse/samples/sed/sed02.c
Normal file
68
qse/samples/sed/sed02.c
Normal file
@ -0,0 +1,68 @@
|
||||
#include <qse/sed/std.h>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include "sed00.h"
|
||||
|
||||
static int sed_main (int argc, qse_char_t* argv[])
|
||||
{
|
||||
qse_sed_t* sed = QSE_NULL;
|
||||
qse_sed_iostd_t in[2];
|
||||
qse_sed_iostd_t out;
|
||||
int ret = -1;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("USAGE: %s command-string input-string\n"), argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* create the sed object */
|
||||
sed = qse_sed_openstd (0);
|
||||
if (sed == QSE_NULL)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open sed\n"));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* compile the command string */
|
||||
if (qse_sed_compstdstr (sed, argv[1]) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: %s\n"), qse_sed_geterrmsg(sed));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* arrange to use the second argument as input data */
|
||||
in[0].type = QSE_SED_IOSTD_STR;
|
||||
in[0].u.str.ptr = argv[2];
|
||||
in[0].u.str.len = qse_strlen (argv[2]);
|
||||
in[1].type = QSE_SED_IOSTD_NULL;
|
||||
|
||||
/* indicate that the output should be placed in a
|
||||
* dynamically allocated memory chunk */
|
||||
out.type = QSE_SED_IOSTD_STR;
|
||||
|
||||
/* execute the compiled command */
|
||||
if (qse_sed_execstd (sed, in, &out) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: %s\n"), qse_sed_geterrmsg(sed));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* access the output data produced */
|
||||
qse_printf (QSE_T("%.*s\n"), (int)out.u.str.len, out.u.str.ptr);
|
||||
|
||||
/* free the output data */
|
||||
qse_sed_freemem (sed, out.u.str.ptr);
|
||||
|
||||
oops:
|
||||
/* destroy the sed object */
|
||||
if (sed) qse_sed_close (sed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
init_sed_sample_locale ();
|
||||
return qse_runmain (argc, argv, sed_main);
|
||||
}
|
||||
|
77
qse/samples/sed/sed03.c
Normal file
77
qse/samples/sed/sed03.c
Normal file
@ -0,0 +1,77 @@
|
||||
#include <qse/sed/std.h>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include "sed00.h"
|
||||
|
||||
static void trace_exec (qse_sed_t* sed, qse_sed_exec_op_t op, qse_sed_cmd_t* cmd)
|
||||
{
|
||||
qse_cstr_t h, p;
|
||||
|
||||
qse_sed_getspace (sed, QSE_SED_SPACE_HOLD, &h);
|
||||
qse_sed_getspace (sed, QSE_SED_SPACE_PATTERN, &p);
|
||||
|
||||
/* print the contents of the hold space and the pattern space
|
||||
* at each phase of execution */
|
||||
qse_printf (QSE_T("HOLD: [%.*s] PATTERN: [%.*s]\n"), (int)h.len, h.ptr, (int)p.len, p.ptr);
|
||||
}
|
||||
|
||||
static int sed_main (int argc, qse_char_t* argv[])
|
||||
{
|
||||
qse_sed_t* sed = QSE_NULL;
|
||||
qse_sed_iostd_t in[2];
|
||||
qse_sed_iostd_t out;
|
||||
int ret = -1;
|
||||
|
||||
/* create the sed object */
|
||||
sed = qse_sed_openstd (0);
|
||||
if (sed == QSE_NULL)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open sed\n"));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* compile the command string */
|
||||
if (qse_sed_compstdstr (sed, QSE_T("s/abc/def/g; s/def/kkk/g")) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: %s\n"), qse_sed_geterrmsg(sed));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* arrange to use the second argument as input data */
|
||||
in[0].type = QSE_SED_IOSTD_STR;
|
||||
in[0].u.str.ptr = QSE_T("ABCDEFGHI abcdefghi abcdefghi\nhigh abc dom\n");
|
||||
in[0].u.str.len = qse_strlen (in[0].u.str.ptr);
|
||||
in[1].type = QSE_SED_IOSTD_NULL;
|
||||
|
||||
/* indicate that the output should be placed in a
|
||||
* dynamically allocated memory chunk */
|
||||
out.type = QSE_SED_IOSTD_STR;
|
||||
|
||||
/* squeeze in a tracing hook */
|
||||
qse_sed_setexectracer (sed, trace_exec);
|
||||
|
||||
/* execute the compiled command */
|
||||
if (qse_sed_execstd (sed, in, &out) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: %s\n"), qse_sed_geterrmsg(sed));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* access the output data produced */
|
||||
qse_printf (QSE_T("%.*s\n"), (int)out.u.str.len, out.u.str.ptr);
|
||||
|
||||
/* free the output data */
|
||||
qse_sed_freemem (sed, out.u.str.ptr);
|
||||
|
||||
oops:
|
||||
/* destroy the sed object */
|
||||
if (sed) qse_sed_close (sed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
init_sed_sample_locale ();
|
||||
return qse_runmain (argc, argv, sed_main);
|
||||
}
|
||||
|
@ -1,16 +1,9 @@
|
||||
#include <qse/sed/StdSed.hpp>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <iostream>
|
||||
#include "sed00.h"
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
# include <stdio.h>
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef QSE_CHAR_IS_MCHAR
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
# define xcout std::cout
|
||||
#else
|
||||
# define xcout std::wcout
|
||||
@ -27,7 +20,7 @@ int sed_main (int argc, qse_char_t* argv[])
|
||||
|
||||
QSE::StdSed sed;
|
||||
|
||||
if (sed.open () == -1)
|
||||
if (sed.open () <= -1)
|
||||
{
|
||||
xcout << QSE_T("ERR: cannot open") << std::endl;
|
||||
return -1;
|
||||
@ -35,7 +28,7 @@ int sed_main (int argc, qse_char_t* argv[])
|
||||
|
||||
|
||||
QSE::StdSed::StringStream sstream (argv[1]);
|
||||
if (sed.compile (sstream) == -1)
|
||||
if (sed.compile (sstream) <= -1)
|
||||
{
|
||||
xcout << QSE_T("ERR: cannot compile - ") << sed.getErrorMessage() << std::endl;
|
||||
sed.close ();
|
||||
@ -46,7 +39,7 @@ int sed_main (int argc, qse_char_t* argv[])
|
||||
qse_char_t* outfile = (argc >= 4)? argv[3]: QSE_NULL;
|
||||
QSE::StdSed::FileStream fstream (infile, outfile);
|
||||
|
||||
if (sed.execute (fstream) == -1)
|
||||
if (sed.execute (fstream) <= -1)
|
||||
{
|
||||
xcout << QSE_T("ERR: cannot execute - ") << sed.getErrorMessage() << std::endl;
|
||||
sed.close ();
|
||||
@ -59,23 +52,6 @@ int sed_main (int argc, qse_char_t* argv[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
init_sed_sample_locale ();
|
||||
return qse_runmain (argc, argv, sed_main);
|
||||
}
|
||||
|
@ -1,37 +1,10 @@
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2012 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <qse/sed/StdSed.hpp>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/sio.h>
|
||||
#include <iostream>
|
||||
#include "sed00.h"
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
# include <stdio.h>
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef QSE_CHAR_IS_MCHAR
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
# define xcout std::cout
|
||||
#else
|
||||
# define xcout std::wcout
|
||||
@ -94,23 +67,6 @@ int sed_main (int argc, qse_char_t* argv[])
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[])
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
init_sed_sample_locale ();
|
||||
return qse_runmain (argc, argv, sed_main);
|
||||
}
|
||||
|
Reference in New Issue
Block a user