mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
format
This commit is contained in:
parent
c0f155f203
commit
c32c9d97b2
106
src/PikaObj.c
106
src/PikaObj.c
@ -926,62 +926,61 @@ void obj_shellLineProcess(PikaObj* self,
|
||||
__obj_runCharBeforeRun(self);
|
||||
|
||||
/* getchar and run */
|
||||
char inputChar[2] = {0};
|
||||
char inputChar[2] = {0};
|
||||
while (1) {
|
||||
inputChar[1] = inputChar[0];
|
||||
inputChar[1] = inputChar[0];
|
||||
inputChar[0] = __platform_getchar();
|
||||
|
||||
/* #! xxx */
|
||||
if (inputChar[0] == '!' && inputChar[1] == '#'){
|
||||
/* start */
|
||||
char* buff = pikaMalloc(PIKA_READ_FILE_BUFF_SIZE);
|
||||
char input[2] = {0};
|
||||
int buff_i = 0;
|
||||
PIKA_BOOL is_first_line = PIKA_TRUE;
|
||||
while(1){
|
||||
input[1] = input[0];
|
||||
input[0] = __platform_getchar();
|
||||
if(input[0] == '!' && input[1] == '#'){
|
||||
buff[buff_i - 1] = 0;
|
||||
for(int i = 0;i < 4;i++){
|
||||
/* eat 'pika' */
|
||||
__platform_getchar();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if('\r' == input[0]){
|
||||
continue;
|
||||
}
|
||||
if(is_first_line){
|
||||
if('\n' == input[0]){
|
||||
is_first_line = PIKA_FALSE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
buff[buff_i++] = input[0];
|
||||
}
|
||||
/* end */
|
||||
__platform_printf("\r\n=============== [code] ===============\r\n");
|
||||
size_t len = strGetSize(buff);
|
||||
for (int i = 0;i < len; i ++){
|
||||
if(buff[i] == '\r'){
|
||||
continue;
|
||||
}
|
||||
if(buff[i] == '\n'){
|
||||
__platform_printf("\r\n");
|
||||
continue;
|
||||
}
|
||||
__platform_printf("%c", buff[i]);
|
||||
}
|
||||
__platform_printf("\r\n");
|
||||
__platform_printf("=============== [code] ===============\r\n");
|
||||
obj_run(self, (char* )buff);
|
||||
pikaFree(buff, PIKA_READ_FILE_BUFF_SIZE);
|
||||
__platform_printf(cfg->prefix);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* #! xxx */
|
||||
if (inputChar[0] == '!' && inputChar[1] == '#') {
|
||||
/* start */
|
||||
char* buff = pikaMalloc(PIKA_READ_FILE_BUFF_SIZE);
|
||||
char input[2] = {0};
|
||||
int buff_i = 0;
|
||||
PIKA_BOOL is_first_line = PIKA_TRUE;
|
||||
while (1) {
|
||||
input[1] = input[0];
|
||||
input[0] = __platform_getchar();
|
||||
if (input[0] == '!' && input[1] == '#') {
|
||||
buff[buff_i - 1] = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
/* eat 'pika' */
|
||||
__platform_getchar();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ('\r' == input[0]) {
|
||||
continue;
|
||||
}
|
||||
if (is_first_line) {
|
||||
if ('\n' == input[0]) {
|
||||
is_first_line = PIKA_FALSE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
buff[buff_i++] = input[0];
|
||||
}
|
||||
/* end */
|
||||
__platform_printf("\r\n=============== [code] ===============\r\n");
|
||||
size_t len = strGetSize(buff);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
if (buff[i] == '\r') {
|
||||
continue;
|
||||
}
|
||||
if (buff[i] == '\n') {
|
||||
__platform_printf("\r\n");
|
||||
continue;
|
||||
}
|
||||
__platform_printf("%c", buff[i]);
|
||||
}
|
||||
__platform_printf("\r\n");
|
||||
__platform_printf("=============== [code] ===============\r\n");
|
||||
obj_run(self, (char*)buff);
|
||||
pikaFree(buff, PIKA_READ_FILE_BUFF_SIZE);
|
||||
__platform_printf(cfg->prefix);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (SHELL_STATE_EXIT ==
|
||||
_do_obj_runChar(self, inputChar[0], cfg, __lineHandler_fun)) {
|
||||
break;
|
||||
@ -1008,7 +1007,6 @@ void _temp_obj_shellLineProcess(PikaObj* self,
|
||||
static enum shell_state __obj_shellLineHandler_REPL(PikaObj* self,
|
||||
char* input_line,
|
||||
struct shell_config* cfg) {
|
||||
|
||||
/* exit */
|
||||
if (strEqu("exit()", input_line)) {
|
||||
/* exit pika shell */
|
||||
|
@ -38,12 +38,12 @@
|
||||
*/
|
||||
|
||||
/* optimize options */
|
||||
#define PIKA_OPTIMIZE_SIZE 0
|
||||
#define PIKA_OPTIMIZE_SPEED 1
|
||||
#define PIKA_OPTIMIZE_SIZE 0
|
||||
#define PIKA_OPTIMIZE_SPEED 1
|
||||
|
||||
/* syntax support level */
|
||||
#define PIKA_SYNTAX_LEVEL_MINIMAL 0
|
||||
#define PIKA_SYNTAX_LEVEL_MAXIMAL 1
|
||||
#define PIKA_SYNTAX_LEVEL_MINIMAL 0
|
||||
#define PIKA_SYNTAX_LEVEL_MAXIMAL 1
|
||||
|
||||
/* use user config */
|
||||
#ifdef PIKA_CONFIG_ENABLE
|
||||
@ -90,12 +90,10 @@
|
||||
|
||||
#elif PIKA_OPTIMIZE == PIKA_OPTIMIZE_SPEED
|
||||
#ifndef PIKA_METHOD_CACHE_ENABLE
|
||||
#ifndef PIKA_METHOD_CACHE_ENABLE
|
||||
#define PIKA_METHOD_CACHE_ENABLE 1
|
||||
#endif
|
||||
#ifndef PIKA_ARG_CACHE_ENABLE
|
||||
#define PIKA_ARG_CACHE_ENABLE 1
|
||||
#endif
|
||||
#define PIKA_METHOD_CACHE_ENABLE 1
|
||||
#endif
|
||||
#ifndef PIKA_ARG_CACHE_ENABLE
|
||||
#define PIKA_ARG_CACHE_ENABLE 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user