From: Nikos Mavrogiannopoulos Date: Tue, 14 Feb 2012 22:33:33 +0000 (+0100) Subject: break long strings. X-Git-Tag: gnutls_3_0_13~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bfcfa38345be3e19ac014b9cc7b38ad665fd32f3;p=thirdparty%2Fgnutls.git break long strings. --- diff --git a/doc/Makefile.am b/doc/Makefile.am index 2be2c5546e..22288f3f8f 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -306,13 +306,13 @@ AM_CPPFLAGS = \ EXTRA_PROGRAMS = errcodes printlist alert-printlist -errcodes_SOURCES = errcodes.c +errcodes_SOURCES = errcodes.c common.c common.h errcodes_LDADD = ../lib/libgnutls.la ../gl/libgnu.la -printlist_SOURCES = printlist.c +printlist_SOURCES = printlist.c common.c common.h printlist_LDADD = ../lib/libgnutls.la ../gl/libgnu.la -alert_printlist_SOURCES = alert-printlist.c +alert_printlist_SOURCES = alert-printlist.c common.c common.h alert_printlist_LDADD = ../lib/libgnutls.la ../gl/libgnu.la error_codes.texi: $(top_srcdir)/lib/gnutls_errors.c $(srcdir)/errcodes.c diff --git a/doc/alert-printlist.c b/doc/alert-printlist.c index 7ce8e3e65d..59d53193a3 100644 --- a/doc/alert-printlist.c +++ b/doc/alert-printlist.c @@ -25,10 +25,13 @@ #include #include #include +#include "common.h" static void main_texinfo (void); static void main_latex(void); +char buffer[1024]; + int main (int argc, char *argv[]) { @@ -56,7 +59,7 @@ static void main_texinfo (void) { if (gnutls_alert_get_strname(i)==NULL) continue; printf ("@item %s\n@tab %d\n@tab %s\n", - gnutls_alert_get_strname(i), + escape_texi_string(gnutls_alert_get_strname(i), buffer, sizeof(buffer)), (unsigned int) i, gnutls_alert_get_name (i)); } printf ("@end multitable\n"); @@ -81,28 +84,6 @@ static const char headers[] = "\\tablefirsthead{%\n" "\\tablelasttail{\\hline}\n" "\\bottomcaption{The TLS alert table}\n\n"; -static char* escape_string( const char* str) -{ -static char buffer[500]; -int i = 0, j = 0; - - -while( str[i] != 0 && j < sizeof(buffer) - 1) { - if (str[i]=='_') { - buffer[j++] = '\\'; - buffer[j++] = '_'; - } else { - buffer[j++] = str[i]; - } - i++; -}; - -buffer[j] = 0; - -return buffer; - -} - static void main_latex(void) { int i, j; @@ -125,7 +106,7 @@ printf("\\begin{supertabular}{|p{.50\\linewidth}|p{.07\\linewidth}|p{.34\\linewi { if (gnutls_alert_get_strname(i)==NULL) continue; printf ("{\\small{%s}} & \\code{%d} & %s", - escape_string(gnutls_alert_get_strname(i)), + escape_string(gnutls_alert_get_strname(i), buffer, sizeof(buffer)), (unsigned int) i, gnutls_alert_get_name (i)); printf( "\\\\\n"); } diff --git a/doc/common.c b/doc/common.c new file mode 100644 index 0000000000..4ceaff80cb --- /dev/null +++ b/doc/common.c @@ -0,0 +1,47 @@ +char* escape_string( const char* str, char* buffer, int buffer_size) +{ +int i = 0, j = 0; + + +while( str[i] != 0 && j #include #include +#include "common.h" static void main_latex(void); static int main_texinfo (void); @@ -77,28 +78,6 @@ main (int argc, char *argv[]) return 0; } -static char* escape_texi_string( const char* str, char* buffer, int buffer_size) -{ -int i = 0, j = 0; - - -while( str[i] != 0 && j #include #include +#include "common.h" static void main_texinfo (void); static void main_latex(void); +char buffer[1024]; + int main (int argc, char *argv[]) { @@ -58,7 +61,7 @@ static void main_texinfo (void) (i, id, &kx, &cipher, &mac, &version)); i++) { printf ("@item %s\n@tab 0x%02X 0x%02X\n@tab %s\n", - name, + escape_texi_string(name, buffer, sizeof(buffer)), (unsigned char) id[0], (unsigned char) id[1], gnutls_protocol_get_name (version)); } @@ -185,28 +188,6 @@ static const char headers[] = "\\tablefirsthead{%\n" "\\tablelasttail{\\hline}\n" "\\bottomcaption{The ciphersuites table}\n\n"; -static char* escape_string( const char* str) -{ -static char buffer[500]; -int i = 0, j = 0; - - -while( str[i] != 0 && j < sizeof(buffer) - 1) { - if (str[i]=='_') { - buffer[j++] = '\\'; - buffer[j++] = '_'; - } else { - buffer[j++] = str[i]; - } - i++; -}; - -buffer[j] = 0; - -return buffer; - -} - static void main_latex(void) { int i, j; @@ -230,7 +211,7 @@ printf("\\begin{supertabular}{|p{.64\\linewidth}|p{.12\\linewidth}|p{.09\\linewi (i, id, &kx, &cipher, &mac, &version)); i++) { printf ("{\\small{%s}} & \\code{0x%02X 0x%02X} & %s", - escape_string(name), + escape_string(name, buffer, sizeof(buffer)), (unsigned char) id[0], (unsigned char) id[1], gnutls_protocol_get_name (version)); printf( "\\\\\n");