gnupg/g10 (ChangeLog armor.c filter.h keyserver.c)
cvs user dshaw
cvs at cvs.gnupg.org
Thu Jan 6 17:17:13 CET 2005
Date: Thursday, January 6, 2005 @ 17:23:47
Author: dshaw
Path: /cvs/gnupg/gnupg/g10
Modified: ChangeLog armor.c filter.h keyserver.c
* filter.h, armor.c (armor_filter): Use the eol string from the armor
filter context instead of hardcoding '\n' or '\r\n'. If no eol string is
provided, default to '\n' or '\r\n' as appropriate. (is_armor_header):
Trim tabs in armor header lines as well.
* keyserver.c (keyserver_spawn): Use it here to force '\n' line endings
since the keyserver output file gets a LF->CRLF expansion on win32.
-------------+
ChangeLog | 11 +++++++++
armor.c | 67 +++++++++++++++++++++++++++++++++++-----------------------
filter.h | 7 +++++-
keyserver.c | 9 ++++++-
4 files changed, 66 insertions(+), 28 deletions(-)
Index: gnupg/g10/ChangeLog
diff -u gnupg/g10/ChangeLog:1.677 gnupg/g10/ChangeLog:1.678
--- gnupg/g10/ChangeLog:1.677 Thu Jan 6 05:44:38 2005
+++ gnupg/g10/ChangeLog Thu Jan 6 17:23:47 2005
@@ -1,3 +1,14 @@
+2005-01-06 David Shaw <dshaw at jabberwocky.com>
+
+ * filter.h, armor.c (armor_filter): Use the eol string from the
+ armor filter context instead of hardcoding '\n' or '\r\n'. If no
+ eol string is provided, default to '\n' or '\r\n' as appropriate.
+ (is_armor_header): Trim tabs in armor header lines as well.
+
+ * keyserver.c (keyserver_spawn): Use it here to force '\n' line
+ endings since the keyserver output file gets a LF->CRLF expansion
+ on win32.
+
2005-01-05 David Shaw <dshaw at jabberwocky.com>
* g10.c (main): Typo.
Index: gnupg/g10/armor.c
diff -u gnupg/g10/armor.c:1.78 gnupg/g10/armor.c:1.79
--- gnupg/g10/armor.c:1.78 Thu Jan 6 05:44:38 2005
+++ gnupg/g10/armor.c Thu Jan 6 17:23:47 2005
@@ -1,6 +1,6 @@
/* armor.c - Armor flter
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
- * 2004 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+ * 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -38,12 +38,6 @@
#include "status.h"
#include "i18n.h"
-#ifdef HAVE_DOSISH_SYSTEM
-#define LF "\r\n"
-#else
-#define LF "\n"
-#endif
-
#define MAX_LINELEN 20000
#define CRCINIT 0xB704CE
@@ -119,7 +113,6 @@
};
-
static void
initialize(void)
{
@@ -306,7 +299,7 @@
p++;
}
else
- while(*p==' ' || *p=='\r' || *p=='\n')
+ while(*p==' ' || *p=='\r' || *p=='\n' || *p=='\t')
p++;
if( *p )
@@ -984,10 +977,14 @@
log_bug("afx->what=%d", afx->what);
iobuf_writestr(a, "-----");
iobuf_writestr(a, head_strings[afx->what] );
- iobuf_writestr(a, "-----" LF );
+ iobuf_writestr(a, "-----" );
+ iobuf_writestr(a,afx->eol);
if( !opt.no_version )
+ {
iobuf_writestr(a, "Version: GnuPG v" VERSION " ("
- PRINTABLE_OS_NAME ")" LF );
+ PRINTABLE_OS_NAME ")" );
+ iobuf_writestr(a,afx->eol);
+ }
/* write the comment strings */
for(s=comment->d;comment;comment=comment->next,s=comment->d)
@@ -1004,7 +1001,8 @@
else
iobuf_put(a, *s );
}
- iobuf_writestr(a, LF );
+
+ iobuf_writestr(a,afx->eol);
}
if ( afx->hdrlines ) {
@@ -1016,7 +1014,8 @@
iobuf_put(a, *s );
}
}
- iobuf_writestr(a, LF );
+
+ iobuf_writestr(a,afx->eol);
afx->status++;
afx->idx = 0;
afx->idx2 = 0;
@@ -1045,10 +1044,11 @@
iobuf_put(a, c);
c = bintoasc[radbuf[2]&077];
iobuf_put(a, c);
- if( ++idx2 >= (64/4) ) { /* pgp doesn't like 72 here */
- iobuf_writestr(a, LF );
+ if( ++idx2 >= (64/4) )
+ { /* pgp doesn't like 72 here */
+ iobuf_writestr(a,afx->eol);
idx2=0;
- }
+ }
}
}
for(i=0; i < idx; i++ )
@@ -1057,10 +1057,23 @@
afx->idx2 = idx2;
afx->crc = crc;
}
- else if( control == IOBUFCTRL_INIT ) {
+ else if( control == IOBUFCTRL_INIT )
+ {
if( !is_initialized )
- initialize();
- }
+ initialize();
+
+ /* Figure out what we're using for line endings if the caller
+ didn't specify. */
+ if(afx->eol[0]==0)
+ {
+#ifdef HAVE_DOSISH_SYSTEM
+ afx->eol[0]='\r';
+ afx->eol[1]='\n';
+#else
+ afx->eol[0]='\n';
+#endif
+ }
+ }
else if( control == IOBUFCTRL_CANCEL ) {
afx->cancel = 1;
}
@@ -1089,14 +1102,15 @@
iobuf_put(a, c);
iobuf_put(a, '=');
}
- if( ++idx2 >= (64/4) ) { /* pgp doesn't like 72 here */
- iobuf_writestr(a, LF );
+ if( ++idx2 >= (64/4) )
+ { /* pgp doesn't like 72 here */
+ iobuf_writestr(a,afx->eol);
idx2=0;
- }
+ }
}
/* may need a linefeed */
if( idx2 )
- iobuf_writestr(a, LF );
+ iobuf_writestr(a,afx->eol);
/* write the CRC */
iobuf_put(a, '=');
radbuf[0] = crc >>16;
@@ -1110,13 +1124,14 @@
iobuf_put(a, c);
c = bintoasc[radbuf[2]&077];
iobuf_put(a, c);
- iobuf_writestr(a, LF );
+ iobuf_writestr(a,afx->eol);
/* and the the trailer */
if( afx->what >= DIM(tail_strings) )
log_bug("afx->what=%d", afx->what);
iobuf_writestr(a, "-----");
iobuf_writestr(a, tail_strings[afx->what] );
- iobuf_writestr(a, "-----" LF );
+ iobuf_writestr(a, "-----" );
+ iobuf_writestr(a,afx->eol);
}
else if( !afx->any_data && !afx->inp_bypass ) {
log_error(_("no valid OpenPGP data found.\n"));
Index: gnupg/g10/filter.h
diff -u gnupg/g10/filter.h:1.46 gnupg/g10/filter.h:1.47
--- gnupg/g10/filter.h:1.46 Fri Oct 31 06:39:01 2003
+++ gnupg/g10/filter.h Thu Jan 6 17:23:47 2005
@@ -1,5 +1,6 @@
/* filter.h
- * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2003,
+ * 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -48,6 +49,10 @@
int truncated; /* number of truncated lines */
int qp_detected;
int pgp2mode;
+ byte eol[3]; /* The end of line characters as a
+ zero-terminated string. Defaults
+ (eol[0]=='\0') to whatever the local
+ platform uses. */
byte *buffer; /* malloced buffer */
unsigned buffer_size; /* and size of this buffer */
Index: gnupg/g10/keyserver.c
diff -u gnupg/g10/keyserver.c:1.76 gnupg/g10/keyserver.c:1.77
--- gnupg/g10/keyserver.c:1.76 Fri Dec 24 20:51:02 2004
+++ gnupg/g10/keyserver.c Thu Jan 6 17:23:47 2005
@@ -1,5 +1,5 @@
/* keyserver.c - generic keyserver code
- * Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -966,6 +966,13 @@
memset(&afx,0,sizeof(afx));
afx.what=1;
+ /* Tell the armor filter to use Unix-style \n line
+ endings, since we're going to fprintf this to a file
+ that (on Win32) is open in text mode. The win32 stdio
+ will transform the \n to \r\n and we'll end up with the
+ proper line endings on win32. This is a no-op on
+ Unix. */
+ afx.eol[0]='\n';
iobuf_push_filter(buffer,armor_filter,&afx);
/* TODO: Remove Comment: lines from keys exported this
More information about the Gnupg-commits
mailing list