]> rtime.felk.cvut.cz Git - sysless.git/commitdiff
cmdproc: Handle returned error correctly
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 31 Jul 2013 13:49:00 +0000 (15:49 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 31 Jul 2013 13:49:00 +0000 (15:49 +0200)
This case should not happen when cmd_processor_run() calls the
respective functions, but let's fix this is somebody calls the functions
differently.

libs4c/cmdproc/cmd_io_line.c

index a7fdf23deb9e0d91e6e04295add282d3b749cee8..4abace0b425a0181ee024b8ef0966c711ce45436 100644 (file)
@@ -29,7 +29,7 @@
  * @param elb Edit line buffer.
  * @param ch character to add.
  * 
- * @return 1 in case of end of line, 0 otherwise.
+ * @return 1 in case of end of line, -1 if called at inaproprate time, 0 otherwise.
  */
 int cmd_ed_line_buf(ed_line_buf_t *elb, int ch)
 {
@@ -98,6 +98,8 @@ int cmd_io_line_in(cmd_io_t *cmd_io)
   while((ch=cmd_io_getc(io_stack))>=0){
 //    DPRINT("Added %c (%d)\n", ch, ch);
     int eol = cmd_ed_line_buf(ed_line_in,ch);
+    if (eol == -1)
+      return -1;
     if(eol){
       if(ed_line_in->flg&FL_ELB_ECHO){
         while(cmd_io_putc(io_stack,'\r')<0);