[cvslog] (2004-07-11 13:54:57 UTC) Module eggdrop1.9: Change committed!

cvslog cvs at tsss.org
Sun Jul 11 07:54:57 CST 2004


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.9
Commit time: 2004-07-11 13:54:57 UTC
Commited by: Darko Ilic <darko at onvol.net>

Modified files:
     lib/eggdrop/users.c lib/eggdrop/memory.c lib/eggdrop/help.c

Log message:

- Fixed strdup() to behave properly. strdup("") should still allocate
  space for, and put in it, the NUL char. This solved the issues with
  .help and possibly others.
  Even though I've tested the code and there appear not to be any problems,
  it is still possible that someone relied on this (broken) functionality,
  so please update your code accordingly if that's the case.

- As the XXX tag in code said, it was wrong to only do partial checking
  when comparing two flags_t structures. Changed it to use
  flags_check_subset() which correctly checks that all flags from 'left'
  appear in 'right'.

- Fixed some formating for .help, as well as broken code to check if user
  has access to use command or not (so to print the warning message).
  It was caused by extra semicolon that sneaked in in my last commit :)

---------------------- diff included ----------------------
Index: eggdrop1.9/lib/eggdrop/help.c
diff -u eggdrop1.9/lib/eggdrop/help.c:1.15 eggdrop1.9/lib/eggdrop/help.c:1.16
--- eggdrop1.9/lib/eggdrop/help.c:1.15	Mon Jul  5 17:12:22 2004
+++ eggdrop1.9/lib/eggdrop/help.c	Sun Jul 11 08:54:46 2004
@@ -24,7 +24,7 @@
  */
  
 #ifndef lint
-static const char rcsid[] = "$Id: help.c,v 1.15 2004/07/05 22:12:22 darko Exp $";
+static const char rcsid[] = "$Id: help.c,v 1.16 2004/07/11 13:54:46 darko Exp $";
 #endif
 
 #include <sys/types.h>
@@ -198,7 +198,7 @@
 		}
 
 		if (ptr == NULL)
-			break;	
+			break;
 
 		text +=(size_t)(ptr - text) + 1;
 		if (text [-1] == '\r' && text[0] == '\n')
@@ -502,7 +502,7 @@
 	help_entry_t *entry = *e;
 	help_section_t *section = entry->section;
 	int i;
-	
+
 	if (ul->module != NULL || ul->filename != NULL) {
 		if (0 != strcmp(entry->module, ul->module)
 			&& 0 != strcmp(entry->filename, ul->filename))
@@ -540,7 +540,7 @@
 	 
 	/* Delete entry */
 	help_delete_entry(entry);
-	
+
 	/* Remove empty sections */
 	if (section->nentries == 0)
 		help_delete_section(section);		
@@ -552,10 +552,10 @@
 	
 	unload.module = module;
 	unload.filename = filename;
-	
-	hash_table_walk(entries, 
+
+	hash_table_walk(entries,
 		(hash_table_node_func)unload_entry, &unload);
-			
+
 	return 1;
 }
 
@@ -572,12 +572,12 @@
 	/* Command */
 	if (0 == strcmp(entry->type, "Command")) {
 		partymember_printf(member, "%s: %s %s", entry->type, entry->name,
-			entry->ext.command.syntax);	
-			
+			entry->ext.command.syntax);
+
 	/* Variable */
 	} else if (0 == strcmp(entry->type, "Variable")) {
 		partymember_printf(member, "%s: %s(%s)", entry->type, entry->name,
-			entry->ext.variable.path);		
+			entry->ext.variable.path);
 		partymember_printf(member, ("  Type: %s"), entry->ext.variable.type);
 	}
 
@@ -587,8 +587,8 @@
 	for (i = 0; i < entry->desc.nlines; i++) {
 		partymember_printf(member, "    %s", entry->desc.lines[i]);
 	}
-	for (i = 0; i < entry->nseealso; i++) { 
-		partymember_printf(member, _("See also: %s"), entry->seealso[i]);
+	for (i = 0; i < entry->nseealso; i++) {
+		partymember_printf(member, _("  See also: %s"), entry->seealso[i]);
 	}
 }
 
@@ -598,41 +598,35 @@
 	help_section_t *section = *s;
 	help_entry_t *entry;
 	char *names[4];
-	
+
 	partymember_printf(member, _("%s:"), name);
 	for (i = 0; i < section->desc.nlines; i++) {
 		partymember_printf(member, "  %s", section->desc.lines[i]);
-	}	
+	}
 
 	/* we want 4 entries in one row */
 	for (i = 0; i < section->nentries; ) {
 		names[0] = names[1] = names[2] = names[3] = "";
 
 		for (j = 0; j < 4 && i < section->nentries; ) {
-			entry = section->entries[i++]; 
-
-		        /* check if user is allowed to see this entry */
-			if (entry->flags && !user_check_flags_str(member->user, NULL, entry->flags))
-				continue;
-
+			entry = section->entries[i++];
 			names[j++] = entry->name;
 		}
 
-		partymember_printf(member, 
+		partymember_printf(member,
 			"    %-16s %-16s %-16s %-16s",
 				names[0], names[1], names[2], names[3]);
 	}
 	partymember_printf(member, _(""));
 }
