diff options
Diffstat (limited to 'src/bin/pg_dump/dumputils.c')
-rw-r--r-- | src/bin/pg_dump/dumputils.c | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 267a8573ac0..aa999173b2b 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.19 2005/07/02 17:01:51 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.20 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,8 +49,8 @@ fmtId(const char *rawid) id_return = createPQExpBuffer(); /* - * These checks need to match the identifier production in scan.l. - * Don't use islower() etc. + * These checks need to match the identifier production in scan.l. Don't + * use islower() etc. */ if (ScanKeywordLookup(rawid)) @@ -111,14 +111,14 @@ fmtId(const char *rawid) void appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll) { - char ch; + char ch; const char *p; for (p = str; *p; p++) { ch = *p; if (ch == '\\' || - ((unsigned char)ch < (unsigned char)' ' && + ((unsigned char) ch < (unsigned char) ' ' && (escapeAll || (ch != '\t' && ch != '\n' && ch != '\v' && ch != '\f' && ch != '\r')))) @@ -127,7 +127,7 @@ appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll) break; } } - + appendPQExpBufferChar(buf, '\''); for (p = str; *p; p++) { @@ -137,14 +137,13 @@ appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll) appendPQExpBufferChar(buf, ch); appendPQExpBufferChar(buf, ch); } - else if ((unsigned char)ch < (unsigned char)' ' && + else if ((unsigned char) ch < (unsigned char) ' ' && (escapeAll || (ch != '\t' && ch != '\n' && ch != '\v' && ch != '\f' && ch != '\r'))) { /* - * generate octal escape for control chars other than - * whitespace + * generate octal escape for control chars other than whitespace */ appendPQExpBufferChar(buf, '\\'); appendPQExpBufferChar(buf, ((ch >> 6) & 3) + '0'); @@ -179,10 +178,9 @@ appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix) appendPQExpBufferStr(delimBuf, dqprefix); /* - * Make sure we choose a delimiter which (without the trailing $) is - * not present in the string being quoted. We don't check with the - * trailing $ because a string ending in $foo must not be quoted with - * $foo$. + * Make sure we choose a delimiter which (without the trailing $) is not + * present in the string being quoted. We don't check with the trailing $ + * because a string ending in $foo must not be quoted with $foo$. */ while (strstr(str, delimBuf->data) != NULL) { @@ -260,15 +258,13 @@ parsePGArray(const char *atext, char ***itemarray, int *nitems) /* * We expect input in the form of "{item,item,item}" where any item is - * either raw data, or surrounded by double quotes (in which case - * embedded characters including backslashes and quotes are - * backslashed). + * either raw data, or surrounded by double quotes (in which case embedded + * characters including backslashes and quotes are backslashed). * - * We build the result as an array of pointers followed by the actual - * string data, all in one malloc block for convenience of - * deallocation. The worst-case storage need is not more than one - * pointer and one character for each input character (consider - * "{,,,,,,,,,,}"). + * We build the result as an array of pointers followed by the actual string + * data, all in one malloc block for convenience of deallocation. The + * worst-case storage need is not more than one pointer and one character + * for each input character (consider "{,,,,,,,,,,}"). */ *itemarray = NULL; *nitems = 0; @@ -374,12 +370,11 @@ buildACLCommands(const char *name, const char *type, privswgo = createPQExpBuffer(); /* - * At the end, these two will be pasted together to form the result. - * But the owner privileges need to go before the other ones to keep - * the dependencies valid. In recent versions this is normally the - * case, but in old versions they come after the PUBLIC privileges and - * that results in problems if we need to run REVOKE on the owner - * privileges. + * At the end, these two will be pasted together to form the result. But + * the owner privileges need to go before the other ones to keep the + * dependencies valid. In recent versions this is normally the case, but + * in old versions they come after the PUBLIC privileges and that results + * in problems if we need to run REVOKE on the owner privileges. */ firstsql = createPQExpBuffer(); secondsql = createPQExpBuffer(); @@ -450,7 +445,7 @@ buildACLCommands(const char *name, const char *type, else if (strncmp(grantee->data, "group ", strlen("group ")) == 0) appendPQExpBuffer(secondsql, "GROUP %s;\n", - fmtId(grantee->data + strlen("group "))); + fmtId(grantee->data + strlen("group "))); else appendPQExpBuffer(secondsql, "%s;\n", fmtId(grantee->data)); } @@ -463,7 +458,7 @@ buildACLCommands(const char *name, const char *type, else if (strncmp(grantee->data, "group ", strlen("group ")) == 0) appendPQExpBuffer(secondsql, "GROUP %s", - fmtId(grantee->data + strlen("group "))); + fmtId(grantee->data + strlen("group "))); else appendPQExpBuffer(secondsql, "%s", fmtId(grantee->data)); appendPQExpBuffer(secondsql, " WITH GRANT OPTION;\n"); @@ -477,8 +472,7 @@ buildACLCommands(const char *name, const char *type, } /* - * If we didn't find any owner privs, the owner must have revoked 'em - * all + * If we didn't find any owner privs, the owner must have revoked 'em all */ if (!found_owner_privs && owner) { @@ -638,8 +632,7 @@ copyAclUserName(PQExpBuffer output, char *input) while (*input && *input != '=') { /* - * If user name isn't quoted, then just add it to the output - * buffer + * If user name isn't quoted, then just add it to the output buffer */ if (*input != '"') appendPQExpBufferChar(output, *input++); @@ -654,8 +647,8 @@ copyAclUserName(PQExpBuffer output, char *input) return input; /* really a syntax error... */ /* - * Quoting convention is to escape " as "". Keep this - * code in sync with putid() in backend's acl.c. + * Quoting convention is to escape " as "". Keep this code in + * sync with putid() in backend's acl.c. */ if (*input == '"' && *(input + 1) == '"') input++; |