Index: pjproject/trunk/pjlib-util/src/pjlib-util/cli_console.c
===================================================================
--- pjproject/trunk/pjlib-util/src/pjlib-util/cli_console.c	(revision 4537)
+++ pjproject/trunk/pjlib-util/src/pjlib-util/cli_console.c	(revision 4728)
@@ -46,11 +46,11 @@
     pj_thread_t        *input_thread;
     pj_bool_t           thread_quit;
-    pj_sem_t           *thread_sem;   
-    pj_cli_console_cfg  cfg;    
+    pj_sem_t           *thread_sem;
+    pj_cli_console_cfg  cfg;
 
     struct async_input_t
-    {        
+    {
         char       *buf;
-        unsigned    maxlen;	
+        unsigned    maxlen;
         pj_sem_t   *sem;
     } input;
@@ -127,5 +127,5 @@
     if (!pool)
         return PJ_ENOMEM;
-	
+
     sess = PJ_POOL_ZALLOC_T(pool, pj_cli_sess);
     fe = PJ_POOL_ZALLOC_T(pool, struct cli_console_fe);
@@ -136,5 +136,5 @@
     }
     sess->fe = &fe->base;
-    sess->log_level = param->log_level;    
+    sess->log_level = param->log_level;
     sess->op = PJ_POOL_ZALLOC_T(pool, struct pj_cli_sess_op);
     fe->base.op = PJ_POOL_ZALLOC_T(pool, struct pj_cli_front_end_op);
@@ -155,14 +155,14 @@
 
     pj_cli_register_front_end(cli, &fe->base);
-    if (param->prompt_str.slen == 0) {	
+    if (param->prompt_str.slen == 0) {
 	pj_str_t prompt_sign = pj_str(">>> ");
 	fe->cfg.prompt_str.ptr = pj_pool_alloc(fe->pool, prompt_sign.slen+1);
-	pj_strcpy(&fe->cfg.prompt_str, &prompt_sign);	
+	pj_strcpy(&fe->cfg.prompt_str, &prompt_sign);
     } else {
-	fe->cfg.prompt_str.ptr = pj_pool_alloc(fe->pool, 
+	fe->cfg.prompt_str.ptr = pj_pool_alloc(fe->pool,
 					       param->prompt_str.slen+1);
 	pj_strcpy(&fe->cfg.prompt_str, &param->prompt_str);
-    }    
-    fe->cfg.prompt_str.ptr[fe->cfg.prompt_str.slen] = 0; 
+    }
+    fe->cfg.prompt_str.ptr[fe->cfg.prompt_str.slen] = 0;
 
     if (param->quit_command.slen)
@@ -184,5 +184,5 @@
     send_data.ptr = data_str;
     send_data.slen = 0;
-    
+
     pj_strcat(&send_data, &fe->cfg.prompt_str);
     send_data.ptr[send_data.slen] = 0;
@@ -191,6 +191,6 @@
 }
 
-static void send_err_arg(pj_cli_sess *sess, 
-			 const pj_cli_exec_info *info, 
+static void send_err_arg(pj_cli_sess *sess,
+			 const pj_cli_exec_info *info,
 			 const pj_str_t *msg,
 			 pj_bool_t with_return)
@@ -219,8 +219,8 @@
 
     send_data.ptr[send_data.slen] = 0;
-    printf("%s", send_data.ptr);    
-}
-
-static void send_inv_arg(pj_cli_sess *sess, 
+    printf("%s", send_data.ptr);
+}
+
+static void send_inv_arg(pj_cli_sess *sess,
 			 const pj_cli_exec_info *info,
 			 pj_bool_t with_return)
@@ -230,5 +230,5 @@
 }
 
-static void send_too_many_arg(pj_cli_sess *sess, 
+static void send_too_many_arg(pj_cli_sess *sess,
 			      const pj_cli_exec_info *info,
 			      pj_bool_t with_return)
@@ -238,5 +238,5 @@
 }
 
