Skip to content

Commit f756e65

Browse files
formatting
1 parent 8d3886d commit f756e65

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

ulisp.hpp

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,9 +1489,9 @@ object* iptostring (uint32_t ip) {
14891489
object* lispstring (const char* s) {
14901490
object* obj = newstring();
14911491
object* tail = obj;
1492-
while(1) {
1492+
for (;;) {
14931493
char ch = *s++;
1494-
if (ch == 0) break;
1494+
if (ch == '\0') break;
14951495
if (ch == '\\') ch = *s++;
14961496
buildstring(ch, &tail);
14971497
}
@@ -1511,18 +1511,42 @@ int stringcompare (object* args, bool lt, bool gt, bool eq) {
15111511
object* arg2 = checkstring(second(args));
15121512
arg1 = cdr(arg1);
15131513
arg2 = cdr(arg2);
1514-
int m = 0; chars_t a = 0, b = 0;
1515-
while ((arg1 != NULL) || (arg2 != NULL)) {
1516-
if (arg1 == NULL) return lt ? m : -1;
1517-
if (arg2 == NULL) return gt ? m : -1;
1514+
int m = 0;
1515+
chars_t a = 0, b = 0;
1516+
while (arg1 || arg2) {
1517+
if (!arg1) return lt ? m : -1;
1518+
if (!arg2) return gt ? m : -1;
15181519
a = arg1->chars; b = arg2->chars;
1519-
if (a < b) { if (lt) { m = m + sizeof(int); while (a != b) { m--; a = a >> 8; b = b >> 8; } return m; } else return -1; }
1520-
if (a > b) { if (gt) { m = m + sizeof(int); while (a != b) { m--; a = a >> 8; b = b >> 8; } return m; } else return -1; }
1521-
arg1 = car(arg1); arg2 = car(arg2);
1522-
m = m + sizeof(int);
1520+
if (a < b) {
1521+
if (lt) {
1522+
m += sizeof(int);
1523+
while (a != b) {
1524+
m--;
1525+
a = a >> 8;
1526+
b = b >> 8;
1527+
}
1528+
return m;
1529+
}
1530+
else return -1;
1531+
}
1532+
if (a > b) {
1533+
if (gt) {
1534+
m += sizeof(int);
1535+
while (a != b) {
1536+
m--;
1537+
a = a >> 8;
1538+
b = b >> 8;
1539+
}
1540+
return m;
1541+
}
1542+
else return -1;
1543+
}
1544+
arg1 = car(arg1);
1545+
arg2 = car(arg2);
1546+
m += sizeof(int);
15231547
}
15241548
if (eq) {
1525-
m = m - sizeof(int);
1549+
m -= sizeof(int);
15261550
while (a != 0) {
15271551
m++;
15281552
a = a << 8;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy