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/ntshell/ntshell/core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.c

    r321 r331  
    5757}
    5858
     59int ntlibc_strlcpy(char *des, const char *src, int n)
     60{
     61        char *d = des, *e = &des[n];
     62        const char *s = src;
     63        while (*s && d < e) {
     64                *d = *s;
     65                d++;
     66                s++;
     67        }
     68        *d++ = '\0';
     69        return (int)d - (int)des;
     70}
     71
    5972char *ntlibc_strcat(char *des, const char *src)
    6073{
     
    7184        *d = '\0';
    7285        return des;
     86}
     87
     88int ntlibc_strlcat(char *des, const char *src, int n)
     89{
     90        char *d = des, *e = &des[n];
     91        const char *s = src;
     92        while (*d && d < e) {
     93                d++;
     94        }
     95        while (*s && d < e) {
     96                *d = *s;
     97                d++;
     98                s++;
     99        }
     100        *d++ = '\0';
     101        return (int)d - (int)des;
    73102}
    74103
     
    223252}
    224253
     254unsigned long ntlibc_strtoul(const char *restrict nptr, char **restrict endptr, int base)
     255{
     256        int cnt;
     257        int num = 0;
     258        int ofs = 0;
     259        int sign = 0;
     260        int scnt = 0;
     261        char *p = (char *)nptr;
     262        while (*p != '\0') {
     263                if (!ntlibc_isdigit(*p)) {
     264                        if (*p == ' ') {
     265                                ofs++;
     266                        }
     267                        if (*p == '+') {
     268                                sign = 0;
     269                                ofs++;
     270                                if (scnt++ > 0) {
     271                                        *endptr = p;
     272                                        break;
     273                                }
     274                        }
     275                        if (*p == '-') {
     276                                sign = 1;
     277                                ofs++;
     278                                if (scnt++ > 0) {
     279                                        *endptr = p;
     280                                        break;
     281                                }
     282                        }
     283                        *endptr = p;
     284                        break;
     285                }
     286                p++;
     287        }
     288        for (cnt = ofs; (nptr[cnt] >= '0') && (nptr[cnt] <= '9'); cnt++) {
     289                num = 10 * num + (nptr[cnt] - '0');
     290        }
     291        if (sign) {
     292                return -num;
     293        }
     294        else {
     295                return num;
     296        }
     297}
     298
    225299char *ntlibc_strchr(const char *s, int c)
    226300{
  • EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.h

    r321 r331  
    4040int ntlibc_strlen(const char *s);
    4141char *ntlibc_strcpy(char *des, const char *src);
     42int ntlibc_strlcpy(char *des, const char *src, int n);
    4243char *ntlibc_strcat(char *des, const char *src);
     44int ntlibc_strlcat(char *des, const char *src, int n);
    4345int ntlibc_strcmp(const char *s1, const char *s2);
    4446int ntlibc_stricmp(const char *s1, const char *s2);
     
    5052int ntlibc_tolower(int c);
    5153int ntlibc_atoi(const char *nptr);
     54unsigned long ntlibc_strtoul(const char *__restrict nptr, char **__restrict endptr, int base);
    5255char *ntlibc_strchr(const char *s, int c);
    5356char *ntlibc_utoa(unsigned int value, char *s, int radix);
  • EcnlProtoTool/trunk/ntshell/ntshell/core/ntshell.c

    r321 r331  
    3333#include <string.h>
    3434#include "ntshell.h"
     35#include "core/ntlibc.h"
    3536
    3637int ntshell_exit;
     
    107108 * @param HANDLE A pointer of the handle.
    108109 */
    109 #define PROMPT_WRITE(HANDLE)            SERIAL_WRITE((HANDLE), (HANDLE)->prompt, strlen((HANDLE)->prompt))
     110#define PROMPT_WRITE(HANDLE)            SERIAL_WRITE((HANDLE), (HANDLE)->prompt, ntlibc_strlen((HANDLE)->prompt))
    110111
    111112/**
     
    114115 * @param HANDLE A pointer of the handle.
    115116 */
    116 #define PROMPT_NEWLINE(HANDLE)          SERIAL_WRITE((HANDLE), NTSHELL_PROMPT_NEWLINE, strlen(NTSHELL_PROMPT_NEWLINE))
     117#define PROMPT_NEWLINE(HANDLE)          SERIAL_WRITE((HANDLE), NTSHELL_PROMPT_NEWLINE, ntlibc_strlen(NTSHELL_PROMPT_NEWLINE))
    117118
    118119/**
     
    399400                                 * Found the suggestion.
    400401                                 */
    401                                 int n = strlen((const char *)buf);
     402                                int n = ntlibc_strlen((const char *)buf);
    402403                                VTSEND_ERASE_LINE(ntshell);
    403404                                VTSEND_CURSOR_HEAD(ntshell);
     
    429430                         * Found the suggestion.
    430431                         */
    431                         int n = strlen((const char *)buf);
     432                        int n = ntlibc_strlen((const char *)buf);
    432433                        VTSEND_ERASE_LINE(ntshell);
    433434                        VTSEND_CURSOR_HEAD(ntshell);
     
    441442                         * Recall the previous input text string.
    442443                         */
    443                         int n = strlen(SUGGEST_SOURCE(ntshell));
     444                        int n = ntlibc_strlen(SUGGEST_SOURCE(ntshell));
    444445                        VTSEND_ERASE_LINE(ntshell);
    445446                        VTSEND_CURSOR_HEAD(ntshell);
     
    484485        UNUSED_VARIABLE(ch);
    485486        text_editor_get_text(GET_EDITOR(ntshell), buf, sizeof(buf));
    486         len = strlen((const char *)buf);
     487        len = ntlibc_strlen((const char *)buf);
    487488        VTSEND_CURSOR_HEAD(ntshell);
    488489        PROMPT_WRITE(ntshell);
     
    606607        p->func_callback = func_callback;
    607608        p->extobj = extobj;
    608         strcpy(p->prompt, NTSHELL_PROMPT_DEFAULT);
     609        ntlibc_strcpy(p->prompt, NTSHELL_PROMPT_DEFAULT);
    609610
    610611        p->vtrecv.user_data = p;
     
    666667        }
    667668
    668         strcpy(p->prompt, prompt);
     669        ntlibc_strcpy(p->prompt, prompt);
    669670}
    670671
  • EcnlProtoTool/trunk/ntshell/ntshell/core/text_history.c

    r321 r331  
    3333#include <string.h>
    3434#include "text_history.h"
     35#include "core/ntlibc.h"
    3536
    3637/**
     
    145146        char *buf, const int siz)
    146147{
    147         const int text_len = strlen((const char *)text);
     148        const int text_len = ntlibc_strlen((const char *)text);
    148149        int found = 0;
    149150        int i;
     
    151152                int target = (p->rp + i) % TEXTHISTORY_DEPTH;
    152153                char *txtp = p->history + (TEXTHISTORY_MAXLEN * target);
    153                 const int target_len = strlen((const char *)txtp);
     154                const int target_len = ntlibc_strlen((const char *)txtp);
    154155                int comp_len = (target_len < text_len) ? target_len : text_len;
    155                 if ((strncmp(
     156                if ((ntlibc_strncmp(
    156157                        (const char *)txtp,
    157158                        (const char *)text, comp_len) == 0) && (comp_len > 0)) {
    158159                        if (found == index) {
    159                                 if (siz <= strlen(txtp)) {
     160                                if (siz <= ntlibc_strlen(txtp)) {
    160161                                        return -1;
    161162                                }
    162                                 strcpy((char *)buf, (char *)txtp);
     163                                ntlibc_strcpy((char *)buf, (char *)txtp);
    163164                                return 0;
    164165                        }
Note: See TracChangeset for help on using the changeset viewer.