diff options
author | Bruce Momjian | 2001-10-25 05:50:21 +0000 |
---|---|---|
committer | Bruce Momjian | 2001-10-25 05:50:21 +0000 |
commit | b81844b1738c584d92330a5ccd0fbd8b603d2886 (patch) | |
tree | 4fae0d4cd26048177fc5cd1a2dd91abc99ba0f99 /src/bin/psql | |
parent | 59da2105d8e6d95345b3b942a2e2aba8cead4838 (diff) |
pgindent run on all C files. Java run to follow. initdb/regression
tests pass.
Diffstat (limited to 'src/bin/psql')
-rw-r--r-- | src/bin/psql/command.c | 56 | ||||
-rw-r--r-- | src/bin/psql/command.h | 15 | ||||
-rw-r--r-- | src/bin/psql/common.c | 17 | ||||
-rw-r--r-- | src/bin/psql/common.h | 21 | ||||
-rw-r--r-- | src/bin/psql/copy.h | 3 | ||||
-rw-r--r-- | src/bin/psql/describe.c | 130 | ||||
-rw-r--r-- | src/bin/psql/describe.h | 5 | ||||
-rw-r--r-- | src/bin/psql/help.c | 16 | ||||
-rw-r--r-- | src/bin/psql/help.h | 3 | ||||
-rw-r--r-- | src/bin/psql/input.c | 10 | ||||
-rw-r--r-- | src/bin/psql/input.h | 3 | ||||
-rw-r--r-- | src/bin/psql/large_obj.c | 10 | ||||
-rw-r--r-- | src/bin/psql/large_obj.h | 3 | ||||
-rw-r--r-- | src/bin/psql/mainloop.c | 20 | ||||
-rw-r--r-- | src/bin/psql/mainloop.h | 4 | ||||
-rw-r--r-- | src/bin/psql/mbprint.c | 308 | ||||
-rw-r--r-- | src/bin/psql/mbprint.h | 12 | ||||
-rw-r--r-- | src/bin/psql/print.c | 127 | ||||
-rw-r--r-- | src/bin/psql/print.h | 18 | ||||
-rw-r--r-- | src/bin/psql/prompt.c | 8 | ||||
-rw-r--r-- | src/bin/psql/prompt.h | 17 | ||||
-rw-r--r-- | src/bin/psql/settings.h | 3 | ||||
-rw-r--r-- | src/bin/psql/startup.c | 29 | ||||
-rw-r--r-- | src/bin/psql/stringutils.h | 3 | ||||
-rw-r--r-- | src/bin/psql/tab-complete.c | 28 | ||||
-rw-r--r-- | src/bin/psql/tab-complete.h | 3 | ||||
-rw-r--r-- | src/bin/psql/variables.h | 3 |
27 files changed, 441 insertions, 434 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index b6f8be54e86..004b8bacafa 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.60 2001/10/11 16:54:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.61 2001/10/25 05:49:53 momjian Exp $ */ #include "postgres_fe.h" #include "command.h" @@ -56,7 +56,7 @@ static backslashResult exec_command(const char *cmd, enum option_type { - OT_NORMAL, OT_SQLID, OT_FILEPIPE + OT_NORMAL, OT_SQLID, OT_FILEPIPE }; static char *scan_option(char **string, enum option_type type, char *quote, bool semicolon); static char *unescape(const unsigned char *source, size_t len); @@ -130,11 +130,10 @@ HandleSlashCmds(const char *line, if (status == CMD_UNKNOWN) { - /* - * If the command was not recognized, try to parse it as a one-letter - * command with immediately following argument (a still-supported, - * but no longer encouraged, syntax). + * If the command was not recognized, try to parse it as a + * one-letter command with immediately following argument (a + * still-supported, but no longer encouraged, syntax). */ char new_cmd[2]; @@ -144,7 +143,10 @@ HandleSlashCmds(const char *line, /* use line for options, because my_line was clobbered above */ status = exec_command(new_cmd, line + 1, &continue_parse, query_buf); - /* continue_parse must be relative to my_line for calculation below */ + /* + * continue_parse must be relative to my_line for calculation + * below + */ continue_parse += my_line - line; #if 0 /* turned out to be too annoying */ @@ -262,8 +264,8 @@ exec_command(const char *cmd, /* \cd */ else if (strcmp(cmd, "cd") == 0) { - char *opt = scan_option(&string, OT_NORMAL, NULL, true); - char *dir; + char *opt = scan_option(&string, OT_NORMAL, NULL, true); + char *dir; if (opt) dir = opt; @@ -279,12 +281,14 @@ exec_command(const char *cmd, exit(EXIT_FAILURE); } dir = pw->pw_dir; -#else /* WIN32 */ - /* On Windows, 'cd' without arguments prints the current - directory, so if someone wants to code this here - instead... */ +#else /* WIN32 */ + + /* + * On Windows, 'cd' without arguments prints the current + * directory, so if someone wants to code this here instead... + */ dir = "/"; -#endif /* WIN32 */ +#endif /* WIN32 */ } if (chdir(dir) == -1) @@ -315,6 +319,7 @@ exec_command(const char *cmd, { char *name; bool show_verbose; + name = scan_option(&string, OT_SQLID, NULL, true); show_verbose = strchr(cmd, '+') ? true : false; @@ -359,7 +364,7 @@ exec_command(const char *cmd, break; case 'u': success = describeUsers(name); - break; + break; default: status = CMD_UNKNOWN; } @@ -401,7 +406,7 @@ exec_command(const char *cmd, fout = pset.queryFout; else fout = stdout; - + while ((value = scan_option(&string, OT_NORMAL, "ed, false))) { if (!quoted && strcmp(value, "-n") == 0) @@ -649,7 +654,6 @@ exec_command(const char *cmd, } else { - /* * Set variable to the concatenation of the arguments. */ @@ -866,7 +870,6 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon) switch (options_string[pos]) { - /* * Double quoted string */ @@ -937,7 +940,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon) *string = options_string + jj + 1; if (quote) *quote = '"'; - + return return_val; } @@ -1119,10 +1122,13 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon) return_val[token_end] = 0; /* Strip any trailing semi-colons for some types */ - if (semicolon) { - int i; - for (i = strlen(return_val)-1; i && return_val[i]==';'; i--); - if (i<strlen(return_val)-1) return_val[i+1]='\0'; + if (semicolon) + { + int i; + + for (i = strlen(return_val) - 1; i && return_val[i] == ';'; i--); + if (i < strlen(return_val) - 1) + return_val[i + 1] = '\0'; } if (type == OT_SQLID) @@ -1331,7 +1337,6 @@ do_connect(const char *new_dbname, const char *new_user) } else { - /* * we don't want unpredictable things to happen in scripting * mode @@ -1466,7 +1471,6 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf) #ifndef WIN32 struct stat before, after; - #endif if (filename_arg) @@ -1626,7 +1630,7 @@ _align2string(enum printFormat in) { switch (in) { - case PRINT_NOTHING: + case PRINT_NOTHING: return "nothing"; break; case PRINT_UNALIGNED: diff --git a/src/bin/psql/command.h b/src/bin/psql/command.h index f719d2aa206..8141201eea2 100644 --- a/src/bin/psql/command.h +++ b/src/bin/psql/command.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.10 2000/04/12 17:16:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.11 2001/10/25 05:49:53 momjian Exp $ */ #ifndef COMMAND_H #define COMMAND_H @@ -16,12 +16,12 @@ typedef enum _backslashResult { - CMD_UNKNOWN = 0, /* not done parsing yet (internal only) */ - CMD_SEND, /* query complete; send off */ - CMD_SKIP_LINE, /* keep building query */ - CMD_TERMINATE, /* quit program */ - CMD_NEWEDIT, /* query buffer was changed (e.g., via \e) */ - CMD_ERROR /* the execution of the backslash command + CMD_UNKNOWN = 0,/* not done parsing yet (internal only) */ + CMD_SEND, /* query complete; send off */ + CMD_SKIP_LINE, /* keep building query */ + CMD_TERMINATE, /* quit program */ + CMD_NEWEDIT, /* query buffer was changed (e.g., via \e) */ + CMD_ERROR /* the execution of the backslash command * resulted in an error */ } backslashResult; @@ -40,5 +40,4 @@ bool do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet); - #endif /* COMMAND_H */ diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 336d8138783..0380f1f1bcf 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.36 2001/10/18 21:57:11 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.37 2001/10/25 05:49:53 momjian Exp $ */ #include "postgres_fe.h" @@ -176,7 +176,9 @@ simple_prompt(const char *prompt, int maxlen, bool echo) { int length; char *destination; - FILE *termin, *termout; + FILE *termin, + *termout; + #ifdef HAVE_TERMIOS_H struct termios t_orig, t; @@ -189,8 +191,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo) prompt_state = true; /* disable SIGINT */ /* - * Do not try to collapse these into one "w+" mode file. - * Doesn't work on some platforms (eg, HPUX 10.20). + * Do not try to collapse these into one "w+" mode file. Doesn't work + * on some platforms (eg, HPUX 10.20). */ termin = fopen("/dev/tty", "r"); termout = fopen("/dev/tty", "w"); @@ -213,7 +215,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo) tcsetattr(fileno(termin), TCSAFLUSH, &t); } #endif - + if (prompt) { fputs(gettext(prompt), termout); @@ -304,7 +306,6 @@ handle_sigint(SIGNAL_ARGS) } errno = save_errno; /* just in case the write changed it */ } - #endif /* not WIN32 */ @@ -314,7 +315,7 @@ handle_sigint(SIGNAL_ARGS) * This is the way to send "backdoor" queries (those not directly entered * by the user). It is subject to -E but not -e. */ -PGresult * +PGresult * PSQLexec(const char *query) { PGresult *res; @@ -509,7 +510,7 @@ SendQuery(const char *query) case PGRES_COPY_IN: if (pset.cur_cmd_interactive && !QUIET()) puts(gettext("Enter data to be copied followed by a newline.\n" - "End with a backslash and a period on a line by itself.")); + "End with a backslash and a period on a line by itself.")); success = handleCopyIn(pset.db, pset.cur_cmd_source, pset.cur_cmd_interactive ? get_prompt(PROMPT_COPY) : NULL); diff --git a/src/bin/psql/common.h b/src/bin/psql/common.h index f9604bf90d8..617e4d5a844 100644 --- a/src/bin/psql/common.h +++ b/src/bin/psql/common.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.14 2001/10/03 21:58:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.15 2001/10/25 05:49:53 momjian Exp $ */ #ifndef COMMON_H #define COMMON_H @@ -13,28 +13,27 @@ #include "pqsignal.h" #include "libpq-fe.h" -extern char *xstrdup(const char *string); +extern char *xstrdup(const char *string); -extern bool setQFout(const char *fname); +extern bool setQFout(const char *fname); -extern void psql_error(const char *fmt, ...) +extern void +psql_error(const char *fmt,...) /* This lets gcc check the format string for consistency. */ __attribute__((format(printf, 1, 2))); -extern void NoticeProcessor(void *arg, const char *message); +extern void NoticeProcessor(void *arg, const char *message); -extern char *simple_prompt(const char *prompt, int maxlen, bool echo); +extern char *simple_prompt(const char *prompt, int maxlen, bool echo); extern volatile bool cancel_pressed; extern PGconn *cancelConn; #ifndef WIN32 -extern void handle_sigint(SIGNAL_ARGS); - +extern void handle_sigint(SIGNAL_ARGS); #endif /* not WIN32 */ -extern PGresult *PSQLexec(const char *query); - -extern bool SendQuery(const char *query); +extern PGresult *PSQLexec(const char *query); +extern bool SendQuery(const char *query); #endif /* COMMON_H */ diff --git a/src/bin/psql/copy.h b/src/bin/psql/copy.h index 66114fdbf42..3bda9913f3b 100644 --- a/src/bin/psql/copy.h +++ b/src/bin/psql/copy.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.9 2000/03/01 21:09:58 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.10 2001/10/25 05:49:53 momjian Exp $ */ #ifndef COPY_H #define COPY_H @@ -19,5 +19,4 @@ bool do_copy(const char *args); bool handleCopyOut(PGconn *conn, FILE *copystream); bool handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt); - #endif diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 62fec530e90..6fefdf49da1 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.40 2001/10/06 14:41:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.41 2001/10/25 05:49:53 momjian Exp $ */ #include "postgres_fe.h" #include "describe.h" @@ -54,7 +54,7 @@ describeAggregates(const char *name) " obj_description(a.oid, 'pg_aggregate') as \"%s\"\n" "FROM pg_aggregate a\n", _("Name"), _("(all types)"), - _("Data type"), _("Description") ); + _("Data type"), _("Description")); if (name) { @@ -98,7 +98,7 @@ describeFunctions(const char *name, bool verbose) " p.proname as \"%s\",\n" " oidvectortypes(p.proargtypes) as \"%s\"", _("Result data type"), _("Name"), - _("Argument data types") ); + _("Argument data types")); if (verbose) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), @@ -107,7 +107,7 @@ describeFunctions(const char *name, bool verbose) " p.prosrc as \"%s\",\n" " obj_description(p.oid, 'pg_proc') as \"%s\"", _("Owner"), _("Language"), - _("Source code"), _("Description") ); + _("Source code"), _("Description")); if (!verbose) strcat(buf, @@ -155,7 +155,7 @@ describeTypes(const char *name, bool verbose) snprintf(buf, sizeof(buf), "SELECT format_type(t.oid, NULL) AS \"%s\",\n", - _("Name") ); + _("Name")); if (verbose) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " t.typname AS \"%s\",\n" @@ -163,10 +163,10 @@ describeTypes(const char *name, bool verbose) " THEN CAST('var' AS text)\n" " ELSE CAST(t.typlen AS text)\n" " END AS \"%s\",\n", - _("Internal name"), _("Size") ); - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + _("Internal name"), _("Size")); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " obj_description(t.oid, 'pg_type') as \"%s\"\n", - _("Description") ); + _("Description")); /* * do not include array types (start with underscore), do not include @@ -218,7 +218,7 @@ describeOperators(const char *name) "FROM pg_proc p, pg_operator o\n" "WHERE RegprocToOid(o.oprcode) = p.oid\n", _("Name"), _("Left arg type"), _("Right arg type"), - _("Result type"), _("Description") ); + _("Result type"), _("Description")); if (name) { strcat(buf, " AND o.oprname = '"); @@ -265,10 +265,10 @@ listAllDbs(bool desc) #endif if (desc) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), - ",\n obj_description(d.oid, 'pg_database') as \"%s\"", + ",\n obj_description(d.oid, 'pg_database') as \"%s\"", _("Description")); strcat(buf, - "\nFROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid\n" + "\nFROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid\n" "ORDER BY 1;"); res = PSQLexec(buf); @@ -347,32 +347,32 @@ objectDescription(const char *object) "SELECT DISTINCT tt.name AS \"%s\", tt.object AS \"%s\", d.description AS \"%s\"\n" "FROM (\n" - /* Aggregate descriptions */ + /* Aggregate descriptions */ " SELECT a.oid as oid, a.tableoid as tableoid,\n" - " CAST(a.aggname AS text) as name, CAST('%s' AS text) as object\n" + " CAST(a.aggname AS text) as name, CAST('%s' AS text) as object\n" " FROM pg_aggregate a\n" - /* Function descriptions (except in/outs for datatypes) */ + /* Function descriptions (except in/outs for datatypes) */ "UNION ALL\n" " SELECT p.oid as oid, p.tableoid as tableoid,\n" - " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n" + " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n" " FROM pg_proc p\n" - " WHERE p.pronargs = 0 or oidvectortypes(p.proargtypes) <> ''\n" + " WHERE p.pronargs = 0 or oidvectortypes(p.proargtypes) <> ''\n" - /* Operator descriptions (must get comment via associated function) */ + /* Operator descriptions (must get comment via associated function) */ "UNION ALL\n" " SELECT RegprocToOid(o.oprcode) as oid,\n" " (SELECT oid FROM pg_class WHERE relname = 'pg_proc') as tableoid,\n" - " CAST(o.oprname AS text) as name, CAST('%s' AS text) as object\n" + " CAST(o.oprname AS text) as name, CAST('%s' AS text) as object\n" " FROM pg_operator o\n" - /* Type description */ + /* Type description */ "UNION ALL\n" " SELECT t.oid as oid, t.tableoid as tableoid,\n" - " format_type(t.oid, NULL) as name, CAST('%s' AS text) as object\n" + " format_type(t.oid, NULL) as name, CAST('%s' AS text) as object\n" " FROM pg_type t\n" - /* Relation (tables, views, indexes, sequences) descriptions */ + /* Relation (tables, views, indexes, sequences) descriptions */ "UNION ALL\n" " SELECT c.oid as oid, c.tableoid as tableoid,\n" " CAST(c.relname AS text) as name,\n" @@ -381,17 +381,17 @@ objectDescription(const char *object) " AS text) as object\n" " FROM pg_class c\n" - /* Rule description (ignore rules for views) */ + /* Rule description (ignore rules for views) */ "UNION ALL\n" " SELECT r.oid as oid, r.tableoid as tableoid,\n" - " CAST(r.rulename AS text) as name, CAST('%s' AS text) as object\n" + " CAST(r.rulename AS text) as name, CAST('%s' AS text) as object\n" " FROM pg_rewrite r\n" " WHERE r.rulename !~ '^_RET'\n" - /* Trigger description */ + /* Trigger description */ "UNION ALL\n" " SELECT t.oid as oid, t.tableoid as tableoid,\n" - " CAST(t.tgname AS text) as name, CAST('%s' AS text) as object\n" + " CAST(t.tgname AS text) as name, CAST('%s' AS text) as object\n" " FROM pg_trigger t\n" ") AS tt,\n" @@ -664,10 +664,10 @@ describeTableDetails(const char *name, bool desc) error = true; else { - char *indisunique = PQgetvalue(result, 0, 0); - char *indisprimary = PQgetvalue(result, 0, 1); - char *indamname = PQgetvalue(result, 0, 2); - char *indpred = PQgetvalue(result, 0, 3); + char *indisunique = PQgetvalue(result, 0, 0); + char *indisprimary = PQgetvalue(result, 0, 1); + char *indamname = PQgetvalue(result, 0, 2); + char *indpred = PQgetvalue(result, 0, 3); footers = xmalloc(3 * sizeof(*footers)); /* XXX This construction is poorly internationalized. */ @@ -704,18 +704,18 @@ describeTableDetails(const char *name, bool desc) else if (tableinfo.relkind == 'r') { /* Footer information about a table */ - PGresult *result1 = NULL, - *result2 = NULL, - *result3 = NULL, - *result4 = NULL, - *result5 = NULL, - *result6 = NULL; + PGresult *result1 = NULL, + *result2 = NULL, + *result3 = NULL, + *result4 = NULL, + *result5 = NULL, + *result6 = NULL; int index_count = 0, - primary_count = 0, - unique_count = 0, - constr_count = 0, - rule_count = 0, - trigger_count = 0; + primary_count = 0, + unique_count = 0, + constr_count = 0, + rule_count = 0, + trigger_count = 0; int count_footers = 0; /* count indexes */ @@ -724,7 +724,7 @@ describeTableDetails(const char *name, bool desc) sprintf(buf, "SELECT c2.relname\n" "FROM pg_class c, pg_class c2, pg_index i\n" "WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n" - "AND NOT i.indisunique ORDER BY c2.relname", + "AND NOT i.indisunique ORDER BY c2.relname", name); result1 = PSQLexec(buf); if (!result1) @@ -739,7 +739,7 @@ describeTableDetails(const char *name, bool desc) sprintf(buf, "SELECT c2.relname\n" "FROM pg_class c, pg_class c2, pg_index i\n" "WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n" - "AND i.indisprimary AND i.indisunique ORDER BY c2.relname", + "AND i.indisprimary AND i.indisunique ORDER BY c2.relname", name); result5 = PSQLexec(buf); if (!result5) @@ -754,7 +754,7 @@ describeTableDetails(const char *name, bool desc) sprintf(buf, "SELECT c2.relname\n" "FROM pg_class c, pg_class c2, pg_index i\n" "WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n" - "AND NOT i.indisprimary AND i.indisunique ORDER BY c2.relname", + "AND NOT i.indisprimary AND i.indisunique ORDER BY c2.relname", name); result6 = PSQLexec(buf); if (!result6) @@ -808,18 +808,18 @@ describeTableDetails(const char *name, bool desc) } footers = xmalloc((index_count + primary_count + unique_count + - constr_count + rule_count + trigger_count + 1) - * sizeof(*footers)); + constr_count + rule_count + trigger_count + 1) + * sizeof(*footers)); /* print indexes */ for (i = 0; i < index_count; i++) { - char *s = _("Indexes"); + char *s = _("Indexes"); if (i == 0) snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result1, i, 0)); else - snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result1, i, 0)); + snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result1, i, 0)); if (i < index_count - 1) strcat(buf, ","); @@ -829,12 +829,12 @@ describeTableDetails(const char *name, bool desc) /* print primary keys */ for (i = 0; i < primary_count; i++) { - char *s = _("Primary key"); + char *s = _("Primary key"); if (i == 0) snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result5, i, 0)); else - snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result5, i, 0)); + snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result5, i, 0)); if (i < primary_count - 1) strcat(buf, ","); @@ -844,12 +844,12 @@ describeTableDetails(const char *name, bool desc) /* print unique constraints */ for (i = 0; i < unique_count; i++) { - char *s = _("Unique keys"); + char *s = _("Unique keys"); if (i == 0) snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result6, i, 0)); else - snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result6, i, 0)); + snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result6, i, 0)); if (i < unique_count - 1) strcat(buf, ","); @@ -859,26 +859,26 @@ describeTableDetails(const char *name, bool desc) /* print constraints */ for (i = 0; i < constr_count; i++) { - char *s = _("Check constraints"); + char *s = _("Check constraints"); if (i == 0) snprintf(buf, sizeof(buf), _("%s: \"%s\" %s"), s, - PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0)); + PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0)); else - snprintf(buf, sizeof(buf), _("%*s \"%s\" %s"), (int)strlen(s), "", - PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0)); + snprintf(buf, sizeof(buf), _("%*s \"%s\" %s"), (int) strlen(s), "", + PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0)); footers[count_footers++] = xstrdup(buf); } /* print rules */ for (i = 0; i < rule_count; i++) { - char *s = _("Rules"); + char *s = _("Rules"); if (i == 0) snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result3, i, 0)); else - snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result3, i, 0)); + snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result3, i, 0)); if (i < rule_count - 1) strcat(buf, ","); @@ -888,12 +888,12 @@ describeTableDetails(const char *name, bool desc) /* print triggers */ for (i = 0; i < trigger_count; i++) { - char *s = _("Triggers"); + char *s = _("Triggers"); if (i == 0) snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result4, i, 0)); else - snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result4, i, 0)); + snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result4, i, 0)); if (i < trigger_count - 1) strcat(buf, ","); @@ -944,16 +944,16 @@ describeTableDetails(const char *name, bool desc) */ bool -describeUsers (const char *name) +describeUsers(const char *name) { char buf[384 + REGEXP_CUTOFF]; PGresult *res; printQueryOpt myopt = pset.popt; - + snprintf(buf, sizeof(buf), "SELECT u.usename AS \"%s\",\n" " u.usesysid AS \"%s\",\n" - " CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('%s' AS text)\n" + " CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('%s' AS text)\n" " WHEN u.usesuper THEN CAST('%s' AS text)\n" " WHEN u.usecreatedb THEN CAST('%s' AS text)\n" " ELSE CAST('' AS text)\n" @@ -962,7 +962,7 @@ describeUsers (const char *name) _("User name"), _("User ID"), _("superuser, create database"), _("superuser"), _("create database"), - _("Attributes") ); + _("Attributes")); if (name) { strcat(buf, "WHERE u.usename ~ '^"); @@ -1033,7 +1033,7 @@ listTables(const char *infotype, const char *name, bool desc) ",\n obj_description(c.oid, 'pg_class') as \"%s\"", _("Description")); strcat(buf, - "\nFROM pg_class c LEFT JOIN pg_user u ON c.relowner = u.usesysid\n" + "\nFROM pg_class c LEFT JOIN pg_user u ON c.relowner = u.usesysid\n" "WHERE c.relkind IN ("); if (showTables) strcat(buf, "'r',"); @@ -1045,7 +1045,7 @@ listTables(const char *infotype, const char *name, bool desc) strcat(buf, "'S',"); if (showSystem && showTables) strcat(buf, "'s',"); - strcat(buf, "''"); /* dummy */ + strcat(buf, "''"); /* dummy */ strcat(buf, ")\n"); if (showSystem) diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h index 98821fbed05..2fc05f9d324 100644 --- a/src/bin/psql/describe.h +++ b/src/bin/psql/describe.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.10 2001/05/09 17:29:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.11 2001/10/25 05:49:53 momjian Exp $ */ #ifndef DESCRIBE_H #define DESCRIBE_H @@ -23,7 +23,7 @@ bool describeTypes(const char *name, bool verbose); bool describeOperators(const char *name); /* \du */ -bool describeUsers(const char *name); +bool describeUsers(const char *name); /* \z (or \dp) */ bool permissionsList(const char *name); @@ -39,5 +39,4 @@ bool listAllDbs(bool desc); /* \dt, \di, \ds, \dS, etc. */ bool listTables(const char *infotype, const char *name, bool desc); - #endif /* DESCRIBE_H */ diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 46d5794afad..b4614627a7f 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.41 2001/06/11 18:23:33 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.42 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "help.h" @@ -54,7 +54,6 @@ usage(void) #ifndef WIN32 struct passwd *pw = NULL; - #endif /* Find default user, in case we need it. */ @@ -132,10 +131,10 @@ usage(void) puts(_(" -X Do not read startup file (~/.psqlrc)")); puts(_( - "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"\n" - "(for SQL commands) from within psql, or consult the psql section in\n" - "the PostgreSQL documentation.\n\n" - "Report bugs to <[email protected]>.")); + "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"\n" + "(for SQL commands) from within psql, or consult the psql section in\n" + "the PostgreSQL documentation.\n\n" + "Report bugs to <[email protected]>.")); } @@ -152,7 +151,6 @@ struct winsize int ws_row; int ws_col; }; - #endif void @@ -193,7 +191,7 @@ slashUsage(void) /* if you add/remove a line here, change the row test above */ fprintf(fout, _(" \\a toggle between unaligned and aligned output mode\n")); fprintf(fout, _(" \\c[onnect] [DBNAME|- [USER]]\n" - " connect to new database (currently \"%s\")\n"), + " connect to new database (currently \"%s\")\n"), PQdb(pset.db)); fprintf(fout, _(" \\C TITLE set table title\n")); fprintf(fout, _(" \\cd [DIRNAME] change the current working directory\n")); @@ -334,5 +332,5 @@ print_copyright(void) "PARTICULAR PURPOSE.THE SOFTWARE PROVIDED HEREUNDER IS ON AN \"AS IS\" BASIS,\n" "AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,\n" "SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." - ); + ); } diff --git a/src/bin/psql/help.h b/src/bin/psql/help.h index 47fed65b410..36cf326a01c 100644 --- a/src/bin/psql/help.h +++ b/src/bin/psql/help.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/help.h,v 1.6 2000/02/16 13:15:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/help.h,v 1.7 2001/10/25 05:49:54 momjian Exp $ */ #ifndef HELP_H #define HELP_H @@ -15,5 +15,4 @@ void slashUsage(void); void helpSQL(const char *topic); void print_copyright(void); - #endif diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c index 17cfee41aeb..32872e9d71f 100644 --- a/src/bin/psql/input.c +++ b/src/bin/psql/input.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.17 2001/09/11 23:08:07 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.18 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "input.h" @@ -19,18 +19,17 @@ /* (of course there is no runtime command for doing that :) */ #ifdef USE_READLINE static bool useReadline; - #endif #ifdef USE_HISTORY static bool useHistory; - #endif #ifdef HAVE_ATEXIT -static void finishInput(void); +static void finishInput(void); + #else /* designed for use with on_exit() */ -static void finishInput(int, void*); +static void finishInput(int, void *); #endif @@ -48,7 +47,6 @@ gets_interactive(char *prompt) #ifdef USE_HISTORY const char *var; static char *prev_hist = NULL; - #endif #ifdef USE_READLINE diff --git a/src/bin/psql/input.h b/src/bin/psql/input.h index ff9deade1d9..86caad4f0e0 100644 --- a/src/bin/psql/input.h +++ b/src/bin/psql/input.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.12 2001/09/11 23:08:07 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.13 2001/10/25 05:49:54 momjian Exp $ */ #ifndef INPUT_H #define INPUT_H @@ -39,5 +39,4 @@ char *gets_fromFile(FILE *source); void initializeInput(int flags); bool saveHistory(char *fname); - #endif /* INPUT_H */ diff --git a/src/bin/psql/large_obj.c b/src/bin/psql/large_obj.c index 5fe95a4343b..9aba63767e6 100644 --- a/src/bin/psql/large_obj.c +++ b/src/bin/psql/large_obj.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.17 2001/10/04 22:39:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.18 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "large_obj.h" @@ -194,9 +194,9 @@ do_lo_import(const char *filename_arg, const char *comment_arg) /* XXX ought to replace this with some kind of COMMENT command */ if (comment_arg && pset.issuper) { - char *cmdbuf; - char *bufptr; - int slen = strlen(comment_arg); + char *cmdbuf; + char *bufptr; + int slen = strlen(comment_arg); cmdbuf = malloc(slen * 2 + 256); if (!cmdbuf) @@ -210,7 +210,7 @@ do_lo_import(const char *filename_arg, const char *comment_arg) } sprintf(cmdbuf, "INSERT INTO pg_description VALUES ('%u', " - "(SELECT oid FROM pg_class WHERE relname = 'pg_largeobject')," + "(SELECT oid FROM pg_class WHERE relname = 'pg_largeobject')," " 0, '", loid); bufptr = cmdbuf + strlen(cmdbuf); for (i = 0; i < slen; i++) diff --git a/src/bin/psql/large_obj.h b/src/bin/psql/large_obj.h index b8fcfde04db..85e708b1a4b 100644 --- a/src/bin/psql/large_obj.h +++ b/src/bin/psql/large_obj.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.h,v 1.8 2000/02/16 13:15:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.h,v 1.9 2001/10/25 05:49:54 momjian Exp $ */ #ifndef LARGE_OBJ_H #define LARGE_OBJ_H @@ -12,5 +12,4 @@ bool do_lo_export(const char *loid_arg, const char *filename_arg); bool do_lo_import(const char *filename_arg, const char *comment_arg); bool do_lo_unlink(const char *loid_arg); bool do_lo_list(void); - #endif /* LARGE_OBJ_H */ diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index 3c8e8ec268a..f728e4df1f1 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.40 2001/06/02 18:25:18 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.41 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "mainloop.h" @@ -101,7 +101,6 @@ MainLoop(FILE *source) { if (!pset.cur_cmd_interactive) { - /* * You get here if you stopped a script with Ctrl-C and a * query cancel was issued. In that case we don't do the @@ -137,14 +136,15 @@ MainLoop(FILE *source) } } - /* establish the control-C handler only after main_loop_jmp is ready */ - pqsignal(SIGINT, handle_sigint); /* control-C => cancel */ - + /* + * establish the control-C handler only after main_loop_jmp is + * ready + */ + pqsignal(SIGINT, handle_sigint); /* control-C => cancel */ #endif /* not WIN32 */ if (slashCmdStatus == CMD_NEWEDIT) { - /* * just returned from editing the line? then just copy to the * input buffer @@ -393,7 +393,7 @@ MainLoop(FILE *source) line = new; len = strlen(new); - goto rescan;/* reparse the just substituted */ + goto rescan; /* reparse the just substituted */ } else { @@ -410,7 +410,6 @@ MainLoop(FILE *source) /* is there anything else on the line? */ if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0') { - /* * insert a cosmetic newline, if this is not the first * line in the buffer @@ -454,7 +453,6 @@ MainLoop(FILE *source) /* is there anything else on the line for the command? */ if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0') { - /* * insert a cosmetic newline, if this is not the first * line in the buffer @@ -563,8 +561,8 @@ MainLoop(FILE *source) /* * Reset SIGINT handler because main_loop_jmp will be invalid as soon * as we exit this routine. If there is an outer MainLoop instance, - * it will re-enable ^C catching as soon as it gets back to the top - * of its loop and resets main_loop_jmp to point to itself. + * it will re-enable ^C catching as soon as it gets back to the top of + * its loop and resets main_loop_jmp to point to itself. */ #ifndef WIN32 pqsignal(SIGINT, SIG_DFL); diff --git a/src/bin/psql/mainloop.h b/src/bin/psql/mainloop.h index cc832f194b0..55e0a65fb1f 100644 --- a/src/bin/psql/mainloop.h +++ b/src/bin/psql/mainloop.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.h,v 1.10 2001/02/10 02:31:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.h,v 1.11 2001/10/25 05:49:54 momjian Exp $ */ #ifndef MAINLOOP_H #define MAINLOOP_H @@ -14,9 +14,7 @@ #include <setjmp.h> extern sigjmp_buf main_loop_jmp; - #endif int MainLoop(FILE *source); - #endif /* MAINLOOP_H */ diff --git a/src/bin/psql/mbprint.c b/src/bin/psql/mbprint.c index 986861fe4a5..1ca86f0e509 100644 --- a/src/bin/psql/mbprint.c +++ b/src/bin/psql/mbprint.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.1 2001/10/15 01:25:10 ishii Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.2 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" @@ -26,21 +26,23 @@ * original available at : http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c */ -struct mbinterval { +struct mbinterval +{ unsigned short first; unsigned short last; }; /* auxiliary function for binary search in interval table */ static int -mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max) +mbbisearch(pg_wchar ucs, const struct mbinterval * table, int max) { - int min = 0; - int mid; + int min = 0; + int mid; if (ucs < table[0].first || ucs > table[max].last) return 0; - while (max >= min) { + while (max >= min) + { mid = (min + max) / 2; if (ucs > table[mid].last) min = mid + 1; @@ -57,28 +59,28 @@ mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max) /* The following functions define the column width of an ISO 10646 * character as follows: * - * - The null character (U+0000) has a column width of 0. + * - The null character (U+0000) has a column width of 0. * - * - Other C0/C1 control characters and DEL will lead to a return - * value of -1. + * - Other C0/C1 control characters and DEL will lead to a return + * value of -1. * - * - Non-spacing and enclosing combining characters (general - * category code Mn or Me in the Unicode database) have a - * column width of 0. + * - Non-spacing and enclosing combining characters (general + * category code Mn or Me in the Unicode database) have a + * column width of 0. * - * - Other format characters (general category code Cf in the Unicode - * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0. + * - Other format characters (general category code Cf in the Unicode + * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0. * - * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF) - * have a column width of 0. + * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF) + * have a column width of 0. * - * - Spacing characters in the East Asian Wide (W) or East Asian - * FullWidth (F) category as defined in Unicode Technical - * Report #11 have a column width of 2. + * - Spacing characters in the East Asian Wide (W) or East Asian + * FullWidth (F) category as defined in Unicode Technical + * Report #11 have a column width of 2. * - * - All remaining characters (including all printable - * ISO 8859-1 and WGL4 characters, Unicode control characters, - * etc.) have a column width of 1. + * - All remaining characters (including all printable + * ISO 8859-1 and WGL4 characters, Unicode control characters, + * etc.) have a column width of 1. * * This implementation assumes that wchar_t characters are encoded * in ISO 10646. @@ -89,68 +91,69 @@ ucs_wcwidth(pg_wchar ucs) { /* sorted list of non-overlapping intervals of non-spacing characters */ static const struct mbinterval combining[] = { - { 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 }, - { 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 }, - { 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, - { 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 }, - { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED }, - { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A }, - { 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C }, - { 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 }, - { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC }, - { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 }, - { 0x0A02, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 }, - { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 }, - { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 }, - { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 }, - { 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, - { 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, - { 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, - { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, - { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, - { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA }, - { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 }, - { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 }, - { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD }, - { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 }, - { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 }, - { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC }, - { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 }, - { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 }, - { 0x1160, 0x11FF }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 }, - { 0x17C9, 0x17D3 }, { 0x180B, 0x180E }, { 0x18A9, 0x18A9 }, - { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x206A, 0x206F }, - { 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A }, - { 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, - { 0xFFF9, 0xFFFB } + {0x0300, 0x034E}, {0x0360, 0x0362}, {0x0483, 0x0486}, + {0x0488, 0x0489}, {0x0591, 0x05A1}, {0x05A3, 0x05B9}, + {0x05BB, 0x05BD}, {0x05BF, 0x05BF}, {0x05C1, 0x05C2}, + {0x05C4, 0x05C4}, {0x064B, 0x0655}, {0x0670, 0x0670}, + {0x06D6, 0x06E4}, {0x06E7, 0x06E8}, {0x06EA, 0x06ED}, + {0x070F, 0x070F}, {0x0711, 0x0711}, {0x0730, 0x074A}, + {0x07A6, 0x07B0}, {0x0901, 0x0902}, {0x093C, 0x093C}, + {0x0941, 0x0948}, {0x094D, 0x094D}, {0x0951, 0x0954}, + {0x0962, 0x0963}, {0x0981, 0x0981}, {0x09BC, 0x09BC}, + {0x09C1, 0x09C4}, {0x09CD, 0x09CD}, {0x09E2, 0x09E3}, + {0x0A02, 0x0A02}, {0x0A3C, 0x0A3C}, {0x0A41, 0x0A42}, + {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A70, 0x0A71}, + {0x0A81, 0x0A82}, {0x0ABC, 0x0ABC}, {0x0AC1, 0x0AC5}, + {0x0AC7, 0x0AC8}, {0x0ACD, 0x0ACD}, {0x0B01, 0x0B01}, + {0x0B3C, 0x0B3C}, {0x0B3F, 0x0B3F}, {0x0B41, 0x0B43}, + {0x0B4D, 0x0B4D}, {0x0B56, 0x0B56}, {0x0B82, 0x0B82}, + {0x0BC0, 0x0BC0}, {0x0BCD, 0x0BCD}, {0x0C3E, 0x0C40}, + {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, {0x0C55, 0x0C56}, + {0x0CBF, 0x0CBF}, {0x0CC6, 0x0CC6}, {0x0CCC, 0x0CCD}, + {0x0D41, 0x0D43}, {0x0D4D, 0x0D4D}, {0x0DCA, 0x0DCA}, + {0x0DD2, 0x0DD4}, {0x0DD6, 0x0DD6}, {0x0E31, 0x0E31}, + {0x0E34, 0x0E3A}, {0x0E47, 0x0E4E}, {0x0EB1, 0x0EB1}, + {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC}, {0x0EC8, 0x0ECD}, + {0x0F18, 0x0F19}, {0x0F35, 0x0F35}, {0x0F37, 0x0F37}, + {0x0F39, 0x0F39}, {0x0F71, 0x0F7E}, {0x0F80, 0x0F84}, + {0x0F86, 0x0F87}, {0x0F90, 0x0F97}, {0x0F99, 0x0FBC}, + {0x0FC6, 0x0FC6}, {0x102D, 0x1030}, {0x1032, 0x1032}, + {0x1036, 0x1037}, {0x1039, 0x1039}, {0x1058, 0x1059}, + {0x1160, 0x11FF}, {0x17B7, 0x17BD}, {0x17C6, 0x17C6}, + {0x17C9, 0x17D3}, {0x180B, 0x180E}, {0x18A9, 0x18A9}, + {0x200B, 0x200F}, {0x202A, 0x202E}, {0x206A, 0x206F}, + {0x20D0, 0x20E3}, {0x302A, 0x302F}, {0x3099, 0x309A}, + {0xFB1E, 0xFB1E}, {0xFE20, 0xFE23}, {0xFEFF, 0xFEFF}, + {0xFFF9, 0xFFFB} }; /* test for 8-bit control characters */ - if (ucs == 0) { + if (ucs == 0) return 0; - } - if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0) || ucs > 0x0010ffff) { + if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0) || ucs > 0x0010ffff) return -1; - } /* binary search in table of non-spacing characters */ if (mbbisearch(ucs, combining, - sizeof(combining) / sizeof(struct mbinterval) - 1)) { + sizeof(combining) / sizeof(struct mbinterval) - 1)) return 0; - } - /* if we arrive here, ucs is not a combining or C0/C1 control character */ + /* + * if we arrive here, ucs is not a combining or C0/C1 control + * character + */ - return 1 + + return 1 + (ucs >= 0x1100 && - (ucs <= 0x115f || /* Hangul Jamo init. consonants */ + (ucs <= 0x115f || /* Hangul Jamo init. consonants */ (ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a && - ucs != 0x303f) || /* CJK ... Yi */ - (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */ - (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */ - (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */ - (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */ + ucs != 0x303f) || /* CJK ... Yi */ + (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */ + (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility + * Ideographs */ + (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */ + (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */ (ucs >= 0xffe0 && ucs <= 0xffe6) || (ucs >= 0x20000 && ucs <= 0x2ffff))); } @@ -158,28 +161,32 @@ ucs_wcwidth(pg_wchar ucs) pg_wchar utf2ucs(const unsigned char *c) { - /* one char version of pg_utf2wchar_with_len. - * no control here, c must point to a large enough string + /* + * one char version of pg_utf2wchar_with_len. no control here, c must + * point to a large enough string */ - if ((*c & 0x80) == 0) { - return (pg_wchar)c[0]; - } - else if ((*c & 0xe0) == 0xc0) { - return (pg_wchar)(((c[0] & 0x1f) << 6) | - (c[1] & 0x3f)); + if ((*c & 0x80) == 0) + return (pg_wchar) c[0]; + else if ((*c & 0xe0) == 0xc0) + { + return (pg_wchar) (((c[0] & 0x1f) << 6) | + (c[1] & 0x3f)); } - else if ((*c & 0xf0) == 0xe0) { - return (pg_wchar)(((c[0] & 0x0f) << 12) | - ((c[1] & 0x3f) << 6) | - (c[2] & 0x3f)); + else if ((*c & 0xf0) == 0xe0) + { + return (pg_wchar) (((c[0] & 0x0f) << 12) | + ((c[1] & 0x3f) << 6) | + (c[2] & 0x3f)); } - else if ((*c & 0xf0) == 0xf0) { - return (pg_wchar)(((c[0] & 0x07) << 18) | - ((c[1] & 0x3f) << 12) | - ((c[2] & 0x3f) << 6) | - (c[3] & 0x3f)); + else if ((*c & 0xf0) == 0xf0) + { + return (pg_wchar) (((c[0] & 0x07) << 18) | + ((c[1] & 0x3f) << 12) | + ((c[2] & 0x3f) << 6) | + (c[3] & 0x3f)); } - else { + else + { /* that is an invalid code on purpose */ return 0xffffffff; } @@ -190,14 +197,15 @@ utf2ucs(const unsigned char *c) static int mb_utf_wcswidth(unsigned char *pwcs, int len) { - int w, l = 0; - int width = 0; + int w, + l = 0; + int width = 0; - for (;*pwcs && len > 0; pwcs+=l) { + for (; *pwcs && len > 0; pwcs += l) + { l = pg_utf_mblen(pwcs); - if ((len < l) || ((w = ucs_wcwidth(utf2ucs(pwcs))) < 0)) { + if ((len < l) || ((w = ucs_wcwidth(utf2ucs(pwcs))) < 0)) return width; - } len -= l; width += w; } @@ -207,91 +215,95 @@ mb_utf_wcswidth(unsigned char *pwcs, int len) static int utf_charcheck(const unsigned char *c) { - /* Unicode 3.1 compliant validation : - * for each category, it checks the combination of each byte to make sur - * it maps to a valid range. It also returns -1 for the following UCS values: - * ucs > 0x10ffff - * ucs & 0xfffe = 0xfffe - * 0xfdd0 < ucs < 0xfdef - * ucs & 0xdb00 = 0xd800 (surrogates) + /* + * Unicode 3.1 compliant validation : for each category, it checks the + * combination of each byte to make sur it maps to a valid range. It + * also returns -1 for the following UCS values: ucs > 0x10ffff ucs & + * 0xfffe = 0xfffe 0xfdd0 < ucs < 0xfdef ucs & 0xdb00 = 0xd800 + * (surrogates) */ - if ((*c & 0x80) == 0) { + if ((*c & 0x80) == 0) return 1; - } - else if ((*c & 0xe0) == 0xc0) { + else if ((*c & 0xe0) == 0xc0) + { /* two-byte char */ - if(((c[1] & 0xc0) == 0x80) && ((c[0] & 0x1f) > 0x01)) { + if (((c[1] & 0xc0) == 0x80) && ((c[0] & 0x1f) > 0x01)) return 2; - } return -1; } - else if ((*c & 0xf0) == 0xe0) { + else if ((*c & 0xf0) == 0xe0) + { /* three-byte char */ if (((c[1] & 0xc0) == 0x80) && (((c[0] & 0x0f) != 0x00) || ((c[1] & 0x20) == 0x20)) && - ((c[2] & 0xc0) == 0x80)) { - int z = c[0] & 0x0f; - int yx = ((c[1] & 0x3f) << 6) | (c[0] & 0x3f); - int lx = yx & 0x7f; + ((c[2] & 0xc0) == 0x80)) + { + int z = c[0] & 0x0f; + int yx = ((c[1] & 0x3f) << 6) | (c[0] & 0x3f); + int lx = yx & 0x7f; /* check 0xfffe/0xffff, 0xfdd0..0xfedf range, surrogates */ if (((z == 0x0f) && (((yx & 0xffe) == 0xffe) || - (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) || - ((z == 0x0d) && ((yx & 0xb00) == 0x800))) { + (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) || + ((z == 0x0d) && ((yx & 0xb00) == 0x800))) return -1; - } return 3; } return -1; } - else if ((*c & 0xf8) == 0xf0) { - int u = ((c[0] & 0x07) << 2) | ((c[1] & 0x30) >> 4); + else if ((*c & 0xf8) == 0xf0) + { + int u = ((c[0] & 0x07) << 2) | ((c[1] & 0x30) >> 4); /* four-byte char */ if (((c[1] & 0xc0) == 0x80) && (u > 0x00) && (u <= 0x10) && - ((c[2] & 0xc0) == 0x80) && ((c[3] & 0xc0) == 0x80)) { + ((c[2] & 0xc0) == 0x80) && ((c[3] & 0xc0) == 0x80)) + { /* test for 0xzzzzfffe/0xzzzzfffff */ if (((c[1] & 0x0f) == 0x0f) && ((c[2] & 0x3f) == 0x3f) && - ((c[3] & 0x3e) == 0x3e)) { + ((c[3] & 0x3e) == 0x3e)) return -1; - } return 4; } return -1; } return -1; } - + static unsigned char * mb_utf_validate(unsigned char *pwcs) { - int l = 0; + int l = 0; unsigned char *p = pwcs; unsigned char *p0 = pwcs; - while( *pwcs ) { - if ((l = utf_charcheck(pwcs)) > 0) { - if (p != pwcs) { - int i; - for( i = 0; i < l; i++) { + while (*pwcs) + { + if ((l = utf_charcheck(pwcs)) > 0) + { + if (p != pwcs) + { + int i; + + for (i = 0; i < l; i++) *p++ = *pwcs++; - } } - else { + else + { pwcs += l; p += l; } } - else { + else + { /* we skip the char */ pwcs++; } } - if (p != pwcs) { + if (p != pwcs) *p = '\0'; - } return p0; } @@ -300,35 +312,41 @@ mb_utf_validate(unsigned char *pwcs) */ int -pg_wcswidth(unsigned char *pwcs, int len) { - if (pset.encoding == PG_UTF8) { +pg_wcswidth(unsigned char *pwcs, int len) +{ + if (pset.encoding == PG_UTF8) return mb_utf_wcswidth(pwcs, len); - } - else { - /* obviously, other encodings may want to fix this, but I don't know them - * myself, unfortunately. + else + { + /* + * obviously, other encodings may want to fix this, but I don't + * know them myself, unfortunately. */ return len; } } unsigned char * -mbvalidate(unsigned char *pwcs) { - if (pset.encoding == PG_UTF8) { +mbvalidate(unsigned char *pwcs) +{ + if (pset.encoding == PG_UTF8) return mb_utf_validate(pwcs); - } - else { - /* other encodings needing validation should add their own routines here + else + { + /* + * other encodings needing validation should add their own + * routines here */ return pwcs; } } -#else /* !MULTIBYTE */ + +#else /* !MULTIBYTE */ /* in single-byte environment, all cells take 1 column */ -int pg_wcswidth(unsigned char *pwcs, int len) { +int +pg_wcswidth(unsigned char *pwcs, int len) +{ return len; } #endif - - diff --git a/src/bin/psql/mbprint.h b/src/bin/psql/mbprint.h index adf92f53056..4d0cab1b9dc 100644 --- a/src/bin/psql/mbprint.h +++ b/src/bin/psql/mbprint.h @@ -1,4 +1,4 @@ -/* $Id: mbprint.h,v 1.1 2001/10/15 04:52:59 ishii Exp $ */ +/* $Id: mbprint.h,v 1.2 2001/10/25 05:49:54 momjian Exp $ */ #ifndef MBPRINT_H #define MBPRINT_H @@ -7,12 +7,10 @@ #include "mb/pg_wchar.h" -pg_wchar utf2ucs(const unsigned char *c); +pg_wchar utf2ucs(const unsigned char *c); unsigned char *mbvalidate(unsigned char *pwcs); -#endif /* MULTIBYTE */ - -int pg_wcswidth(unsigned char *pwcs, int len); - -#endif /* MBPRINT_H */ +#endif /* MULTIBYTE */ +int pg_wcswidth(unsigned char *pwcs, int len); +#endif /* MBPRINT_H */ diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index c3f71951bab..97ca96d6601 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.22 2001/10/15 01:25:10 ishii Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.23 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "print.h" @@ -218,7 +218,8 @@ print_aligned_text(const char *title, const char *const * headers, #ifdef MULTIBYTE unsigned int cell_count = 0; - unsigned int *head_w, *cell_w; + unsigned int *head_w, + *cell_w; #endif unsigned int i, @@ -240,38 +241,39 @@ print_aligned_text(const char *title, const char *const * headers, #ifdef MULTIBYTE head_w = calloc(col_count, sizeof(*head_w)); - if (!head_w) { - perror("calloc"); - exit(EXIT_FAILURE); + if (!head_w) + { + perror("calloc"); + exit(EXIT_FAILURE); } /* count rows */ - for (ptr = cells; *ptr; ptr++) { - cell_count++; - } + for (ptr = cells; *ptr; ptr++) + cell_count++; cell_w = calloc(cell_count, sizeof(*cell_w)); - if (!cell_w) { - perror("calloc"); - exit(EXIT_FAILURE); + if (!cell_w) + { + perror("calloc"); + exit(EXIT_FAILURE); } #endif - + /* calc column widths */ - for (i = 0; i < col_count; i++) { - if ((tmp = pg_wcswidth((unsigned char *)headers[i], strlen(headers[i]))) > widths[i]) { + for (i = 0; i < col_count; i++) + { + if ((tmp = pg_wcswidth((unsigned char *) headers[i], strlen(headers[i]))) > widths[i]) widths[i] = tmp; - } #ifdef MULTIBYTE head_w[i] = tmp; #endif } - for (i = 0, ptr = cells; *ptr; ptr++, i++) { - if ((tmp = pg_wcswidth((unsigned char *)*ptr, strlen(*ptr))) > widths[i % col_count]) { + for (i = 0, ptr = cells; *ptr; ptr++, i++) + { + if ((tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr))) > widths[i % col_count]) widths[i % col_count] = tmp; - } #ifdef MULTIBYTE cell_w[i] = tmp; #endif @@ -287,14 +289,14 @@ print_aligned_text(const char *title, const char *const * headers, total_w += widths[i]; /* print title */ - if (title && !opt_barebones) { - int tlen; - if ((tlen = pg_wcswidth((unsigned char *)title, strlen(title))) >= total_w) { + if (title && !opt_barebones) + { + int tlen; + + if ((tlen = pg_wcswidth((unsigned char *) title, strlen(title))) >= total_w) fprintf(fout, "%s\n", title); - } - else { + else fprintf(fout, "%-*s%s\n", (int) (total_w - tlen) / 2, "", title); - } } /* print headers */ @@ -310,16 +312,17 @@ print_aligned_text(const char *title, const char *const * headers, for (i = 0; i < col_count; i++) { - int nbspace; + int nbspace; + #ifdef MULTIBYTE - nbspace = widths[i] - head_w[i]; + nbspace = widths[i] - head_w[i]; #else - nbspace = widths[i] - strlen(headers[i]); + nbspace = widths[i] - strlen(headers[i]); #endif /* centered */ - fprintf(fout, "%-*s%s%-*s", - nbspace / 2, "", headers[i], (nbspace+1) / 2, ""); + fprintf(fout, "%-*s%s%-*s", + nbspace / 2, "", headers[i], (nbspace + 1) / 2, ""); if (i < col_count - 1) { @@ -352,10 +355,11 @@ print_aligned_text(const char *title, const char *const * headers, } /* content */ - if (opt_align[(i) % col_count] == 'r') { + if (opt_align[(i) % col_count] == 'r') + { #ifdef MULTIBYTE - fprintf(fout, "%*s%s", - widths[i % col_count] - cell_w[i], "", cells[i] ); + fprintf(fout, "%*s%s", + widths[i % col_count] - cell_w[i], "", cells[i]); #else fprintf(fout, "%*s", widths[i % col_count], cells[i]); #endif @@ -364,10 +368,11 @@ print_aligned_text(const char *title, const char *const * headers, { if ((i + 1) % col_count == 0 && opt_border != 2) fputs(cells[i], fout); - else { + else + { #ifdef MULTIBYTE - fprintf(fout, "%-s%*s", cells[i], - widths[i % col_count] - cell_w[i], "" ); + fprintf(fout, "%-s%*s", cells[i], + widths[i % col_count] - cell_w[i], ""); #else fprintf(fout, "%-*s", widths[i % col_count], cells[i]); #endif @@ -425,9 +430,11 @@ print_aligned_vertical(const char *title, const char *const * headers, hwidth = 0, dwidth = 0; char *divider; + #ifdef MULTIBYTE unsigned int cell_count = 0; - unsigned int *cell_w,*head_w; + unsigned int *cell_w, + *head_w; #endif if (cells[0] == NULL) @@ -438,36 +445,36 @@ print_aligned_vertical(const char *title, const char *const * headers, #ifdef MULTIBYTE /* pre-count headers */ - for (ptr = headers; *ptr; ptr++) { - col_count++; - } + for (ptr = headers; *ptr; ptr++) + col_count++; head_w = calloc(col_count, sizeof(*head_w)); - if (!head_w) { - perror("calloc"); - exit(EXIT_FAILURE); + if (!head_w) + { + perror("calloc"); + exit(EXIT_FAILURE); } for (i = 0; i < col_count; i++) { - if ((tmp = pg_wcswidth((unsigned char *)headers[i], strlen(headers[i]))) > hwidth) + if ((tmp = pg_wcswidth((unsigned char *) headers[i], strlen(headers[i]))) > hwidth) hwidth = tmp; head_w[i] = tmp; } - for (ptr = cells; *ptr; ptr++) { - cell_count++; - } + for (ptr = cells; *ptr; ptr++) + cell_count++; cell_w = calloc(cell_count, sizeof(*cell_w)); - if (!cell_w) { - perror("calloc"); - exit(EXIT_FAILURE); - } + if (!cell_w) + { + perror("calloc"); + exit(EXIT_FAILURE); + } /* find longest data cell */ - for (i = 0, ptr = cells; *ptr; ptr++, i++) { - if ((tmp = pg_wcswidth((unsigned char *)*ptr, strlen(*ptr))) > dwidth) { + for (i = 0, ptr = cells; *ptr; ptr++, i++) + { + if ((tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr))) > dwidth) dwidth = tmp; - } - cell_w[i] = tmp; + cell_w[i] = tmp; } #else /* count columns and find longest header */ @@ -479,7 +486,8 @@ print_aligned_vertical(const char *title, const char *const * headers, } /* find longest data cell */ - for (ptr = cells; *ptr; ptr++) { + for (ptr = cells; *ptr; ptr++) + { if ((tmp = strlen(*ptr)) > dwidth) dwidth = tmp; } @@ -571,7 +579,8 @@ print_aligned_vertical(const char *title, const char *const * headers, if (opt_border < 2) fprintf(fout, "%s\n", *ptr); - else { + else + { #ifdef MULTIBYTE fprintf(fout, "%-s%*s |\n", *ptr, dwidth - cell_w[i], ""); #else @@ -1152,7 +1161,8 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout) exit(EXIT_FAILURE); } - for (i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) + { #ifdef MULTIBYTE headers[i] = mbvalidate(PQfname(result, i)); #else @@ -1173,7 +1183,8 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout) { if (PQgetisnull(result, i / nfields, i % nfields)) cells[i] = opt->nullPrint ? opt->nullPrint : ""; - else { + else + { #ifdef MULTIBYTE cells[i] = mbvalidate(PQgetvalue(result, i / nfields, i % nfields)); #else diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h index 1cc3bcb6e22..d469149b694 100644 --- a/src/bin/psql/print.h +++ b/src/bin/psql/print.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/print.h,v 1.9 2001/05/12 19:44:46 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/print.h,v 1.10 2001/10/25 05:49:54 momjian Exp $ */ #ifndef PRINT_H #define PRINT_H @@ -12,11 +12,12 @@ enum printFormat { - PRINT_NOTHING = 0, /* to make sure someone initializes this */ - PRINT_UNALIGNED, - PRINT_ALIGNED, - PRINT_HTML, - PRINT_LATEX + PRINT_NOTHING = 0, /* to make sure someone + * initializes this */ + PRINT_UNALIGNED, + PRINT_ALIGNED, + PRINT_HTML, + PRINT_LATEX /* add your favourite output format here ... */ }; @@ -64,7 +65,7 @@ typedef struct _printQueryOpt char *title; /* override title */ char **footers; /* override footer (default is "(xx * rows)") */ - bool default_footer; /* print default footer if footers==NULL */ + bool default_footer; /* print default footer if footers==NULL */ } printQueryOpt; /* @@ -73,7 +74,6 @@ typedef struct _printQueryOpt * It calls the printTable above with all the things set straight. */ void -printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout); - + printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout); #endif /* PRINT_H */ diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c index 12818d8afaa..f01a55b5696 100644 --- a/src/bin/psql/prompt.c +++ b/src/bin/psql/prompt.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.21 2001/08/24 19:59:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.22 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "prompt.h" @@ -33,7 +33,7 @@ * * Defined interpolations are: * %M - database server "hostname.domainname", "[local]" for AF_UNIX - * sockets, "[local:/dir/name]" if not default + * sockets, "[local:/dir/name]" if not default * %m - like %M, but hostname only (before first dot), or always "[local]" * %> - database server port number * %n - database user name @@ -120,7 +120,7 @@ get_prompt(promptStatus_t status) case 'm': if (pset.db) { - const char * host = PQhost(pset.db); + const char *host = PQhost(pset.db); /* INET socket */ if (host && host[0] && host[0] != '/') @@ -134,7 +134,7 @@ get_prompt(promptStatus_t status) else { if (!host - || strcmp(host, DEFAULT_PGSOCKET_DIR)==0 + || strcmp(host, DEFAULT_PGSOCKET_DIR) == 0 || *p == 'm') strncpy(buf, "[local]", MAX_PROMPT_SIZE); else diff --git a/src/bin/psql/prompt.h b/src/bin/psql/prompt.h index 0c0c209ff30..4c2b0a693ba 100644 --- a/src/bin/psql/prompt.h +++ b/src/bin/psql/prompt.h @@ -3,22 +3,21 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/prompt.h,v 1.8 2000/04/12 17:16:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/prompt.h,v 1.9 2001/10/25 05:49:54 momjian Exp $ */ #ifndef PROMPT_H #define PROMPT_H typedef enum _promptStatus { - PROMPT_READY, - PROMPT_CONTINUE, - PROMPT_COMMENT, - PROMPT_SINGLEQUOTE, - PROMPT_DOUBLEQUOTE, - PROMPT_PAREN, - PROMPT_COPY + PROMPT_READY, + PROMPT_CONTINUE, + PROMPT_COMMENT, + PROMPT_SINGLEQUOTE, + PROMPT_DOUBLEQUOTE, + PROMPT_PAREN, + PROMPT_COPY } promptStatus_t; char *get_prompt(promptStatus_t status); - #endif /* PROMPT_H */ diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h index d5d306b1586..1be01f445c3 100644 --- a/src/bin/psql/settings.h +++ b/src/bin/psql/settings.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.10 2000/04/12 17:16:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.11 2001/10/25 05:49:54 momjian Exp $ */ #ifndef SETTINGS_H #define SETTINGS_H @@ -69,5 +69,4 @@ extern PsqlSettings pset; #define EXIT_BADCONN 2 #define EXIT_USER 3 - #endif diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index bd0dddcb365..75d04551c33 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.51 2001/06/30 17:26:12 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.52 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" @@ -56,11 +56,11 @@ PsqlSettings pset; */ enum _actions { - ACT_NOTHING = 0, - ACT_SINGLE_SLASH, - ACT_LIST_DB, - ACT_SINGLE_QUERY, - ACT_FILE + ACT_NOTHING = 0, + ACT_SINGLE_SLASH, + ACT_LIST_DB, + ACT_SINGLE_QUERY, + ACT_FILE }; struct adhoc_opts @@ -87,7 +87,6 @@ static void #ifdef USE_SSL static void printSSLInfo(void); - #endif @@ -167,7 +166,6 @@ main(int argc, char *argv[]) if (options.username) { - /* * The \001 is a hack to support the deprecated -u option which * issues a username prompt. The recommended option is -U followed @@ -241,7 +239,7 @@ main(int argc, char *argv[]) /* * process file given by -f */ - if (options.action == ACT_FILE && strcmp(options.action_string, "-")!=0) + if (options.action == ACT_FILE && strcmp(options.action_string, "-") != 0) { if (!options.no_psqlrc) process_psqlrc(); @@ -286,8 +284,8 @@ main(int argc, char *argv[]) printf(gettext("Welcome to %s, the PostgreSQL interactive terminal.\n\n" "Type: \\copyright for distribution terms\n" " \\h for help with SQL commands\n" - " \\? for help on internal slash commands\n" - " \\g or terminate with semicolon to execute query\n" + " \\? for help on internal slash commands\n" + " \\g or terminate with semicolon to execute query\n" " \\q to quit\n\n"), pset.progname); #ifdef USE_SSL @@ -302,7 +300,7 @@ main(int argc, char *argv[]) process_psqlrc(); if (!pset.notty) initializeInput(options.no_readline ? 0 : 1); - if (options.action_string) /* -f - was used */ + if (options.action_string) /* -f - was used */ pset.inputfile = "<stdin>"; successResult = MainLoop(stdin); } @@ -326,7 +324,6 @@ int getopt(int, char *const[], const char *); /* And it requires progname to be set */ char *__progname = "psql"; - #endif static void @@ -367,7 +364,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) }; int optindex; - #endif /* HAVE_GETOPT_LONG */ extern char *optarg; @@ -554,7 +550,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) case '-': fprintf(stderr, gettext("%s was compiled without support for long options.\n" - "Use --help for help on invocation options.\n"), + "Use --help for help on invocation options.\n"), pset.progname); exit(EXIT_FAILURE); break; @@ -673,7 +669,7 @@ showVersion(void) puts(gettext("Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group\n" "Portions Copyright (c) 1996, Regents of the University of California\n" - "Read the file COPYRIGHT or use the command \\copyright to see the\n" + "Read the file COPYRIGHT or use the command \\copyright to see the\n" "usage and distribution terms.")); } @@ -699,5 +695,4 @@ printSSLInfo(void) printf(gettext("SSL connection (cipher: %s, bits: %i)\n\n"), SSL_get_cipher(ssl), sslbits); } - #endif diff --git a/src/bin/psql/stringutils.h b/src/bin/psql/stringutils.h index 4201fd53001..2d7bdaa86b9 100644 --- a/src/bin/psql/stringutils.h +++ b/src/bin/psql/stringutils.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.h,v 1.14 2000/02/07 23:10:07 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.h,v 1.15 2001/10/25 05:49:54 momjian Exp $ */ #ifndef STRINGUTILS_H #define STRINGUTILS_H @@ -17,5 +17,4 @@ extern char *strtokx(const char *s, char *was_quoted, unsigned int *token_pos, int encoding); - #endif /* STRINGUTILS_H */ diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index c76d9c807a2..500ded13fef 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.38 2001/09/21 03:32:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.39 2001/10/25 05:49:54 momjian Exp $ */ /*---------------------------------------------------------------------- @@ -106,7 +106,7 @@ void initialize_readline(void) { rl_readline_name = pset.progname; - rl_attempted_completion_function = (void *)psql_completion; + rl_attempted_completion_function = (void *) psql_completion; rl_basic_word_break_characters = "\t\n@$><=;|&{( "; @@ -584,7 +584,11 @@ psql_completion(char *text, int start, int end) /* Complete INSERT INTO with table names */ else if (strcasecmp(prev2_wd, "INSERT") == 0 && strcasecmp(prev_wd, "INTO") == 0) COMPLETE_WITH_QUERY(Query_for_list_of_tables); - /* Complete INSERT INTO <table> with "VALUES" or "SELECT" or "DEFAULT VALUES" */ + + /* + * Complete INSERT INTO <table> with "VALUES" or "SELECT" or "DEFAULT + * VALUES" + */ else if (strcasecmp(prev3_wd, "INSERT") == 0 && strcasecmp(prev2_wd, "INTO") == 0) { char *list_INSERT[] = {"DEFAULT VALUES", "SELECT", "VALUES", NULL}; @@ -662,19 +666,17 @@ psql_completion(char *text, int start, int end) /* Complete SET SESSION with AUTHORIZATION or CHARACTERISTICS... */ else if (strcasecmp(prev2_wd, "SET") == 0 && strcasecmp(prev_wd, "SESSION") == 0) { - char *my_list[] = {"AUTHORIZATION", - "CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL", - NULL}; + char *my_list[] = {"AUTHORIZATION", + "CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL", + NULL}; COMPLETE_WITH_LIST(my_list); } /* Complete SET SESSION AUTHORIZATION with username */ - else if (strcasecmp(prev3_wd, "SET") == 0 + else if (strcasecmp(prev3_wd, "SET") == 0 && strcasecmp(prev2_wd, "SESSION") == 0 && strcasecmp(prev_wd, "AUTHORIZATION") == 0) - { COMPLETE_WITH_QUERY(Query_for_list_of_users); - } /* Complete SET <var> with "TO" */ else if (strcasecmp(prev2_wd, "SET") == 0 && strcasecmp(prev4_wd, "UPDATE") != 0) @@ -755,12 +757,12 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_LIST(my_list); } else if (strcmp(prev_wd, "\\cd") == 0 || - strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 || + strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 || strcmp(prev_wd, "\\g") == 0 || strcmp(prev_wd, "\\i") == 0 || strcmp(prev_wd, "\\include") == 0 || - strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 || + strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 || strcmp(prev_wd, "\\s") == 0 || - strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0 + strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0 ) matches = completion_matches(text, filename_completion_function); @@ -1110,7 +1112,5 @@ dequote_file_name(char *text, char quote_char) return s; } - #endif /* 0 */ - #endif /* USE_READLINE */ diff --git a/src/bin/psql/tab-complete.h b/src/bin/psql/tab-complete.h index 81182eae534..7200fd6feb8 100644 --- a/src/bin/psql/tab-complete.h +++ b/src/bin/psql/tab-complete.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.6 2001/02/10 02:31:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.7 2001/10/25 05:49:54 momjian Exp $ */ #ifndef TAB_COMPLETE_H #define TAB_COMPLETE_H @@ -11,5 +11,4 @@ #include "postgres_fe.h" void initialize_readline(void); - #endif diff --git a/src/bin/psql/variables.h b/src/bin/psql/variables.h index 0814d71a9a4..8e96966f8e8 100644 --- a/src/bin/psql/variables.h +++ b/src/bin/psql/variables.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.8 2000/04/12 17:16:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.9 2001/10/25 05:49:54 momjian Exp $ */ /* @@ -36,5 +36,4 @@ bool SetVariableBool(VariableSpace space, const char *name); bool DeleteVariable(VariableSpace space, const char *name); void DestroyVariableSpace(VariableSpace space); - #endif /* VARIABLES_H */ |