File tree 2 files changed +75
-0
lines changed
2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ #if 0 // This code is copied from https://people.cs.umu.se/isak/snippets/ltoa.c
3
+ /*
4
+ ** LTOA.C
5
+ **
6
+ ** Converts a long integer to a string.
7
+ **
8
+ ** Copyright 1988-90 by Robert B. Stout dba MicroFirm
9
+ **
10
+ ** Released to public domain, 1991
11
+ **
12
+ ** Parameters: 1 - number to be converted
13
+ ** 2 - buffer in which to build the converted string
14
+ ** 3 - number base to use for conversion
15
+ **
16
+ ** Returns: A character pointer to the converted string if
17
+ ** successful, a NULL pointer if the number base specified
18
+ ** is out of range.
19
+ */
20
+
21
+ #include <stdlib.h>
22
+ #include <string.h>
23
+
24
+ #define BUFSIZE (sizeof(long) * 8 + 1)
25
+
26
+ char *ltoa(long N, char *str, int base)
27
+ {
28
+ register int i = 2;
29
+ long uarg;
30
+ char *tail, *head = str, buf[BUFSIZE];
31
+
32
+ if (36 < base || 2 > base)
33
+ base = 10; /* can only use 0-9, A-Z */
34
+ tail = &buf[BUFSIZE - 1]; /* last character position */
35
+ *tail-- = '\0';
36
+
37
+ if (10 == base && N < 0L)
38
+ {
39
+ *head++ = '-';
40
+ uarg = -N;
41
+ }
42
+ else uarg = N;
43
+
44
+ if (uarg)
45
+ {
46
+ for (i = 1; uarg; ++i)
47
+ {
48
+ register ldiv_t r;
49
+
50
+ r = ldiv(uarg, base);
51
+ *tail-- = (char)(r.rem + ((9L < r.rem) ?
52
+ ('A' - 10L) : '0'));
53
+ uarg = r.quot;
54
+ }
55
+ }
56
+ else *tail-- = '0';
57
+
58
+ memcpy(head, ++tail, i);
59
+ return str;
60
+ }
61
+ #endif
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ // Header file to compensate for differences between
4
+ // arduino-1.x.x/hardware/tools/avr/avr/include/stdlib.h and /usr/include/stdlib.h.
5
+
6
+ #include_next <stdlib.h>
7
+
8
+ /*
9
+ * Arduino stdlib.h includes a prototype for itoa which is not a standard function,
10
+ * and is not available in /usr/include/stdlib.h. Provide one here.
11
+ * http://www.cplusplus.com/reference/cstdlib/itoa/
12
+ * https://stackoverflow.com/questions/190229/where-is-the-itoa-function-in-linux
13
+ */
14
+ char * itoa (int val , char * s , int radix );
You can’t perform that action at this time.
0 commit comments