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

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.