فهرست منبع

Merge pull request #16 from mysterywolf/master

去除RT_USING_POSIX预编译判断,全部改为默认使用POSIX
Meco Jianting Man 4 سال پیش
والد
کامیت
d83adceddb
2فایلهای تغییر یافته به همراه1 افزوده شده و 62 حذف شده
  1. 1 14
      vi.c
  2. 0 48
      vi_utils.c

+ 1 - 14
vi.c

@@ -116,7 +116,6 @@ enum {
 /* vi.c expects chars to be unsigned. */
 /* busybox build system provides that, but it's better */
 /* to audit and fix the source */
-
 struct globals {
     /* many references - keep near the top of globals */
     char *text, *end;       // pointers to the user data in memory
@@ -573,9 +572,6 @@ static int vi_main(int argc, char **argv)
     }
     // "Use normal screen buffer, restore cursor"
     write1("\033[?1049l");
-#ifndef RT_USING_POSIX
-    wait_read(STDIN_FILENO, status_buffer, STATUS_BUFFER_LEN, 0);
-#endif
 
     /* RT-Thread team added */
     fflush_all();
@@ -2739,7 +2735,7 @@ static void int_handler(int sig)
     siglongjmp(restart, sig);
 }
 #endif /* FEATURE_VI_USE_SIGNALS */
-#ifdef RT_USING_POSIX
+
 static int mysleep(int hund)    // sleep for 'hund' 1/100 seconds or stdin ready
 {
     struct pollfd pfd[1];
@@ -2751,16 +2747,7 @@ static int mysleep(int hund)    // sleep for 'hund' 1/100 seconds or stdin ready
     pfd[0].events = POLLIN;
     return safe_poll(pfd, 1, hund*10) > 0;
 }
-#else
-extern struct finsh_shell *shell;
-static int mysleep(int hund)
-{
-    if (hund != 0)
-        fflush_all();
 
-    return rt_sem_take(&shell->rx_sem, hund*10) == RT_EOK;
-}
-#endif
 //----- IO Routines --------------------------------------------
 static int readit(void) // read (maybe cursor) key from stdin
 {

+ 0 - 48
vi_utils.c

@@ -78,7 +78,6 @@ char* skip_non_whitespace(const char *s)
 }
 #endif
 
-#ifdef RT_USING_POSIX
 void bb_perror_msg(const char *s, ...)
 {
     rt_kprintf("%s", s);
@@ -200,25 +199,6 @@ ssize_t full_read(int fd, void *buf, size_t len)
 
     return total;
 }
-#else
-extern rt_device_t rt_console_get_device(void);
-int wait_read(int fd, void *buf, size_t len, int timeout)
-{
-    int ret = 0;
-    rt_device_t console_device = rt_console_get_device();
-    rt_sem_take(&shell->rx_sem, 0);
-    ret = rt_device_read(console_device,0,buf,len);
-    if (ret <= 0)
-    {
-        while (rt_sem_take(&shell->rx_sem, 0) == RT_EOK);
-        rt_sem_take(&shell->rx_sem, timeout);
-        ret = rt_device_read(console_device,0,buf,len);
-        if (ret <= 0)
-            errno = EAGAIN;
-    }
-    return ret;
-}
-#endif
 
 void* xzalloc(size_t size)
 {
@@ -234,9 +214,7 @@ void bb_show_usage(void)
 
 int64_t read_key(int fd, char *buffer, int timeout)
 {
-#ifdef RT_USING_POSIX
     struct pollfd pfd;
-#endif
     const char *seq;
     int n;
 
@@ -324,10 +302,8 @@ int64_t read_key(int fd, char *buffer, int timeout)
         /* '[','3',';','3','~' |0x80, (char) KEYCODE_ALT_DELETE, - unused */
         0
     };
-#ifdef RT_USING_POSIX
     pfd.fd = fd;
     pfd.events = POLLIN;
-#endif
     buffer++; /* saved chars counter is in buffer[-1] now */
 
  start_over:
@@ -339,11 +315,7 @@ int64_t read_key(int fd, char *buffer, int timeout)
          * if fd can be in non-blocking mode.
          */
         if (timeout >= -1) {
-#ifdef RT_USING_POSIX
             if (safe_poll(&pfd, 1, timeout) == 0) {
-#else
-            if (rt_sem_take(&shell->rx_sem, timeout) != RT_EOK) {
-#endif
                 /* Timed out */
                 errno = EAGAIN;
                 return -1;
@@ -355,11 +327,7 @@ int64_t read_key(int fd, char *buffer, int timeout)
          * When we were reading 3 bytes here, we were eating
          * "li" too, and cat was getting wrong input.
          */
-#ifdef RT_USING_POSIX
         n = safe_read(fd, buffer, 1);
-#else
-        n = wait_read(fd, buffer, 1, -1);
-#endif
         if (n <= 0)
             return -1;
     }
@@ -392,11 +360,7 @@ int64_t read_key(int fd, char *buffer, int timeout)
                  * so if we block for long it's not really an escape sequence.
                  * Timeout is needed to reconnect escape sequences
                  * split up by transmission over a serial console. */
-#ifdef RT_USING_POSIX
                 if (safe_poll(&pfd, 1, 50) == 0) {
-#else
-                if (0 != 0) {
-#endif
                     /* No more data!
                      * Array is sorted from shortest to longest,
                      * we can't match anything later in array -
@@ -405,11 +369,7 @@ int64_t read_key(int fd, char *buffer, int timeout)
                     goto got_all;
                 }
                 errno = 0;
-#ifdef RT_USING_POSIX
                 read_num = safe_read(fd, buffer + n, 1);
-#else
-                read_num = wait_read(fd, buffer + n, 1, 50);
-#endif
                 if (read_num <= 0) {
                     /* If EAGAIN, then fd is O_NONBLOCK and poll lied:
                      * in fact, there is no data. */
@@ -451,20 +411,12 @@ int64_t read_key(int fd, char *buffer, int timeout)
      */
     while (n < KEYCODE_BUFFER_SIZE-1) { /* 1 for count byte at buffer[-1] */
         int read_num;
-#ifdef RT_USING_POSIX
         if (safe_poll(&pfd, 1, 50) == 0) {
-#else
-        if (0 != 0) {
-#endif
             /* No more data! */
             break;
         }
         errno = 0;
-#ifdef RT_USING_POSIX
         read_num = safe_read(fd, buffer + n, 1);
-#else
-        read_num = wait_read(fd, buffer + n, 1, 50);
-#endif
         if (read_num <= 0) {
             /* If EAGAIN, then fd is O_NONBLOCK and poll lied:
              * in fact, there is no data. */