r106539 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106538‎ | r106539 | r106540 >
Date:00:40, 18 December 2011
Author:reedy
Status:deferred
Tags:
Comment:
Bring in System.Text.RegularExpressions

Fix string append bug in listAll
Modified paths:
  • /trunk/tools/wmib/Core.cs (modified) (history)

Diff [purge]

Index: trunk/tools/wmib/Core.cs
@@ -11,6 +11,7 @@
1212 using System;
1313 using System.Collections.Generic;
1414 using System.IO;
 15+using System.Text.RegularExpressions;
1516
1617 namespace wmib
1718 {
@@ -22,7 +23,7 @@
2324
2425 try
2526 {
26 - System.Text.RegularExpressions.Regex.Match("", pattern);
 27+ Regex.Match("", pattern);
2728 }
2829 catch (ArgumentException)
2930 {
@@ -88,7 +89,7 @@
8990
9091 private void Run()
9192 {
92 - System.Text.RegularExpressions.Regex c = new System.Text.RegularExpressions.Regex(regex);
 93+ Regex c = new Regex(regex);
9394 result = c.Match(value).Success;
9495 searching = false;
9596 }
@@ -172,7 +173,7 @@
173174
174175 public static string normalize(string name)
175176 {
176 - name = System.Text.RegularExpressions.Regex.Escape(name);
 177+ name = Regex.Escape(name);
177178 name = name.Replace("?", "\\?");
178179 return name;
179180 }
@@ -277,7 +278,7 @@
278279 string users_ok = "";
279280 foreach (user b in Users)
280281 {
281 - users_ok = users_ok + " " + b.name + ",";
 282+ users_ok += users_ok + " " + b.name + ",";
282283 }
283284 Message("I trust: " + users_ok, _Channel);
284285 }
@@ -666,11 +667,7 @@
667668
668669 private void StartSearch()
669670 {
670 - System.Text.RegularExpressions.Regex value = new System.Text.RegularExpressions.Regex(search_key,
671 - System.Text.
672 - RegularExpressions
673 - .RegexOptions.
674 - Compiled);
 671+ Regex value = new Regex(search_key, RegexOptions.Compiled);
675672 string results = "";
676673 foreach (item data in text)
677674 {
@@ -713,7 +710,7 @@
714711 }
715712 search_key = key.Substring(11);
716713 running = true;
717 - System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(StartSearch));
 714+ System.Threading.Thread th = new System.Threading.Thread(StartSearch);
718715 th.Start();
719716 int check = 1;
720717 while (running)
@@ -1000,11 +997,8 @@
1001998 channel.Users.delUser(rights_info[1]);
1002999 return 0;
10031000 }
1004 - else
1005 - {
1006 - Message("You are not autorized to perform this, sorry", channel.name);
1007 - return 0;
1008 - }
 1001+ Message("You are not autorized to perform this, sorry", channel.name);
 1002+ return 0;
10091003 }
10101004 Message("Invalid user", channel.name);
10111005 }
@@ -1044,7 +1038,7 @@
10451039 timedateToString(System.DateTime.Now.Second) + "] " + "<" + user + ">\t " + message + "\n";
10461040 }
10471041 File.AppendAllText(
1048 - channel.log + DateTime.Now.Year + DateTime.Now.Month + System.DateTime.Now.Day + ".txt", log);
 1042+ channel.log + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + ".txt", log);
10491043 }
10501044 }
10511045 catch (Exception er)
@@ -1156,11 +1150,8 @@
11571151 config.Save();
11581152 return;
11591153 }
1160 - else
1161 - {
1162 - Message(messages.PermissionDenied, chan.name);
1163 - return;
1164 - }
 1154+ Message(messages.PermissionDenied, chan.name);
 1155+ return;