- 
+
 static void search_entries(const char *name, help_entry_t **entry, help_search_t *search)
 {
 	if (wild_match(search->text, name) > 0) {
 		print_entry(name, *entry, search->member);
-		/* check if user is allowed to see this entry */
 		if ((*entry)->flags && *(*entry)->flags &&
-			!user_check_flags_str(search->member->user, NULL, (*entry)->flags));
-			partymember_printf(search->member, _("NOTE: You do NOT have access to this command!"));
+			!user_check_flags_str(search->member->user, NULL, (*entry)->flags))
+			partymember_printf(search->member, _("  NOTE: You do NOT have access to this command!\n"));
 		search->hits++;
 	}
 	else {
@@ -642,10 +636,9 @@
 		for (i = 0; i <(*entry)->desc.nlines; i++) {
 			if (wild_match(search->text, (*entry)->desc.lines[i]) > 0) {
 				print_entry(name, *entry, search->member);
-				/* check if user is allowed to see this entry */
 				if ((*entry)->flags && *(*entry)->flags &&
-					!user_check_flags_str(search->member->user, NULL, (*entry)->flags));
-				partymember_printf(search->member, _("NOTE: You do NOT have access to this command!"));
+					!user_check_flags_str(search->member->user, NULL, (*entry)->flags))
+				partymember_printf(search->member, _("  NOTE: You do NOT have access to this command!\n"));
 				search->hits++;
 				return;
 			}
@@ -657,7 +650,7 @@
 {
 	help_search_t search;
 
-	search.member = member;	
+	search.member = member;
 	search.text = text;
 	search.hits = 0;
 
@@ -670,7 +663,7 @@
 {
 	help_entry_t *entry;
 	help_section_t *section;
-		 
+
 	if (nentries == 0) {
 		partymember_printf(member, _("No help entries loaded."));
 		return BIND_RET_LOG;
@@ -678,7 +671,7 @@
 
 	/* if no args given just print out full help */
 	if (args == NULL || 0 == strcmp(args, "all")) {
-		hash_table_walk(sections, 
+		hash_table_walk(sections,
 			(hash_table_node_func)print_section, member);
 		partymember_printf(member, _("You can get help on individual command or variable: '.help <entry>'."));
 		partymember_printf(member, _("If you only remember a part of the entrie's name you are"));
@@ -686,17 +679,16 @@
 		partymember_printf(member, _("all matching help texts will be displayed."));
 		return BIND_RET_LOG;
 	}
-	
+
 	/* may be either a section or a entry, whatever comes first */
 	entry = help_lookup_entry(args);
 	if (entry != NULL) {
 		print_entry(entry->name, entry, member);
-	        /* check if user is allowed to see this entry */
         	if (entry->flags && *entry->flags && !user_check_flags_str(member->user, NULL, entry->flags))
-			partymember_printf(member, _("NOTE: You do NOT have access to this command!"));
+			partymember_printf(member, _("  NOTE: You do NOT have access to this command!"));
 		return BIND_RET_LOG;
 	}
-		
+
 	section = help_lookup_section(args);
 	if (section != NULL) {
 		print_section(section->name, &section, member);
@@ -709,6 +701,6 @@
 			args);
 		return BIND_RET_BREAK;
 	}
-		
+
 	return BIND_RET_LOG;
 }
Index: eggdrop1.9/lib/eggdrop/memory.c
diff -u eggdrop1.9/lib/eggdrop/memory.c:1.7 eggdrop1.9/lib/eggdrop/memory.c:1.8
--- eggdrop1.9/lib/eggdrop/memory.c:1.7	Fri Jun 25 12:44:03 2004
+++ eggdrop1.9/lib/eggdrop/memory.c	Sun Jul 11 08:54:46 2004
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: memory.c,v 1.7 2004/06/25 17:44:03 darko Exp $";
+static const char rcsid[] = "$Id: memory.c,v 1.8 2004/07/11 13:54:46 darko Exp $";
 #endif
 
 #include <stdio.h>
@@ -119,7 +119,7 @@
 	size_t size;
 	void *ptr;
 
-	if (file == NULL || !*str)
+	if (file == NULL)
 		return NULL;
 
 	size = strlen(str) + 1;
Index: eggdrop1.9/lib/eggdrop/users.c
diff -u eggdrop1.9/lib/eggdrop/users.c:1.38 eggdrop1.9/lib/eggdrop/users.c:1.39
--- eggdrop1.9/lib/eggdrop/users.c:1.38	Mon Jul  5 17:12:22 2004
+++ eggdrop1.9/lib/eggdrop/users.c	Sun Jul 11 08:54:46 2004
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: users.c,v 1.38 2004/07/05 22:12:22 darko Exp $";
+static const char rcsid[] = "$Id: users.c,v 1.39 2004/07/11 13:54:46 darko Exp $";
 #endif
 
 #include <stdio.h>
@@ -717,8 +717,7 @@
 
 	user_get_flags (u, chan, &f);
 
-	/* XXX: this is wrong. */
-	return flag_match_partial (flags, &f);
+	return flag_match_subset (flags, &f);
 }
 
 int
----------------------- End of diff -----------------------



More information about the Changes mailing list