aboutsummaryrefslogtreecommitdiffstats
path: root/src/mkhelp.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mkhelp.pl')
-rw-r--r--src/mkhelp.pl60
1 files changed, 51 insertions, 9 deletions
diff --git a/src/mkhelp.pl b/src/mkhelp.pl
index 03c884fe..088a09a0 100644
--- a/src/mkhelp.pl
+++ b/src/mkhelp.pl
@@ -1,4 +1,25 @@
#!/usr/local/bin/perl
+#***************************************************************************
+# _ _ ____ _
+# Project ___| | | | _ \| |
+# / __| | | | |_) | |
+# | (__| |_| | _ <| |___
+# \___|\___/|_| \_\_____|
+#
+# Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://curl.haxx.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+###########################################################################
# Yeah, I know, probably 1000 other persons already wrote a script like
# this, but I'll tell ya:
@@ -33,6 +54,9 @@ while (<STDIN>) {
# this should be removed:
$line =~ s/(.|_)//g;
+ # remove trailing CR from line. msysgit checks out files as line+CRLF
+ $line =~ s/\r$//;
+
if($line =~ /^([ \t]*\n|curl)/i) {
# cut off headers and empty lines
$wline++; # count number of cut off lines
@@ -40,7 +64,7 @@ while (<STDIN>) {
}
my $text = $line;
- $text =~ s/^\s+//g; # cut off preceeding...
+ $text =~ s/^\s+//g; # cut off preceding...
$text =~ s/\s+$//g; # and trailing whitespaces
$tlen = length($text);
@@ -69,7 +93,12 @@ open(READ, "<$README") ||
die "couldn't read the README infile $README";
while(<READ>) {
- push @out, $_;
+ my $line = $_;
+
+ # remove trailing CR from line. msysgit checks out files as line+CRLF
+ $line =~ s/\r$//;
+
+ push @out, $line;
}
close(READ);
@@ -112,16 +141,14 @@ print <<HEAD
* NEVER EVER edit this manually, fix the mkhelp.pl script instead!
* Generation time: $now
*/
-#include "setup.h"
#ifdef USE_MANUAL
-#include "hugehelp.h"
-#include <stdio.h>
+#include "tool_hugehelp.h"
HEAD
;
if($c) {
print <<HEAD
-#include <stdlib.h>
#include <zlib.h>
+#include "memdebug.h" /* keep this as LAST include */
static const unsigned char hugehelpgz[] = {
/* This mumbo-jumbo is the huge help text compressed with gzip.
Thanks to this operation, the size of this data shrunk from $gzip
@@ -146,6 +173,17 @@ HEAD
print <<EOF
#define BUF_SIZE 0x10000
+static voidpf zalloc_func(voidpf opaque, unsigned int items, unsigned int size)
+{
+ (void) opaque;
+ /* not a typo, keep it calloc() */
+ return (voidpf) calloc(items, size);
+}
+static void zfree_func(voidpf opaque, voidpf ptr)
+{
+ (void) opaque;
+ free(ptr);
+}
/* Decompress and send to stdout a gzip-compressed buffer */
void hugehelp(void)
{
@@ -158,11 +196,11 @@ void hugehelp(void)
return;
headerlen = 10;
+ memset(&z, 0, sizeof(z_stream));
+ z.zalloc = (alloc_func)zalloc_func;
+ z.zfree = (free_func)zfree_func;
z.avail_in = (unsigned int)(sizeof(hugehelpgz) - headerlen);
z.next_in = (unsigned char *)hugehelpgz + headerlen;
- z.zalloc = (alloc_func)Z_NULL;
- z.zfree = (free_func)Z_NULL;
- z.opaque = 0;
if (inflateInit2(&z, -MAX_WBITS) != Z_OK)
return;
@@ -226,6 +264,10 @@ foot();
sub foot {
print <<FOOT
+#else /* !USE_MANUAL */
+/* built-in manual is disabled, blank function */
+#include "tool_hugehelp.h"
+void hugehelp(void) {}
#endif /* USE_MANUAL */
FOOT
;