11651156 }
11661157 if (message == "@part")
11671158 {
@@ -1203,11 +1194,8 @@
12041195 Message("Channel config was reloaded", chan.name);
12051196 return;
12061197 }
1207 - else
1208 - {
1209 - Message(messages.PermissionDenied, chan.name);
1210 - return;
1211 - }
 1198+ Message(messages.PermissionDenied, chan.name);
 1199+ return;
12121200 }
12131201 if (message == "@logon")
12141202 {
@@ -1218,14 +1206,11 @@
12191207 Message("Channel is already logged", chan.name);
12201208 return;
12211209 }
1222 - else
1223 - {
1224 - Message("Channel is now logged", chan.name);
1225 - chan.logged = true;
1226 - chan.SaveConfig();
1227 - config.Save();
1228 - return;
1229 - }
 1210+ Message("Channel is now logged", chan.name);
 1211+ chan.logged = true;
 1212+ chan.SaveConfig();
 1213+ config.Save();
 1214+ return;
12301215 }
12311216 else
12321217 {
@@ -1241,11 +1226,8 @@
12421227 Message("You are unknown to me :)", chan.name);
12431228 return;
12441229 }
1245 - else
1246 - {
1247 - Message("You are " + current.level + " identified by name " + current.name, chan.name);
1248 - return;
1249 - }
 1230+ Message("You are " + current.level + " identified by name " + current.name, chan.name);
 1231+ return;
12501232 }
12511233
12521234 if (message == "@logoff")
@@ -1257,19 +1239,13 @@
12581240 Message("Channel was already not logged", chan.name);
12591241 return;
12601242 }
1261 - else
1262 - {
1263 - chan.logged = false;
1264 - config.Save();
1265 - chan.SaveConfig();
1266 - Message("Channel is not logged", chan.name);
1267 - return;
1268 - }
 1243+ chan.logged = false;
 1244+ config.Save();
 1245+ chan.SaveConfig();
 1246+ Message("Channel is not logged", chan.name);
 1247+ return;
12691248 }
1270 - else
1271 - {
1272 - Message(messages.PermissionDenied, chan.name);
1273 - }
 1249+ Message(messages.PermissionDenied, chan.name);
12741250 }
12751251 if (message == "@channellist")
12761252 {
@@ -1290,20 +1266,14 @@
12911267 Message("Channel had infobot disabled", chan.name);
12921268 return;
12931269 }
1294 - else
1295 - {
1296 - Message("Infobot disabled", chan.name);
1297 - chan.info = false;
1298 - chan.SaveConfig();
1299 - config.Save();
1300 - return;
1301 - }
1302 - }
1303 - else
1304 - {
1305 - Message(messages.PermissionDenied, chan.name);
 1270+ Message("Infobot disabled", chan.name);
 1271+ chan.info = false;
 1272+ chan.SaveConfig();
 1273+ config.Save();
13061274 return;
13071275 }
 1276+ Message(messages.PermissionDenied, chan.name);
 1277+ return;
13081278 }
13091279 if (message == "@infobot-on")
13101280 {
@@ -1314,14 +1284,11 @@
13151285 Message("Infobot was already enabled :O", chan.name);
13161286 return;
13171287 }
1318 - else
1319 - {
1320 - chan.info = true;
1321 - config.Save();
1322 - chan.SaveConfig();
1323 - Message("Infobot enabled", chan.name);
1324 - return;
1325 - }
 1288+ chan.info = true;
 1289+ config.Save();
 1290+ chan.SaveConfig();
 1291+ Message("Infobot enabled", chan.name);
 1292+ return;
13261293 }
13271294 Message(messages.PermissionDenied, chan.name);
13281295 return;
@@ -1488,7 +1455,7 @@
14891456 if (message.StartsWith(":" + delimiter.ToString() + "TIME"))
14901457 {
14911458 wd.WriteLine("NOTICE " + nick + " :" + delimiter.ToString() + "TIME " +
1492 - System.DateTime.Now.ToString());
 1459+ DateTime.Now.ToString());
14931460 wd.Flush();
14941461 continue;
14951462 }

Status & tagging log