Ver código fonte

Merge branch 'feature/#21-remove-e' of shimatta/shellmatta into develop

Replaced all bad escapes and added -pedantic to the compiler flags fix #21
shimatta 4 anos atrás
pai
commit
1c294bb7d1

+ 2 - 2
makefile

@@ -43,8 +43,8 @@ UNITTEST_CPPOBJ  := $(patsubst %.cpp,$(OBJ_DIR)%.o,$(UNITTEST_SOURCES))
 
 INTEGRATIONTEST_CPPOBJ  := $(patsubst %.cpp,$(OBJ_DIR)%.o,$(INTEGRATIONTEST_SOURCES))
 
-CFLAGS      := $(INCLUDES:%=-I%) -g -Wall -Werror
-TESTFLAGS   := $(INCLUDES:%=-I%) -g -Wall -Werror -fprofile-arcs -ftest-coverage
+CFLAGS      := $(INCLUDES:%=-I%) -g -Wall -Werror -pedantic
+TESTFLAGS   := $(INCLUDES:%=-I%) -g -Wall -Werror -fprofile-arcs -ftest-coverage -pedantic
 TESTLFLAGS  := -fprofile-arcs -Wl,--allow-multiple-definition
 
 DEPEND      = -MT $@ -MF "$(@:%.o=%.d)" -MG -MM

+ 1 - 1
src/shellmatta.c

@@ -403,7 +403,7 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t     handle,
                 utils_removeChars(inst, 1u, false);
             }
             /** -# check for start of escape sequence */
-            else if('\e' == *data)
+            else if('\x1b' == *data)
             {
                 inst->escapeCounter = 1u;
             }

+ 5 - 5
src/shellmatta_utils.c

