summaryrefslogtreecommitdiff
path: root/lib/str2int.c
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-03-27 11:39:12 -0400
committerFreya Murphy <freya@freyacat.org>2025-03-27 11:39:12 -0400
commit0ff301cda68669c59351e5854ce98f2cf460543f (patch)
treecfe8f976261962420ada64b821559b9da0a56841 /lib/str2int.c
parentadd compile_flags.txt for clangd lsp (diff)
downloadcomus-0ff301cda68669c59351e5854ce98f2cf460543f.tar.gz
comus-0ff301cda68669c59351e5854ce98f2cf460543f.tar.bz2
comus-0ff301cda68669c59351e5854ce98f2cf460543f.zip
pull upstream changes, add auto formatting
Diffstat (limited to 'lib/str2int.c')
-rw-r--r--lib/str2int.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/str2int.c b/lib/str2int.c
index c0f777d..ce28a7a 100644
--- a/lib/str2int.c
+++ b/lib/str2int.c
@@ -21,31 +21,32 @@
**
** @return The converted integer
*/
-int str2int( register const char *str, register int base ) {
+int str2int(register const char *str, register int base)
+{
register int num = 0;
register char bchar = '9';
int sign = 1;
// check for leading '-'
- if( *str == '-' ) {
+ if (*str == '-') {
sign = -1;
++str;
}
- if( base != 10 ) {
+ if (base != 10) {
bchar = '0' + base - 1;
}
// iterate through the characters
- while( *str ) {
- if( *str < '0' || *str > bchar )
+ while (*str) {
+ if (*str < '0' || *str > bchar)
break;
num = num * base + *str - '0';
++str;
}
// return the converted value
- return( num * sign );
+ return (num * sign);
}
#endif