Browse code

- *bsd & mac os x fixes - use alternative to rl_attempted_completion_over which is not present in some readline emulations (e.g. libedit readline emulation on mac os x)

Andrei Pelinescu-Onciul authored on 23/02/2006 23:36:54
Showing 2 changed files
... ...
@@ -34,6 +34,7 @@
34 34
 #include <stdlib.h> /* malloc */
35 35
 #include <string.h>
36 36
 #include <netdb.h> /* getservbyname*/
37
+#include <arpa/inet.h> /* ntohs */
37 38
 
38 39
 #include "parse_listen_id.h"
39 40
 
... ...
@@ -231,6 +231,11 @@ static struct sercmd_builtin builtins[]={
231 231
 
232 232
 
233 233
 #ifdef USE_READLINE
234
+
235
+/* instead of rl_attempted_completion_over which is not present in
236
+   some readline emulations */
237
+static int attempted_completion_over=0; 
238
+
234 239
 /* commands for which we complete the params to other command names */
235 240
 char* complete_params[]={
236 241
 	"?",
... ...
@@ -1173,7 +1178,6 @@ static int sercmd_warranty(int s, struct binrpc_cmd *cmd)
1173 1173
 
1174 1174
 #ifdef USE_READLINE
1175 1175
 
1176
-
1177 1176
 /* readline command generator */
1178 1177
 static char* sercmd_generator(const char* text, int state)
1179 1178
 {
... ...
@@ -1182,6 +1186,9 @@ static char* sercmd_generator(const char* text, int state)
1182 1182
 	static int len;
1183 1183
 	char* name;
1184 1184
 	
1185
+	if (attempted_completion_over)
1186
+		return 0;
1187
+	
1185 1188
 	if (state==0){
1186 1189
 		/* init */
1187 1190
 		idx=list=0;
... ...
@@ -1229,10 +1236,10 @@ char** sercmd_completion(const char* text, int start, int end)
1229 1229
 	int r;
1230 1230
 	int i;
1231 1231
 	
1232
-	rl_attempted_completion_over=1;
1232
+	attempted_completion_over=1;
1233 1233
 	/* complete only at beginning */
1234 1234
 	if (start==0){
1235
-		rl_attempted_completion_over=0;
1235
+		attempted_completion_over=0;
1236 1236
 	}else{ /* or if this is a command for which we complete the parameters */
1237 1237
 		/* find first whitespace */
1238 1238
 		for(r=0; (r<start) && (rl_line_buffer[r]!=' ') && 
... ...
@@ -1240,7 +1247,7 @@ char** sercmd_completion(const char* text, int start, int end)
1240 1240
 		for(i=0; complete_params[i]; i++){
1241 1241
 			if ((r==strlen(complete_params[i])) &&
1242 1242
 					(strncmp(rl_line_buffer, complete_params[i], r)==0)){
1243
-					rl_attempted_completion_over=0;
1243
+					attempted_completion_over=0;
1244 1244
 					break;
1245 1245
 			}
1246 1246
 		}