Index: pjproject/trunk/pjlib-util/src/pjlib-util/cli_telnet.c
===================================================================
--- pjproject/trunk/pjlib-util/src/pjlib-util/cli_telnet.c	(revision 4476)
+++ pjproject/trunk/pjlib-util/src/pjlib-util/cli_telnet.c	(revision 4513)
@@ -668,5 +668,5 @@
     cli_telnet_fe *fe = (cli_telnet_fe *)sess->base.fe;
 
-    send_data.ptr = &data_str[0];
+    send_data.ptr = data_str;
     send_data.slen = 0;
     
@@ -692,5 +692,5 @@
     cli_telnet_fe *fe = (cli_telnet_fe *)sess->base.fe;
 
-    send_data.ptr = &data_str[0];
+    send_data.ptr = data_str;
     send_data.slen = 0;
 
@@ -709,5 +709,5 @@
     pj_strcat(&send_data, &fe->cfg.prompt_str);
     if (with_last_cmd)
-	pj_strcat2(&send_data, (char *)&sess->rcmd->rbuf[0]);
+	pj_strcat2(&send_data, (char *)sess->rcmd->rbuf);
 
     telnet_sess_send(sess, &send_data);
@@ -772,5 +772,5 @@
     static const pj_str_t sc_type = {"sc", 2};
     static const pj_str_t choice_type = {"choice", 6};
-    send_data.ptr = &data[0];
+    send_data.ptr = data;
     send_data.slen = 0;
     
@@ -787,7 +787,10 @@
     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) {
-		//Additional delimiter " | "
-		cmd_length += (hint[i].name.slen + 3);
+	    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;
@@ -817,16 +820,9 @@
 	}
 	
-	if ((parse_state != OP_SHORTCUT)) {
-	    if (cmd_desc) {
-		/* Print data if previous hint is shortcut */
-		send_hint_arg(sess, &send_data, 
-			      cmd_desc, cmd_length, 
-			      max_length);
-		cmd_desc = 0;
-	    }
+	if (parse_state != OP_SHORTCUT) {
 	    pj_strcat2(&send_data, "\r\n  ");
 	    cmd_length = hint[i].name.slen;
-	}
-
+	}	    
+	
 	switch (parse_state) {
 	case OP_CHOICE:
@@ -844,7 +840,14 @@
 	case OP_SHORTCUT:
 	    /* Format : "Command | sc |  description" */
-	    pj_strcat2(&send_data, " | ");
-	    pj_strcat(&send_data, &hint[i].name);
-	    cmd_length += (hint[i].name.slen + 3);
+	    {		
+		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;		    
+		} else {
+		    pj_strcat2(&send_data, "\r\n  ");
+		}
+		pj_strcat(&send_data, &hint[i].name);	
+	    }
 	    break;
 	default:
@@ -856,5 +859,6 @@
     	
 	if ((parse_state == OP_TYPE) || (parse_state == OP_CHOICE) || 
-	    ((i+1) >= info->hint_cnt)) 
+	    ((i+1) >= info->hint_cnt) ||
+	    (pj_strncmp(&hint[i].desc, &hint[i+1].desc, hint[i].desc.slen))) 
 	{
 	    /* Add description info */
@@ -862,4 +866,6 @@
 			  &hint[i].desc, cmd_length, 
 			  max_length);
+
+	    cmd_length = 0;
 	}	
     }  
@@ -867,5 +873,5 @@
     pj_strcat(&send_data, &fe->cfg.prompt_str);
     if (with_last_cmd)
-	pj_strcat2(&send_data, (char *)&sess->rcmd->rbuf[0]);
+	pj_strcat2(&send_data, (char *)sess->rcmd->rbuf);
 
     telnet_sess_send(sess, &send_data);    
@@ -883,5 +889,5 @@
     pj_strcat2(&info->hint[0].name, " ");
 
-    send_data.ptr = &data[0];
+    send_data.ptr = data;
     send_data.slen = 0;
 
@@ -901,5 +907,5 @@
 	    unsigned char echo[5] = {0x1b, 0x5b, 0x31, 0x40, 0x00};
 	    echo[4] = *data;
-	    telnet_sess_send2(sess, &echo[0], 5);
+	    telnet_sess_send2(sess, echo, 5);
 	} else {
 	    /* Append character */
@@ -925,8 +931,8 @@
 	    unsigned char echo[5] = {0x00, 0x1b, 0x5b, 0x31, 0x50};
 	    echo[0] = *data;
-	    telnet_sess_send2(sess, &echo[0], 5);
+	    telnet_sess_send2(sess, echo, 5);
 	} else {
 	    const static unsigned char echo[3] = {0x08, 0x20, 0x08};	    
-	    telnet_sess_send2(sess, &echo[0], 3);
+	    telnet_sess_send2(sess, echo, 3);
 	}
 	return PJ_TRUE;
@@ -987,5 +993,5 @@
 			       pool, &info);    
 
-    len = pj_ansi_strlen((char *)&sess->rcmd->rbuf[0]);
+    len = pj_ansi_strlen((char *)sess->rcmd->rbuf);
 
     switch (status) {
@@ -1010,5 +1016,5 @@
 	if (info.hint_cnt > 0) {	
 	    /* Complete command */
-	    pj_str_t cmd = pj_str((char *)&sess->rcmd->rbuf[0]);
+	    pj_str_t cmd = pj_str((char *)sess->rcmd->rbuf);
 	    pj_str_t last_token;
 
@@ -1019,5 +1025,5 @@
 		if (hint_info->slen >= last_token.slen) {
 		    hint_info->slen -= last_token.slen;
-		    pj_memmove(&hint_info->ptr[0], 
+		    pj_memmove(hint_info->ptr, 
 			       &hint_info->ptr[last_token.slen], 
 			       hint_info->slen);		    
@@ -1025,5 +1031,5 @@
 		send_comp_arg(sess, &info);
 
-		pj_memcpy(&sess->rcmd->rbuf[len], &info.hint[0].name.ptr[0], 
+		pj_memcpy(&sess->rcmd->rbuf[len], info.hint[0].name.ptr, 
 			  info.hint[0].name.slen);
 
@@ -1136,5 +1142,5 @@
 	    CLEAR_CHAR = 0x20
 	};
-	send_data.ptr = &str[0];
+	send_data.ptr = str;
 	send_data.slen = 0;
 
