~ubuntu-branches/ubuntu/wily/avr-libc/wily-proposed

« back to all changes in this revision

Viewing changes to tests/simulate/stdlib/strtol.h

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2009-10-31 11:52:10 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20091031115210-crjd42sn6ezrj52c
Tags: 1:1.6.7-1
* New upstream relese (closes: #544030)
* Added lintian overrides (closes: #553265)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: strtol.h,v 1.1 2007/02/06 12:36:58 dmix Exp $   */
2
 
 
3
 
#include <ctype.h>
4
 
#include <errno.h>
5
 
#include <limits.h>
6
 
#include <stdlib.h>
7
 
#ifndef __AVR__
8
 
# include <stdio.h>
9
 
#endif
10
 
#ifndef EINVAL          /* Addition for errno.h in avr-libc-1.2.0       */
11
 
# define EINVAL 22      /* Invalid argument     */
12
 
#endif
13
 
 
14
 
static int t_strtol (const char *s, int base, long ret, int err, int len)
15
 
{
16
 
    char * endptr;
17
 
    
18
 
    errno = 0;
19
 
    endptr = (char *)s - 1;             /* invalid value        */
20
 
    if (strtol (s, & endptr, base) != ret
21
 
        || errno != err
22
 
#ifdef  __AVR__
23
 
        || endptr - s != len)
24
 
#else           /* Glibc 2.3.1 is not set endptr in the case of EINVAL  */
25
 
        || (errno != EINVAL && (endptr - s) != len) )
26
 
#endif
27
 
    {
28
 
#ifndef __AVR__
29
 
        printf ("strtol(\"%s\",,%d): %ld, errno: %d, len: %d\n",
30
 
            s, base, strtol(s, & endptr, base), errno, endptr - s);
31
 
#endif
32
 
        return 1;
33
 
    }
34
 
    return 0;
35
 
}