From 18096f3d6ae9c38633bbfa70e31327ba75394edb Mon Sep 17 00:00:00 2001 From: Martin Nilsson <mani@lysator.liu.se> Date: Fri, 22 Aug 2003 16:26:26 +0200 Subject: [PATCH] Don't pretend return is a function. Rev: lib/modules/Graphics.pmod/Graph.pmod/polyline.pike:1.5 Rev: lib/modules/Parser.pmod/LR.pmod/GrammarParser.pmod:1.5 Rev: lib/modules/Parser.pmod/LR.pmod/lr.pike:1.5 Rev: lib/modules/Parser.pmod/LR.pmod/module.pmod:1.11 Rev: lib/modules/Protocols.pmod/DNS.pmod:1.80 Rev: lib/modules/SSL.pmod/sslfile.pike:1.56 Rev: lib/modules/Sql.pmod/mysql.pike:1.18 Rev: lib/modules/Sql.pmod/sql_result.pike:1.12 Rev: lib/modules/Sql.pmod/sql_util.pmod:1.12 Rev: lib/modules/Stdio.pmod/module.pmod:1.181 --- .../Graphics.pmod/Graph.pmod/polyline.pike | 6 +- .../Parser.pmod/LR.pmod/GrammarParser.pmod | 59 +++++++++---------- lib/modules/Parser.pmod/LR.pmod/lr.pike | 32 +++++----- lib/modules/Parser.pmod/LR.pmod/module.pmod | 36 ++++++----- lib/modules/Protocols.pmod/DNS.pmod | 11 ++-- lib/modules/SSL.pmod/sslfile.pike | 4 +- lib/modules/Sql.pmod/mysql.pike | 6 +- lib/modules/Sql.pmod/sql_result.pike | 18 +++--- lib/modules/Sql.pmod/sql_util.pmod | 4 +- lib/modules/Stdio.pmod/module.pmod | 4 +- 10 files changed, 86 insertions(+), 94 deletions(-) diff --git a/lib/modules/Graphics.pmod/Graph.pmod/polyline.pike b/lib/modules/Graphics.pmod/Graph.pmod/polyline.pike index 233865fd3b..76d3f5b431 100644 --- a/lib/modules/Graphics.pmod/Graph.pmod/polyline.pike +++ b/lib/modules/Graphics.pmod/Graph.pmod/polyline.pike @@ -1,6 +1,6 @@ /* * Graph sub-module providing draw functions. - * $Id: polyline.pike,v 1.4 2001/11/19 00:01:32 nilsson Exp $ + * $Id: polyline.pike,v 1.5 2003/08/22 14:26:26 nilsson Exp $ */ #pike __REAL_VERSION__ @@ -33,7 +33,7 @@ static array(float) init_cap_sin_table() for (int i = 0; i < CAPSTEPS; i++) { s_t[i] = sin(PI*i/(CAPSTEPS-1)); } - return(s_t); + return s_t; } static array(float) cap_sin_table = init_cap_sin_table(); @@ -45,7 +45,7 @@ static array(float) init_cap_cos_table() for (int i = 0; i < CAPSTEPS; i++) { c_t[i] = cos(PI*i/(CAPSTEPS-1)); } - return(c_t); + return c_t; } static array(float) cap_cos_table = init_cap_cos_table(); diff --git a/lib/modules/Parser.pmod/LR.pmod/GrammarParser.pmod b/lib/modules/Parser.pmod/LR.pmod/GrammarParser.pmod index 28acf98967..d385857b78 100755 --- a/lib/modules/Parser.pmod/LR.pmod/GrammarParser.pmod +++ b/lib/modules/Parser.pmod/LR.pmod/GrammarParser.pmod @@ -3,7 +3,7 @@ #pike __REAL_VERSION__ /* - * $Id: GrammarParser.pmod,v 1.4 2002/06/12 19:28:58 jhs Exp $ + * $Id: GrammarParser.pmod,v 1.5 2003/08/22 14:25:57 nilsson Exp $ * * Generates a parser from a textual specification. * @@ -61,7 +61,7 @@ static private class Scan { while (1) { if (pos >= sizeof(str)) { /* EOF */ - return(""); + return ""; } else { int start=pos++; switch (str[start]) { @@ -72,7 +72,7 @@ static private class Scan { (('a' <= str[pos]) && ('z' >= str[pos])))) { pos++; } - return (lower_case(str[start..pos-1])); + return lower_case(str[start..pos-1]); case '\"': /* String */ while ((pos < sizeof(str)) && @@ -108,17 +108,17 @@ static private class Scan { } break; case '(': - return("("); + return "("; case ')': - return(")"); + return ")"; case '{': - return("{"); + return "{"; case '}': - return("}"); + return "}"; case ':': - return(":"); + return ":"; case ';': - return(";"); + return ";"; case '\n': case '\r': case ' ': @@ -131,7 +131,7 @@ static private class Scan { ('0' <= str[pos]) && ('9' >= str[pos])) { pos++; } - return (({ "int", (int)str[start .. pos-1] })); + return ({ "int", (int)str[start .. pos-1] }); default: /* Identifier */ while ((pos < sizeof(str)) && @@ -141,7 +141,7 @@ static private class Scan { ('_' == str[pos]) || (str[pos] >= 128))) { pos++; } - return (({ "identifier", str[start .. pos-1] })); + return ({ "identifier", str[start .. pos-1] }); } } } @@ -184,7 +184,7 @@ static private int add_nonterminal(string id) nt = nonterminal_lookup[id] = id_stack->ptr; id_stack->push(id); } - return(nt); + return nt; } static private void add_tokens(array(string) tokens) @@ -207,25 +207,22 @@ static private void set_left_tokens(string ignore, int pri_val, array(string) to static private string internal_symbol_to_string(int|string symbol) { - if (intp(symbol)) { - return (nonterminals[symbol]); - } else { - return ("\"" + symbol + "\""); - } + if (intp(symbol)) + return nonterminals[symbol]; + else + return "\"" + symbol + "\""; } static private string symbol_to_string(int|string symbol) { if (intp(symbol)) { - if (symbol < id_stack->ptr) { - return (id_stack->arr[symbol]); - } else { + if (symbol < id_stack->ptr) + return id_stack->arr[symbol]; + else /* Only happens with the initial(automatic) rule */ - return ("nonterminal"+symbol); - } - } else { - return ("\""+symbol+"\""); - } + return "nonterminal"+symbol; + } else + return "\""+symbol+"\""; } static private void add_rule(int nt, string colon, array(mixed) symbols, string action) @@ -275,30 +272,30 @@ void create() return ({}); } )); /* symbols */ _parser->add_rule(Rule(5, ({ 5, 7 }), lambda (array x, mixed|void y) { - if (y) { return (x + ({ y })); } - else { return (x); }} )); /* symbols */ + if (y) { return x + ({ y }); } + else { return x; }} )); /* symbols */ _parser->add_rule(Rule(6, ({ 10 }), lambda (string x) { return ({ x }); } )); /* terminals */ _parser->add_rule(Rule(6, ({ 6, 10 }), lambda (array(string) x, string y) { - return (x + ({ y })); } )); /* terminals */ + return x + ({ y }); } )); /* terminals */ _parser->add_rule(Rule(7, ({ 9 }), 0 )); /* symbol */ _parser->add_rule(Rule(7, ({ 10 }), 0 )); /* symbol */ _parser->add_rule(Rule(8, ({ "{", "identifier", "}" }), lambda (mixed brace_l, string id, mixed brace_r) { - return (id); } )); /* action */ + return id; } )); /* action */ _parser->add_rule(Rule(8, ({ "{", "string", "}" }), lambda (mixed brace_l, string str, mixed brace_r) { werror(sprintf("Warning: Converting string \"%s\" " "to identifier\n", str)); - return(str); } )); /* action */ + return str; } )); /* action */ _parser->add_rule(Rule(9, ({ "identifier" }), add_nonterminal)); /* nonterminal */ _parser->add_rule(Rule(10, ({ "string" }), 0)); /* terminal */ _parser->add_rule(Rule(11, ({ "(", "int", ")" }), lambda (mixed paren_l, int val, mixed paren_r) { - return (val); + return val; } )); /* priority */ _parser->add_rule(Rule(11, ({}), 0)); /* priority */ diff --git a/lib/modules/Parser.pmod/LR.pmod/lr.pike b/lib/modules/Parser.pmod/LR.pmod/lr.pike index fd549daa23..f48cb172c8 100755 --- a/lib/modules/Parser.pmod/LR.pmod/lr.pike +++ b/lib/modules/Parser.pmod/LR.pmod/lr.pike @@ -1,7 +1,7 @@ #!/usr/local/bin/pike /* - * $Id: lr.pike,v 1.4 2002/05/24 15:36:53 grubba Exp $ + * $Id: lr.pike,v 1.5 2003/08/22 14:25:57 nilsson Exp $ * * An LR(1) Parser in Pike * @@ -21,28 +21,28 @@ Parser g; int add_values(int x, mixed ignore, int y) { werror(x+" + "+y+" = "+(x+y)+"\n"); - return (x+y); + return x+y; } int mul_values(int x, mixed ignore, int y) { werror(x+" * "+y+" = "+(x*y)+"\n"); - return (x*y); + return x*y; } int get_second_value(mixed ignored, int x, mixed ... ignored_also) { - return(x); + return x; } int concat_values(int x, int y) { - return (x*10 + y); + return x*10 + y; } int make_value(string s) { - return((int)s); + return (int)s; } /* @@ -118,25 +118,23 @@ string a_init(string ... args) werror(sprintf("Reducing %s => \"%s\"\n", Array.map(args, g->symbol_to_string) * ", ", args * "")); - return (`+(@args)); + return `+(@args); } else { /* Empty rule */ werror("Reducing /* empty */ => \"\"\n"); - return(""); + return ""; } } string symbol_to_string(int|string symbol) { if (intp(symbol)) { - if (symbol < sizeof(nonterminals)) { - return(nonterminals[symbol]); - } else { - return("nonterminal"+symbol); - } - } else { - return("\""+symbol+"\""); - } + if (symbol < sizeof(nonterminals)) + return nonterminals[symbol]; + else + return "nonterminal"+symbol; + } else + return "\""+symbol+"\""; } void create() @@ -177,7 +175,7 @@ class scan { string scan() { - return(s_init[s_pos++]); + return s_init[s_pos++]; } } diff --git a/lib/modules/Parser.pmod/LR.pmod/module.pmod b/lib/modules/Parser.pmod/LR.pmod/module.pmod index ebff6af382..a81c14a603 100644 --- a/lib/modules/Parser.pmod/LR.pmod/module.pmod +++ b/lib/modules/Parser.pmod/LR.pmod/module.pmod @@ -1,5 +1,5 @@ /* - * $Id: module.pmod,v 1.10 2002/06/14 14:32:04 nilsson Exp $ + * $Id: module.pmod,v 1.11 2003/08/22 14:25:57 nilsson Exp $ * * A BNF-grammar in Pike. * Compiles to a LALR(1) state-machine. @@ -431,7 +431,7 @@ class Parser report(NOTICE, "goto_set", "=> (< %s >)", map(indices(set), symbol_to_string) * ", "); - return (set); + return set; } //! Generates the state reached when doing goto on the specified symbol. @@ -621,7 +621,7 @@ class Parser } res += ({ "\n" }); } - return (res * ""); + return res * ""; } string cast_to_string() @@ -635,10 +635,9 @@ class Parser //! Type to cast to. mixed cast(string type) { - if (type == "string") { - return(_sprintf()); - } - throw(({ sprintf("Cast to %s not supported\n", type), backtrace() })); + if (type == "string") + return _sprintf(); + error("Cast to %s not supported\n", type); } /* Here come the functions that actually do some work */ @@ -1017,14 +1016,13 @@ class Parser master->relation[current_item] = 1; } } - return(nullable[i->r->symbols[i->offset]]); - } else { - return (0); /* Not nullable */ - } + return nullable[i->r->symbols[i->offset]]; + } else + return 0; /* Not nullable */ } else { /* At end of rule */ master->relation[current_item] = 1; - return (1); /* Always nullable */ + return 1; /* Always nullable */ } } @@ -1283,11 +1281,11 @@ class Parser "on symbols (< %s >)", state_to_string(state), map(indices(conflict_set), symbol_to_string) * ", "); - return (ERROR_CONFLICTS); + return ERROR_CONFLICTS; } else { report(WARNING, "repair", "All conflicts removed!"); - return (0); + return 0; } } @@ -1555,7 +1553,7 @@ class Parser report(NOTICE, "compile", "DONE\n"); #endif /* LR_PROFILE */ - return (lr_error); + return lr_error; } //! Parse the input according to the compiled grammar. @@ -1593,7 +1591,7 @@ class Parser !(objectp(scanner) && functionp(scanner->`()))) { report(ERROR, "parse", "parser->parse(): scanner not set!\n"); lr_error = ERROR_NO_SCANNER; - return(0); + return 0; } while (1) { @@ -1677,7 +1675,7 @@ class Parser if (input == "") { /* Only the final state is allowed to shift on ""(EOF) */ /* ACCEPT */ - return(value_stack->pop()); + return value_stack->pop(); } /* SHIFT */ report(NOTICE, "parse", @@ -1699,11 +1697,11 @@ class Parser continue; } else { report(ERROR, "parse", "Empty stack at EOF!"); - return (0); + return 0; } } else { report(ERROR, "parse", "Bad state at EOF"); - return(value_stack->pop()); + return value_stack->pop(); } } else { lr_error |= ERROR_SYNTAX; diff --git a/lib/modules/Protocols.pmod/DNS.pmod b/lib/modules/Protocols.pmod/DNS.pmod index 930ee19caa..71fb69ab19 100644 --- a/lib/modules/Protocols.pmod/DNS.pmod +++ b/lib/modules/Protocols.pmod/DNS.pmod @@ -1,4 +1,4 @@ -// $Id: DNS.pmod,v 1.79 2003/08/07 14:22:17 nilsson Exp $ +// $Id: DNS.pmod,v 1.80 2003/08/22 14:25:27 nilsson Exp $ // Not yet finished -- Fredrik Hubinette //! Domain Name System @@ -552,9 +552,8 @@ class client static private int is_ip(string ip) { - return(replace(ip, - ({ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "." }), - ({ "", "", "", "", "", "", "", "", "", "", "" })) == ""); + // FIXME: Doesn't work with IPv6 + return (replace(ip, "0123456789."/1, allocate(11,"")) == ""); } static private mapping etc_hosts; @@ -628,7 +627,7 @@ class client } } } - return(etc_hosts[lower_case(host)]); + return etc_hosts[lower_case(host)]; } //! @decl void create() @@ -982,7 +981,7 @@ class client }); } else { // Lookup failed. - return({ 0, ({}), ({}) }); + return ({ 0, ({}), ({}) }); } } diff --git a/lib/modules/SSL.pmod/sslfile.pike b/lib/modules/SSL.pmod/sslfile.pike index 0072fe96ac..7fcafcd467 100644 --- a/lib/modules/SSL.pmod/sslfile.pike +++ b/lib/modules/SSL.pmod/sslfile.pike @@ -1,6 +1,6 @@ #pike __REAL_VERSION__ -/* $Id: sslfile.pike,v 1.55 2003/03/08 23:01:37 nilsson Exp $ +/* $Id: sslfile.pike,v 1.56 2003/08/22 14:25:00 nilsson Exp $ * */ @@ -99,7 +99,7 @@ private int queue_write() if (catch { socket->set_write_callback(ssl_write_callback); }) { - return(0); + return 0; } } #ifdef SSL3_DEBUG diff --git a/lib/modules/Sql.pmod/mysql.pike b/lib/modules/Sql.pmod/mysql.pike index 3095594595..17df1f6b51 100644 --- a/lib/modules/Sql.pmod/mysql.pike +++ b/lib/modules/Sql.pmod/mysql.pike @@ -1,5 +1,5 @@ /* - * $Id: mysql.pike,v 1.17 2002/11/27 15:40:34 mast Exp $ + * $Id: mysql.pike,v 1.18 2003/08/22 14:24:06 nilsson Exp $ * * Glue for the Mysql-module */ @@ -32,9 +32,9 @@ void drop_db( string db ) //! String to quote. string quote(string s) { - return(replace(s, + return replace(s, ({ "\\", "\"", "\0", "\'", "\n", "\r" }), - ({ "\\\\", "\\\"", "\\0", "\\\'", "\\n", "\\r" }))); + ({ "\\\\", "\\\"", "\\0", "\\\'", "\\n", "\\r" })); } // The following time conversion functions assumes the SQL server diff --git a/lib/modules/Sql.pmod/sql_result.pike b/lib/modules/Sql.pmod/sql_result.pike index c76c676c62..856d9fd781 100644 --- a/lib/modules/Sql.pmod/sql_result.pike +++ b/lib/modules/Sql.pmod/sql_result.pike @@ -1,5 +1,5 @@ /* - * $Id: sql_result.pike,v 1.11 2002/11/29 01:29:14 nilsson Exp $ + * $Id: sql_result.pike,v 1.12 2003/08/22 14:24:06 nilsson Exp $ * * Implements the generic result module of the SQL-interface * @@ -42,27 +42,27 @@ string _sprintf(int type, mapping|void flags) int num_rows() { if (arrayp(master_res)) { - return(sizeof(master_res)); + return sizeof(master_res); } - return(master_res->num_rows()); + return master_res->num_rows(); } //! Returns the number of fields in the result. int num_fields() { if (arrayp(master_res)) { - return(sizeof(master_res[0])); + return sizeof(master_res[0]); } - return(master_res->num_fields()); + return master_res->num_fields(); } //! Returns non-zero if there are no more rows. int eof() { if (arrayp(master_res)) { - return(index >= sizeof(master_res)); + return index >= sizeof(master_res); } - return(master_res->eof()); + return master_res->eof(); } //! Return information about the available fields. @@ -76,9 +76,9 @@ array(mapping(string:mixed)) fetch_fields() foreach(sort(indices(master_res[0])), string name) { res[index++] = ([ "name": name ]); } - return(res); + return res; } - return(master_res->fetch_fields()); + return master_res->fetch_fields(); } //! Skip past a number of rows. diff --git a/lib/modules/Sql.pmod/sql_util.pmod b/lib/modules/Sql.pmod/sql_util.pmod index 238f50f3cb..d25a66c994 100644 --- a/lib/modules/Sql.pmod/sql_util.pmod +++ b/lib/modules/Sql.pmod/sql_util.pmod @@ -1,5 +1,5 @@ /* - * $Id: sql_util.pmod,v 1.11 2003/04/22 18:02:53 nilsson Exp $ + * $Id: sql_util.pmod,v 1.12 2003/08/22 14:24:06 nilsson Exp $ * * Some SQL utility functions. * They are kept here to avoid circular references. @@ -17,7 +17,7 @@ //! String to quote. string quote(string s) { - return(replace(s, "\'", "\'\'")); + return replace(s, "\'", "\'\'"); } //! Throw an error in case an unimplemented function is called. diff --git a/lib/modules/Stdio.pmod/module.pmod b/lib/modules/Stdio.pmod/module.pmod index f90a7f9eb8..e59f1b388d 100644 --- a/lib/modules/Stdio.pmod/module.pmod +++ b/lib/modules/Stdio.pmod/module.pmod @@ -1,4 +1,4 @@ -// $Id: module.pmod,v 1.180 2003/07/30 16:05:20 mast Exp $ +// $Id: module.pmod,v 1.181 2003/08/22 14:23:47 nilsson Exp $ #pike __REAL_VERSION__ inherit files; @@ -461,7 +461,7 @@ class File set_nonblocking(0, 0, 0, 0, 0); call_out(_async_check_cb, 0); } - return(1); // OK so far. (Or rather the callback will be used). + return 1; // OK so far. (Or rather the callback will be used). } //! This function creates a bi-directional pipe between the object it -- GitLab