~ubuntu-branches/ubuntu/vivid/curl/vivid

« back to all changes in this revision

Viewing changes to src/tool_parsecfg.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-05-07 12:16:37 UTC
  • mfrom: (3.4.37 sid)
  • Revision ID: package-import@ubuntu.com-20130507121637-9t3i98qgsyr9dw5d
Tags: 7.30.0-1ubuntu1
* Resynchronize on Debian. Remaining changes:
  - Drop dependencies not in main:
    + Build-Depends: Drop stunnel4 and libssh2-1-dev.
    + Drop libssh2-1-dev from binary package Depends.
  - Add new libcurl3-udeb package.
  - Add new curl-udeb package.
* Add warning to debian/patches/series.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
275
275
{
276
276
  char buf[4096];
277
277
  char *nl = NULL;
278
 
  char *retval = NULL;
 
278
  char *line = NULL;
279
279
 
280
280
  do {
281
281
    if(NULL == fgets(buf, sizeof(buf), fp))
282
282
      break;
283
 
    if(!retval) {
284
 
      retval = strdup(buf);
285
 
      if(!retval)
 
283
    if(!line) {
 
284
      line = strdup(buf);
 
285
      if(!line)
286
286
        return NULL;
287
287
    }
288
288
    else {
289
289
      char *ptr;
290
 
      ptr = realloc(retval, strlen(retval) + strlen(buf) + 1);
 
290
      size_t linelen = strlen(line);
 
291
      ptr = realloc(line, linelen + strlen(buf) + 1);
291
292
      if(!ptr) {
292
 
        Curl_safefree(retval);
 
293
        Curl_safefree(line);
293
294
        return NULL;
294
295
      }
295
 
      retval = ptr;
296
 
      strcat(retval, buf);
 
296
      line = ptr;
 
297
      strcpy(&line[linelen], buf);
297
298
    }
298
 
    nl = strchr(retval, '\n');
 
299
    nl = strchr(line, '\n');
299
300
  } while(!nl);
300
301
 
301
302
  if(nl)
302
303
    *nl = '\0';
303
304
 
304
 
  return retval;
 
305
  return line;
305
306
}
306
307