]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Apply ldif2index atol bug fix from rel eng 1.1
authorKurt Zeilenga <kurt@openldap.org>
Sat, 5 Dec 1998 03:40:42 +0000 (03:40 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 5 Dec 1998 03:40:42 +0000 (03:40 +0000)
servers/slapd/tools/ldif2id2children.c
servers/slapd/tools/ldif2id2entry.c
servers/slapd/tools/ldif2index.c

index 0bb8e5ec6d0ebd0d8c38d2815024df37f3131bbf..170567beff4d2bc8345862afd56c0ccee8432ae4 100644 (file)
@@ -1,7 +1,9 @@
 #include <stdio.h>
 #include <string.h>
+#include <ctype.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+
 #include "../slap.h"
 #include "../back-ldbm/back-ldbm.h"
 
@@ -170,7 +172,11 @@ main( int argc, char **argv )
                }
                if ( line[0] == '\n' || stop && buf && *buf ) {
                        if ( *buf != '\n' ) {
-                               id++;
+                               if (isdigit(*buf)) {
+                                       id = atol(buf);
+                               } else {
+                                       id++;
+                               }
                                s = buf;
                                elineno = 0;
                                while ( (linep = str_getline( &s )) != NULL ) {
index ec2bf272797d167a761c8d55c874086dc0d49ced..ebb8ab6b94366d716a8687a0a279fdad457067b8 100644 (file)
@@ -1,7 +1,9 @@
 #include <stdio.h>
+#include <ctype.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+
 #include "../slap.h"
 #include "../back-ldbm/back-ldbm.h"
 
@@ -150,8 +152,18 @@ main( int argc, char **argv )
 
                        len = strlen( line );
                        if ( buf == NULL || *buf == '\0' ) {
+<<<<<<< ldif2id2entry.c
                                sprintf( idbuf, "%d\n", id + 1 );
                                idlen = strlen( idbuf );
+=======
+                               if (!isdigit(line[0])) {
+                                       sprintf( idbuf, "%d\n", id + 1 );
+                                       idlen = strlen( idbuf );
+                               } else {
+                                       id = atol(line) - 1;
+                                       idlen = 0;
+                               }
+>>>>>>> 1.4.2.3
                        } else {
                                idlen = 0;
                        }
@@ -172,11 +184,16 @@ main( int argc, char **argv )
                }
                if ( line[0] == '\n' || stop && buf && *buf ) {
                        if ( *buf != '\n' ) {
+                               int len;
+
                                id++;
                                key.dptr = (char *) &id;
                                key.dsize = sizeof(ID);
                                data.dptr = buf;
-                               data.dsize = strlen( buf ) + 1;
+                               len = strlen(buf);
+                               if (buf[len - 1] == '\n')
+                                       buf[--len] = '\0';
+                               data.dsize = len + 1;
                                if ( ldbm_store( db->dbc_db, key, data,
                                    LDBM_INSERT ) != 0 ) {
                                        perror( "id2entry ldbm_store" );
index dd03f3dc7821cec1ff481bd98eabce04a860d85a..245e2834cf3a2e15612db7e20efe42c51c25e13d 100644 (file)
@@ -1,7 +1,9 @@
 #include <stdio.h>
 #include <string.h>
+#include <ctype.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+
 #include "../slap.h"
 
 #include "ldapconfig.h"
@@ -151,7 +153,11 @@ main( int argc, char **argv )
                }
                if ( line[0] == '\n' || stop && buf && *buf ) {
                        if ( *buf != '\n' ) {
-                               id++;
+                               if (isdigit(*buf)) {
+                                       id = atol(buf);
+                               } else {
+                                       id++;
+                               }
                                s = buf;
                                elineno = 0;
                                while ( (linep = str_getline( &s )) != NULL ) {