Skip to content

Commit 9bbbe94

Browse files
hlovdalianfixes
authored andcommitted
Convert from ltoa to itoa and enable
1 parent f4f553e commit 9bbbe94

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

cpp/arduino/stdlib.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
#if 0 // This code is copied from https://people.cs.umu.se/isak/snippets/ltoa.c
2+
#if 1 // This code is copied from https://people.cs.umu.se/isak/snippets/ltoa.c and then converted from ltoa to itoa.
33
/*
44
** LTOA.C
55
**
6-
** Converts a long integer to a string.
6+
** Converts a integer to a string.
77
**
88
** Copyright 1988-90 by Robert B. Stout dba MicroFirm
99
**
@@ -21,12 +21,12 @@
2121
#include <stdlib.h>
2222
#include <string.h>
2323

24-
#define BUFSIZE (sizeof(long) * 8 + 1)
24+
#define BUFSIZE (sizeof(int) * 8 + 1)
2525

26-
char *ltoa(long N, char *str, int base)
26+
char *itoa(int N, char *str, int base)
2727
{
28-
register int i = 2;
29-
long uarg;
28+
int i = 2;
29+
int uarg;
3030
char *tail, *head = str, buf[BUFSIZE];
3131

3232
if (36 < base || 2 > base)
@@ -45,7 +45,7 @@ char *ltoa(long N, char *str, int base)
4545
{
4646
for (i = 1; uarg; ++i)
4747
{
48-
register ldiv_t r;
48+
ldiv_t r;
4949

5050
r = ldiv(uarg, base);
5151
*tail-- = (char)(r.rem + ((9L < r.rem) ?

0 commit comments

Comments
 (0)