]> git.sur5r.net Git - openldap/commitdiff
Ignore comments surrounded by empty lines in ldif_read_record().
authorHallvard Furuseth <hallvard@openldap.org>
Fri, 31 Oct 2003 19:13:20 +0000 (19:13 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Fri, 31 Oct 2003 19:13:20 +0000 (19:13 +0000)
Slapadd treated these as separate, incorrect, entries.

libraries/libldif/line64.c

index c3775a7bd21f8af9744a27eb786a6f71aab52571..b82933d9714b641c83a16c85d875fe9e14ff6aaa 100644 (file)
@@ -571,7 +571,7 @@ ldif_read_record(
 {
        char        linebuf[BUFSIZ], *line, *nbufp;
        ber_len_t   lcur = 0, len, linesize;
-       int         last_ch = '\n', found_entry = 0, stop;
+       int         last_ch = '\n', found_entry = 0, stop, top_comment = 0;
 
        line     = linebuf;
        linesize = sizeof( linebuf );
@@ -588,18 +588,25 @@ ldif_read_record(
                        (*lno)++;
 
                        if ( line[0] == '\n' ) {
-                               if ( !found_entry )
+                               if ( !found_entry ) {
+                                       lcur = 0;
+                                       top_comment = 0;
                                        continue;
+                               }
                                break;
                        }
 
                        if ( !found_entry ) {
-                               /* Found a new entry */
-                               found_entry = 1;
-
-                               if ( isdigit( (unsigned char) line[0] ) ) {
-                                       /* skip index */
-                                       continue;
+                               if ( line[0] == '#' ) {
+                                       top_comment = 1;
+                               } else if ( ! ( top_comment && line[0] == ' ' ) ) {
+                                       /* Found a new entry */
+                                       found_entry = 1;
+
+                                       if ( isdigit( (unsigned char) line[0] ) ) {
+                                               /* skip index */
+                                               continue;
+                                       }
                                }
                        }                       
                }