Browse Source

- *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 19 years ago
parent
commit
82d35e58c7
2 changed files with 12 additions and 4 deletions
  1. 1 0
      utils/sercmd/parse_listen_id.c
  2. 11 4
      utils/sercmd/sercmd.c

+ 1 - 0
utils/sercmd/parse_listen_id.c

@@ -34,6 +34,7 @@
 #include <stdlib.h> /* malloc */
 #include <string.h>
 #include <netdb.h> /* getservbyname*/
+#include <arpa/inet.h> /* ntohs */
 
 #include "parse_listen_id.h"
 

+ 11 - 4
utils/sercmd/sercmd.c

@@ -231,6 +231,11 @@ static struct sercmd_builtin builtins[]={
 
 
 #ifdef USE_READLINE
+
+/* instead of rl_attempted_completion_over which is not present in
+   some readline emulations */
+static int attempted_completion_over=0; 
+
 /* commands for which we complete the params to other command names */
 char* complete_params[]={
 	"?",
@@ -1173,7 +1178,6 @@ static int sercmd_warranty(int s, struct binrpc_cmd *cmd)
 
 #ifdef USE_READLINE
 
-
 /* readline command generator */
 static char* sercmd_generator(const char* text, int state)
 {
@@ -1182,6 +1186,9 @@ static char* sercmd_generator(const char* text, int state)
 	static int len;
 	char* name;
 	
+	if (attempted_completion_over)
+		return 0;
+	
 	if (state==0){
 		/* init */
 		idx=list=0;
@@ -1229,10 +1236,10 @@ char** sercmd_completion(const char* text, int start, int end)
 	int r;
 	int i;
 	
-	rl_attempted_completion_over=1;
+	attempted_completion_over=1;
 	/* complete only at beginning */
 	if (start==0){
-		rl_attempted_completion_over=0;
+		attempted_completion_over=0;
 	}else{ /* or if this is a command for which we complete the parameters */
 		/* find first whitespace */
 		for(r=0; (r<start) && (rl_line_buffer[r]!=' ') && 
@@ -1240,7 +1247,7 @@ char** sercmd_completion(const char* text, int start, int end)
 		for(i=0; complete_params[i]; i++){
 			if ((r==strlen(complete_params[i])) &&
 					(strncmp(rl_line_buffer, complete_params[i], r)==0)){
-					rl_attempted_completion_over=0;
+					attempted_completion_over=0;
 					break;
 			}
 		}