Changeset: 23eab2c22941 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=23eab2c22941 Modified Files: clients/mapiclient/mclient.c Branch: Jan2014 Log Message:
Layout. diffs (truncated from 463 to 300 lines): diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -419,8 +419,7 @@ SQLrow(int *len, int *numeric, char **re if (trim == 1) { for (i = 0; i < fields; i++) { if ((t = rest[i]) != NULL && - utf8strlen(t, NULL) > (size_t) len[i]) - { + utf8strlen(t, NULL) > (size_t) len[i]) { /* eat leading whitespace */ while (*t != 0 && isascii((int) *t) && isspace((int) *t)) t++; @@ -443,9 +442,12 @@ SQLrow(int *len, int *numeric, char **re ulen = utf8strlen(rest[i], NULL); if (first && trim == 2) { - /* calculate the height of this field according to - * the golden ratio, with a correction for a - * terminal screen (1.62 * 2 -> 3 : 9.72~10) */ + /* calculate the height of + * this field according to the + * golden ratio, with a + * correction for a terminal + * screen (1.62 * 2 -> 3 : + * 9.72~10) */ if (ulen > (size_t) len[i]) cutafter[i] = 3 * len[i] / 10; } @@ -476,8 +478,11 @@ SQLrow(int *len, int *numeric, char **re ""); if (!numeric[i]) { - /* replace tabs with a single space to avoid - * screwup the width calculations */ + /* replace tabs with a + * single space to + * avoid screwup the + * width + * calculations */ for (s = rest[i]; *s != *t; s++) if (*s == '\t') *s = ' '; @@ -507,8 +512,8 @@ SQLrow(int *len, int *numeric, char **re croppedfields++; } else { mnstr_printf(toConsole, " %.*s ", - (int) (t - rest[i]), - rest[i]); + (int) (t - rest[i]), + rest[i]); if (!numeric[i]) mnstr_printf(toConsole, "%*s", (int) (len[i] - (ulen - utf8strlen(t, NULL))), @@ -516,8 +521,10 @@ SQLrow(int *len, int *numeric, char **re } rest[i] = *s ? s : 0; if (rest[i] == NULL) { - /* avoid > as border marker if everything - * actually just fits */ + /* avoid > as border + * marker if + * everything actually + * just fits */ cutafter[i] = -1; } if (cutafter[i] == 0) @@ -529,27 +536,31 @@ SQLrow(int *len, int *numeric, char **re first ? '|' : i > 0 && cutafter[i - 1] == 0 ? '>' : ':'); if (numeric[i]) { mnstr_printf(toConsole, "%*s", - (int) (len[i] - ulen), - ""); + (int) (len[i] - ulen), + ""); mnstr_printf(toConsole, " %s ", - rest[i]); + rest[i]); } if (!numeric[i]) { char *p; - /* replace tabs with a single space to avoid - * screwup the width calculations */ + /* replace tabs with a + * single space to + * avoid screwup the + * width + * calculations */ for (p = rest[i]; *p != '\0'; p++) if (*p == '\t') *p = ' '; mnstr_printf(toConsole, " %s ", - rest[i]); + rest[i]); mnstr_printf(toConsole, "%*s", - (int) (len[i] - ulen), - ""); + (int) (len[i] - ulen), + ""); } rest[i] = 0; - /* avoid > as border marker if everything - * actually just fits */ + /* avoid > as border marker if + * everything actually just + * fits */ if (cutafter[i] == 0) cutafter[i] = -1; } @@ -617,13 +628,13 @@ XMLrenderer(MapiHdl hdl) mnstr_flush(toConsole); mnstr_printf(toConsole_raw, "<?xml version='1.0' encoding='UTF-8'?>\n"); mnstr_printf(toConsole_raw, - "<!DOCTYPE table [\n" - " <!ELEMENT table (row)*>\n" /* a table consists of zero or more rows */ - " <!ELEMENT row (column)+>\n" /* a row consists of one or more columns */ - " <!ELEMENT column (#PCDATA)>\n" - " <!ATTLIST table name CDATA #IMPLIED>\n" /* a table may have a name */ - " <!ATTLIST column name CDATA #IMPLIED\n" /* a column may have a name */ - " isnull (true|false) 'false'>]>\n"); + "<!DOCTYPE table [\n" + " <!ELEMENT table (row)*>\n" /* a table consists of zero or more rows */ + " <!ELEMENT row (column)+>\n" /* a row consists of one or more columns */ + " <!ELEMENT column (#PCDATA)>\n" + " <!ATTLIST table name CDATA #IMPLIED>\n" /* a table may have a name */ + " <!ATTLIST column name CDATA #IMPLIED\n" /* a column may have a name */ + " isnull (true|false) 'false'>]>\n"); mnstr_printf(toConsole_raw, "<table"); name = mapi_get_table(hdl, 0); if (name != NULL && *name != 0) @@ -681,7 +692,7 @@ CSVrenderer(MapiHdl hdl) strchr(s, '\n') != NULL || strchr(s, '"') != NULL) { mnstr_printf(toConsole, "%s\"", - i == 0 ? "" : sep); + i == 0 ? "" : sep); while (*s) { switch (*s) { case '\n': @@ -708,7 +719,7 @@ CSVrenderer(MapiHdl hdl) mnstr_write(toConsole, "\"", 1, 1); } else mnstr_printf(toConsole, "%s%s", - i == 0 ? "" : sep, s); + i == 0 ? "" : sep, s); } mnstr_printf(toConsole, "\n"); } @@ -768,20 +779,20 @@ static char * classify(const char *s, size_t l) { /* state is the current state of the state machine: - 0 - initial state, no input seen - 1 - initial sign - 2 - valid integer (with optionally a sign) - 3 - valid integer, followed by a decimal point - 4 - fixed point number of the form [sign] digits period digits - 5 - exponent marker after integer or fixed point number - 6 - sign after exponent marker - 7 - valid floating point number with exponent - 8 - integer followed by single 'L' - 9 - integer followed by 'LL' (lng) - 10 - fixed or floating point number followed by single 'L' - 11 - fixed or floating point number followed by 'LL' (dbl) - 12 - integer followed by '@' - 13 - valid OID (integer followed by '@0') + * 0 - initial state, no input seen + * 1 - initial sign + * 2 - valid integer (with optionally a sign) + * 3 - valid integer, followed by a decimal point + * 4 - fixed point number of the form [sign] digits period digits + * 5 - exponent marker after integer or fixed point number + * 6 - sign after exponent marker + * 7 - valid floating point number with exponent + * 8 - integer followed by single 'L' + * 9 - integer followed by 'LL' (lng) + * 10 - fixed or floating point number followed by single 'L' + * 11 - fixed or floating point number followed by 'LL' (dbl) + * 12 - integer followed by '@' + * 13 - valid OID (integer followed by '@0') */ int state = 0; @@ -970,8 +981,8 @@ TESTrenderer(MapiHdl hdl) default: if ((unsigned char) *s < ' ') mnstr_printf(toConsole, - "\\%03o", - (int) (unsigned char) *s); + "\\%03o", + (int) (unsigned char) *s); else mnstr_write(toConsole, s, 1, 1); break; @@ -1179,9 +1190,8 @@ SQLrenderer(MapiHdl hdl, char singleinst /* do a very pessimistic calculation to determine if more * columns would actually fit on the screen */ if (pagewidth > 0 && - ((((printfields + 1) * 3) - 1) + 2) + /* graphwaste */ - (total - vartotal) + minvartotal > pagewidth) - { + ((((printfields + 1) * 3) - 1) + 2) + /* graphwaste */ + (total - vartotal) + minvartotal > pagewidth) { /* this last column was too much */ total -= len[i]; if (!numeric[i]) @@ -1489,22 +1499,24 @@ format_result(Mapi mid, MapiHdl hdl, cha lid = mapi_get_last_id(hdl); if (lid != -1) { mnstr_printf(toConsole, - LLFMT " affected row%s, " - "last generated key: " LLFMT "%s%s%s\n", - aff, - (aff == 1 ? "" : "s"), - lid, - singleinstr ? " (" : "", - singleinstr && formatter != TESTformatter ? timerHuman() : "", - singleinstr ? ")" : ""); + LLFMT " affected row%s, " + "last generated key: " + LLFMT "%s%s%s\n", + aff, + (aff == 1 ? "" : "s"), + lid, + singleinstr ? " (" : "", + singleinstr && formatter != TESTformatter ? timerHuman() : "", + singleinstr ? ")" : ""); } else { mnstr_printf(toConsole, - LLFMT " affected row%s%s%s%s\n", - aff, - (aff == 1 ? "" : "s"), - singleinstr ? " (" : "", - singleinstr && formatter != TESTformatter ? timerHuman() : "", - singleinstr ? ")" : ""); + LLFMT " affected row%s" + "%s%s%s\n", + aff, + (aff == 1 ? "" : "s"), + singleinstr ? " (" : "", + singleinstr && formatter != TESTformatter ? timerHuman() : "", + singleinstr ? ")" : ""); } } continue; @@ -1522,16 +1534,16 @@ format_result(Mapi mid, MapiHdl hdl, cha SQLqueryEcho(hdl); if (formatter == TABLEformatter) mnstr_printf(toConsole, - "auto commit mode: %s\n", - mapi_get_autocommit(mid) ? "on" : "off"); + "auto commit mode: %s\n", + mapi_get_autocommit(mid) ? "on" : "off"); continue; case Q_PREPARE: SQLqueryEcho(hdl); if (formatter == TABLEformatter) mnstr_printf(toConsole, - "execute prepared statement " - "using: EXEC %d(...)\n", - mapi_get_tableid(hdl)); + "execute prepared statement " + "using: EXEC %d(...)\n", + mapi_get_tableid(hdl)); /* fall through */ case Q_TABLE: timerHumanStop(); @@ -1540,17 +1552,22 @@ format_result(Mapi mid, MapiHdl hdl, cha if (formatter == TABLEformatter && specials != DEBUGmodifier) { int i; mnstr_printf(stderr_stream, - "invalid/unknown response from server, " - "ignoring output\n"); + "invalid/unknown response from server, " + "ignoring output\n"); for (i = 0; i < 5 && (reply = fetch_line(hdl)) != 0; i++) mnstr_printf(stderr_stream, "? %s\n", reply); if (i == 5 && fetch_line(hdl) != 0) { - mnstr_printf(stderr_stream, "(remaining output omitted, " - "use \\fraw to examine in detail)\n"); - /* skip over the unknown/invalid stuff, otherwise - * mapi_next_result call will assert in close_result - * because the logic there doesn't expect random unread - * garbage somehow */ + mnstr_printf(stderr_stream, + "(remaining output omitted, " + "use \\fraw to examine in detail)\n"); + /* skip over the + * unknown/invalid stuff, + * otherwise mapi_next_result + * call will assert in + * close_result because the + * logic there doesn't expect + * random unread garbage + * somehow */ while (fetch_line(hdl) != 0) ; } @@ -1643,11 +1660,12 @@ doRequest(Mapi mid, const char *buf) break; \ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list