1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-20 05:03:10 +03:00

Massive commit to run PGINDENT on all *.c and *.h files.

This commit is contained in:
Bruce Momjian
1997-09-07 05:04:48 +00:00
parent 8fecd4febf
commit 1ccd423235
687 changed files with 150775 additions and 136888 deletions

View File

@ -1,14 +1,14 @@
/*-------------------------------------------------------------------------
*
* scansup.c--
* support routines for the lex/flex scanner, used by both the normal
* support routines for the lex/flex scanner, used by both the normal
* backend as well as the bootstrap backend
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.5 1996/11/15 18:38:55 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.6 1997/09/07 04:44:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -24,12 +24,12 @@
#include "parser/scansup.h"
/* ----------------
* scanstr
*
* scanstr
*
* if the string passed in has escaped codes, map the escape codes to actual
* chars
*
* also, remove leading and ending quotes '"' if any
* also, remove leading and ending quotes '"' if any
*
* the string passed in must be non-null
*
@ -38,88 +38,95 @@
* ----------------
*/
char*
char *
scanstr(char *s)
{
static char newStr[MAX_PARSE_BUFFER];
int len, i, j;
if (s == NULL || s[0] == '\0')
return s;
static char newStr[MAX_PARSE_BUFFER];
int len,
i,
j;
len = strlen(s);
if (s == NULL || s[0] == '\0')
return s;
for (i = 0, j = 0; i < len ; i++) {
if (s[i] == '\'') {
i = i + 1;
if (s[i] == '\'')
newStr[j] = '\'';
len = strlen(s);
for (i = 0, j = 0; i < len; i++)
{
if (s[i] == '\'')
{
i = i + 1;
if (s[i] == '\'')
newStr[j] = '\'';
}
else
{
if (s[i] == '\\')
{
i = i + 1;
switch (s[i])
{
case '\\':
newStr[j] = '\\';
break;
case 'b':
newStr[j] = '\b';
break;
case 'f':
newStr[j] = '\f';
break;
case 'n':
newStr[j] = '\n';
break;
case 'r':
newStr[j] = '\r';
break;
case 't':
newStr[j] = '\t';
break;
case '"':
newStr[j] = '"';
break;
case '\'':
newStr[j] = '\'';
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{
char octal[4];
int k;
long octVal;
for (k = 0;
s[i + k] >= '0' && s[i + k] <= '7' && k < 3;
k++)
octal[k] = s[i + k];
i += k - 1;
octal[3] = '\0';
octVal = strtol(octal, 0, 8);
/* elog (NOTICE, "octal = %s octVal = %d, %od", octal, octVal, octVal);*/
if (octVal <= 0377)
{
newStr[j] = ((char) octVal);
break;
}
}
default:
newStr[j] = s[i];
} /* switch */
} /* s[i] == '\\' */
else
newStr[j] = s[i];
}
j++;
}
else {
if (s[i] == '\\') {
i = i + 1;
switch (s[i]) {
case '\\':
newStr[j] = '\\';
break;
case 'b':
newStr[j] = '\b';
break;
case 'f':
newStr[j] = '\f';
break;
case 'n':
newStr[j] = '\n';
break;
case 'r':
newStr[j] = '\r';
break;
case 't':
newStr[j] = '\t';
break;
case '"':
newStr[j] = '"';
break;
case '\'':
newStr[j] = '\'';
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{
char octal[4];
int k;
long octVal;
for (k=0;
s[i+k] >= '0' && s[i+k] <= '7' && k < 3;
k++)
octal[k] = s[i+k];
i += k-1;
octal[3] = '\0';
octVal = strtol(octal,0,8);
/* elog (NOTICE, "octal = %s octVal = %d, %od", octal, octVal, octVal);*/
if (octVal <= 0377) {
newStr[j] = ((char)octVal);
break;
}
}
default:
newStr[j] = s[i];
} /* switch */
} /* s[i] == '\\' */
else
newStr[j] = s[i];
}
j++;
}
newStr[j] = '\0';
return newStr;
newStr[j] = '\0';
return newStr;
}