Print this page
libiberty/testsuite: Avoid conflicting getline()

Split Close
Expand all
Collapse all
          --- old/libiberty/testsuite/test-demangle.c
          +++ new/libiberty/testsuite/test-demangle.c
↓ open down ↓ 38 lines elided ↑ open up ↑
  39   39    char *data;
  40   40  };
  41   41  
  42   42  static unsigned int lineno;
  43   43  
  44   44  /* Safely read a single line of arbitrary length from standard input.  */
  45   45  
  46   46  #define LINELEN 80
  47   47  
  48   48  static void
  49      -getline(buf)
       49 +_getline(buf)
  50   50       struct line *buf;
  51   51  {
  52   52    char *data = buf->data;
  53   53    size_t alloc = buf->alloced;
  54   54    size_t count = 0;
  55   55    int c;
  56   56  
  57   57    if (data == 0)
  58   58      {
  59   59        data = xmalloc (LINELEN);
↓ open down ↓ 129 lines elided ↑ open up ↑
 189  189      }
 190  190  
 191  191    format.data = 0;
 192  192    input.data = 0;
 193  193    expect.data = 0;
 194  194  
 195  195    for (;;)
 196  196      {
 197  197        const char *inp;
 198  198        
 199      -      getline (&format);
      199 +      _getline (&format);
 200  200        if (feof (stdin))
 201  201          break;
 202  202  
 203      -      getline (&input);
 204      -      getline (&expect);
      203 +      _getline (&input);
      204 +      _getline (&expect);
 205  205  
 206  206        inp = protect_end (input.data);
 207  207  
 208  208        tests++;
 209  209  
 210  210        no_params = 0;
 211  211        ret_postfix = 0;
 212  212        is_v3_ctor = 0;
 213  213        is_v3_dtor = 0;
 214  214        if (format.data[0] == '\0')
↓ open down ↓ 100 lines elided ↑ open up ↑
 315  315            ? strcmp (result, expect.data)
 316  316            : strcmp (input.data, expect.data))
 317  317          {
 318  318            fail (lineno, format.data, input.data, result, expect.data);
 319  319            failures++;
 320  320          }
 321  321        free (result);
 322  322  
 323  323        if (no_params)
 324  324          {
 325      -          getline (&expect);
      325 +          _getline (&expect);
 326  326            result = cplus_demangle (inp, DMGL_ANSI|DMGL_TYPES);
 327  327  
 328  328            if (result
 329  329                ? strcmp (result, expect.data)
 330  330                : strcmp (input.data, expect.data))
 331  331              {
 332  332                fail (lineno, format.data, input.data, result, expect.data);
 333  333                failures++;
 334  334              }
 335  335            free (result);
 336  336          }
 337  337      }
 338  338  
 339  339    free (format.data);
 340  340    free (input.data);
 341  341    free (expect.data);
 342  342  
 343  343    printf ("%s: %d tests, %d failures\n", argv[0], tests, failures);
 344  344    return failures ? 1 : 0;
 345  345  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX