[Pkg-utopia-commits] r1104 - packages/unstable/networkmanager/debian/patches

Michael Biebl biebl at costa.debian.org
Tue Oct 24 21:23:25 UTC 2006


Author: biebl
Date: 2006-10-24 21:23:24 +0000 (Tue, 24 Oct 2006)
New Revision: 1104

Modified:
   packages/unstable/networkmanager/debian/patches/05-debian_backend.patch
Log:
Make the /e/n/i a bit more robust and easier to read.


Modified: packages/unstable/networkmanager/debian/patches/05-debian_backend.patch
===================================================================
--- packages/unstable/networkmanager/debian/patches/05-debian_backend.patch	2006-10-24 20:31:49 UTC (rev 1103)
+++ packages/unstable/networkmanager/debian/patches/05-debian_backend.patch	2006-10-24 21:23:24 UTC (rev 1104)
@@ -194,10 +194,25 @@
  
  
 diff --git a/src/backends/interface_parser.c b/src/backends/interface_parser.c
-index 53d6487..2fa559f 100644
+index 53d6487..b3ad300 100644
 --- a/src/backends/interface_parser.c
 +++ b/src/backends/interface_parser.c
-@@ -71,7 +71,8 @@ void add_data(const char *key,const char
+@@ -50,11 +50,13 @@ void add_block(const char *type, const c
+ 
+ void add_data(const char *key,const char *data)
+ {
++	if_data *ret;
++
+ 	// Check if there is a block where we can attach our data
+ 	if (first == NULL)
+ 		return;
+ 			
+-	if_data *ret = (if_data*)calloc(1,sizeof(struct _if_data));
++	ret = (if_data*) calloc(1,sizeof(struct _if_data));
+ 	ret->key = g_strdup(key);
+ 	ret->data = g_strdup(data);
+ 	
+@@ -71,14 +73,18 @@ void add_data(const char *key,const char
  	//printf("added data '%s' with key '%s'\n",data,key);
  }
  
@@ -207,65 +222,124 @@
  
  void ifparser_init(void)
  {
-@@ -105,36 +106,52 @@ void ifparser_init(void)
- 		if (line[0]=='#' || line[0]=='\0')
+ 	FILE *inp = fopen(INTERFACES,"r");
+ 	int ret = 0;
++	int pos;
++	int len;
+ 	char *line;
+-	char *space;
++	char *key;
++	char *data;
+ 	char rline[255];
+ 
+ 	if (inp == NULL)
+@@ -89,7 +95,7 @@ void ifparser_init(void)
+ 	first = last = NULL;
+ 	while(1)
+ 	{
+-		line = space = NULL;
++		line = NULL;
+ 		ret = fscanf(inp,"%255[^\n]\n",rline);
+ 		if (ret == EOF)
+ 			break;
+@@ -102,50 +108,71 @@ void ifparser_init(void)
+ 		line = rline;
+ 		while(line[0] == ' ')
+ 			line++;
+-		if (line[0]=='#' || line[0]=='\0')
++		if (line[0] == '#' || line[0] == '\0')
  			continue;
  		
 -		SPACE_OR_TAB(line,space)
-+		space = line;
-+		while (!strchr(WS, space[0])) space++;
+-		if (space == NULL)
++		len = strlen(line);
++		pos = 0;
++		while (!strchr(WS, line[pos]) && pos < len) pos++;
 +
- 		if (space == NULL)
++		// terminate key string and skip further whitespaces
++		line[pos++] = '\0';
++		while (strchr(WS, line[pos]) && pos < len) pos++;
++
++		if (pos >= len)
  		{
 -			nm_warning ("Error: Can't parse interface line '%s'\n",line);
-+			nm_warning ("Error: Can't parse line '%s'\n",line);
++			nm_warning ("Error: Can't parse line '%s'\n", line);
  			continue;
  		}
-+
-+		// terminate line string and skip further whitespaces
- 		space[0] = '\0';
+-		space[0] = '\0';
 -		
-+		while (isspace(space[1])) space++;
++		key = &line[0];
++		data = &line[pos];
 +
  		// There are four different stanzas:
  		// iface, mapping, auto and allow-*. Create a block for each of them.
- 		if (strcmp(line,"iface")==0)
+-		if (strcmp(line,"iface")==0)
++		if (strcmp(key, "iface") == 0)
  		{
 -			char *space2 = strchr(space+1,' ');
-+			char *space2 = space+1;
-+			while (!strchr(WS, space2[0])) space2++;
+-			if (space2 == NULL)
++			char *key2;
 +
- 			if (space2 == NULL)
++			while (!strchr(WS, line[pos]) && pos < len ) pos++;
++
++			// terminate first data string and skip further whitespaces
++			line[pos++] = '\0';
++			while (strchr(WS, line[pos]) && pos < len) pos++;
++			if (pos >= len)
  			{
- 				nm_warning ("Error: Can't parse iface line '%s'\n",space+1);
+-				nm_warning ("Error: Can't parse iface line '%s'\n",space+1);
++				nm_warning ("Error: Can't parse iface line '%s'\n", data);
  				continue;
  			}
-+
-+			// terminate space string and skip further whitespaces
- 			space2[0]='\0';
-+			while (isspace(space2[1])) space2++;
-+
- 			add_block(line,space+1);
+-			space2[0]='\0';
+-			add_block(line,space+1);
++			key2 = &line[pos];
++			
++			add_block(key, data);
  
- 			if (space2[1]!='\0')
+-			if (space2[1]!='\0')
++			if (pos < len)
  			{
 -				space = strchr(space2+1,' ');
-+				space = space2+1;
-+				while (!strchr(WS, space[0])) space++;
+-				if (space == NULL)
++				
++				while (!strchr(WS, line[pos]) && pos < len ) pos++;
 +
- 				if (space == NULL)
++				// terminate key2 string and skip further whitespaces
++				line[pos++] = '\0';
++				while (strchr(WS, line[pos]) && pos < len) pos++;
++				if (pos >= len)
  				{
- 					nm_warning ("Error: Can't parse data '%s'\n",space2+1);
+-					nm_warning ("Error: Can't parse data '%s'\n",space2+1);
++					nm_warning ("Error: Can't parse inet line '%s'\n", key2);
  					continue;
  				}
-+				// terminate space2 string and skip further whitespaces
- 				space[0] = '\0';
-+				while (isspace(space[1])) space++;
+-				space[0] = '\0';
+-				add_data(space2+1,space+1);
++				data = &line[pos];
 +
- 				add_data(space2+1,space+1);
++				add_data(key2, data);
  			}
  		}
-@@ -198,6 +215,18 @@ if_block *ifparser_getif(const char* ifa
+-		else if (strcmp(line,"auto")==0)
+-			add_block(line,space+1);
+-		else if (strcmp(line,"mapping")==0)
+-			add_block(line,space+1);
+-		else if (strncmp(line,"allow-",6)==0)
+-			add_block(line,space+1);
++		else if (strcmp(key, "auto") == 0)
++			add_block(key, data);
++		else if (strcmp(key, "mapping") == 0)
++			add_block(key, data);
++		else if (strncmp(key, "allow-", 6) == 0)
++			add_block(key, data);
+ 		else
+-			add_data(line,space+1);
++			add_data(key, data);
+ 		
+ 		//printf("line: '%s' ret=%d\n",rline,ret);
+ 	}
+@@ -198,6 +225,18 @@ if_block *ifparser_getif(const char* ifa
  	return NULL;
  }
  




More information about the Pkg-utopia-commits mailing list