* sim/ucsim/cmd.src/newcmd.cc, sim/ucsim/cmd.src/newcmdcl.h:
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 20 Aug 2006 13:57:43 +0000 (13:57 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 20 Aug 2006 13:57:43 +0000 (13:57 +0000)
  removed cl_listen_console::match(), cl_console::match(),
  restructured cl_commander::proc_input()

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4341 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
sim/ucsim/cmd.src/newcmd.cc
sim/ucsim/cmd.src/newcmdcl.h

index 242623c0eb9b1330b8f7285c1d9a1a5f88ef7f2c..067a1c64d7e1b781274fce1bcb0f698fa01d329b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-08-20 Borut Razem <borut.razem AT siol.net>
+
+       * sim/ucsim/cmd.src/newcmd.cc, sim/ucsim/cmd.src/newcmdcl.h:
+         removed cl_listen_console::match(), cl_console::match(),
+         restructured cl_commander::proc_input()
+
 2006-08-16 Borut Razem <borut.razem AT siol.net>
 
        * sim/ucsim/cmd.src/newcmd.cc, sim/ucsim/cmd.src/newcmdcl.h,
index 76e088c4bc6f30683de65c2800d968e57c145bba..4717409eaf72fdb037af51559a84c086b1da680f 100644 (file)
@@ -66,10 +66,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "cmdutil.h"
 
 
-extern "C" int vasprintf(char **strp, const  char *format, va_list ap);
-extern "C" int vsnprintf(char *str, size_t size,const char *format,va_list ap);
-
-
 /*
  * Options of console
  */
@@ -336,14 +332,16 @@ cl_console::un_redirect(void)
 int
 cl_console::cmd_do_print(char *format, va_list ap)
 {
+  int ret;
   FILE *f = get_out();
-  int ret = 0;
 
   if (f)
    {
-      vfprintf(f, format, ap);
+      ret= vfprintf(f, format, ap);
       fflush(f);
     }
+  else
+    ret= 0;
 
   return(ret);
 }
@@ -426,15 +424,6 @@ cl_console::print_char_octal(char c)
  * Input functions
  */
 
-int
-cl_console::match(int fdnum)
-{
-  if (in &&
-      fileno(in) == fdnum)
-    return(1);
-  return(0);
-}
-
 int
 cl_console::get_in_fd(void)
 {
@@ -467,9 +456,7 @@ cl_console::read_line(void)
 #ifdef HAVE_GETLINE
   if (getline(&s, 0, in) < 0)
     return(0);
-#else
-
-# ifdef HAVE_GETDELIM
+#elif defined HAVE_GETDELIM
   size_t n= 30;
   s= (char *)malloc(n);
   if (getdelim(&s, &n, '\n', in) < 0)
@@ -477,17 +464,13 @@ cl_console::read_line(void)
       free(s);
       return(0);
     }
-# else
-
-#  ifdef HAVE_FGETS
+#elif defined HAVE_FGETS
   s= (char *)malloc(300);
   if (fgets(s, 300, in) == NULL)
     {
       free(s);
       return(0);
     }
-#  endif
-# endif
 #endif
   s[strlen(s)-1]= '\0';
   if (s[strlen(s)-1] == '\r')
@@ -632,12 +615,6 @@ cl_listen_console::cl_listen_console(int serverport, class cl_app *the_app)
   in= out= 0;
 }
 
-int
-cl_listen_console::match(int fdnum)
-{
-  return(sock == fdnum);
-}
-
 int
 cl_listen_console::get_in_fd(void)
 {
@@ -1051,31 +1028,25 @@ cl_commander::wait_input(void)
 int
 cl_commander::proc_input(void)
 {
-  UCSOCKET_T i;
+  for (int j = 0; j < cons->count; j++)
+    {
+      class cl_console *c = (class cl_console*)(cons->at(j));
 
-  for (i= 0; i < fd_num; i++)
-    if (FD_ISSET(i, &active_set))
-      {
-        class cl_console *c;
-        int j;
-        for (j= 0; j < cons->count; j++)
-          {
-            c= (class cl_console*)(cons->at(j));
-            if (c->match(i))
-              {
-                actual_console= c;
-                int retval= c->proc_input(cmdset);
-                if (retval)
-                  {
-                    del_console(c);
-                    delete c;
-                  }
-                actual_console= 0;
-                return(cons->count == 0);
-              }
-          }
-      }
-  return(0);
+      int fd = c->get_in_fd();
+      if (fd >= 0 && FD_ISSET(fd, &active_set))
+        {
+          actual_console = c;
+          int retval = c->proc_input(cmdset);
+          if (retval)
+            {
+              del_console(c);
+              delete c;
+            }
+          actual_console = 0;
+          return(0 == cons->count);
+        }
+    }
+  return 0;
 }
 
 void
index e091fa54b76652ca6318b26b4548c97337e9f930..471614c8030577483cabad4a54f67994028db8e2 100644 (file)
@@ -2,7 +2,7 @@
  * Simulator of microcontrollers (cmd.src/cmdcl.h)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
- * 
+ *
  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
  *
  */
@@ -114,7 +114,7 @@ public:
   class cl_app *app;
   int flags; // See CONS_XXXX
   char *prompt;
-  
+
 public:
   cl_console(void): cl_base() { app= 0; in= out= 0; flags= 0; }
   cl_console(char *fin, char *fout, class cl_app *the_app);
@@ -138,7 +138,6 @@ public:
   virtual int  debug(char *format, ...);
   virtual void print_bin(long data, int bits);
   virtual void print_char_octal(char c);
-  virtual int  match(int fdnum);
   virtual int  get_in_fd(void);
   virtual int  input_avail(void);
   virtual char *read_line(void);
@@ -161,7 +160,6 @@ public:
 
   virtual void welcome(void) {}
 
-  virtual int match(int fdnum);
   virtual int get_in_fd(void);
   virtual int proc_input(class cl_cmdset *cmdset);
 };