Commit 8a65b820 authored by Tom Lane's avatar Tom Lane

Suppress signed-vs-unsigned-char warnings in contrib.

parent 88896855
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
/* open a dbf-file, get it's field-info and store this information */ /* open a dbf-file, get it's field-info and store this information */
dbhead * dbhead *
dbf_open(u_char *file, int flags) dbf_open(char *file, int flags)
{ {
int file_no; int file_no;
dbhead *dbh; dbhead *dbh;
...@@ -200,7 +200,7 @@ dbf_put_fields(dbhead * dbh) ...@@ -200,7 +200,7 @@ dbf_put_fields(dbhead * dbh)
} }
int int
dbf_add_field(dbhead * dbh, u_char *name, u_char type, dbf_add_field(dbhead * dbh, char *name, u_char type,
u_char length, u_char dec) u_char length, u_char dec)
{ {
f_descr *ptr; f_descr *ptr;
...@@ -232,7 +232,7 @@ dbf_add_field(dbhead * dbh, u_char *name, u_char type, ...@@ -232,7 +232,7 @@ dbf_add_field(dbhead * dbh, u_char *name, u_char type,
} }
dbhead * dbhead *
dbf_open_new(u_char *name, int flags) dbf_open_new(char *name, int flags)
{ {
dbhead *dbh; dbhead *dbh;
...@@ -339,7 +339,7 @@ dbf_get_record(dbhead * dbh, field * fields, u_long rec) ...@@ -339,7 +339,7 @@ dbf_get_record(dbhead * dbh, field * fields, u_long rec)
end--; end--;
i--; i--;
} }
strncpy(fields[t].db_contents, dbffield, i); strncpy((char *) fields[t].db_contents, (char *) dbffield, i);
fields[t].db_contents[i] = '\0'; fields[t].db_contents[i] = '\0';
} }
else else
...@@ -351,7 +351,7 @@ dbf_get_record(dbhead * dbh, field * fields, u_long rec) ...@@ -351,7 +351,7 @@ dbf_get_record(dbhead * dbh, field * fields, u_long rec)
end++; end++;
i--; i--;
} }
strncpy(fields[t].db_contents, end, i); strncpy((char *) fields[t].db_contents, (char *) end, i);
fields[t].db_contents[i] = '\0'; fields[t].db_contents[i] = '\0';
} }
...@@ -419,7 +419,7 @@ dbf_put_record(dbhead * dbh, field * rec, u_long where) ...@@ -419,7 +419,7 @@ dbf_put_record(dbhead * dbh, field * rec, u_long where)
u_char *data, u_char *data,
end = 0x1a; end = 0x1a;
double fl; double fl;
u_char foo[128], char foo[128],
format[32]; format[32];
/* offset: offset in file for this record /* offset: offset in file for this record
...@@ -473,11 +473,12 @@ dbf_put_record(dbhead * dbh, field * rec, u_long where) ...@@ -473,11 +473,12 @@ dbf_put_record(dbhead * dbh, field * rec, u_long where)
/* Handle text */ /* Handle text */
if (rec[t].db_type == 'C') if (rec[t].db_type == 'C')
{ {
if (strlen(rec[t].db_contents) > rec[t].db_flen) if (strlen((char *) rec[t].db_contents) > rec[t].db_flen)
length = rec[t].db_flen; length = rec[t].db_flen;
else else
length = strlen(rec[t].db_contents); length = strlen((char *) rec[t].db_contents);
strncpy(data + idx, rec[t].db_contents, length); strncpy((char *) data + idx, (char *) rec[t].db_contents,
length);
} }
else else
{ {
...@@ -485,18 +486,18 @@ dbf_put_record(dbhead * dbh, field * rec, u_long where) ...@@ -485,18 +486,18 @@ dbf_put_record(dbhead * dbh, field * rec, u_long where)
/* Numeric is special, because of real numbers */ /* Numeric is special, because of real numbers */
if ((rec[t].db_type == 'N') && (rec[t].db_dec != 0)) if ((rec[t].db_type == 'N') && (rec[t].db_dec != 0))
{ {
fl = atof(rec[t].db_contents); fl = atof((char *) rec[t].db_contents);
snprintf(format, 32, "%%.%df", rec[t].db_dec); snprintf(format, 32, "%%.%df", rec[t].db_dec);
snprintf(foo, 128, format, fl); snprintf(foo, 128, format, fl);
} }
else else
strncpy(foo, rec[t].db_contents, 128); strncpy(foo, (char *) rec[t].db_contents, 128);
if (strlen(foo) > rec[t].db_flen) if (strlen(foo) > rec[t].db_flen)
length = rec[t].db_flen; length = rec[t].db_flen;
else else
length = strlen(foo); length = strlen(foo);
h = rec[t].db_flen - length; h = rec[t].db_flen - length;
strncpy(data + idx + h, foo, length); strncpy((char *) (data + idx + h), foo, length);
} }
} }
idx += rec[t].db_flen; idx += rec[t].db_flen;
......
...@@ -60,7 +60,7 @@ typedef struct ...@@ -60,7 +60,7 @@ typedef struct
typedef struct typedef struct
{ {
u_char dbf_name[DBF_NAMELEN]; /* field-name terminated with \0 */ char dbf_name[DBF_NAMELEN]; /* field-name terminated with \0 */
u_char dbf_type; /* field-type */ u_char dbf_type; /* field-type */
u_char dbf_reserved[4]; /* some reserved stuff */ u_char dbf_reserved[4]; /* some reserved stuff */
u_char dbf_flen; /* field-length */ u_char dbf_flen; /* field-length */
...@@ -73,7 +73,7 @@ typedef struct ...@@ -73,7 +73,7 @@ typedef struct
typedef struct typedef struct
{ {
u_char db_name[DBF_NAMELEN]; /* field-name terminated with \0 */ char db_name[DBF_NAMELEN]; /* field-name terminated with \0 */
u_char db_type; /* field-type */ u_char db_type; /* field-type */
u_char db_flen; /* field-length */ u_char db_flen; /* field-length */
u_char db_dec; /* number of decimal positions */ u_char db_dec; /* number of decimal positions */
...@@ -107,7 +107,7 @@ typedef struct ...@@ -107,7 +107,7 @@ typedef struct
typedef struct typedef struct
{ {
u_char db_name[DBF_NAMELEN]; /* field-name terminated with \0 */ char db_name[DBF_NAMELEN]; /* field-name terminated with \0 */
u_char db_type; /* field-type */ u_char db_type; /* field-type */
u_char db_flen; /* field-length */ u_char db_flen; /* field-length */
u_char db_dec; /* number of decimal positions */ u_char db_dec; /* number of decimal positions */
...@@ -116,12 +116,12 @@ typedef struct ...@@ -116,12 +116,12 @@ typedef struct
/* prototypes for functions */ /* prototypes for functions */
extern dbhead *dbf_open(u_char *file, int flags); extern dbhead *dbf_open(char *file, int flags);
extern int dbf_write_head(dbhead * dbh); extern int dbf_write_head(dbhead * dbh);
extern int dbf_put_fields(dbhead * dbh); extern int dbf_put_fields(dbhead * dbh);
extern int dbf_add_field(dbhead * dbh, u_char *name, u_char type, extern int dbf_add_field(dbhead * dbh, char *name, u_char type,
u_char length, u_char dec); u_char length, u_char dec);
extern dbhead *dbf_open_new(u_char *name, int flags); extern dbhead *dbf_open_new(char *name, int flags);
extern void dbf_close(dbhead * dbh); extern void dbf_close(dbhead * dbh);
extern int dbf_get_record(dbhead * dbh, field * fields, u_long rec); extern int dbf_get_record(dbhead * dbh, field * fields, u_long rec);
extern field *dbf_build_record(dbhead * dbh); extern field *dbf_build_record(dbhead * dbh);
......
...@@ -434,11 +434,11 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh) ...@@ -434,11 +434,11 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh)
* separator */ * separator */
if (upper) if (upper)
strtoupper(fields[h].db_contents); strtoupper((char *) fields[h].db_contents);
if (lower) if (lower)
strtolower(fields[h].db_contents); strtolower((char *) fields[h].db_contents);
foo = fields[h].db_contents; foo = (char *) fields[h].db_contents;
#ifdef HAVE_ICONV_H #ifdef HAVE_ICONV_H
if (charset_from) if (charset_from)
foo = convert_charset(foo); foo = convert_charset(foo);
......
...@@ -469,7 +469,7 @@ lquery_in(PG_FUNCTION_ARGS) ...@@ -469,7 +469,7 @@ lquery_in(PG_FUNCTION_ARGS)
cur->totallen += MAXALIGN(LVAR_HDRSIZE + lptr->len); cur->totallen += MAXALIGN(LVAR_HDRSIZE + lptr->len);
lrptr->len = lptr->len; lrptr->len = lptr->len;
lrptr->flag = lptr->flag; lrptr->flag = lptr->flag;
lrptr->val = ltree_crc32_sz((uint8 *) lptr->start, lptr->len); lrptr->val = ltree_crc32_sz(lptr->start, lptr->len);
memcpy(lrptr->name, lptr->start, lptr->len); memcpy(lrptr->name, lptr->start, lptr->len);
lptr++; lptr++;
lrptr = LVAR_NEXT(lrptr); lrptr = LVAR_NEXT(lrptr);
......
...@@ -171,7 +171,7 @@ pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, uint16 flag ...@@ -171,7 +171,7 @@ pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, uint16 flag
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("word is too long"))); errmsg("word is too long")));
pushquery(state, type, ltree_crc32_sz((uint8 *) strval, lenval), pushquery(state, type, ltree_crc32_sz(strval, lenval),
state->curop - state->op, lenval, flag); state->curop - state->op, lenval, flag);
while (state->curop - state->op + lenval + 1 >= state->lenop) while (state->curop - state->op + lenval + 1 >= state->lenop)
......
...@@ -651,9 +651,9 @@ px_crypt_des(const char *key, const char *setting) ...@@ -651,9 +651,9 @@ px_crypt_des(const char *key, const char *setting)
r0, r0,
r1, r1,
keybuf[2]; keybuf[2];
uint8 *p, char *p;
*q; uint8 *q;
static uint8 output[21]; static char output[21];
if (!des_initialised) if (!des_initialised)
des_init(); des_init();
...@@ -669,7 +669,7 @@ px_crypt_des(const char *key, const char *setting) ...@@ -669,7 +669,7 @@ px_crypt_des(const char *key, const char *setting)
if ((*q++ = *key << 1)) if ((*q++ = *key << 1))
key++; key++;
} }
if (des_setkey((uint8 *) keybuf)) if (des_setkey((char *) keybuf))
return (NULL); return (NULL);
#ifndef DISABLE_XDES #ifndef DISABLE_XDES
...@@ -690,7 +690,7 @@ px_crypt_des(const char *key, const char *setting) ...@@ -690,7 +690,7 @@ px_crypt_des(const char *key, const char *setting)
/* /*
* Encrypt the key with itself. * Encrypt the key with itself.
*/ */
if (des_cipher((uint8 *) keybuf, (uint8 *) keybuf, 0L, 1)) if (des_cipher((char *) keybuf, (char *) keybuf, 0L, 1))
return (NULL); return (NULL);
/* /*
...@@ -700,7 +700,7 @@ px_crypt_des(const char *key, const char *setting) ...@@ -700,7 +700,7 @@ px_crypt_des(const char *key, const char *setting)
while (q - (uint8 *) keybuf - 8 && *key) while (q - (uint8 *) keybuf - 8 && *key)
*q++ ^= *key++ << 1; *q++ ^= *key++ << 1;
if (des_setkey((uint8 *) keybuf)) if (des_setkey((char *) keybuf))
return (NULL); return (NULL);
} }
strncpy(output, setting, 9); strncpy(output, setting, 9);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* $FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.5 1999/12/17 20:21:45 peter Exp $ * $FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.5 1999/12/17 20:21:45 peter Exp $
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/crypt-md5.c,v 1.4 2005/07/11 15:07:59 tgl Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-md5.c,v 1.5 2005/09/24 19:14:04 tgl Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -63,18 +63,18 @@ px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen) ...@@ -63,18 +63,18 @@ px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen)
err = px_find_digest("md5", &ctx1); err = px_find_digest("md5", &ctx1);
/* The password first, since that is what is most unknown */ /* The password first, since that is what is most unknown */
px_md_update(ctx, pw, strlen(pw)); px_md_update(ctx, (uint8 *) pw, strlen(pw));
/* Then our magic string */ /* Then our magic string */
px_md_update(ctx, magic, strlen(magic)); px_md_update(ctx, (uint8 *) magic, strlen(magic));
/* Then the raw salt */ /* Then the raw salt */
px_md_update(ctx, sp, sl); px_md_update(ctx, (uint8 *) sp, sl);
/* Then just as many characters of the MD5(pw,salt,pw) */ /* Then just as many characters of the MD5(pw,salt,pw) */
px_md_update(ctx1, pw, strlen(pw)); px_md_update(ctx1, (uint8 *) pw, strlen(pw));
px_md_update(ctx1, sp, sl); px_md_update(ctx1, (uint8 *) sp, sl);
px_md_update(ctx1, pw, strlen(pw)); px_md_update(ctx1, (uint8 *) pw, strlen(pw));
px_md_finish(ctx1, final); px_md_finish(ctx1, final);
for (pl = strlen(pw); pl > 0; pl -= MD5_SIZE) for (pl = strlen(pw); pl > 0; pl -= MD5_SIZE)
px_md_update(ctx, final, pl > MD5_SIZE ? MD5_SIZE : pl); px_md_update(ctx, final, pl > MD5_SIZE ? MD5_SIZE : pl);
...@@ -87,7 +87,7 @@ px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen) ...@@ -87,7 +87,7 @@ px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen)
if (i & 1) if (i & 1)
px_md_update(ctx, final, 1); px_md_update(ctx, final, 1);
else else
px_md_update(ctx, pw, 1); px_md_update(ctx, (uint8 *) pw, 1);
/* Now make the output string */ /* Now make the output string */
strcpy(passwd, magic); strcpy(passwd, magic);
...@@ -105,20 +105,20 @@ px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen) ...@@ -105,20 +105,20 @@ px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen)
{ {
px_md_reset(ctx1); px_md_reset(ctx1);
if (i & 1) if (i & 1)
px_md_update(ctx1, pw, strlen(pw)); px_md_update(ctx1, (uint8 *) pw, strlen(pw));
else else
px_md_update(ctx1, final, MD5_SIZE); px_md_update(ctx1, final, MD5_SIZE);
if (i % 3) if (i % 3)
px_md_update(ctx1, sp, sl); px_md_update(ctx1, (uint8 *) sp, sl);
if (i % 7) if (i % 7)
px_md_update(ctx1, pw, strlen(pw)); px_md_update(ctx1, (uint8 *) pw, strlen(pw));
if (i & 1) if (i & 1)
px_md_update(ctx1, final, MD5_SIZE); px_md_update(ctx1, final, MD5_SIZE);
else else
px_md_update(ctx1, pw, strlen(pw)); px_md_update(ctx1, (uint8 *) pw, strlen(pw));
px_md_finish(ctx1, final); px_md_finish(ctx1, final);
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.18 2005/03/21 05:19:55 neilc Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.19 2005/09/24 19:14:04 tgl Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -75,8 +75,8 @@ pg_digest(PG_FUNCTION_ARGS) ...@@ -75,8 +75,8 @@ pg_digest(PG_FUNCTION_ARGS)
arg = PG_GETARG_BYTEA_P(0); arg = PG_GETARG_BYTEA_P(0);
len = VARSIZE(arg) - VARHDRSZ; len = VARSIZE(arg) - VARHDRSZ;
px_md_update(md, VARDATA(arg), len); px_md_update(md, (uint8 *) VARDATA(arg), len);
px_md_finish(md, VARDATA(res)); px_md_finish(md, (uint8 *) VARDATA(res));
px_md_free(md); px_md_free(md);
PG_FREE_IF_COPY(arg, 0); PG_FREE_IF_COPY(arg, 0);
...@@ -144,9 +144,9 @@ pg_hmac(PG_FUNCTION_ARGS) ...@@ -144,9 +144,9 @@ pg_hmac(PG_FUNCTION_ARGS)
len = VARSIZE(arg) - VARHDRSZ; len = VARSIZE(arg) - VARHDRSZ;
klen = VARSIZE(key) - VARHDRSZ; klen = VARSIZE(key) - VARHDRSZ;
px_hmac_init(h, VARDATA(key), klen); px_hmac_init(h, (uint8 *) VARDATA(key), klen);
px_hmac_update(h, VARDATA(arg), len); px_hmac_update(h, (uint8 *) VARDATA(arg), len);
px_hmac_finish(h, VARDATA(res)); px_hmac_finish(h, (uint8 *) VARDATA(res));
px_hmac_free(h); px_hmac_free(h);
PG_FREE_IF_COPY(arg, 0); PG_FREE_IF_COPY(arg, 0);
...@@ -346,9 +346,10 @@ pg_encrypt(PG_FUNCTION_ARGS) ...@@ -346,9 +346,10 @@ pg_encrypt(PG_FUNCTION_ARGS)
rlen = px_combo_encrypt_len(c, dlen); rlen = px_combo_encrypt_len(c, dlen);
res = palloc(VARHDRSZ + rlen); res = palloc(VARHDRSZ + rlen);
err = px_combo_init(c, VARDATA(key), klen, NULL, 0); err = px_combo_init(c, (uint8 *) VARDATA(key), klen, NULL, 0);
if (!err) if (!err)
err = px_combo_encrypt(c, VARDATA(data), dlen, VARDATA(res), &rlen); err = px_combo_encrypt(c, (uint8 *) VARDATA(data), dlen,
(uint8 *) VARDATA(res), &rlen);
px_combo_free(c); px_combo_free(c);
PG_FREE_IF_COPY(data, 0); PG_FREE_IF_COPY(data, 0);
...@@ -397,9 +398,10 @@ pg_decrypt(PG_FUNCTION_ARGS) ...@@ -397,9 +398,10 @@ pg_decrypt(PG_FUNCTION_ARGS)
rlen = px_combo_decrypt_len(c, dlen); rlen = px_combo_decrypt_len(c, dlen);
res = palloc(VARHDRSZ + rlen); res = palloc(VARHDRSZ + rlen);
err = px_combo_init(c, VARDATA(key), klen, NULL, 0); err = px_combo_init(c, (uint8 *) VARDATA(key), klen, NULL, 0);
if (!err) if (!err)
err = px_combo_decrypt(c, VARDATA(data), dlen, VARDATA(res), &rlen); err = px_combo_decrypt(c, (uint8 *) VARDATA(data), dlen,
(uint8 *) VARDATA(res), &rlen);
px_combo_free(c); px_combo_free(c);
...@@ -452,9 +454,11 @@ pg_encrypt_iv(PG_FUNCTION_ARGS) ...@@ -452,9 +454,11 @@ pg_encrypt_iv(PG_FUNCTION_ARGS)
rlen = px_combo_encrypt_len(c, dlen); rlen = px_combo_encrypt_len(c, dlen);
res = palloc(VARHDRSZ + rlen); res = palloc(VARHDRSZ + rlen);
err = px_combo_init(c, VARDATA(key), klen, VARDATA(iv), ivlen); err = px_combo_init(c, (uint8 *) VARDATA(key), klen,
(uint8 *) VARDATA(iv), ivlen);
if (!err) if (!err)
px_combo_encrypt(c, VARDATA(data), dlen, VARDATA(res), &rlen); px_combo_encrypt(c, (uint8 *) VARDATA(data), dlen,
(uint8 *) VARDATA(res), &rlen);
px_combo_free(c); px_combo_free(c);
...@@ -508,9 +512,11 @@ pg_decrypt_iv(PG_FUNCTION_ARGS) ...@@ -508,9 +512,11 @@ pg_decrypt_iv(PG_FUNCTION_ARGS)
rlen = px_combo_decrypt_len(c, dlen); rlen = px_combo_decrypt_len(c, dlen);
res = palloc(VARHDRSZ + rlen); res = palloc(VARHDRSZ + rlen);
err = px_combo_init(c, VARDATA(key), klen, VARDATA(iv), ivlen); err = px_combo_init(c, (uint8 *) VARDATA(key), klen,
(uint8 *) VARDATA(iv), ivlen);
if (!err) if (!err)
px_combo_decrypt(c, VARDATA(data), dlen, VARDATA(res), &rlen); px_combo_decrypt(c, (uint8 *) VARDATA(data), dlen,
(uint8 *) VARDATA(res), &rlen);
px_combo_free(c); px_combo_free(c);
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.4 2005/07/18 17:09:01 tgl Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.5 2005/09/24 19:14:04 tgl Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -792,7 +792,7 @@ parse_literal_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt) ...@@ -792,7 +792,7 @@ parse_literal_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt)
break; break;
} }
if (res >= 0 && got_cr) if (res >= 0 && got_cr)
res = mbuf_append(dst, "\r", 1); res = mbuf_append(dst, (const uint8 *) "\r", 1);
return res; return res;
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.4 2005/08/13 02:06:20 momjian Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.5 2005/09/24 19:14:04 tgl Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -94,7 +94,7 @@ static void add_block_entropy(PX_MD *md, text *data) ...@@ -94,7 +94,7 @@ static void add_block_entropy(PX_MD *md, text *data)
uint8 sha1[20]; uint8 sha1[20];
px_md_reset(md); px_md_reset(md);
px_md_update(md, VARDATA(data), VARSIZE(data) - VARHDRSZ); px_md_update(md, (uint8 *) VARDATA(data), VARSIZE(data) - VARHDRSZ);
px_md_finish(md, sha1); px_md_finish(md, sha1);
px_add_entropy(sha1, 20); px_add_entropy(sha1, 20);
...@@ -151,14 +151,14 @@ static text *convert_charset(text *src, int cset_from, int cset_to) ...@@ -151,14 +151,14 @@ static text *convert_charset(text *src, int cset_from, int cset_to)
int src_len = VARSIZE(src) - VARHDRSZ; int src_len = VARSIZE(src) - VARHDRSZ;
int dst_len; int dst_len;
unsigned char *dst; unsigned char *dst;
unsigned char *csrc = VARDATA(src); unsigned char *csrc = (unsigned char *) VARDATA(src);
text *res; text *res;
dst = pg_do_encoding_conversion(csrc, src_len, cset_from, cset_to); dst = pg_do_encoding_conversion(csrc, src_len, cset_from, cset_to);
if (dst == csrc) if (dst == csrc)
return src; return src;
dst_len = strlen(dst); dst_len = strlen((char *) dst);
res = palloc(dst_len + VARHDRSZ); res = palloc(dst_len + VARHDRSZ);
memcpy(VARDATA(res), dst, dst_len); memcpy(VARDATA(res), dst, dst_len);
VARATT_SIZEP(res) = VARHDRSZ + dst_len; VARATT_SIZEP(res) = VARHDRSZ + dst_len;
...@@ -398,7 +398,8 @@ static int parse_args(PGP_Context *ctx, uint8 *args, int arg_len, ...@@ -398,7 +398,8 @@ static int parse_args(PGP_Context *ctx, uint8 *args, int arg_len,
static MBuf * static MBuf *
create_mbuf_from_vardata(text *data) create_mbuf_from_vardata(text *data)
{ {
return mbuf_create_from_data(VARDATA(data), VARSIZE(data) - VARHDRSZ); return mbuf_create_from_data((uint8 *) VARDATA(data),
VARSIZE(data) - VARHDRSZ);
} }
static void static void
...@@ -410,7 +411,8 @@ init_work(PGP_Context **ctx_p, int is_text, ...@@ -410,7 +411,8 @@ init_work(PGP_Context **ctx_p, int is_text,
fill_expect(ex, is_text); fill_expect(ex, is_text);
if (err == 0 && args != NULL) if (err == 0 && args != NULL)
err = parse_args(*ctx_p, VARDATA(args), VARSIZE(args) - VARHDRSZ, ex); err = parse_args(*ctx_p, (uint8 *) VARDATA(args),
VARSIZE(args) - VARHDRSZ, ex);
if (err) if (err)
{ {
...@@ -474,7 +476,8 @@ encrypt_internal(int is_pubenc, int is_text, ...@@ -474,7 +476,8 @@ encrypt_internal(int is_pubenc, int is_text,
mbuf_free(kbuf); mbuf_free(kbuf);
} }
else else
err = pgp_set_symkey(ctx, VARDATA(key), VARSIZE(key) - VARHDRSZ); err = pgp_set_symkey(ctx, (uint8 *) VARDATA(key),
VARSIZE(key) - VARHDRSZ);
/* /*
* encrypt * encrypt
...@@ -532,7 +535,8 @@ decrypt_internal(int is_pubenc, int need_text, text *data, ...@@ -532,7 +535,8 @@ decrypt_internal(int is_pubenc, int need_text, text *data,
init_work(&ctx, need_text, args, &ex); init_work(&ctx, need_text, args, &ex);
src = mbuf_create_from_data(VARDATA(data), VARSIZE(data) - VARHDRSZ); src = mbuf_create_from_data((uint8 *) VARDATA(data),
VARSIZE(data) - VARHDRSZ);
dst = mbuf_create(VARSIZE(data) + 2048); dst = mbuf_create(VARSIZE(data) + 2048);
/* /*
...@@ -550,7 +554,7 @@ decrypt_internal(int is_pubenc, int need_text, text *data, ...@@ -550,7 +554,7 @@ decrypt_internal(int is_pubenc, int need_text, text *data,
MBuf *kbuf; MBuf *kbuf;
if (keypsw) if (keypsw)
{ {
psw = VARDATA(keypsw); psw = (uint8 *) VARDATA(keypsw);
psw_len = VARSIZE(keypsw) - VARHDRSZ; psw_len = VARSIZE(keypsw) - VARHDRSZ;
} }
kbuf = create_mbuf_from_vardata(key); kbuf = create_mbuf_from_vardata(key);
...@@ -558,7 +562,8 @@ decrypt_internal(int is_pubenc, int need_text, text *data, ...@@ -558,7 +562,8 @@ decrypt_internal(int is_pubenc, int need_text, text *data,
mbuf_free(kbuf); mbuf_free(kbuf);
} }
else else
err = pgp_set_symkey(ctx, VARDATA(key), VARSIZE(key) - VARHDRSZ); err = pgp_set_symkey(ctx, (uint8 *) VARDATA(key),
VARSIZE(key) - VARHDRSZ);
/* /*
* decrypt * decrypt
...@@ -846,7 +851,8 @@ pg_armor(PG_FUNCTION_ARGS) ...@@ -846,7 +851,8 @@ pg_armor(PG_FUNCTION_ARGS)
guess_len = pgp_armor_enc_len(data_len); guess_len = pgp_armor_enc_len(data_len);
res = palloc(VARHDRSZ + guess_len); res = palloc(VARHDRSZ + guess_len);
res_len = pgp_armor_encode(VARDATA(data), data_len, VARDATA(res)); res_len = pgp_armor_encode((uint8 *) VARDATA(data), data_len,
(uint8 *) VARDATA(res));
if (res_len > guess_len) if (res_len > guess_len)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
...@@ -875,7 +881,8 @@ pg_dearmor(PG_FUNCTION_ARGS) ...@@ -875,7 +881,8 @@ pg_dearmor(PG_FUNCTION_ARGS)
guess_len = pgp_armor_dec_len(data_len); guess_len = pgp_armor_dec_len(data_len);
res = palloc(VARHDRSZ + guess_len); res = palloc(VARHDRSZ + guess_len);
res_len = pgp_armor_decode(VARDATA(data), data_len, VARDATA(res)); res_len = pgp_armor_decode((uint8 *) VARDATA(data), data_len,
(uint8 *) VARDATA(res));
if (res_len < 0) if (res_len < 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.13 2005/08/13 02:06:20 momjian Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.14 2005/09/24 19:14:04 tgl Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -152,7 +152,7 @@ px_gen_salt(const char *salt_type, char *buf, int rounds) ...@@ -152,7 +152,7 @@ px_gen_salt(const char *salt_type, char *buf, int rounds)
return PXE_BAD_SALT_ROUNDS; return PXE_BAD_SALT_ROUNDS;
} }
res = px_get_pseudo_random_bytes(rbuf, g->input_len); res = px_get_pseudo_random_bytes((uint8 *) rbuf, g->input_len);
if (res < 0) if (res < 0)
return res; return res;
......
...@@ -111,7 +111,7 @@ snb_lexize(PG_FUNCTION_ARGS) ...@@ -111,7 +111,7 @@ snb_lexize(PG_FUNCTION_ARGS)
} }
else else
{ {
SN_set_current(d->z, strlen(txt), txt); SN_set_current(d->z, strlen(txt), (symbol *) txt);
(d->stem) (d->z); (d->stem) (d->z);
if (d->z->p && d->z->l) if (d->z->p && d->z->l)
{ {
......
...@@ -156,7 +156,7 @@ gtsvector_compress(PG_FUNCTION_ARGS) ...@@ -156,7 +156,7 @@ gtsvector_compress(PG_FUNCTION_ARGS)
len = val->size; len = val->size;
while (len--) while (len--)
{ {
*arr = crc32_sz((uint8 *) &words[ptr->pos], ptr->len); *arr = crc32_sz(&words[ptr->pos], ptr->len);
arr++; arr++;
ptr++; ptr++;
} }
......
...@@ -52,12 +52,12 @@ strnduplicate(char *s, int len) ...@@ -52,12 +52,12 @@ strnduplicate(char *s, int len)
return d; return d;
} }
/* backward string compaire for suffix tree operations */ /* backward string compare for suffix tree operations */
static int static int
strbcmp(const unsigned char *s1, const unsigned char *s2) strbcmp(const unsigned char *s1, const unsigned char *s2)
{ {
int l1 = strlen(s1) - 1, int l1 = strlen((const char *) s1) - 1,
l2 = strlen(s2) - 1; l2 = strlen((const char *) s2) - 1;
while (l1 >= 0 && l2 >= 0) while (l1 >= 0 && l2 >= 0)
{ {
...@@ -78,8 +78,8 @@ strbcmp(const unsigned char *s1, const unsigned char *s2) ...@@ -78,8 +78,8 @@ strbcmp(const unsigned char *s1, const unsigned char *s2)
static int static int
strbncmp(const unsigned char *s1, const unsigned char *s2, size_t count) strbncmp(const unsigned char *s1, const unsigned char *s2, size_t count)
{ {
int l1 = strlen(s1) - 1, int l1 = strlen((const char *) s1) - 1,
l2 = strlen(s2) - 1, l2 = strlen((const char *) s2) - 1,
l = count; l = count;
while (l1 >= 0 && l2 >= 0 && l > 0) while (l1 >= 0 && l2 >= 0 && l > 0)
...@@ -104,14 +104,18 @@ strbncmp(const unsigned char *s1, const unsigned char *s2, size_t count) ...@@ -104,14 +104,18 @@ strbncmp(const unsigned char *s1, const unsigned char *s2, size_t count)
static int static int
cmpaffix(const void *s1, const void *s2) cmpaffix(const void *s1, const void *s2)
{ {
if (((const AFFIX *) s1)->type < ((const AFFIX *) s2)->type) const AFFIX *a1 = (const AFFIX *) s1;
const AFFIX *a2 = (const AFFIX *) s2;
if (a1->type < a2->type)
return -1; return -1;
if (((const AFFIX *) s1)->type > ((const AFFIX *) s2)->type) if (a1->type > a2->type)
return 1; return 1;
if (((const AFFIX *) s1)->type == FF_PREFIX) if (a1->type == FF_PREFIX)
return (strcmp(((const AFFIX *) s1)->repl, ((const AFFIX *) s2)->repl)); return strcmp(a1->repl, a2->repl);
else else
return (strbcmp(((const AFFIX *) s1)->repl, ((const AFFIX *) s2)->repl)); return strbcmp((const unsigned char *) a1->repl,
(const unsigned char *) a2->repl);
} }
int int
...@@ -142,29 +146,29 @@ NIAddSpell(IspellDict * Conf, const char *word, const char *flag) ...@@ -142,29 +146,29 @@ NIAddSpell(IspellDict * Conf, const char *word, const char *flag)
int int
NIImportDictionary(IspellDict * Conf, const char *filename) NIImportDictionary(IspellDict * Conf, const char *filename)
{ {
unsigned char str[BUFSIZ]; char str[BUFSIZ];
FILE *dict; FILE *dict;
if (!(dict = fopen(filename, "r"))) if (!(dict = fopen(filename, "r")))
return (1); return (1);
while (fgets(str, sizeof(str), dict)) while (fgets(str, sizeof(str), dict))
{ {
unsigned char *s; char *s;
const unsigned char *flag; const char *flag;
flag = NULL; flag = NULL;
if ((s = strchr(str, '/'))) if ((s = strchr(str, '/')))
{ {
*s = 0; *s++ = '\0';
s++;
flag = s; flag = s;
while (*s) while (*s)
{ {
if (isprint(*s) && !isspace(*s)) if (isprint((unsigned char) *s) &&
!isspace((unsigned char) *s))
s++; s++;
else else
{ {
*s = 0; *s = '\0';
break; break;
} }
} }
...@@ -177,10 +181,8 @@ NIImportDictionary(IspellDict * Conf, const char *filename) ...@@ -177,10 +181,8 @@ NIImportDictionary(IspellDict * Conf, const char *filename)
s = str; s = str;
while (*s) while (*s)
{ {
if (*s == '\r') if (*s == '\r' || *s == '\n')
*s = 0; *s = '\0';
if (*s == '\n')
*s = 0;
s++; s++;
} }
NIAddSpell(Conf, str, flag); NIAddSpell(Conf, str, flag);
...@@ -311,16 +313,16 @@ remove_spaces(char *dist, char *src) ...@@ -311,16 +313,16 @@ remove_spaces(char *dist, char *src)
int int
NIImportAffixes(IspellDict * Conf, const char *filename) NIImportAffixes(IspellDict * Conf, const char *filename)
{ {
unsigned char str[BUFSIZ]; char str[BUFSIZ];
unsigned char flag = 0; char mask[BUFSIZ];
unsigned char mask[BUFSIZ] = ""; char find[BUFSIZ];
unsigned char find[BUFSIZ] = ""; char repl[BUFSIZ];
unsigned char repl[BUFSIZ] = ""; char *s;
unsigned char *s;
int i; int i;
int suffixes = 0; int suffixes = 0;
int prefixes = 0; int prefixes = 0;
unsigned char flagflags = 0; int flag = 0;
char flagflags = 0;
FILE *affix; FILE *affix;
if (!(affix = fopen(filename, "r"))) if (!(affix = fopen(filename, "r")))
...@@ -374,7 +376,7 @@ NIImportAffixes(IspellDict * Conf, const char *filename) ...@@ -374,7 +376,7 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
if (*s == '\\') if (*s == '\\')
s++; s++;
flag = *s; flag = (unsigned char) *s;
continue; continue;
} }
if ((!suffixes) && (!prefixes)) if ((!suffixes) && (!prefixes))
...@@ -409,7 +411,7 @@ NIImportAffixes(IspellDict * Conf, const char *filename) ...@@ -409,7 +411,7 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
continue; continue;
} }
NIAddAffix(Conf, (int) flag, (char) flagflags, mask, find, repl, suffixes ? FF_SUFFIX : FF_PREFIX); NIAddAffix(Conf, flag, flagflags, mask, find, repl, suffixes ? FF_SUFFIX : FF_PREFIX);
} }
fclose(affix); fclose(affix);
...@@ -681,7 +683,10 @@ NISortAffixes(IspellDict * Conf) ...@@ -681,7 +683,10 @@ NISortAffixes(IspellDict * Conf)
firstsuffix = i; firstsuffix = i;
if (Affix->flagflags & FF_COMPOUNDONLYAFX) if (Affix->flagflags & FF_COMPOUNDONLYAFX)
{ {
if (!ptr->affix || strbncmp((ptr - 1)->affix, Affix->repl, (ptr - 1)->len)) if (!ptr->affix ||
strbncmp((const unsigned char *) (ptr - 1)->affix,
(const unsigned char *) Affix->repl,
(ptr - 1)->len))
{ {
/* leave only unique and minimals suffixes */ /* leave only unique and minimals suffixes */
ptr->affix = Affix->repl; ptr->affix = Affix->repl;
......
...@@ -238,7 +238,7 @@ pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, int2 weight ...@@ -238,7 +238,7 @@ pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, int2 weight
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("word is too long"))); errmsg("word is too long")));
pushquery(state, type, crc32_sz((uint8 *) strval, lenval), pushquery(state, type, crc32_sz(strval, lenval),
state->curop - state->op, lenval, weight); state->curop - state->op, lenval, weight);
while (state->curop - state->op + lenval + 1 >= state->lenop) while (state->curop - state->op + lenval + 1 >= state->lenop)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment