*polished main.c.

This commit is contained in:
tony 2015-09-21 23:58:14 +08:00
parent b6ab676ad7
commit b7b11efb41

View File

@ -1,27 +1,27 @@
/* /*
** This source file is part of MY-BASIC ** This source file is part of MY-BASIC
** **
** For the latest info, see https://github.com/paladin-t/my_basic/ ** For the latest info, see https://github.com/paladin-t/my_basic/
** **
** Copyright (C) 2011 - 2015 Wang Renxin ** Copyright (C) 2011 - 2015 Wang Renxin
** **
** Permission is hereby granted, free of charge, to any person obtaining a copy of ** Permission is hereby granted, free of charge, to any person obtaining a copy of
** this software and associated documentation files (the "Software"), to deal in ** this software and associated documentation files (the "Software"), to deal in
** the Software without restriction, including without limitation the rights to ** the Software without restriction, including without limitation the rights to
** use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of ** use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
** the Software, and to permit persons to whom the Software is furnished to do so, ** the Software, and to permit persons to whom the Software is furnished to do so,
** subject to the following conditions: ** subject to the following conditions:
** **
** The above copyright notice and this permission notice shall be included in all ** The above copyright notice and this permission notice shall be included in all
** copies or substantial portions of the Software. ** copies or substantial portions of the Software.
** **
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
** FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR ** FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
** COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER ** COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
** IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ** IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
** CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ** CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER
# ifndef _CRT_SECURE_NO_WARNINGS # ifndef _CRT_SECURE_NO_WARNINGS
@ -60,9 +60,9 @@
#endif /* __POCC__ */ #endif /* __POCC__ */
/* /*
** {======================================================== ** {========================================================
** Common declarations ** Common declarations
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER
# define _BIN_FILE_NAME "my_basic" # define _BIN_FILE_NAME "my_basic"
@ -86,9 +86,9 @@ static struct mb_interpreter_t* bas = 0;
/* ========================================================} */ /* ========================================================} */
/* /*
** {======================================================== ** {========================================================
** Common ** Common
*/ */
#ifndef _printf #ifndef _printf
# define _printf printf # define _printf printf
@ -97,9 +97,9 @@ static struct mb_interpreter_t* bas = 0;
/* ========================================================} */ /* ========================================================} */
/* /*
** {======================================================== ** {========================================================
** Memory manipulation ** Memory manipulation
*/ */
#ifdef _USE_MEM_POOL #ifdef _USE_MEM_POOL
@ -263,9 +263,9 @@ static void _push_mem(char* p) {
/* ========================================================} */ /* ========================================================} */
/* /*
** {======================================================== ** {========================================================
** Code manipulation ** Code manipulation
*/ */
typedef struct _code_line_t { typedef struct _code_line_t {
char** lines; char** lines;
@ -409,9 +409,9 @@ static int _save_file(const char* path, const char* txt) {
/* ========================================================} */ /* ========================================================} */
/* /*
** {======================================================== ** {========================================================
** Interactive commands ** Interactive commands
*/ */
static void _clear_screen(void) { static void _clear_screen(void) {
#ifdef _MSC_VER #ifdef _MSC_VER
@ -672,17 +672,17 @@ static int _do_line(void) {
/* ========================================================} */ /* ========================================================} */
/* /*
** {======================================================== ** {========================================================
** Parameter processing ** Parameter processing
*/ */
#define _CHECK_ARG(__c, __i, __e) \ #define _CHECK_ARG(__c, __i, __e) \
do { \ do { \
if(__c <= __i + 1) { \ if(__c <= __i + 1) { \
_printf(__e); \ _printf(__e); \
return; \ return; \
} \ } \
} while(0) } while(0)
static void _run_file(char* path) { static void _run_file(char* path) {
if(mb_load_file(bas, path) == MB_FUNC_OK) { if(mb_load_file(bas, path) == MB_FUNC_OK) {
@ -766,9 +766,9 @@ static void _process_parameters(int argc, char* argv[]) {
/* ========================================================} */ /* ========================================================} */
/* /*
** {======================================================== ** {========================================================
** Scripting interfaces ** Scripting interfaces
*/ */
static int beep(struct mb_interpreter_t* s, void** l) { static int beep(struct mb_interpreter_t* s, void** l) {
int result = MB_FUNC_OK; int result = MB_FUNC_OK;
@ -786,9 +786,9 @@ static int beep(struct mb_interpreter_t* s, void** l) {
/* ========================================================} */ /* ========================================================} */
/* /*
** {======================================================== ** {========================================================
** Callbacks and handlers ** Callbacks and handlers
*/ */
static void _on_stepped(struct mb_interpreter_t* s, int p, unsigned short row, unsigned short col) { static void _on_stepped(struct mb_interpreter_t* s, int p, unsigned short row, unsigned short col) {
mb_unrefvar(s); mb_unrefvar(s);
@ -809,9 +809,9 @@ static void _on_error(struct mb_interpreter_t* s, mb_error_e e, char* m, char* f
/* ========================================================} */ /* ========================================================} */
/* /*
** {======================================================== ** {========================================================
** Initialization and disposing ** Initialization and disposing
*/ */
static void _on_startup(void) { static void _on_startup(void) {
#ifdef _USE_MEM_POOL #ifdef _USE_MEM_POOL
@ -851,9 +851,9 @@ static void _on_exit(void) {
/* ========================================================} */ /* ========================================================} */
/* /*
** {======================================================== ** {========================================================
** Entry ** Entry
*/ */
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
int status = 0; int status = 0;