mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting.
This commit is contained in:
@ -40,21 +40,21 @@
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/elog.h"
|
||||
|
||||
static int32
|
||||
static int32
|
||||
array_iterator(Oid elemtype, Oid proc, int and, ArrayType * array, Datum value)
|
||||
{
|
||||
HeapTuple typ_tuple;
|
||||
TypeTupleForm typ_struct;
|
||||
bool typbyval;
|
||||
int typlen;
|
||||
func_ptr proc_fn;
|
||||
int pronargs;
|
||||
int nitems,
|
||||
i,
|
||||
result;
|
||||
int ndim,
|
||||
*dim;
|
||||
char *p;
|
||||
HeapTuple typ_tuple;
|
||||
TypeTupleForm typ_struct;
|
||||
bool typbyval;
|
||||
int typlen;
|
||||
func_ptr proc_fn;
|
||||
int pronargs;
|
||||
int nitems,
|
||||
i,
|
||||
result;
|
||||
int ndim,
|
||||
*dim;
|
||||
char *p;
|
||||
|
||||
/* Sanity checks */
|
||||
if ((array == (ArrayType *) NULL)
|
||||
@ -101,16 +101,16 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType * array, Datum value)
|
||||
{
|
||||
switch (typlen)
|
||||
{
|
||||
case 1:
|
||||
result = (int) (*proc_fn) (*p, value);
|
||||
break;
|
||||
case 2:
|
||||
result = (int) (*proc_fn) (*(int16 *) p, value);
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
result = (int) (*proc_fn) (*(int32 *) p, value);
|
||||
break;
|
||||
case 1:
|
||||
result = (int) (*proc_fn) (*p, value);
|
||||
break;
|
||||
case 2:
|
||||
result = (int) (*proc_fn) (*(int16 *) p, value);
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
result = (int) (*proc_fn) (*(int32 *) p, value);
|
||||
break;
|
||||
}
|
||||
p += typlen;
|
||||
}
|
||||
|
@ -13,33 +13,34 @@
|
||||
#include "utils/datetime.h"
|
||||
|
||||
|
||||
TimeADT *
|
||||
TimeADT *
|
||||
time_difference(TimeADT * time1, TimeADT * time2)
|
||||
{
|
||||
TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT));
|
||||
TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT));
|
||||
|
||||
*result = *time1 - *time2;
|
||||
return (result);
|
||||
}
|
||||
|
||||
TimeADT *
|
||||
TimeADT *
|
||||
currenttime()
|
||||
{
|
||||
time_t current_time;
|
||||
struct tm *tm;
|
||||
TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT));
|
||||
time_t current_time;
|
||||
struct tm *tm;
|
||||
TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT));
|
||||
|
||||
current_time = time(NULL);
|
||||
tm = localtime(¤t_time);
|
||||
*result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec);
|
||||
return (result);
|
||||
}
|
||||
|
||||
DateADT
|
||||
currentdate()
|
||||
{
|
||||
time_t current_time;
|
||||
struct tm *tm;
|
||||
DateADT result;
|
||||
time_t current_time;
|
||||
struct tm *tm;
|
||||
DateADT result;
|
||||
|
||||
current_time = time(NULL);
|
||||
tm = localtime(¤t_time);
|
||||
@ -48,6 +49,7 @@ currentdate()
|
||||
date2j(100, 1, 1);
|
||||
return (result);
|
||||
}
|
||||
|
||||
int4
|
||||
hours(TimeADT * time)
|
||||
{
|
||||
@ -65,47 +67,52 @@ seconds(TimeADT * time)
|
||||
{
|
||||
return (((int) *time) % 60);
|
||||
}
|
||||
|
||||
int4
|
||||
day(DateADT * date)
|
||||
{
|
||||
struct tm tm;
|
||||
struct tm tm;
|
||||
|
||||
j2date((*date + date2j(2000, 1, 1)),
|
||||
&tm.tm_year, &tm.tm_mon, &tm.tm_mday);
|
||||
|
||||
return (tm.tm_mday);
|
||||
}
|
||||
|
||||
int4
|
||||
month(DateADT * date)
|
||||
{
|
||||
struct tm tm;
|
||||
struct tm tm;
|
||||
|
||||
j2date((*date + date2j(2000, 1, 1)),
|
||||
&tm.tm_year, &tm.tm_mon, &tm.tm_mday);
|
||||
|
||||
return (tm.tm_mon);
|
||||
}
|
||||
|
||||
int4
|
||||
year(DateADT * date)
|
||||
{
|
||||
struct tm tm;
|
||||
struct tm tm;
|
||||
|
||||
j2date((*date + date2j(2000, 1, 1)),
|
||||
&tm.tm_year, &tm.tm_mon, &tm.tm_mday);
|
||||
|
||||
return (tm.tm_year);
|
||||
}
|
||||
|
||||
int4
|
||||
asminutes(TimeADT * time)
|
||||
{
|
||||
int seconds = (int) *time;
|
||||
int seconds = (int) *time;
|
||||
|
||||
return (seconds / 60);
|
||||
}
|
||||
|
||||
int4
|
||||
asseconds(TimeADT * time)
|
||||
{
|
||||
int seconds = (int) *time;
|
||||
int seconds = (int) *time;
|
||||
|
||||
return (seconds);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_64BIT_INTS
|
||||
typedef char [8] int64;
|
||||
typedef char[8] int64;
|
||||
|
||||
#elif defined(__alpha)
|
||||
typedef long int int64;
|
||||
@ -44,40 +44,40 @@ typedef long int int64;
|
||||
#define INT64_FORMAT "%ld"
|
||||
#endif
|
||||
|
||||
int64 *int8in(char *str);
|
||||
char *int8out(int64 * val);
|
||||
int64 *int8in(char *str);
|
||||
char *int8out(int64 * val);
|
||||
|
||||
bool int8eq(int64 * val1, int64 * val2);
|
||||
bool int8ne(int64 * val1, int64 * val2);
|
||||
bool int8lt(int64 * val1, int64 * val2);
|
||||
bool int8gt(int64 * val1, int64 * val2);
|
||||
bool int8le(int64 * val1, int64 * val2);
|
||||
bool int8ge(int64 * val1, int64 * val2);
|
||||
bool int8eq(int64 * val1, int64 * val2);
|
||||
bool int8ne(int64 * val1, int64 * val2);
|
||||
bool int8lt(int64 * val1, int64 * val2);
|
||||
bool int8gt(int64 * val1, int64 * val2);
|
||||
bool int8le(int64 * val1, int64 * val2);
|
||||
bool int8ge(int64 * val1, int64 * val2);
|
||||
|
||||
bool int84eq(int64 * val1, int32 val2);
|
||||
bool int84ne(int64 * val1, int32 val2);
|
||||
bool int84lt(int64 * val1, int32 val2);
|
||||
bool int84gt(int64 * val1, int32 val2);
|
||||
bool int84le(int64 * val1, int32 val2);
|
||||
bool int84ge(int64 * val1, int32 val2);
|
||||
bool int84eq(int64 * val1, int32 val2);
|
||||
bool int84ne(int64 * val1, int32 val2);
|
||||
bool int84lt(int64 * val1, int32 val2);
|
||||
bool int84gt(int64 * val1, int32 val2);
|
||||
bool int84le(int64 * val1, int32 val2);
|
||||
bool int84ge(int64 * val1, int32 val2);
|
||||
|
||||
int64 *int8um(int64 * val);
|
||||
int64 *int8pl(int64 * val1, int64 * val2);
|
||||
int64 *int8mi(int64 * val1, int64 * val2);
|
||||
int64 *int8mul(int64 * val1, int64 * val2);
|
||||
int64 *int8div(int64 * val1, int64 * val2);
|
||||
int64 *int8um(int64 * val);
|
||||
int64 *int8pl(int64 * val1, int64 * val2);
|
||||
int64 *int8mi(int64 * val1, int64 * val2);
|
||||
int64 *int8mul(int64 * val1, int64 * val2);
|
||||
int64 *int8div(int64 * val1, int64 * val2);
|
||||
|
||||
int64 *int48(int32 val);
|
||||
int32 int84(int64 * val);
|
||||
int64 *int48(int32 val);
|
||||
int32 int84(int64 * val);
|
||||
|
||||
#if FALSE
|
||||
int64 *int28(int16 val);
|
||||
int16 int82(int64 * val);
|
||||
int64 *int28(int16 val);
|
||||
int16 int82(int64 * val);
|
||||
|
||||
#endif
|
||||
|
||||
float64 i8tod(int64 * val);
|
||||
int64 *dtoi8(float64 val);
|
||||
float64 i8tod(int64 * val);
|
||||
int64 *dtoi8(float64 val);
|
||||
|
||||
#if USE_LOCAL_CODE
|
||||
|
||||
@ -103,10 +103,10 @@ int64 *dtoi8(float64 val);
|
||||
|
||||
/* int8in()
|
||||
*/
|
||||
int64 *
|
||||
int64 *
|
||||
int8in(char *str)
|
||||
{
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
|
||||
#if HAVE_64BIT_INTS
|
||||
if (!PointerIsValid(str))
|
||||
@ -126,13 +126,13 @@ int8in(char *str)
|
||||
|
||||
/* int8out()
|
||||
*/
|
||||
char *
|
||||
char *
|
||||
int8out(int64 * val)
|
||||
{
|
||||
char *result;
|
||||
char *result;
|
||||
|
||||
int len;
|
||||
char buf[MAXINT8LEN + 1];
|
||||
int len;
|
||||
char buf[MAXINT8LEN + 1];
|
||||
|
||||
#if HAVE_64BIT_INTS
|
||||
if (!PointerIsValid(val))
|
||||
@ -242,10 +242,10 @@ int84ge(int64 * val1, int32 val2)
|
||||
* Arithmetic operators on 64-bit integers.
|
||||
*---------------------------------------------------------*/
|
||||
|
||||
int64 *
|
||||
int64 *
|
||||
int8um(int64 * val)
|
||||
{
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
|
||||
if (!PointerIsValid(val))
|
||||
return NULL;
|
||||
@ -255,10 +255,10 @@ int8um(int64 * val)
|
||||
return (result);
|
||||
} /* int8um() */
|
||||
|
||||
int64 *
|
||||
int64 *
|
||||
int8pl(int64 * val1, int64 * val2)
|
||||
{
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
|
||||
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
||||
return NULL;
|
||||
@ -268,10 +268,10 @@ int8pl(int64 * val1, int64 * val2)
|
||||
return (result);
|
||||
} /* int8pl() */
|
||||
|
||||
int64 *
|
||||
int64 *
|
||||
int8mi(int64 * val1, int64 * val2)
|
||||
{
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
|
||||
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
||||
return NULL;
|
||||
@ -281,10 +281,10 @@ int8mi(int64 * val1, int64 * val2)
|
||||
return (result);
|
||||
} /* int8mi() */
|
||||
|
||||
int64 *
|
||||
int64 *
|
||||
int8mul(int64 * val1, int64 * val2)
|
||||
{
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
|
||||
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
||||
return NULL;
|
||||
@ -294,10 +294,10 @@ int8mul(int64 * val1, int64 * val2)
|
||||
return (result);
|
||||
} /* int8mul() */
|
||||
|
||||
int64 *
|
||||
int64 *
|
||||
int8div(int64 * val1, int64 * val2)
|
||||
{
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
|
||||
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
|
||||
return NULL;
|
||||
@ -312,10 +312,10 @@ int8div(int64 * val1, int64 * val2)
|
||||
* Conversion operators.
|
||||
*---------------------------------------------------------*/
|
||||
|
||||
int64 *
|
||||
int64 *
|
||||
int48(int32 val)
|
||||
{
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
|
||||
*result = val;
|
||||
|
||||
@ -325,7 +325,7 @@ int48(int32 val)
|
||||
int32
|
||||
int84(int64 * val)
|
||||
{
|
||||
int32 result;
|
||||
int32 result;
|
||||
|
||||
if (!PointerIsValid(val))
|
||||
elog(WARN, "Invalid (null) int64, can't convert int8 to int4", NULL);
|
||||
@ -339,10 +339,10 @@ int84(int64 * val)
|
||||
} /* int84() */
|
||||
|
||||
#if FALSE
|
||||
int64 *
|
||||
int64 *
|
||||
int28(int16 val)
|
||||
{
|
||||
int64 *result;
|
||||
int64 *result;
|
||||
|
||||
if (!PointerIsValid(result = PALLOCTYPE(int64)))
|
||||
elog(WARN, "Memory allocation failed, can't convert int8 to int2", NULL);
|
||||
@ -355,7 +355,7 @@ int28(int16 val)
|
||||
int16
|
||||
int82(int64 * val)
|
||||
{
|
||||
int16 result;
|
||||
int16 result;
|
||||
|
||||
if (!PointerIsValid(val))
|
||||
elog(WARN, "Invalid (null) int8, can't convert to int2", NULL);
|
||||
@ -370,17 +370,17 @@ int82(int64 * val)
|
||||
float64
|
||||
i8tod(int64 * val)
|
||||
{
|
||||
float64 result = PALLOCTYPE(float64data);
|
||||
float64 result = PALLOCTYPE(float64data);
|
||||
|
||||
*result = *val;
|
||||
|
||||
return (result);
|
||||
} /* i8tod() */
|
||||
|
||||
int64 *
|
||||
int64 *
|
||||
dtoi8(float64 val)
|
||||
{
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
int64 *result = PALLOCTYPE(int64);
|
||||
|
||||
if ((*val < (-pow(2, 64) + 1)) || (*val > (pow(2, 64) - 1)))
|
||||
elog(WARN, "Floating point conversion to int64 is out of range", NULL);
|
||||
|
@ -24,10 +24,10 @@ void
|
||||
halt(va_alist)
|
||||
va_dcl
|
||||
{
|
||||
va_list arg_ptr;
|
||||
char *format,
|
||||
*pstr;
|
||||
void (*sig_func) ();
|
||||
va_list arg_ptr;
|
||||
char *format,
|
||||
*pstr;
|
||||
void (*sig_func) ();
|
||||
|
||||
va_start(arg_ptr);
|
||||
format = va_arg(arg_ptr, char *);
|
||||
|
@ -3,4 +3,4 @@
|
||||
**
|
||||
*/
|
||||
|
||||
void halt();
|
||||
void halt();
|
||||
|
@ -13,17 +13,17 @@
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char query[4000];
|
||||
int row = 1;
|
||||
int aint;
|
||||
float afloat;
|
||||
double adouble;
|
||||
char achar[11],
|
||||
achar16[17],
|
||||
abpchar[11],
|
||||
avarchar[51],
|
||||
atext[51];
|
||||
time_t aabstime;
|
||||
char query[4000];
|
||||
int row = 1;
|
||||
int aint;
|
||||
float afloat;
|
||||
double adouble;
|
||||
char achar[11],
|
||||
achar16[17],
|
||||
abpchar[11],
|
||||
avarchar[51],
|
||||
atext[51];
|
||||
time_t aabstime;
|
||||
|
||||
if (argc != 2)
|
||||
halt("Usage: %s database\n", argv[0]);
|
||||
|
@ -12,31 +12,31 @@
|
||||
#include "halt.h"
|
||||
#include "pginterface.h"
|
||||
|
||||
static void sig_disconnect();
|
||||
static void set_signals();
|
||||
static void sig_disconnect();
|
||||
static void set_signals();
|
||||
|
||||
#define NUL '\0'
|
||||
|
||||
/* GLOBAL VARIABLES */
|
||||
static PGconn *conn;
|
||||
static PGconn *conn;
|
||||
static PGresult *res = NULL;
|
||||
|
||||
#define ON_ERROR_STOP 0
|
||||
#define ON_ERROR_CONTINUE 1
|
||||
|
||||
static int on_error_state = ON_ERROR_STOP;
|
||||
static int on_error_state = ON_ERROR_STOP;
|
||||
|
||||
/* LOCAL VARIABLES */
|
||||
static sigset_t block_sigs,
|
||||
unblock_sigs;
|
||||
static int tuple;
|
||||
unblock_sigs;
|
||||
static int tuple;
|
||||
|
||||
/*
|
||||
**
|
||||
** connectdb - returns PGconn structure
|
||||
**
|
||||
*/
|
||||
PGconn *
|
||||
PGconn *
|
||||
connectdb(char *dbName,
|
||||
char *pghost,
|
||||
char *pgport,
|
||||
@ -68,7 +68,7 @@ disconnectdb()
|
||||
** doquery - returns PGresult structure
|
||||
**
|
||||
*/
|
||||
PGresult *
|
||||
PGresult *
|
||||
doquery(char *query)
|
||||
{
|
||||
if (res != NULL)
|
||||
@ -104,9 +104,9 @@ doquery(char *query)
|
||||
int
|
||||
fetch(void *param,...)
|
||||
{
|
||||
va_list ap;
|
||||
int arg,
|
||||
num_fields;
|
||||
va_list ap;
|
||||
int arg,
|
||||
num_fields;
|
||||
|
||||
num_fields = PQnfields(res);
|
||||
|
||||
@ -142,9 +142,9 @@ fetch(void *param,...)
|
||||
int
|
||||
fetchwithnulls(void *param,...)
|
||||
{
|
||||
va_list ap;
|
||||
int arg,
|
||||
num_fields;
|
||||
va_list ap;
|
||||
int arg,
|
||||
num_fields;
|
||||
|
||||
num_fields = PQnfields(res);
|
||||
|
||||
|
@ -3,12 +3,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
PGresult *doquery(char *query);
|
||||
PGconn *connectdb();
|
||||
void disconnectdb();
|
||||
int fetch(void *param,...);
|
||||
int fetchwithnulls(void *param,...);
|
||||
void on_error_continue();
|
||||
void on_error_stop();
|
||||
PGresult *doquery(char *query);
|
||||
PGconn *connectdb();
|
||||
void disconnectdb();
|
||||
int fetch(void *param,...);
|
||||
int fetchwithnulls(void *param,...);
|
||||
void on_error_continue();
|
||||
void on_error_stop();
|
||||
|
||||
#define END_OF_TUPLES (-1)
|
||||
|
@ -15,26 +15,26 @@
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char query[4000];
|
||||
int row = 1;
|
||||
int aint;
|
||||
float afloat;
|
||||
double adouble;
|
||||
char achar[11],
|
||||
achar16[17],
|
||||
abpchar[11],
|
||||
avarchar[51],
|
||||
atext[51];
|
||||
time_t aabstime;
|
||||
int aint_null,
|
||||
afloat_null,
|
||||
adouble_null,
|
||||
achar_null,
|
||||
achar16_null,
|
||||
abpchar_null,
|
||||
avarchar_null,
|
||||
atext_null,
|
||||
aabstime_null;
|
||||
char query[4000];
|
||||
int row = 1;
|
||||
int aint;
|
||||
float afloat;
|
||||
double adouble;
|
||||
char achar[11],
|
||||
achar16[17],
|
||||
abpchar[11],
|
||||
avarchar[51],
|
||||
atext[51];
|
||||
time_t aabstime;
|
||||
int aint_null,
|
||||
afloat_null,
|
||||
adouble_null,
|
||||
achar_null,
|
||||
achar16_null,
|
||||
abpchar_null,
|
||||
avarchar_null,
|
||||
atext_null,
|
||||
aabstime_null;
|
||||
|
||||
if (argc != 2)
|
||||
halt("Usage: %s database\n", argv[0]);
|
||||
|
@ -13,10 +13,10 @@
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char query[4000];
|
||||
int row = 0;
|
||||
int count;
|
||||
char line[4000];
|
||||
char query[4000];
|
||||
int row = 0;
|
||||
int count;
|
||||
char line[4000];
|
||||
|
||||
if (argc != 2)
|
||||
halt("Usage: %s database\n", argv[0]);
|
||||
|
@ -11,18 +11,18 @@
|
||||
#include <ctype.h>
|
||||
|
||||
/* prototype for soundex function */
|
||||
char *soundex(char *instr, char *outstr);
|
||||
char *soundex(char *instr, char *outstr);
|
||||
|
||||
text *
|
||||
text *
|
||||
text_soundex(text * t)
|
||||
{
|
||||
/* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
|
||||
char *table = "01230120022455012623010202";
|
||||
int count = 0;
|
||||
text *new_t;
|
||||
char *table = "01230120022455012623010202";
|
||||
int count = 0;
|
||||
text *new_t;
|
||||
|
||||
char outstr[6 + 1]; /* max length of soundex is 6 */
|
||||
char *instr;
|
||||
char outstr[6 + 1]; /* max length of soundex is 6 */
|
||||
char *instr;
|
||||
|
||||
/* make a null-terminated string */
|
||||
instr = palloc(VARSIZE(t) + 1);
|
||||
@ -47,11 +47,11 @@ text_soundex(text * t)
|
||||
return (new_t);
|
||||
}
|
||||
|
||||
char *
|
||||
char *
|
||||
soundex(char *instr, char *outstr)
|
||||
{ /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
|
||||
char *table = "01230120022455012623010202";
|
||||
int count = 0;
|
||||
char *table = "01230120022455012623010202";
|
||||
int count = 0;
|
||||
|
||||
while (!isalpha(instr[0]) && instr[0])
|
||||
++instr;
|
||||
|
@ -45,15 +45,15 @@
|
||||
* representation of data.
|
||||
*/
|
||||
|
||||
char *
|
||||
char *
|
||||
string_output(char *data, int size)
|
||||
{
|
||||
register unsigned char c,
|
||||
*p,
|
||||
*r,
|
||||
*result;
|
||||
register int l,
|
||||
len;
|
||||
*p,
|
||||
*r,
|
||||
*result;
|
||||
register int l,
|
||||
len;
|
||||
|
||||
if (data == NULL)
|
||||
{
|
||||
@ -74,23 +74,23 @@ string_output(char *data, int size)
|
||||
{
|
||||
switch (*p)
|
||||
{
|
||||
case '\\':
|
||||
case '"':
|
||||
case '{':
|
||||
case '}':
|
||||
case '\b':
|
||||
case '\f':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\t':
|
||||
case '\v':
|
||||
len++;
|
||||
break;
|
||||
default:
|
||||
if (NOTPRINTABLE(*p))
|
||||
{
|
||||
len += 3;
|
||||
}
|
||||
case '\\':
|
||||
case '"':
|
||||
case '{':
|
||||
case '}':
|
||||
case '\b':
|
||||
case '\f':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\t':
|
||||
case '\v':
|
||||
len++;
|
||||
break;
|
||||
default:
|
||||
if (NOTPRINTABLE(*p))
|
||||
{
|
||||
len += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
len++;
|
||||
@ -101,53 +101,53 @@ string_output(char *data, int size)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '\\':
|
||||
case '"':
|
||||
case '{':
|
||||
case '}':
|
||||
*r++ = '\\';
|
||||
*r++ = c;
|
||||
break;
|
||||
case '\b':
|
||||
*r++ = '\\';
|
||||
*r++ = 'b';
|
||||
break;
|
||||
case '\f':
|
||||
*r++ = '\\';
|
||||
*r++ = 'f';
|
||||
break;
|
||||
case '\n':
|
||||
*r++ = '\\';
|
||||
*r++ = 'n';
|
||||
break;
|
||||
case '\r':
|
||||
*r++ = '\\';
|
||||
*r++ = 'r';
|
||||
break;
|
||||
case '\t':
|
||||
*r++ = '\\';
|
||||
*r++ = 't';
|
||||
break;
|
||||
case '\v':
|
||||
*r++ = '\\';
|
||||
*r++ = 'v';
|
||||
break;
|
||||
default:
|
||||
if (NOTPRINTABLE(c))
|
||||
{
|
||||
*r = '\\';
|
||||
r += 3;
|
||||
*r-- = DIGIT(c & 07);
|
||||
c >>= 3;
|
||||
*r-- = DIGIT(c & 07);
|
||||
c >>= 3;
|
||||
*r = DIGIT(c & 03);
|
||||
r += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
case '\\':
|
||||
case '"':
|
||||
case '{':
|
||||
case '}':
|
||||
*r++ = '\\';
|
||||
*r++ = c;
|
||||
}
|
||||
break;
|
||||
case '\b':
|
||||
*r++ = '\\';
|
||||
*r++ = 'b';
|
||||
break;
|
||||
case '\f':
|
||||
*r++ = '\\';
|
||||
*r++ = 'f';
|
||||
break;
|
||||
case '\n':
|
||||
*r++ = '\\';
|
||||
*r++ = 'n';
|
||||
break;
|
||||
case '\r':
|
||||
*r++ = '\\';
|
||||
*r++ = 'r';
|
||||
break;
|
||||
case '\t':
|
||||
*r++ = '\\';
|
||||
*r++ = 't';
|
||||
break;
|
||||
case '\v':
|
||||
*r++ = '\\';
|
||||
*r++ = 'v';
|
||||
break;
|
||||
default:
|
||||
if (NOTPRINTABLE(c))
|
||||
{
|
||||
*r = '\\';
|
||||
r += 3;
|
||||
*r-- = DIGIT(c & 07);
|
||||
c >>= 3;
|
||||
*r-- = DIGIT(c & 07);
|
||||
c >>= 3;
|
||||
*r = DIGIT(c & 03);
|
||||
r += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
*r++ = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
*r = '\0';
|
||||
@ -181,13 +181,13 @@ string_output(char *data, int size)
|
||||
* a pointer to the new string or the header.
|
||||
*/
|
||||
|
||||
char *
|
||||
char *
|
||||
string_input(char *str, int size, int hdrsize, int *rtn_size)
|
||||
{
|
||||
register unsigned char *p,
|
||||
*r;
|
||||
unsigned char *result;
|
||||
int len;
|
||||
*r;
|
||||
unsigned char *result;
|
||||
int len;
|
||||
|
||||
if ((str == NULL) || (hdrsize < 0))
|
||||
{
|
||||
@ -247,48 +247,48 @@ string_input(char *str, int size, int hdrsize, int *rtn_size)
|
||||
{
|
||||
switch (c = *p++)
|
||||
{
|
||||
case '\0':
|
||||
p--;
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
c = VALUE(c);
|
||||
if (isdigit(*p))
|
||||
{
|
||||
c = (c << 3) + VALUE(*p++);
|
||||
}
|
||||
if (isdigit(*p))
|
||||
{
|
||||
c = (c << 3) + VALUE(*p++);
|
||||
}
|
||||
*r++ = c;
|
||||
break;
|
||||
case 'b':
|
||||
*r++ = '\b';
|
||||
break;
|
||||
case 'f':
|
||||
*r++ = '\f';
|
||||
break;
|
||||
case 'n':
|
||||
*r++ = '\n';
|
||||
break;
|
||||
case 'r':
|
||||
*r++ = '\r';
|
||||
break;
|
||||
case 't':
|
||||
*r++ = '\t';
|
||||
break;
|
||||
case 'v':
|
||||
*r++ = '\v';
|
||||
break;
|
||||
default:
|
||||
*r++ = c;
|
||||
case '\0':
|
||||
p--;
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
c = VALUE(c);
|
||||
if (isdigit(*p))
|
||||
{
|
||||
c = (c << 3) + VALUE(*p++);
|
||||
}
|
||||
if (isdigit(*p))
|
||||
{
|
||||
c = (c << 3) + VALUE(*p++);
|
||||
}
|
||||
*r++ = c;
|
||||
break;
|
||||
case 'b':
|
||||
*r++ = '\b';
|
||||
break;
|
||||
case 'f':
|
||||
*r++ = '\f';
|
||||
break;
|
||||
case 'n':
|
||||
*r++ = '\n';
|
||||
break;
|
||||
case 'r':
|
||||
*r++ = '\r';
|
||||
break;
|
||||
case 't':
|
||||
*r++ = '\t';
|
||||
break;
|
||||
case 'v':
|
||||
*r++ = '\v';
|
||||
break;
|
||||
default:
|
||||
*r++ = c;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -300,10 +300,10 @@ string_input(char *str, int size, int hdrsize, int *rtn_size)
|
||||
return ((char *) result);
|
||||
}
|
||||
|
||||
char *
|
||||
char *
|
||||
c_charout(int32 c)
|
||||
{
|
||||
char str[2];
|
||||
char str[2];
|
||||
|
||||
str[0] = (char) c;
|
||||
str[1] = '\0';
|
||||
@ -311,25 +311,25 @@ c_charout(int32 c)
|
||||
return (string_output(str, 1));
|
||||
}
|
||||
|
||||
char *
|
||||
char *
|
||||
c_char2out(uint16 s)
|
||||
{
|
||||
return (string_output((char *) &s, 2));
|
||||
}
|
||||
|
||||
char *
|
||||
char *
|
||||
c_char4out(uint32 s)
|
||||
{
|
||||
return (string_output((char *) &s, 4));
|
||||
}
|
||||
|
||||
char *
|
||||
char *
|
||||
c_char8out(char *s)
|
||||
{
|
||||
return (string_output(s, 8));
|
||||
}
|
||||
|
||||
char *
|
||||
char *
|
||||
c_char16out(char *s)
|
||||
{
|
||||
return (string_output(s, 16));
|
||||
@ -339,11 +339,11 @@ c_char16out(char *s)
|
||||
* This can be used for text, bytea, SET and unknown data types
|
||||
*/
|
||||
|
||||
char *
|
||||
char *
|
||||
c_textout(struct varlena * vlena)
|
||||
{
|
||||
int len = 0;
|
||||
char *s = NULL;
|
||||
int len = 0;
|
||||
char *s = NULL;
|
||||
|
||||
if (vlena)
|
||||
{
|
||||
@ -357,10 +357,10 @@ c_textout(struct varlena * vlena)
|
||||
* This can be used for varchar and bpchar strings
|
||||
*/
|
||||
|
||||
char *
|
||||
char *
|
||||
c_varcharout(char *s)
|
||||
{
|
||||
int len;
|
||||
int len;
|
||||
|
||||
if (s)
|
||||
{
|
||||
@ -375,7 +375,7 @@ struct varlena *
|
||||
c_textin(char *str)
|
||||
{
|
||||
struct varlena *result;
|
||||
int len;
|
||||
int len;
|
||||
|
||||
if (str == NULL)
|
||||
{
|
||||
@ -388,7 +388,7 @@ c_textin(char *str)
|
||||
return (result);
|
||||
}
|
||||
|
||||
char *
|
||||
char *
|
||||
c_char16in(char *str)
|
||||
{
|
||||
return (string_input(str, 16, 0, NULL));
|
||||
|
Reference in New Issue
Block a user