tizen 2.3.1 release
[external/curl.git] / src / mkhelp.pl
index 03c884f..7ed86f7 100644 (file)
@@ -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:
@@ -40,7 +61,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);
@@ -112,16 +133,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 +165,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 +188,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 +256,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
   ;