@@ -91,7 +91,7 @@ uint32_t utils_shellItoa(int32_t value, char *buffer, uint32_t base)
  */
 void utils_saveCursorPos(shellmatta_instance_t *inst)
 {
-    utils_writeEcho(inst, "\e[s", 3u);
+    utils_writeEcho(inst, "\x1b[s", 3u);
 }
 
 /**
@@ -100,7 +100,7 @@ void utils_saveCursorPos(shellmatta_instance_t *inst)
  */
 void utils_restoreCursorPos(shellmatta_instance_t *inst)
 {
-    utils_writeEcho(inst, "\e[u", 3u);
+    utils_writeEcho(inst, "\x1b[u", 3u);
 }
 
 /**
@@ -110,7 +110,7 @@ void utils_restoreCursorPos(shellmatta_instance_t *inst)
  */
 void utils_eraseLine(shellmatta_instance_t *inst)
 {
-    utils_writeEcho(inst, "\e[K", 3u);
+    utils_writeEcho(inst, "\x1b[K", 3u);
 }
 
 /**
@@ -126,7 +126,7 @@ void utils_rewindCursor(shellmatta_instance_t *inst, uint32_t length)
     length = SHELLMATTA_MIN (length, inst->cursor);
     if(length > 0u)
     {
-        terminalCmd[0]  = '\e';
+        terminalCmd[0]  = '\x1b';
         terminalCmd[1]  = '[';
         size = 2u + utils_shellItoa(length, &terminalCmd[2], 10);
         terminalCmd[size] = 'D';
@@ -148,7 +148,7 @@ void utils_forwardCursor(shellmatta_instance_t *inst, uint32_t length)
     length = SHELLMATTA_MIN (length, (inst->inputCount - inst->cursor));
     if (length > 0u)
     {
-        terminalCmd[0]  = '\e';
+        terminalCmd[0]  = '\x1b';
         terminalCmd[1]  = '[';
         size = 2u + utils_shellItoa(length, &terminalCmd[2], 10);
         terminalCmd[size] = 'C';

+ 1 - 1
test/unittest/shellmatta_utils/test_utils_eraseLine.cpp

@@ -36,5 +36,5 @@ TEST_CASE( "shellmatta_utils_eraseLine" ) {
 
     CHECK( write_callCnt == 1u);
     CHECK( write_length == 3u);
-    REQUIRE( strncmp("\e[K", write_data, 3u) == 0);
+    REQUIRE( strncmp("\x1b[K", write_data, 3u) == 0);
 }

+ 2 - 2
test/unittest/shellmatta_utils/test_utils_forwardCursor.cpp

@@ -36,7 +36,7 @@ TEST_CASE( "shellmatta_utils_forwardCursor normal" ) {
 
     CHECK( write_callCnt == 1u);
     CHECK( write_length == 4u);
-    REQUIRE( strncmp("\e[5C", write_data, 4u) == 0);
+    REQUIRE( strncmp("\x1b[5C", write_data, 4u) == 0);
 }
 
 TEST_CASE( "shellmatta_utils_forwardCursor normal echo off" ) {
@@ -85,7 +85,7 @@ TEST_CASE( "shellmatta_utils_forwardCursor forward by 12 with cursor at 5 and in
 
     CHECK( write_callCnt == 1u);
     CHECK( write_length == 4u);
-    REQUIRE( strncmp("\e[5C", write_data, 4u) == 0);
+    REQUIRE( strncmp("\x1b[5C", write_data, 4u) == 0);
 }
 
 TEST_CASE( "shellmatta_utils_forwardCursor forward by 0" ) {

+ 1 - 1
test/unittest/shellmatta_utils/test_utils_insertChars.cpp

@@ -36,7 +36,7 @@ TEST_CASE( "shellmatta_insertChars normal call" ) {
     CHECK( inst.cursor == 12);
     CHECK( inst.inputCount == 14);
     CHECK( write_callCnt == 5u );
-    CHECK( strncmp("blks\e[K\e[sij\e[u", write_data, 15u) == 0);
+    CHECK( strncmp("blks\x1b[K\x1b[sij\x1b[u", write_data, 15u) == 0);
     REQUIRE( strncmp("abcdefghblksij\0\0\0\0\0\0\0", buffer, sizeof(buffer)) == 0);
 }
 

+ 1 - 1
test/unittest/shellmatta_utils/test_utils_restoreCursorPos.cpp

@@ -36,5 +36,5 @@ TEST_CASE( "shellmatta_utils_restoreCursorPos" ) {
 
     CHECK( write_callCnt == 1u);
     CHECK( write_length == 3u);
-    REQUIRE( strncmp("\e[u", write_data, 3u) == 0);
+    REQUIRE( strncmp("\x1b[u", write_data, 3u) == 0);
 }

+ 2 - 2
test/unittest/shellmatta_utils/test_utils_rewindCursor.cpp

@@ -36,7 +36,7 @@ TEST_CASE( "shellmatta_utils_rewindCursor normal" ) {
 
     CHECK( write_callCnt == 1u);
     CHECK( write_length == 4u);
-    REQUIRE( strncmp("\e[5D", write_data, 4u) == 0);
+    REQUIRE( strncmp("\x1b[5D", write_data, 4u) == 0);
 }
 
 
@@ -61,7 +61,7 @@ TEST_CASE( "shellmatta_utils_rewindCursor rewind by 12 with cursor at 10" ) {
 
     CHECK( write_callCnt == 1u);
     CHECK( write_length == 5u);
-    REQUIRE( strncmp("\e[10D", write_data, 5u) == 0);
+    REQUIRE( strncmp("\x1b[10D", write_data, 5u) == 0);
 }
 
 TEST_CASE( "shellmatta_utils_rewindCursor rewind by 0" ) {

+ 1 - 1
test/unittest/shellmatta_utils/test_utils_saveCursorPos.cpp

@@ -36,5 +36,5 @@ TEST_CASE( "shellmatta_utils_saveCursorPos" ) {
 
     CHECK( write_callCnt == 1u);
     CHECK( write_length == 3u);
-    REQUIRE( strncmp("\e[s", write_data, 3u) == 0);
+    REQUIRE( strncmp("\x1b[s", write_data, 3u) == 0);
 }