-static void send_hint_arg(pj_str_t *send_data, 
+static void send_hint_arg(pj_str_t *send_data,
 			  const pj_str_t *desc,
 			  pj_ssize_t cmd_len,
@@ -257,5 +257,5 @@
 }
 
-static void send_ambi_arg(pj_cli_sess *sess, 
+static void send_ambi_arg(pj_cli_sess *sess,
 			  const pj_cli_exec_info *info,
 			  pj_bool_t with_return)
@@ -270,10 +270,9 @@
     pj_ssize_t max_length = 0;
     pj_ssize_t cmd_length = 0;
-    const pj_str_t *cmd_desc = 0;
     static const pj_str_t sc_type = {"sc", 2};
     static const pj_str_t choice_type = {"choice", 6};
     send_data.ptr = data;
     send_data.slen = 0;
-    
+
     if (with_return)
 	pj_strcat2(&send_data, "\r\n");
@@ -284,18 +283,18 @@
 	pj_strcat2(&send_data, " ");
     }
-    pj_strcat2(&send_data, "^");        
+    pj_strcat2(&send_data, "^");
     /* Get the max length of the command name */
     for (i=0;i<info->hint_cnt;++i) {
-	if ((&hint[i].type) && (hint[i].type.slen > 0)) {	    
-	    if (pj_stricmp(&hint[i].type, &sc_type) == 0) {		
+	if ((&hint[i].type) && (hint[i].type.slen > 0)) {
+	    if (pj_stricmp(&hint[i].type, &sc_type) == 0) {
 		if ((i > 0) && (!pj_stricmp(&hint[i-1].desc, &hint[i].desc))) {
 		    cmd_length += (hint[i].name.slen + 3);
 		} else {
 		    cmd_length = hint[i].name.slen;
-		}		
+		}
 	    } else {
 		cmd_length = hint[i].name.slen;
 	    }
-	} else {	    	    
+	} else {
 	    cmd_length = hint[i].name.slen;
 	}
@@ -308,5 +307,5 @@
     cmd_length = 0;
     for (i=0;i<info->hint_cnt;++i) {
-	if ((&hint[i].type) && (hint[i].type.slen > 0)) {	    
+	if ((&hint[i].type) && (hint[i].type.slen > 0)) {
 	    if (pj_stricmp(&hint[i].type, &sc_type) == 0) {
 		parse_state = OP_SHORTCUT;
@@ -316,5 +315,5 @@
 		parse_state = OP_TYPE;
 	    }
-	} else {	    	    
+	} else {
 	    parse_state = OP_NORMAL;
 	}
@@ -324,38 +323,37 @@
 	    cmd_length = hint[i].name.slen;
 	}
-    
+
 	switch (parse_state) {
 	case OP_CHOICE:
 	    pj_strcat2(&send_data, "[");
 	    pj_strcat(&send_data, &hint[i].name);
-	    pj_strcat2(&send_data, "]");	
+	    pj_strcat2(&send_data, "]");
 	    break;
 	case OP_TYPE:
 	    pj_strcat2(&send_data, "<");
 	    pj_strcat(&send_data, &hint[i].type);
-	    pj_strcat2(&send_data, ">");	
+	    pj_strcat2(&send_data, ">");
 	    break;
 	case OP_SHORTCUT:
 	    /* Format : "Command | sc |  description" */
-	    {		
+	    {
 		cmd_length += hint[i].name.slen;
 		if ((i > 0) && (!pj_stricmp(&hint[i-1].desc, &hint[i].desc))) {
 		    pj_strcat2(&send_data, " | ");
-		    cmd_length += 3;		    
+		    cmd_length += 3;
 		} else {
 		    pj_strcat2(&send_data, "\r\n  ");
 		}
-		pj_strcat(&send_data, &hint[i].name);	
+		pj_strcat(&send_data, &hint[i].name);
 	    }
 	    break;
 	default:
 	    pj_strcat(&send_data, &hint[i].name);
-	    cmd_desc = &hint[i].desc;
 	    break;
 	}
-    	
-	if ((parse_state == OP_TYPE) || (parse_state == OP_CHOICE) || 
+
+	if ((parse_state == OP_TYPE) || (parse_state == OP_CHOICE) ||
 	    ((i+1) >= info->hint_cnt) ||
-	    (pj_strncmp(&hint[i].desc, &hint[i+1].desc, hint[i].desc.slen))) 
+	    (pj_strncmp(&hint[i].desc, &hint[i+1].desc, hint[i].desc.slen)))
 	{
 	    /* Add description info */
@@ -364,9 +362,9 @@
 	    cmd_length = 0;
 	}
-    }  
+    }
     pj_strcat2(&send_data, "\r\n");
     pj_strcat(&send_data, &fe->cfg.prompt_str);
     send_data.ptr[send_data.slen] = 0;
-    printf("%s", send_data.ptr);    
+    printf("%s", send_data.ptr);
 }
 
@@ -375,5 +373,5 @@
     pj_status_t status;
     pj_bool_t retval = PJ_TRUE;
-    
+
     pj_pool_t *pool;
     pj_cli_cmd_val *cmd_val;
@@ -388,11 +386,11 @@
 
     cmd_val = PJ_POOL_ZALLOC_T(pool, pj_cli_cmd_val);
-    
-    status = pj_cli_sess_parse(sess, recv_buf, cmd_val, 
+
+    status = pj_cli_sess_parse(sess, recv_buf, cmd_val,
 			       pool, &info);
 
     switch (status) {
     case PJ_CLI_EINVARG:
-	send_inv_arg(sess, &info, PJ_TRUE);		
+	send_inv_arg(sess, &info, PJ_TRUE);
 	break;
     case PJ_CLI_ETOOMANYARGS:
@@ -403,16 +401,16 @@
 	send_ambi_arg(sess, &info, PJ_TRUE);
 	break;
-    case PJ_SUCCESS:	
-	if (info.hint_cnt > 0) {	
-	    /* Compelete command */	    
-	    send_ambi_arg(sess, &info, PJ_TRUE);	    		
+    case PJ_SUCCESS:
+	if (info.hint_cnt > 0) {
+	    /* Compelete command */
+	    send_ambi_arg(sess, &info, PJ_TRUE);
 	} else {
 	    retval = PJ_FALSE;
-	}	
-	break;
-    }
-
-    pj_pool_release(pool);	
-    return retval; 
+	}
+	break;
+    }
+
+    pj_pool_release(pool);
+    return retval;
 }
 
@@ -421,23 +419,23 @@
     pj_status_t status;
     pj_bool_t retval = PJ_TRUE;
-    
-    pj_pool_t *pool;    
+
+    pj_pool_t *pool;
     pj_cli_exec_info info;
     pj_cli_t *cli = sess->fe->cli;
     struct cli_console_fe *fe = (struct cli_console_fe *)sess->fe;
     char *recv_buf = fe->input.buf;
-        
+
     printf("\r\n");
 
     pool = pj_pool_create(pj_cli_get_param(cli)->pf, "handle_exec",
 			  PJ_CLI_CONSOLE_POOL_SIZE, PJ_CLI_CONSOLE_POOL_INC,
-			  NULL);    
-    
-    status = pj_cli_sess_exec(sess, recv_buf, 
+			  NULL);
+
+    status = pj_cli_sess_exec(sess, recv_buf,
 			      pool, &info);
 
     switch (status) {
     case PJ_CLI_EINVARG:
-	send_inv_arg(sess, &info, PJ_FALSE);	
+	send_inv_arg(sess, &info, PJ_FALSE);
 	break;
     case PJ_CLI_ETOOMANYARGS:
@@ -452,14 +450,14 @@
 	break;
     case PJ_SUCCESS:
-	send_prompt_str(sess);	
-	break;
-    }    
-
-    pj_pool_release(pool);	
-    return retval; 
+	send_prompt_str(sess);
+	break;
+    }
+
+    pj_pool_release(pool);
+    return retval;
 }
 
 static int readline_thread(void * p)
