Ignore:
Timestamp:
Jan 21, 2018, 12:10:09 AM (6 years ago)
Author:
coas-nagasima
Message:

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

Location:
EcnlProtoTool/trunk/prototool/src
Files:
3 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/prototool/src/arduino.c

    r321 r331  
    44#include <stdio.h>
    55#include <fcntl.h>
     6#include <sys/stat.h>
    67#include "../llbruby.h"
    78
     
    544545        return 0;
    545546}
     547
     548unsigned int Utf8_to_Utf16(const char *src, int *code_size)
     549{
     550        int i;
     551        unsigned int uc = 0;
     552        unsigned char len = 0;
     553
     554        len = 0;
     555        if ((src[0] & 0x80) == 0) { uc = src[0] & 0x7F; len = 0; }
     556        else if ((src[0] & 0xE0) == 0xC0) { uc = src[0] & 0x1F; len = 1; }
     557        else if ((src[0] & 0xF0) == 0xE0) { uc = src[0] & 0x0F; len = 2; }
     558        else if ((src[0] & 0xF8) == 0xF0) { uc = src[0] & 0x07; len = 3; }
     559        else if ((src[0] & 0xFC) == 0xF8) { uc = src[0] & 0x03; len = 4; }
     560        else if ((src[0] & 0xFE) == 0xFC) { uc = src[0] & 0x01; len = 5; }
     561
     562        i = 1;
     563        while ((i <= len) && ((src[i] & 0xC0) == 0x80)) {
     564                uc = (uc << 6) | (src[i] & 0x3F);
     565                i++;
     566        }
     567
     568        //消費文字数設定
     569        *code_size = i;
     570
     571        //現状、2バイト限定
     572        return uc;
     573}
     574
     575int bs_char_count(char *str, int pos)
     576{
     577        int num = 1, local_pos = pos;
     578        char *c;
     579
     580        while (1) {
     581                c = str + local_pos;
     582
     583                if ((*c & 0x80) != 0x80)
     584                        return num;
     585
     586                if (((*c & 0xE0) == 0xC0) && (num == 2)) {
     587                        return num;
     588                }
     589                else if (((*c & 0xF0) == 0xE0) && (num == 3)) {
     590                        return num;
     591                }
     592                else if (((*c & 0xF8) == 0xF0) && (num == 4)) {
     593                        return num;
     594                }
     595                else if (((*c & 0xFC) == 0xF8) && (num == 5)) {
     596                        return num;
     597                }
     598                else if (((*c & 0xFE) == 0xFC) && (num == 6)) {
     599                        return num;
     600                }
     601                else {
     602                        if (local_pos > 0) {
     603                                local_pos--;
     604                                num++;
     605                        }
     606                        else
     607                                return 0;
     608                }
     609        }
     610
     611        return 0;
     612}
  • EcnlProtoTool/trunk/prototool/src/arduino.h

    r321 r331  
    1010#include <string.h>
    1111#include <time.h>
    12 #include <analogin_api.h>
    13 #include <analogout_api.h>
    14 #include <buffer.h>
    15 #include <can_api.h>
    16 #include <dma_api.h>
    17 #include <ethernet_api.h>
    18 #include <gpio_api.h>
    19 #include <gpio_irq_api.h>
    20 #include <i2c_api.h>
    21 #include <lp_ticker_api.h>
    22 #include <pinmap.h>
    23 #include <port_api.h>
    24 #include <pwmout_api.h>
    25 #include <rtc_api.h>
    26 #include <serial_api.h>
    27 #include <sleep_api.h>
    28 #include <spi_api.h>
    29 #include <ticker_api.h>
    30 #include <us_ticker_api.h>
    31 #include <wait_api.h>
     12#include <mbed_api.h>
    3213
    3314#ifndef bool
  • EcnlProtoTool/trunk/prototool/src/libbb/libbb.h

    r321 r331  
    2525
    2626#include <ctype.h>
    27 #include "_dirent.h"
     27#include "dirent.h"
    2828#include <errno.h>
    2929#include <fcntl.h>
     
    6161#endif
    6262#include <sys/wait.h>
    63 #include "_termios.h"
     63#include <termios.h>
    6464#include <time.h>
    6565#include <sys/param.h>
  • EcnlProtoTool/trunk/prototool/src/libbb/vi.c

    r321 r331  
    210210# define Isprint(c) ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b)
    211211#else
     212#define MULTI_BYTE_MULTIPLE     3
    212213bool Isprint(unsigned char c)
    213214{
     
    228229        mbc_st--;
    229230        return true;
     231}
     232bool IsMultiByteChar(unsigned char c, int *bytes)
     233{
     234        bool ret = false;
     235        *bytes = 1;
     236        if ((c & 0xE0) == 0xC0) { *bytes = 2; }
     237        else if ((c & 0xF0) == 0xE0) { *bytes = 3; }
     238        else if ((c & 0xF8) == 0xF0) { *bytes = 4; }
     239        else if ((c & 0xFC) == 0xF8) { *bytes = 5; }
     240        else if ((c & 0xFE) == 0xFC) { *bytes = 6; }
     241        if (*bytes != 1)
     242                ret = true;
     243        return ret;
    230244}
    231245#endif
     
    583597static int format_edit_status(void);    // format file status on status line
    584598static void redraw(int);        // force a full screen refresh
     599#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
    585600static char* format_line(char* /*, int*/);
     601#else
     602static char* format_line(char* , int*, int*);
     603#endif
    586604static void refresh(int);       // update the terminal from screen[]
    587605
     
    15901608        char *tp;
    15911609        int cnt, ro, co;
     1610#ifdef ENABLE_BASIC_MULTI_CHAR_CODE
     1611        int last_code_size = 0;
     1612#endif
    15921613
    15931614        beg_cur = begin_line(d);        // first char of cur line
     
    16541675                co += (code_size > 1 ? 2 : code_size);
    16551676                tp += code_size;
     1677                last_code_size = code_size;
    16561678#endif
    16571679        }
     
    16741696        }
    16751697        if (co >= columns + offset) {
     1698#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
    16761699                offset = co - columns + 1;
     1700#else
     1701                offset = co - columns + (last_code_size > 1 ? 2 : 1);
     1702#endif
    16771703        }
    16781704        // if the first char of the line is a tab, and "dot" is sitting on it
     
    18311857                        break;
    18321858                if (*p == '\t') {
     1859#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
    18331860                        co = next_tabstop(co);
     1861#else
     1862                        co += tabstop;
     1863                        p++;
     1864#endif
    18341865                }
    18351866#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
     
    19331964{
    19341965        int li;
     1966        int internal_co = co;
     1967#ifdef ENABLE_BASIC_MULTI_CHAR_CODE
     1968        internal_co *= MULTI_BYTE_MULTIPLE;
     1969#endif
    19351970
    19361971        free(screen);
    1937         screensize = ro * co + 8;
     1972        screensize = ro * internal_co + 8;
    19381973        screen = xmalloc(screensize);
    19391974        // initialize the new screen. assume this will be a empty file.
     
    19411976        //   non-existent text[] lines start with a tilde (~).
    19421977        for (li = 1; li < ro - 1; li++) {
    1943                 screen[(li * co) + 0] = '~';
     1978                screen[(li * internal_co) + 0] = '~';
    19441979        }
    19451980        return screen;
     
    33613396}
    33623397
     3398#ifdef ENABLE_BASIC_MULTI_CHAR_CODE
     3399//----- get screen column number of string ---------------------
     3400int get_view_col_from_bytes(char *st, char bytes, int max_size)
     3401{
     3402        char *buf_end = st + max_size;
     3403        int tmp_bytes = 0, tmp_total_bytes = 0, view_col = 0;
     3404        while (tmp_total_bytes < bytes) {
     3405                Utf8_to_Utf16(st, &tmp_bytes);
     3406                tmp_total_bytes += tmp_bytes;
     3407                view_col += tmp_bytes > 1 ? 2 : 1;
     3408                st += tmp_bytes;
     3409                if (st >= buf_end)
     3410                        break;
     3411        }
     3412        return view_col;
     3413}
     3414//----- get string bytes of screen column ----------------------
     3415int get_bytes_from_view_col(char *st, int view_col, int max_size)
     3416{
     3417        char *buf_end = st + max_size;
     3418        int tmp_view_col = 0, bytes = 0, tmp_bytes;
     3419        while (tmp_view_col < view_col) {
     3420                Utf8_to_Utf16(st, &tmp_bytes);
     3421                bytes += tmp_bytes;
     3422                tmp_view_col += tmp_bytes > 1 ? 2 : 1;
     3423                st += tmp_bytes;
     3424                if (st >= buf_end)
     3425                        break;
     3426        }
     3427        return bytes;
     3428}
     3429#endif
     3430
    33633431//----- Format a text[] line into a buffer ---------------------
     3432#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
    33643433static char* format_line(char *src /*, int li*/)
     3434#else
     3435static char* format_line(char *src , int *bytes, int *view_co)
     3436#endif
    33653437{
    33663438        unsigned char c;
     
    33683440        int ofs = offset;
    33693441        char *dest = scr_out_buf; // [MAX_SCR_COLS + MAX_TABSTOP * 2]
     3442#ifdef ENABLE_BASIC_MULTI_CHAR_CODE
     3443        int tmp_bytes, tmp_columns_count, total_bytes = 0, view_columns = 0;
     3444        memset(scr_out_buf, 0x00, sizeof(scr_out_buf));
     3445#endif
    33703446
    33713447        c = '~'; // char in col 0 in non-existent lines is '~'
    33723448        co = 0;
     3449#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
    33733450        while (co < columns + tabstop) {
     3451#else
     3452        while (view_columns < columns + ofs/* + tabstop*/) {
     3453#endif
    33743454                // have we gone past the end?
    33753455                if (src < end) {
     
    33863466                                        while ((co % tabstop) != (tabstop - 1)) {
    33873467                                                dest[co++] = c;
     3468#ifdef ENABLE_BASIC_MULTI_CHAR_CODE
     3469                                                total_bytes++;
     3470                                                view_columns++;
     3471#endif
    33883472                                        }
    33893473                                } else {
     
    33973481                }
    33983482                dest[co++] = c;
     3483#ifdef ENABLE_BASIC_MULTI_CHAR_CODE
     3484                total_bytes++;
     3485                view_columns++;
     3486                if (IsMultiByteChar(c, &tmp_bytes)) {
     3487                        if (view_columns + 1 > columns + ofs) {
     3488                                dest[--co] = ' ';
     3489                        }
     3490                        else {
     3491                                view_columns++;
     3492                                int i;
     3493                                for (i = 0; i < tmp_bytes - 1; i++) {
     3494                                        dest[co++] = *src++;
     3495                                        total_bytes++;
     3496                                }
     3497                        }
     3498                }
     3499#endif
     3500#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
    33993501                // discard scrolled-off-to-the-left portion,
    34003502                // in tabstop-sized pieces
     
    34043506                        ofs -= tabstop;
    34053507                }
     3508#endif
    34063509                if (src >= end)
    34073510                        break;
    34083511        }
     3512#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
    34093513        // check "short line, gigantic offset" case
    34103514        if (co < ofs)
     
    34163520        if (co < columns)
    34173521                memset(&dest[co], ' ', columns - co);
     3522#else
     3523        // check "short line, gigantic offset" case
     3524        if (view_columns < ofs)
     3525                ofs = view_columns;
     3526        // discard last scrolled off part
     3527        view_columns -= ofs;
     3528        tmp_columns_count = 0;
     3529        while (tmp_columns_count < ofs) {
     3530                IsMultiByteChar(*dest, &tmp_bytes);
     3531                dest += tmp_bytes;
     3532                total_bytes -= tmp_bytes;
     3533                tmp_columns_count += tmp_bytes > 1 ? 2 : 1;
     3534        }
     3535        // fill the rest with spaces
     3536        if (view_columns < columns) {
     3537                int ofs_bytes = get_bytes_from_view_col(scr_out_buf, ofs, co);
     3538                memset(&dest[co - ofs_bytes], ' ', columns - view_columns);
     3539                total_bytes = total_bytes + (columns - view_columns);
     3540        }
     3541        *bytes = total_bytes;
     3542        *view_co = view_columns;
     3543#endif
    34183544        return dest;
    34193545}
     
    34303556        int li, changed;
    34313557        char *tp, *sp;          // pointer into text[] and screen[]
     3558#ifdef ENABLE_BASIC_MULTI_CHAR_CODE
     3559        int bytes, view_co;
     3560#endif
    34323561
    34333562        if (ENABLE_FEATURE_VI_WIN_RESIZE IF_FEATURE_VI_ASK_TERMINAL(&& !G.get_rowcol_error) ) {
     
    34443573                char *out_buf;
    34453574                // format current text line
     3575#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
    34463576                out_buf = format_line(tp /*, li*/);
     3577#else
     3578                out_buf = format_line(tp , &bytes, &view_co);
     3579#endif
    34473580
    34483581                // skip to the end of the current text[] line
     
    34563589                changed = FALSE;        // assume no change
    34573590                cs = 0;
     3591#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
    34583592                ce = columns - 1;
    34593593                int cursor_column = 0;
    34603594                sp = &screen[li * columns];     // start of screen line
     3595#else
     3596                ce = bytes - 1;
     3597                int cursor_column = 0;
     3598                sp = &screen[li * columns * MULTI_BYTE_MULTIPLE];       // start of screen line
     3599#endif
    34613600                if (full_screen) {
    34623601                        // force re-draw of every single column from 0 - columns-1
     
    34943633#else
    34953634                while (ce >= cs) {
    3496                         int code_size = bs_char_count(sp, ce);
     3635                        int code_size = bs_char_count(out_buf, ce);
    34973636                        if (memcmp(&out_buf[ce], &sp[ce], code_size)) {
    34983637                                changed = TRUE; // mark for redraw
     
    35013640                        ce -= code_size;
    35023641                }
     3642                if (view_co < columns - 1)
     3643                        ce = bytes;
    35033644#endif
    35043645                // now, cs is index of first diff, and ce is index of last diff
     
    35113652
    35123653                // make a sanity check of columns indexes
     3654#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
    35133655                if (cs < 0) { cs = 0; cursor_column = 0; }
    35143656                if (ce > columns - 1) ce = columns - 1;
    35153657                if (cs > ce) { cs = 0; ce = columns - 1; cursor_column = 0; }
     3658#else
     3659                if (cs < 0) { cs = 0; cursor_column = 0; }
     3660                if (get_view_col_from_bytes(out_buf, ce, (columns * MULTI_BYTE_MULTIPLE)) > columns - 1)
     3661                        ce = get_bytes_from_view_col(out_buf, columns, (columns * MULTI_BYTE_MULTIPLE)) - 1;
     3662                if (cs > ce) {
     3663                        cs = 0;
     3664                        ce = get_bytes_from_view_col(out_buf, columns, (columns * MULTI_BYTE_MULTIPLE)) - 1;
     3665                        cursor_column = 0;
     3666                }
     3667#endif
    35163668                // is there a change between virtual screen and out_buf
    35173669                if (changed) {
  • EcnlProtoTool/trunk/prototool/src/main.c

    r321 r331  
    4949#include <netdb.h>
    5050#include <unistd.h>
    51 #include <setjmp.h>
    5251#include <signal.h>
    5352#include <time.h>
    5453#include <sys/time.h>
    55 #include <sys/unistd.h>
     54#include <unistd.h>
    5655#include <errno.h>
    5756
     
    6564#include <mruby/dump.h>
    6665#include <mruby/string.h>
    67 #include <usrcmd.h>
     66#include <ntshell/usrcmd.h>
    6867
    6968#define ETHER_MAX_LEN 1518
     
    8988extern int mruby_main(int argc, char **argv);
    9089extern int mirb_main(int argc, char **argv);
     90extern int curl_main(int argc, char **argv);
    9191extern int tcc_main(int argc, char **argv);
    9292extern int vi_main(int argc, char **argv);
     
    101101        {"mruby","mruby command", mruby_main},
    102102        {"mirb", "Embeddable Interactive Ruby Shell", mirb_main},
     103        {"curl", "Command lines or scripts to transfer data", curl_main},
    103104        {"tcc", "Tiny C compiler", tcc_main},
    104105        {"vi", "Text editor", vi_main},
    105         {"cd", "change directory", usrcmd_cd },
    106         {"ls", "list files", usrcmd_ls },
    107         {"cp", "copy file", usrcmd_cp },
    108         {"rm", "remove file", usrcmd_rm },
    109         {"mv", "move file", usrcmd_mv },
    110         {"mkdir", "Make directory", usrcmd_mkdir},
    111         {"hexdump", "Hex dump", usrcmd_hexdump},
    112106        {"onitest", "Onigumo Test", onitest_main},
    113107        {"tcp_echo", "TCP echo server/client", tcp_echo_main},
    114108        {"help", "This is a description text string for help command.", usrcmd_help},
    115         {"info", "This is a description text string for info command.", usrcmd_info},
    116         {"exit", "Exit Natural Tyny Shell", usrcmd_exit},
    117109};
    118110cmd_table_info_t cmd_table_info = { &cmdlist, sizeof(cmdlist) / sizeof(cmdlist[0]) };
     
    521513}
    522514
    523 // Provide implementation of _sbrk (low-level dynamic memory allocation
    524 // routine) for GCC_ARM which compares new heap pointer with MSP instead of
    525 // SP.  This make it compatible with RTX RTOS thread stacks.
    526 
    527 // Linker defined symbol used by _sbrk to indicate where heap should start.
    528 int _end;
    529 uint32_t  _stack;
    530 
    531 // Turn off the errno macro and use actual global variable instead.
    532 #undef errno
    533 int errno;
    534 
    535 static unsigned char* heap = (unsigned char*)&_end;
    536 
    537 // Dynamic memory allocation related syscall.
    538 caddr_t _sbrk(int incr) {
    539         unsigned char*        prev_heap = heap;
    540         unsigned char*        new_heap = heap + incr;
    541 
    542         if (new_heap >= (unsigned char*)&_stack) {     /* _stack is end of heap section */
    543                 errno = ENOMEM;
    544                 return (caddr_t)-1;
    545         }
    546 
    547         heap = new_heap;
    548         return (caddr_t) prev_heap;
    549 }
    550 
    551 char *optarg;
     515void _start_c(long *p);
    552516int _data, _mdata, _edata;
    553517int _bss, _ebss;
    554518
    555 int _PowerON_Reset(int argc, char **argv)
     519void _PowerON_Reset(long *args)
    556520{
    557521        memcpy(&_data, &_mdata, (size_t)&_edata - (size_t)&_data);
    558522        memset(&_bss, 0, (size_t)&_ebss - (size_t)&_bss);
    559523
    560         optarg = *argv;
    561         return main(argc, argv);
     524        _start_c(args);
    562525}
    563526
  • EcnlProtoTool/trunk/prototool/src/onitest.c

    r321 r331  
    99
    1010#ifdef POSIX_TEST
    11 #include "onigposix.h"
     11#include "onigmoposix.h"
    1212#else
    13 #include "oniguruma.h"
     13#include "onigmo.h"
    1414#endif
    1515
     
    197197        x2("\\x1f", "\x1f", 0, 1);
    198198        x2("a(?#....\\\\JJJJ)b", "ab", 0, 2);
    199         x2("(?x)  G (o O(?-x)oO) g ", "GoOoOgLe", 0, 7);
     199        x2("(?x)  G (o O(?-x)oO) g L", "GoOoOgLe", 0, 7);
    200200        x2(".", "a", 0, 1);
    201201        n(".", "");
Note: See TracChangeset for help on using the changeset viewer.