~ubuntu-branches/ubuntu/precise/wget/precise-proposed

« back to all changes in this revision

Viewing changes to lib/getdelim.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-10-19 00:00:09 UTC
  • mfrom: (2.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20111019000009-8p33w3wz4b1rdri0
Tags: 1.13-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add wget-udeb to ship wget.gnu as alternative to busybox wget
    implementation.
  - Depend on libssl-dev 0.9.8k-7ubuntu4 (LP: #503339)
* Dropped changes, superseded in Debian:
  - Keep build dependencies in main:
    + debian/control: remove info2man build-dep
    + debian/patches/series: disable wget-infopod_generated_manpage
  - Mark wget Multi-Arch: foreign, so packages that aren't of the same arch
    can depend on it.
* Pass --with-ssl=openssl; we don't want to use gnutls, there's no udeb for
  it.
* Add a second build pass for the udeb, so we can build without libidn.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- buffer-read-only: t -*- vi: set ro: */
 
2
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
1
3
/* getdelim.c --- Implementation of replacement getdelim function.
2
 
   Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007,
3
 
   2008, 2009 Free Software Foundation, Inc.
 
4
   Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2011 Free Software
 
5
   Foundation, Inc.
4
6
 
5
7
   This program is free software; you can redistribute it and/or
6
8
   modify it under the terms of the GNU General Public License as
21
23
 
22
24
#include <config.h>
23
25
 
 
26
/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
 
27
   optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below.  */
 
28
#define _GL_ARG_NONNULL(params)
 
29
 
24
30
#include <stdio.h>
25
31
 
26
32
#include <limits.h>
34
40
 
35
41
#if USE_UNLOCKED_IO
36
42
# include "unlocked-io.h"
37
 
# define getc_maybe_unlocked(fp)        getc(fp)
 
43
# define getc_maybe_unlocked(fp)        getc(fp)
38
44
#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
39
45
# undef flockfile
40
46
# undef funlockfile
41
47
# define flockfile(x) ((void) 0)
42
48
# define funlockfile(x) ((void) 0)
43
 
# define getc_maybe_unlocked(fp)        getc(fp)
 
49
# define getc_maybe_unlocked(fp)        getc(fp)
44
50
#else
45
 
# define getc_maybe_unlocked(fp)        getc_unlocked(fp)
 
51
# define getc_maybe_unlocked(fp)        getc_unlocked(fp)
46
52
#endif
47
53
 
48
54
/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
71
77
      *n = 120;
72
78
      new_lineptr = (char *) realloc (*lineptr, *n);
73
79
      if (new_lineptr == NULL)
74
 
        {
75
 
          result = -1;
76
 
          goto unlock_return;
77
 
        }
 
80
        {
 
81
          result = -1;
 
82
          goto unlock_return;
 
83
        }
78
84
      *lineptr = new_lineptr;
79
85
    }
80
86
 
84
90
 
85
91
      i = getc_maybe_unlocked (fp);
86
92
      if (i == EOF)
87
 
        {
88
 
          result = -1;
89
 
          break;
90
 
        }
 
93
        {
 
94
          result = -1;
 
95
          break;
 
96
        }
91
97
 
92
98
      /* Make enough space for len+1 (for final NUL) bytes.  */
93
99
      if (cur_len + 1 >= *n)
94
 
        {
95
 
          size_t needed_max =
96
 
            SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
97
 
          size_t needed = 2 * *n + 1;   /* Be generous. */
98
 
          char *new_lineptr;
99
 
 
100
 
          if (needed_max < needed)
101
 
            needed = needed_max;
102
 
          if (cur_len + 1 >= needed)
103
 
            {
104
 
              result = -1;
105
 
              errno = EOVERFLOW;
106
 
              goto unlock_return;
107
 
            }
108
 
 
109
 
          new_lineptr = (char *) realloc (*lineptr, needed);
110
 
          if (new_lineptr == NULL)
111
 
            {
112
 
              result = -1;
113
 
              goto unlock_return;
114
 
            }
115
 
 
116
 
          *lineptr = new_lineptr;
117
 
          *n = needed;
118
 
        }
 
100
        {
 
101
          size_t needed_max =
 
102
            SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
 
103
          size_t needed = 2 * *n + 1;   /* Be generous. */
 
104
          char *new_lineptr;
 
105
 
 
106
          if (needed_max < needed)
 
107
            needed = needed_max;
 
108
          if (cur_len + 1 >= needed)
 
109
            {
 
110
              result = -1;
 
111
              errno = EOVERFLOW;
 
112
              goto unlock_return;
 
113
            }
 
114
 
 
115
          new_lineptr = (char *) realloc (*lineptr, needed);
 
116
          if (new_lineptr == NULL)
 
117
            {
 
118
              result = -1;
 
119
              goto unlock_return;
 
120
            }
 
121
 
 
122
          *lineptr = new_lineptr;
 
123
          *n = needed;
 
124
        }
119
125
 
120
126
      (*lineptr)[cur_len] = i;
121
127
      cur_len++;
122
128
 
123
129
      if (i == delimiter)
124
 
        break;
 
130
        break;
125
131
    }
126
132
  (*lineptr)[cur_len] = '\0';
127
133
  result = cur_len ? cur_len : result;