Commit 71ff674a authored by Howard Chu's avatar Howard Chu
Browse files

ITS#7871 fix ldif-wrap length

Doc has been updated to note the default was actually 78.
The off-by-two error is fixed. Note that wrap=1 will still
output 2 columns, otherwise it can't output anything besides
the continuation character.
parent a01d3f96
...@@ -153,7 +153,9 @@ Possible generic options/values are: ...@@ -153,7 +153,9 @@ Possible generic options/values are:
.in .in
\fIn\fP is the number of columns allowed for the LDIF output \fIn\fP is the number of columns allowed for the LDIF output
(\fIn\fP equal to \fI0\fP uses the default, corresponding to 76). (\fIn\fP equal to \fI0\fP uses the default, corresponding to 78).
The minimum is 2, leaving space for one character and one
continuation character.
Use \fIno\fP for no wrap. Use \fIno\fP for no wrap.
.TP .TP
.BI \-s \ subtree-dn .BI \-s \ subtree-dn
......
...@@ -486,8 +486,8 @@ ldif_must_b64_encode( LDAP_CONST char *s ) ...@@ -486,8 +486,8 @@ ldif_must_b64_encode( LDAP_CONST char *s )
return 0; return 0;
} }
/* compatibility with U-Mich off by one bug */ /* compatibility with U-Mich off by two bug */
#define LDIF_KLUDGE 1 #define LDIF_KLUDGE 2
/* NOTE: only preserved for binary compatibility */ /* NOTE: only preserved for binary compatibility */
void void
...@@ -498,7 +498,7 @@ ldif_sput( ...@@ -498,7 +498,7 @@ ldif_sput(
LDAP_CONST char *val, LDAP_CONST char *val,
ber_len_t vlen ) ber_len_t vlen )
{ {
ldif_sput_wrap( out, type, name, val, vlen, LDIF_LINE_WIDTH ); ldif_sput_wrap( out, type, name, val, vlen, LDIF_LINE_WIDTH+LDIF_KLUDGE );
} }
void void
...@@ -521,7 +521,8 @@ ldif_sput_wrap( ...@@ -521,7 +521,8 @@ ldif_sput_wrap(
ber_len_t len=0; ber_len_t len=0;
ber_len_t i; ber_len_t i;
wrap = LDIF_LINE_WIDTH_WRAP( wrap ); if ( !wrap )
wrap = LDIF_LINE_WIDTH+LDIF_KLUDGE;
/* prefix */ /* prefix */
switch( type ) { switch( type ) {
...@@ -633,7 +634,7 @@ ldif_sput_wrap( ...@@ -633,7 +634,7 @@ ldif_sput_wrap(
b64 = 1; b64 = 1;
break; break;
} }
if ( len - LDIF_KLUDGE > wrap ) { if ( len >= wrap ) {
*(*out)++ = '\n'; *(*out)++ = '\n';
*(*out)++ = ' '; *(*out)++ = ' ';
len = 1; len = 1;
...@@ -662,7 +663,7 @@ ldif_sput_wrap( ...@@ -662,7 +663,7 @@ ldif_sput_wrap(
bits |= (byte[2] & 0xff); bits |= (byte[2] & 0xff);
for ( i = 0; i < 4; i++, len++, bits <<= 6 ) { for ( i = 0; i < 4; i++, len++, bits <<= 6 ) {
if ( len - LDIF_KLUDGE > wrap ) { if ( len >= wrap ) {
*(*out)++ = '\n'; *(*out)++ = '\n';
*(*out)++ = ' '; *(*out)++ = ' ';
len = 1; len = 1;
...@@ -687,7 +688,7 @@ ldif_sput_wrap( ...@@ -687,7 +688,7 @@ ldif_sput_wrap(
bits |= (byte[2] & 0xff); bits |= (byte[2] & 0xff);
for ( i = 0; i < 4; i++, len++, bits <<= 6 ) { for ( i = 0; i < 4; i++, len++, bits <<= 6 ) {
if ( len - LDIF_KLUDGE > wrap ) { if ( len >= wrap ) {
*(*out)++ = '\n'; *(*out)++ = '\n';
*(*out)++ = ' '; *(*out)++ = ' ';
len = 1; len = 1;
......
Supports Markdown
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