ソースを参照

* Ported [2397] to 1.2.9

svn: 2572
Bryan Drewery 20 年 前
コミット
a160f0fee7

+ 3 - 0
doc/UPDATES

@@ -11,6 +11,9 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 - Added cmd_iop which will invite the specified nick to a chan and then auto-op them upon joining (does a userhost)
 - Added hijacked invite detection based on server invite notices.
 
+1.2.9
+* Fixed cmd_[un]stick not properly using numbers for channel masks. (#160)
+
 1.2.8
 * Fixed [bot]* cmds depending on case of botnicks.
 * Fixed hubs attempting to generate a ctcp version reply after 'cloak-script' was set.

+ 2 - 0
src/misc.c

@@ -540,6 +540,8 @@ int str_isdigit(const char *str)
 {
   if (!str || (str && !*str))
     return 0;
+  if (*str == '-')
+    str++;
 
   for(; *str; ++str) {
     if (!egg_isdigit(*str))

+ 2 - 1
src/mod/channels.mod/channels.h

@@ -20,6 +20,7 @@ static void check_expired_masks(void);
 static void tell_masks(const char type, int idx, bool show_inact, char *match);
 static void get_mode_protect(struct chanset_t *chan, char *s);
 static void set_mode_protect(struct chanset_t *chan, char *set);
+static int count_mask(maskrec *);
 
 #endif				/* MAKING_CHANNELS */
 
@@ -39,7 +40,7 @@ void set_handle_laston(char *, struct userrec *, time_t);
 int u_delmask(char type, struct chanset_t *c, char *who, int doit);
 bool u_addmask(char type, struct chanset_t *, char *, char *, char *, time_t, int);
 int u_sticky_mask(maskrec *, char *);
-int u_setsticky_mask(struct chanset_t *, maskrec *, char *, bool, const char);
+int u_setsticky_mask(struct chanset_t *, maskrec *, char *, int, const char);
 int SplitList(char *, const char *, int *, const char ***);
 int channel_modify(char *, struct chanset_t *, int, char **);
 int channel_add(char *, char *, char *);

+ 4 - 3
src/mod/channels.mod/cmdschan.c

@@ -715,10 +715,11 @@ static void cmd_stick_yn(int idx, char *par, int yn)
 
   if (str_isdigit(s)) {
     /* substract the numer of global masks to get the number of the channel masks */
-    j = u_setsticky_mask(NULL, channel_list, s, -1, type);
-    if (j < 0)
-      simple_snprintf(s, sizeof s, "%d", -j);
+    j = atoi(s);
+    j -= count_mask(type == 'b' ? global_bans : type == 'e' ? global_exempts : global_invites);
+    simple_snprintf(s, sizeof s, "%d", j);
   }
+
   j = u_setsticky_mask(chan, channel_list, s, yn, type);
   if (j > 0) {
     putlog(LOG_CMDS, "*", "#%s# %sstick %s %s %s", dcc[idx].nick, yn ? "" : "un", str_type, s, chname);

+ 1 - 2
src/mod/channels.mod/userchan.c

@@ -142,10 +142,9 @@ int u_sticky_mask(maskrec *u, char *uhost)
 
 /* Set sticky attribute for a mask.
  */
-int u_setsticky_mask(struct chanset_t *chan, maskrec *u, char *uhost, bool sticky, const char type)
+int u_setsticky_mask(struct chanset_t *chan, maskrec *u, char *uhost, int sticky, const char type)
 {
   int j;
-
   if (str_isdigit(uhost))
     j = atoi(uhost);
   else