correct multiple internal spaces

svn:r3004
This commit is contained in:
Nick Mathewson 2004-11-28 09:14:07 +00:00
parent 6f5dbefa7e
commit f7c6ad065e
3 changed files with 15 additions and 15 deletions

View File

@ -40,13 +40,13 @@ for $fn (@ARGV) {
} }
} }
if (m!/\*.*?\*/!) { if (m!/\*.*?\*/!) {
s!/\*.*?\*/!!; s!\s*/\*.*?\*/!!;
} elsif (m!/\*!) { } elsif (m!/\*!) {
s!/\*!!; s!\s*/\*!!;
$incomment = 1; $incomment = 1;
next; next;
} }
s!"(?:[^\"]+|\\.)*"!!g; s!"(?:[^\"]+|\\.)*"!"X"!g;
next if /^\#/; next if /^\#/;
## Warn about C++-style comments. ## Warn about C++-style comments.
if (m!//!) { if (m!//!) {
@ -57,6 +57,15 @@ for $fn (@ARGV) {
if (/([^\s])\{/) { if (/([^\s])\{/) {
print " $1\{:$fn:$.\n"; print " $1\{:$fn:$.\n";
} }
## Warn about multiple internal spaces.
#if (/[^\s,:]\s{2,}[^\s\\=]/) {
# print " X X:$fn:$.\n";
#}
## Warn about { with stuff after.
#s/\s+$//;
#if (/\{[^\}\\]+$/) {
# print " {X:$fn:$.\n";
#}
## Warn about function calls with space before parens. ## Warn about function calls with space before parens.
if (/(\w+)\s\(/) { if (/(\w+)\s\(/) {
if ($1 ne "if" and $1 ne "while" and $1 ne "for" and if ($1 ne "if" and $1 ne "while" and $1 ne "for" and
@ -65,15 +74,6 @@ for $fn (@ARGV) {
print " fn ():$fn:$.\n"; print " fn ():$fn:$.\n";
} }
} }
## Warn about multiple internal spaces.
#if (/\S\s{2,}[^\s\\]/) {
# print " X X:$fn:$.\n";
#}
## Warn about { with stuff after.
#s/\s+$//;
#if (/\{[^\}\\]+$/) {
# print " {X:$fn:$.\n";
#}
} }
close(F); close(F);
} }

View File

@ -1207,7 +1207,7 @@ parse_addr_and_port_range(const char *s, uint32_t *addr_out,
*port_max_out = 65535; *port_max_out = 65535;
} else { } else {
endptr = NULL; endptr = NULL;
*port_min_out = (uint16_t) tor_parse_long(port, 10, 1, 65535, *port_min_out = (uint16_t) tor_parse_long(port, 10, 1, 65535,
NULL, &endptr); NULL, &endptr);
if (*endptr == '-') { if (*endptr == '-') {
port = endptr+1; port = endptr+1;

View File

@ -680,9 +680,9 @@ test_util(void) {
test_eq(0L, tor_parse_long("10",10,50,100,NULL,NULL)); test_eq(0L, tor_parse_long("10",10,50,100,NULL,NULL));
/* Test parse_line_from_str */ /* Test parse_line_from_str */
strlcpy(buf, "k v\n" " key value with spaces \n" "keykey val\n" strlcpy(buf, "k v\n" " key value with spaces \n" "keykey val\n"
"k2\n" "k2\n"
"k3 \n" "\n" " \n" "#comment\n" "k3 \n" "\n" " \n" "#comment\n"
"k4#a\n" "k5#abc\n" "k6 val #with comment\n", sizeof(buf)); "k4#a\n" "k5#abc\n" "k6 val #with comment\n", sizeof(buf));
cp = buf; cp = buf;