From ba8ed2cfa675b23cb19cba538f719a07a79ffb7f Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Fri, 18 Aug 2017 01:52:52 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?utf8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D1=80=D1=87=D0=B0=20=D0=BF=D0=B0?= =?utf8?q?=D0=BC=D1=8F=D1=82=D0=B8.=20=D0=9D=D0=B0=20=D1=8D=D1=82=D0=BE?= =?utf8?q?=D1=82=20=D1=80=D0=B0=D0=B7=20=D1=82=D0=BE=D1=87=D0=BD=D0=BE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- notes | 2 +- src/oberon.c | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/notes b/notes index a07b3b5..dfa95ca 100644 --- a/notes +++ b/notes @@ -1,3 +1,4 @@ +- Не полная реализация модуля SYSTEM - Не полная реализация модуля Strings - Не полная реализация модуля Files - Сделать проверку повторов в CASE. @@ -23,7 +24,6 @@ Нужен другой тип округления? - Нет счёта строк / столбцов (хрен с ними - у меня есть утилита tail!) -- Нет модуля SYSTEM (на жабе он особо и не нужен) - Нужны средства создания биндингов. На данный момент реализуемо как пустые модули. - Любая ошибка фатальна - Нет проверок переполнения в компилтайме. diff --git a/src/oberon.c b/src/oberon.c index 0bbeec1..d6aefad 100644 --- a/src/oberon.c +++ b/src/oberon.c @@ -356,23 +356,20 @@ oberon_init_scaner(oberon_context_t * ctx, const char * code) static void oberon_read_ident(oberon_context_t * ctx) { - int len = 0; - int i = ctx -> code_index; + int start = ctx -> code_index; - int c = ctx -> code[i]; - while(isalnum(c)) + oberon_get_char(ctx); + while(isalnum(ctx -> c)) { - i += 1; - len += 1; - c = ctx -> code[i]; + oberon_get_char(ctx); } - char * ident = GC_MALLOC(len + 1); - memcpy(ident, &ctx->code[ctx->code_index], len); - ident[len] = 0; + int end = ctx -> code_index; + + char * ident = GC_MALLOC(end - start + 1); + memcpy(ident, &ctx -> code[start], end - start); + ident[end - start] = 0; - ctx -> code_index = i; - ctx -> c = ctx -> code[i]; ctx -> string = ident; ctx -> token = IDENT; @@ -738,7 +735,7 @@ static void oberon_read_string(oberon_context_t * ctx) char * string = GC_MALLOC(end - start + 1); strncpy(string, &ctx -> code[start], end - start); - string[end] = 0; + string[end - start] = 0; ctx -> token = STRING; ctx -> string = string; -- 2.29.2