[asterisk-commits] trunk r15856 - /trunk/channels/chan_zap.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Mar 28 16:20:15 MST 2006


Author: rizzo
Date: Tue Mar 28 17:20:13 2006
New Revision: 15856

URL: http://svn.digium.com/view/asterisk?rev=15856&view=rev
Log:
normalize/simplify a bit of the command completion code.


Modified:
    trunk/channels/chan_zap.c

Modified: trunk/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_zap.c?rev=15856&r1=15855&r2=15856&view=diff
==============================================================================
--- trunk/channels/chan_zap.c (original)
+++ trunk/channels/chan_zap.c Tue Mar 28 17:20:13 2006
@@ -9394,20 +9394,19 @@
 
 static char *complete_span_helper(const char *line, const char *word, int pos, int state, int rpos)
 {
-	int span=1;
-	char tmp[50];
+	int which, span;
+	char *ret = NULL;
+
 	if (pos != rpos)
-		return 0;
-	while(span <= NUM_SPANS) {
-		if (span > state && pris[span-1].pri)
+		return ret;
+
+	for (which = span = 0; span < NUM_SPANS; span++) {
+		if (pris[span].pri && ++which > state) {
+			asprintf(&ret, "%d", span + 1);	/* user indexes start from 1 */
 			break;
-		span++;
-	}
-	if (span <= NUM_SPANS) {
-		snprintf(tmp, sizeof(tmp), "%d", span);
-		return ast_strdup(tmp);
-	} else
-		return NULL;
+		}
+	}
+	return ret;
 }
 
 static char *complete_span_4(const char *line, const char *word, int pos, int state)



More information about the asterisk-commits mailing list