-{    
+{
     struct cli_console_fe * fe = (struct cli_console_fe *)p;
 
@@ -473,5 +471,5 @@
 
 	if (fgets(recv_buf, fe->input.maxlen, stdin) == NULL) {
-	    /* 
+	    /*
 	     * Be friendly to users who redirect commands into
 	     * program, when file ends, resume with kbd.
@@ -488,8 +486,8 @@
 		puts("Cannot switch back to console from file redirection");
 		if (fe->cfg.quit_command.slen) {
-		    pj_memcpy(recv_buf, fe->cfg.quit_command.ptr, 
+		    pj_memcpy(recv_buf, fe->cfg.quit_command.ptr,
 			      fe->input.maxlen);
 		}
-		recv_buf[fe->cfg.quit_command.slen] = '\0';		
+		recv_buf[fe->cfg.quit_command.slen] = '\0';
 	    } else {
 		puts("Switched back to console from file redirection");
@@ -506,5 +504,5 @@
 	    break;
 	}
-	input_len = pj_ansi_strlen(fe->input.buf);	
+	input_len = pj_ansi_strlen(fe->input.buf);
 	if ((input_len > 1) && (fe->input.buf[input_len-2] == '?')) {
 	    fe->input.buf[input_len-1] = 0;
@@ -516,12 +514,12 @@
 	}
 
-        pj_sem_post(fe->input.sem);        
+        pj_sem_post(fe->input.sem);
         pj_sem_wait(fe->thread_sem);
-    }    
+    }
 
     return 0;
 }
 
-PJ_DEF(pj_status_t) pj_cli_console_process(pj_cli_sess *sess, 
+PJ_DEF(pj_status_t) pj_cli_console_process(pj_cli_sess *sess,
 					   char *buf,
 					   unsigned maxlen)
