]> git.sur5r.net Git - openldap/commitdiff
ITS#1328 LDIFv1 CR/LF fix
authorKurt Zeilenga <kurt@openldap.org>
Tue, 25 Sep 2001 18:48:48 +0000 (18:48 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 25 Sep 2001 18:48:48 +0000 (18:48 +0000)
clients/tools/ldapmodify.c
libraries/libldif/line64.c

index 353ad0ae33151e9e96bb22d65b77da6c8dd1c28f..121bd64821453b17f49f886092440558e2b77ef9 100644 (file)
@@ -1156,7 +1156,7 @@ read_one_record( FILE *fp )
     while ( fgets( line, sizeof(line), fp ) != NULL ) {
        int len = strlen( line );
 
-               if( len < 2 ) {
+               if( len < 2 || ( len == 3 && *line == '\r' )) {
                        if( buf == NULL ) {
                                continue;
                        } else {
index 947d35a616768dce83bfc28a8fc0bbb98ab3121f..f0db46a0f719eecc6104e220d0de9dfe568548e4 100644 (file)
@@ -24,7 +24,7 @@ int ldif_debug = 0;
 
 #define RIGHT2                 0x03
 #define RIGHT4                 0x0f
-#define CONTINUED_LINE_MARKER  '\001'
+#define CONTINUED_LINE_MARKER  '\r'
 
 #ifdef CSRIMALLOC
 #define ber_memalloc malloc
@@ -274,7 +274,13 @@ ldif_getline( char **next )
                line = *next;
 
                while ( (*next = strchr( *next, '\n' )) != NULL ) {
-                       unsigned char c = *(*next + 1);
+                       unsigned char c = (*next)[1];
+
+#if CONTINUED_LINE_MARKER != '\r'
+                       if ( (*next)[-1] == '\r' ) {
+                               (*next)[-1] = CONTINUED_LINE_MARKER;
+                       }
+#endif
 
                        if ( !isspace( c ) || c == '\n' ) {
                                *(*next)++ = '\0';
@@ -282,7 +288,7 @@ ldif_getline( char **next )
                        }
 
                        **next = CONTINUED_LINE_MARKER;
-                       *(*next+1) = CONTINUED_LINE_MARKER;
+                       (*next)[1] = CONTINUED_LINE_MARKER;
                        (*next)++;
                }
        } while( *line == '#' );