1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 16:57:57 +01:00

use RegExp#test in preference to String#match

This commit is contained in:
Doug Kearns
2007-11-16 12:48:03 +00:00
parent fea5cceecc
commit f50bca0453
9 changed files with 44 additions and 45 deletions

View File

@@ -117,7 +117,7 @@ vimperator.Command.prototype.hasName = function (name)
{
return true;
}
else if (this.specs[i].match(/^(\w+|!)\[\w+\]$/)) // abbreviation spec
else if (/^(\w+|!)\[\w+\]$/.test(this.specs[i])) // abbreviation spec
{
if (matchAbbreviation(name, this.specs[i]))
return true;
@@ -1037,19 +1037,19 @@ vimperator.Commands = function () //{{{
return;
}
var match;
var matches;
// 1 - type, 2 - name, 3 - +-., 4 - expr
if (match = args.match(/([$@&])?([\w:]+)\s*([+-.])?=\s*(.+)/))
if (matches = args.match(/([$@&])?([\w:]+)\s*([+-.])?=\s*(.+)/))
{
if (!match[1])
if (!matches[1])
{
var reference = vimperator.variableReference(match[2]);
if (!reference[0] && match[3])
return vimperator.echoerr("E121: Undefined variable: " + match[2]);
var reference = vimperator.variableReference(matches[2]);
if (!reference[0] && matches[3])
return vimperator.echoerr("E121: Undefined variable: " + matches[2]);
var expr = vimperator.eval(match[4]);
var expr = vimperator.eval(matches[4]);
if (typeof expr === undefined)
return vimperator.echoerr("E15: Invalid expression: " + match[4]);
return vimperator.echoerr("E15: Invalid expression: " + matches[4]);
else
{
if (!reference[0]) {
@@ -1059,13 +1059,13 @@ vimperator.Commands = function () //{{{
return; // for now
}
if (match[3])
if (matches[3])
{
if (match[3] == "+")
if (matches[3] == "+")
reference[0][reference[1]] += expr;
else if (match[3] == "-")
else if (matches[3] == "-")
reference[0][reference[1]] -= expr;
else if (match[3] == ".")
else if (matches[3] == ".")
reference[0][reference[1]] += expr.toString();
}
else
@@ -1074,11 +1074,11 @@ vimperator.Commands = function () //{{{
}
}
// 1 - name
else if (match = args.match(/^\s*([\w:]+)\s*$/))
else if (matches = args.match(/^\s*([\w:]+)\s*$/))
{
var reference = vimperator.variableReference(match[1]);
var reference = vimperator.variableReference(matches[1]);
if (!reference[0])
return vimperator.echoerr("E121: Undefined variable: " + match[1]);
return vimperator.echoerr("E121: Undefined variable: " + matches[1]);
var value = reference[0][reference[1]];
if (typeof value == "number")
@@ -1394,7 +1394,7 @@ vimperator.Commands = function () //{{{
{
usage: ["norm[al][!] {commands}"],
short_help: "Execute Normal mode commands",
help: "Example: <code class=\"command\">:normal 20j</code> scrolls 20 lines down. " +
help: "Example: <code class=\"command\">:normal 20j</code> scrolls 20 lines down. " +
"If the <code class=\"argument\">[!]</code> is specified mappings will not be used."
}
));