aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2001-09-09 16:09:19 +0000
committerWerner Koch <[email protected]>2001-09-09 16:09:19 +0000
commitd4cd7a3d4bea0bd549b405d89563252d8de95363 (patch)
tree23648971c9dc3386283a74d1218e659417feee9d
parentLast changes before 1.0.6a snapshot release (diff)
downloadgnupg-d4cd7a3d4bea0bd549b405d89563252d8de95363.tar.gz
gnupg-d4cd7a3d4bea0bd549b405d89563252d8de95363.zip
more bug fixesand some warning cleanups
-rw-r--r--ChangeLog10
-rw-r--r--THANKS1
-rw-r--r--TODO4
-rw-r--r--cipher/ChangeLog4
-rw-r--r--cipher/random.c2
-rw-r--r--cipher/rsa.c12
-rw-r--r--configure.ac8
-rw-r--r--g10/ChangeLog20
-rw-r--r--g10/getkey.c3
-rw-r--r--g10/keyedit.c2
-rw-r--r--g10/keygen.c46
-rw-r--r--g10/keylist.c6
-rw-r--r--g10/keyring.c2
-rw-r--r--g10/keyring.obin56784 -> 56848 bytes
-rw-r--r--g10/misc.c17
-rw-r--r--g10/parse-packet.c4
-rw-r--r--g10/passphrase.c2
-rw-r--r--g10/pubkey-enc.c4
-rw-r--r--g10/sign.c16
-rw-r--r--include/ChangeLog4
-rw-r--r--include/util.h3
-rw-r--r--util/ChangeLog4
-rw-r--r--util/strgutil.c51
23 files changed, 164 insertions, 61 deletions
diff --git a/ChangeLog b/ChangeLog
index e2ae693fd..1441f180d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2001-09-09 Werner Koch <[email protected]>
+
+ * configure.ac: autoconf changed the name of the maintainer mode
+ flag, so that not all warnings where enabled. Fixed that.
+ Reported by Dirk Meyer.
+
+2001-09-07 Werner Koch <[email protected]>
+
+ * configure.ac: Test for strsep().
+
2001-09-03 Werner Koch <[email protected]>
* configure.ac: Removed GDBM tests.
diff --git a/THANKS b/THANKS
index 2af6975d4..ee7a0ad4c 100644
--- a/THANKS
+++ b/THANKS
@@ -41,6 +41,7 @@ David R. Bergstein [email protected]
Detlef Lannert [email protected]
Dirk Lattermann [email protected]
+Dirk Meyer [email protected]
Edmund GRIMLEY EVANS [email protected]
Edwin Woudt [email protected]
diff --git a/TODO b/TODO
index 078262c63..66a1c43c3 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,8 @@
+ * 12345678! does not work anymore
+
+ * Always use the primary key to sign other keys.
+
* add listing of notation data
* Check the changes to the gpg random gatherer on all W32 platforms.
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index dd20e1e2d..9174d424b 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,7 @@
+2001-09-09 Werner Koch <[email protected]>
+
+ * rsa.c (rsa_get_info): s/usage/r_usage/ to avoid shadow warnings.
+
2001-08-24 Werner Koch <[email protected]>
* md.c (md_write): Made buf arg const.
diff --git a/cipher/random.c b/cipher/random.c
index cdbd0b700..30c94b5b9 100644
--- a/cipher/random.c
+++ b/cipher/random.c
@@ -296,7 +296,7 @@ set_random_seed_file( const char *name )
* and return true if this was successful
*/
static int
-read_seed_file()
+read_seed_file(void)
{
int fd;
struct stat sb;
diff --git a/cipher/rsa.c b/cipher/rsa.c
index 9e6343f4f..c7078ea1d 100644
--- a/cipher/rsa.c
+++ b/cipher/rsa.c
@@ -446,7 +446,7 @@ rsa_get_nbits( int algo, MPI *pkey )
*/
const char *
rsa_get_info( int algo,
- int *npkey, int *nskey, int *nenc, int *nsig, int *usage )
+ int *npkey, int *nskey, int *nenc, int *nsig, int *r_usage )
{
*npkey = 2;
*nskey = 6;
@@ -454,10 +454,12 @@ rsa_get_info( int algo,
*nsig = 1;
switch( algo ) {
- case 1: *usage = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC; return "RSA";
- case 2: *usage = PUBKEY_USAGE_ENC; return "RSA-E";
- case 3: *usage = PUBKEY_USAGE_SIG; return "RSA-S";
- default:*usage = 0; return NULL;
+ case 1: *r_usage = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC; return "RSA";
+ case 2: *r_usage = PUBKEY_USAGE_ENC; return "RSA-E";
+ case 3: *r_usage = PUBKEY_USAGE_SIG; return "RSA-S";
+ default:*r_usage = 0; return NULL;
}
}
+
+
diff --git a/configure.ac b/configure.ac
index 608bdbdbe..814fe22e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@ dnl (Process this file with autoconf to produce a configure script.)
AC_REVISION($Revision$)dnl
AC_PREREQ(2.52)
-AC_INIT(gnupg,1.0.6a)
+AC_INIT(gnupg,1.0.6b)
AC_CONFIG_SRCDIR(g10/g10.c)
AC_CONFIG_AUX_DIR(scripts)
AC_CONFIG_HEADERS(config.h)
@@ -449,10 +449,10 @@ fi
dnl Checks for library functions.
AC_FUNC_FSEEKO
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(strerror stpcpy strlwr stricmp tcgetattr rand strtoul mmap)
+AC_CHECK_FUNCS(strerror stpcpy strsep strlwr stricmp tcgetattr strtoul mmap)
AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime)
AC_CHECK_FUNCS(memicmp atexit raise getpagesize strftime nl_langinfo)
-AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask)
+AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask rand)
#
# check for gethrtime and run a testprogram to see whether
@@ -794,7 +794,7 @@ esac
if test "$GCC" = yes; then
- if test "$MAINTAINER_MODE" = "yes"; then
+ if test "$USE_MAINTAINER_MODE" = "yes"; then
CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
else
CFLAGS="$CFLAGS -Wall"
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 0345c7f00..e12c6b2a8 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,23 @@
+2001-09-09 Werner Koch <[email protected]>
+
+ * keyedit.c (keyedit_menu): No need to define another p.
+
+ * keylist.c (print_capabilities): s/used/use/ so that it
+ does not shadow a global.
+ * sign.c (sign_file): Renamed arg encrypt to encryptflag
+ * keygen.c: Replaced all "usage" by "use".
+ * misc.c (openpgp_pk_algo_usage): Ditto.
+
+ * pubkey-enc.c (get_it): Renamed arg k to enc so that the later
+ defined k does not shadow it.
+
+ * parse-packet.c (parse_gpg_control): No need to define another i.
+
+ * getkey.c (get_pubkey_byfprint): Must use the enum values and not
+ the fprint_len.
+ * keyring.c (keyring_search): Removed a non-sense break. Both
+ bugs pointed out by Stefan.
+
2001-09-07 Werner Koch <[email protected]>
* status.c, status.h: Added NO_RECP and ALREADY_SIGNED.
diff --git a/g10/getkey.c b/g10/getkey.c
index 31ace1703..d514ad0f7 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -911,7 +911,8 @@ get_pubkey_byfprint( PKT_public_key *pk,
ctx.not_allocated = 1;
ctx.kr_handle = keydb_new (0);
ctx.nitems = 1;
- ctx.items[0].mode = fprint_len;
+ ctx.items[0].mode = fprint_len==16? KEYDB_SEARCH_MODE_FPR16
+ : KEYDB_SEARCH_MODE_FPR20;
memcpy( ctx.items[0].u.fpr, fprint, fprint_len );
rc = lookup( &ctx, &kb, 0 );
if (!rc && pk )
diff --git a/g10/keyedit.c b/g10/keyedit.c
index d1cc9da38..87a971bf7 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -955,7 +955,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands,
case cmdUPDPREF:
{
- char *p = keygen_get_std_prefs ();
+ p = keygen_get_std_prefs ();
tty_printf (("Current preference list: %s\n"), p);
m_free (p);
}
diff --git a/g10/keygen.c b/g10/keygen.c
index e7614bc52..a6a2104f4 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -124,17 +124,17 @@ write_uid( KBNODE root, const char *s )
}
static void
-do_add_key_flags (PKT_signature *sig, unsigned int usage)
+do_add_key_flags (PKT_signature *sig, unsigned int use)
{
byte buf[1];
- if (!usage)
+ if (!use)
return;
buf[0] = 0;
- if (usage & PUBKEY_USAGE_SIG)
+ if (use & PUBKEY_USAGE_SIG)
buf[0] |= 0x01 | 0x02;
- if (usage & PUBKEY_USAGE_ENC)
+ if (use & PUBKEY_USAGE_ENC)
buf[0] |= 0x04 | 0x08;
build_sig_subpkt (sig, SIGSUBPKT_KEY_FLAGS, buf, 1);
}
@@ -292,7 +292,7 @@ add_feature_mdc (PKT_signature *sig)
return; /* already set */
if (!s || !n) { /* create a new one */
n = 1;
- buf = m_alloc (n);
+ buf = m_alloc_clear (n);
}
else {
buf = m_alloc (n);
@@ -358,7 +358,7 @@ keygen_add_std_prefs( PKT_signature *sig, void *opaque )
static int
write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
- unsigned int usage )
+ unsigned int use )
{
PACKET *pkt;
PKT_signature *sig;
@@ -380,7 +380,7 @@ write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
if( !node )
BUG();
pk = node->pkt->pkt.public_key;
- pk->pubkey_usage = usage;
+ pk->pubkey_usage = use;
/* we have to cache the key, so that the verification of the signature
* creation is able to retrieve the public key */
cache_public_key (pk);
@@ -402,7 +402,7 @@ write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
static int
write_keybinding( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
- unsigned int usage )
+ unsigned int use )
{
PACKET *pkt;
PKT_signature *sig;
@@ -433,7 +433,7 @@ write_keybinding( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
BUG();
/* and make the signature */
- oduap.usage = usage;
+ oduap.usage = use;
oduap.pk = subpk;
rc = make_keysig_packet( &sig, pk, NULL, subpk, sk, 0x18, 0, 0,
keygen_add_key_flags_and_expire, &oduap );
@@ -1296,26 +1296,26 @@ parse_parameter_usage (const char *fname,
{
struct para_data_s *r = get_parameter( para, key );
char *p, *pn;
- unsigned int usage;
+ unsigned int use;
if( !r )
return 0; /* none (this is an optional parameter)*/
- usage = 0;
+ use = 0;
pn = r->u.value;
while ( (p = strsep (&pn, " \t,")) ) {
if ( !*p)
;
else if ( !ascii_strcasecmp (p, "sign") )
- usage |= PUBKEY_USAGE_SIG;
+ use |= PUBKEY_USAGE_SIG;
else if ( !ascii_strcasecmp (p, "encrypt") )
- usage |= PUBKEY_USAGE_ENC;
+ use |= PUBKEY_USAGE_ENC;
else {
log_error("%s:%d: invalid usage list\n", fname, r->lnr );
return -1; /* error */
}
}
- r->u.usage = usage;
+ r->u.usage = use;
return 0;
}
@@ -1662,7 +1662,7 @@ generate_keypair( const char *fname )
DEK *dek;
STRING2KEY *s2k;
int algo;
- unsigned int usage;
+ unsigned int use;
int both = 0;
u32 expire;
struct para_data_s *para = NULL;
@@ -1676,7 +1676,7 @@ generate_keypair( const char *fname )
return;
}
- algo = ask_algo( 0, &usage );
+ algo = ask_algo( 0, &use );
if( !algo ) { /* default: DSA with ElG subkey of the specified size */
both = 1;
r = m_alloc_clear( sizeof *r + 20 );
@@ -1705,12 +1705,12 @@ generate_keypair( const char *fname )
r->next = para;
para = r;
- if (usage) {
+ if (use) {
r = m_alloc_clear( sizeof *r + 20 );
r->key = pKEYUSAGE;
sprintf( r->u.value, "%s%s",
- (usage & PUBKEY_USAGE_SIG)? "sign ":"",
- (usage & PUBKEY_USAGE_ENC)? "encrypt ":"" );
+ (use & PUBKEY_USAGE_SIG)? "sign ":"",
+ (use & PUBKEY_USAGE_ENC)? "encrypt ":"" );
r->next = para;
para = r;
}
@@ -1977,7 +1977,7 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
KBNODE node;
PKT_secret_key *sk = NULL; /* this is the primary sk */
int algo;
- unsigned int usage;
+ unsigned int use;
u32 expire;
unsigned nbits;
char *passphrase = NULL;
@@ -2031,7 +2031,7 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
goto leave;
- algo = ask_algo( 1, &usage );
+ algo = ask_algo( 1, &use );
assert(algo);
nbits = ask_keysize( algo );
expire = ask_expire_interval();
@@ -2050,9 +2050,9 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
rc = do_create( algo, nbits, pub_keyblock, sec_keyblock,
dek, s2k, NULL, expire );
if( !rc )
- rc = write_keybinding(pub_keyblock, pub_keyblock, sk, usage);
+ rc = write_keybinding(pub_keyblock, pub_keyblock, sk, use);
if( !rc )
- rc = write_keybinding(sec_keyblock, pub_keyblock, sk, usage);
+ rc = write_keybinding(sec_keyblock, pub_keyblock, sk, use);
if( !rc ) {
okay = 1;
write_status_text (STATUS_KEY_CREATED, "S");
diff --git a/g10/keylist.c b/g10/keylist.c
index 01f208d8c..29893b489 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -166,12 +166,12 @@ print_key_data( PKT_public_key *pk, u32 *keyid )
static void
print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
{
- unsigned int usage = pk? pk->pubkey_usage : sk->pubkey_usage;
+ unsigned int use = pk? pk->pubkey_usage : sk->pubkey_usage;
- if ( usage & PUBKEY_USAGE_ENC ) {
+ if ( use & PUBKEY_USAGE_ENC ) {
putchar ('e');
}
- if ( usage & PUBKEY_USAGE_SIG ) {
+ if ( use & PUBKEY_USAGE_SIG ) {
putchar ('s');
putchar ('c');
}
diff --git a/g10/keyring.c b/g10/keyring.c
index c63f02b84..9186a5ef2 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -795,7 +795,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc)
&& desc[n].u.kid[1] == aki[1])
goto found;
break;
- case KEYDB_SEARCH_MODE_FPR16: break;
+ case KEYDB_SEARCH_MODE_FPR16:
if ((pk||sk) && !memcmp (desc[n].u.fpr, afp, 16))
goto found;
break;
diff --git a/g10/keyring.o b/g10/keyring.o
index e0a98900d..ff1e2ef62 100644
--- a/g10/keyring.o
+++ b/g10/keyring.o
Binary files differ
diff --git a/g10/misc.c b/g10/misc.c
index 57d6257ab..e75c712da 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -299,33 +299,32 @@ openpgp_pk_test_algo( int algo, unsigned int usage_flags )
int
openpgp_pk_algo_usage ( int algo )
{
- int usage = 0;
+ int use = 0;
/* they are hardwired in gpg 1.0 */
switch ( algo ) {
case PUBKEY_ALGO_RSA:
- usage = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
+ use = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
break;
case PUBKEY_ALGO_RSA_E:
- usage = PUBKEY_USAGE_ENC;
+ use = PUBKEY_USAGE_ENC;
break;
case PUBKEY_ALGO_RSA_S:
- usage = PUBKEY_USAGE_SIG;
+ use = PUBKEY_USAGE_SIG;
break;
case PUBKEY_ALGO_ELGAMAL_E:
- usage = PUBKEY_USAGE_ENC;
+ use = PUBKEY_USAGE_ENC;
break;
case PUBKEY_ALGO_DSA:
- usage = PUBKEY_USAGE_SIG;
+ use = PUBKEY_USAGE_SIG;
break;
case PUBKEY_ALGO_ELGAMAL:
- usage = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
+ use = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
break;
default:
break;
}
- return usage;
-
+ return use;
}
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index 2292f9fd2..c1477b010 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -1931,7 +1931,9 @@ parse_gpg_control( IOBUF inp,
skipit:
if ( list_mode ) {
- int c, i=0 ;
+ int c;
+
+ i=0;
printf("- private (rest length %lu)\n", pktlen);
if( iobuf_in_block_mode(inp) ) {
while( (c=iobuf_get(inp)) != -1 )
diff --git a/g10/passphrase.c b/g10/passphrase.c
index 7ca28e72a..6ec3cb10f 100644
--- a/g10/passphrase.c
+++ b/g10/passphrase.c
@@ -211,7 +211,7 @@ readn ( int fd, void *buf, size_t buflen, size_t *ret_nread )
*/
static int
-agent_open ()
+agent_open (void)
{
int fd;
char *infostr, *p;
diff --git a/g10/pubkey-enc.c b/g10/pubkey-enc.c
index 1d0b855d4..7ef9a5a0f 100644
--- a/g10/pubkey-enc.c
+++ b/g10/pubkey-enc.c
@@ -117,7 +117,7 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek )
static int
-get_it( PKT_pubkey_enc *k, DEK *dek, PKT_secret_key *sk, u32 *keyid )
+get_it( PKT_pubkey_enc *enc, DEK *dek, PKT_secret_key *sk, u32 *keyid )
{
int rc;
MPI plain_dek = NULL;
@@ -125,7 +125,7 @@ get_it( PKT_pubkey_enc *k, DEK *dek, PKT_secret_key *sk, u32 *keyid )
unsigned n, nframe;
u16 csum, csum2;
- rc = pubkey_decrypt(sk->pubkey_algo, &plain_dek, k->data, sk->skey );
+ rc = pubkey_decrypt(sk->pubkey_algo, &plain_dek, enc->data, sk->skey );
if( rc )
goto leave;
frame = mpi_get_buffer( plain_dek, &nframe, NULL );
diff --git a/g10/sign.c b/g10/sign.c
index 8c9548fc1..cd560aeea 100644
--- a/g10/sign.c
+++ b/g10/sign.c
@@ -495,7 +495,7 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash,
* make a detached signature. If FILENAMES->d is NULL read from stdin
* and ignore the detached mode. Sign the file with all secret keys
* which can be taken from LOCUSR, if this is NULL, use the default one
- * If ENCRYPT is true, use REMUSER (or ask if it is NULL) to encrypt the
+ * If ENCRYPTFLAG is true, use REMUSER (or ask if it is NULL) to encrypt the
* signed data for these users.
* If OUTFILE is not NULL; this file is used for output and the function
* does not ask for overwrite permission; output is then always
@@ -503,7 +503,7 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash,
*/
int
sign_file( STRLIST filenames, int detached, STRLIST locusr,
- int encrypt, STRLIST remusr, const char *outfile )
+ int encryptflag, STRLIST remusr, const char *outfile )
{
const char *fname;
armor_filter_context_t afx;
@@ -536,7 +536,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
else
fname = NULL;
- if( fname && filenames->next && (!detached || encrypt) )
+ if( fname && filenames->next && (!detached || encryptflag) )
log_bug("multiple files can only be detached signed");
if( (rc=build_sk_list( locusr, &sk_list, 1, PUBKEY_USAGE_SIG )) )
@@ -544,7 +544,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
if( !old_style )
old_style = only_old_style( sk_list );
- if( encrypt ) {
+ if( encryptflag ) {
if( (rc=build_pk_list( remusr, &pk_list, PUBKEY_USAGE_ENC )) )
goto leave;
if( !old_style )
@@ -586,13 +586,13 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
if( !multifile )
iobuf_push_filter( inp, md_filter, &mfx );
- if( detached && !encrypt && !opt.rfc1991 )
+ if( detached && !encryptflag && !opt.rfc1991 )
afx.what = 2;
if( opt.armor && !outfile )
iobuf_push_filter( out, armor_filter, &afx );
- if( encrypt ) {
+ if( encryptflag ) {
efx.pk_list = pk_list;
/* fixme: set efx.cfx.datalen if known */
iobuf_push_filter( out, encrypt_filter, &efx );
@@ -604,7 +604,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
else {
if( old_style
|| compr_algo == 1
- || (compr_algo == -1 && !encrypt) )
+ || (compr_algo == -1 && !encryptflag) )
zfx.algo = 1; /* use the non optional algorithm */
iobuf_push_filter( out, compress_filter, &zfx );
}
@@ -672,7 +672,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
iobuf_cancel(out);
else {
iobuf_close(out);
- if (encrypt)
+ if (encryptflag)
write_status( STATUS_END_ENCRYPTION );
}
iobuf_close(inp);
diff --git a/include/ChangeLog b/include/ChangeLog
index a591c9136..513b036a0 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2001-09-07 Werner Koch <[email protected]>
+
+ * util.h: Add strsep().
+
2001-08-30 Werner Koch <[email protected]>
* cipher.h (DEK): Added use_mdc.
diff --git a/include/util.h b/include/util.h
index aa2d90594..eafcabcf4 100644
--- a/include/util.h
+++ b/include/util.h
@@ -203,6 +203,9 @@ char *stpcpy(char *a,const char *b);
#ifndef HAVE_STRLWR
char *strlwr(char *a);
#endif
+#ifndef HAVE_STRSEP
+char *strsep (char **stringp, const char *delim);
+#endif
#ifndef HAVE_STRCASECMP
int strcasecmp( const char *, const char *b);
#endif
diff --git a/util/ChangeLog b/util/ChangeLog
index ccbe1764b..7097e9125 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,7 @@
+2001-09-07 Werner Koch <[email protected]>
+
+ * strgutil.c (strsep): New, taken from glibc 2.2.1.
+
2001-09-03 Werner Koch <[email protected]>
* miscutil.c (strtimestamp,asctimestamp): Avoid trigraphs.
diff --git a/util/strgutil.c b/util/strgutil.c
index 4bae35e32..5e978eb04 100644
--- a/util/strgutil.c
+++ b/util/strgutil.c
@@ -689,6 +689,56 @@ stpcpy(char *a,const char *b)
}
#endif
+
+#ifndef HAVE_STRSEP
+/* code taken from glibc-2.2.1/sysdeps/generic/strsep.c */
+char *
+strsep (char **stringp, const char *delim)
+{
+ char *begin, *end;
+
+ begin = *stringp;
+ if (begin == NULL)
+ return NULL;
+
+ /* A frequent case is when the delimiter string contains only one
+ character. Here we don't need to call the expensive `strpbrk'
+ function and instead work using `strchr'. */
+ if (delim[0] == '\0' || delim[1] == '\0')
+ {
+ char ch = delim[0];
+
+ if (ch == '\0')
+ end = NULL;
+ else
+ {
+ if (*begin == ch)
+ end = begin;
+ else if (*begin == '\0')
+ end = NULL;
+ else
+ end = strchr (begin + 1, ch);
+ }
+ }
+ else
+ /* Find the end of the token. */
+ end = strpbrk (begin, delim);
+
+ if (end)
+ {
+ /* Terminate the token and set *STRINGP past NUL character. */
+ *end++ = '\0';
+ *stringp = end;
+ }
+ else
+ /* No more delimiters; this is the last token. */
+ *stringp = NULL;
+
+ return begin;
+}
+#endif /*HAVE_STRSEP*/
+
+
#ifndef HAVE_STRLWR
char *
strlwr(char *s)
@@ -823,4 +873,3 @@ vasprintf ( char **result, const char *format, va_list args)
#endif /*__MINGW32__*/
-