Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (17 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/libbb/fgets_str.c

    r821 r1765  
    66 * If you wrote this, please acknowledge your work.
    77 *
    8  * This program is free software; you can redistribute it and/or modify
    9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  * General Public License for more details.
    17  *
    18  * You should have received a copy of the GNU General Public License
    19  * along with this program; if not, write to the Free Software
    20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
     8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
    219 */
    22 
    23 
    24 #include <stdio.h>
    25 #include <stdlib.h>
    26 #include <string.h>
    2710
    2811#include "libbb.h"
     
    3114 * Return NULL on EOF.  */
    3215
    33 char *fgets_str(FILE *file, const char *terminating_string)
     16char *xmalloc_fgets_str(FILE *file, const char *terminating_string)
    3417{
    3518    char *linebuf = NULL;
     
    4932        /* grow the line buffer as necessary */
    5033        while (idx > linebufsz - 2) {
    51             linebuf = xrealloc(linebuf, linebufsz += 1000);
     34            linebufsz += 200;
     35            linebuf = xrealloc(linebuf, linebufsz);
    5236        }
    5337
     
    5741        /* Check for terminating string */
    5842        end_string_offset = idx - term_length;
    59         if ((end_string_offset > 0) && (memcmp(&linebuf[end_string_offset], terminating_string, term_length) == 0)) {
     43        if (end_string_offset > 0
     44         && memcmp(&linebuf[end_string_offset], terminating_string, term_length) == 0
     45        ) {
    6046            idx -= term_length;
    6147            break;
    6248        }
    6349    }
     50    linebuf = xrealloc(linebuf, idx + 1);
    6451    linebuf[idx] = '\0';
    65     return(linebuf);
     52    return linebuf;
    6653}
    67 
Note: See TracChangeset for help on using the changeset viewer.