1
0
mirror of https://github.com/janet-lang/janet synced 2025-05-05 17:04:15 +00:00

Fix some typos and update comments.

This commit is contained in:
Calvin Rose 2019-01-02 12:21:59 -05:00
parent 618f8d6818
commit 122312dbf6
2 changed files with 12 additions and 13 deletions

View File

@ -164,7 +164,7 @@ static void integer_to_string_b(JanetBuffer *buffer, int32_t x) {
#define HEX(i) (((uint8_t *) janet_base64)[(i)]) #define HEX(i) (((uint8_t *) janet_base64)[(i)])
/* Returns a string description for a pointer. Truncates /* Returns a string description for a pointer. Truncates
* title to 12 characters */ * title to 32 characters */
static int32_t string_description_impl(uint8_t *buf, const char *title, void *pointer) { static int32_t string_description_impl(uint8_t *buf, const char *title, void *pointer) {
uint8_t *c = buf; uint8_t *c = buf;
int32_t i; int32_t i;
@ -607,7 +607,7 @@ JanetBuffer *janet_pretty(JanetBuffer *buffer, int depth, Janet x) {
} }
/* Helper function for formatting strings. Useful for generating error messages and the like. /* Helper function for formatting strings. Useful for generating error messages and the like.
* Similiar to printf, but specialized for operating with janet. */ * Similar to printf, but specialized for operating with janet. */
const uint8_t *janet_formatc(const char *format, ...) { const uint8_t *janet_formatc(const char *format, ...) {
va_list args; va_list args;
int32_t len = 0; int32_t len = 0;
@ -1246,7 +1246,7 @@ static const JanetReg cfuns[] = {
}, },
{"string/replace", cfun_replace, {"string/replace", cfun_replace,
"(string/replace patt subst str)\n\n" "(string/replace patt subst str)\n\n"
"Replace the first occurrence of patt with subst in the the string str. " "Replace the first occurrence of patt with subst in the string str. "
"Will return the new string if patt is found, otherwise returns str." "Will return the new string if patt is found, otherwise returns str."
}, },
{"string/replace-all", cfun_replaceall, {"string/replace-all", cfun_replaceall,
@ -1287,7 +1287,7 @@ static const JanetReg cfuns[] = {
}, },
{"string/pretty", cfun_pretty, {"string/pretty", cfun_pretty,
"(string/pretty x [,depth=4 [,buffer=@\"\"]])\n\n" "(string/pretty x [,depth=4 [,buffer=@\"\"]])\n\n"
"Pretty prints a value to a buffer. Optionally allwos setting max " "Pretty prints a value to a buffer. Optionally allows setting max "
"recursion depth, as well as writing to a buffer. Returns the buffer." "recursion depth, as well as writing to a buffer. Returns the buffer."
}, },
{NULL, NULL, NULL} {NULL, NULL, NULL}

View File

@ -104,7 +104,8 @@ static void bignat_append(struct BigNat *mant, uint32_t dig) {
} }
/* Multiply the mantissa mant by a factor and the add a term /* Multiply the mantissa mant by a factor and the add a term
* in one operation. Both factor and term will be between 2 and 36. */ * in one operation. factor will be between 2 and 36^4,
* term will be between 0 and 36. */
static void bignat_muladd(struct BigNat *mant, uint32_t factor, uint32_t term) { static void bignat_muladd(struct BigNat *mant, uint32_t factor, uint32_t term) {
int32_t i; int32_t i;
uint64_t carry = ((uint64_t) mant->first_digit) * factor + term; uint64_t carry = ((uint64_t) mant->first_digit) * factor + term;
@ -215,10 +216,9 @@ static double convert(
* Get exponent to zero while holding X constant. */ * Get exponent to zero while holding X constant. */
/* Positive exponents are simple */ /* Positive exponents are simple */
while (exponent > 0) { for (;exponent > 3; exponent -= 4) bignat_muladd(mant, base * base * base * base, 0);
bignat_muladd(mant, base, 0); for (;exponent > 1; exponent -= 2) bignat_muladd(mant, base * base, 0);
exponent--; for (;exponent > 0; exponent -= 1) bignat_muladd(mant, base, 0);
}
/* Negative exponents are tricky - we don't want to loose bits /* Negative exponents are tricky - we don't want to loose bits
* from integer division, so we need to premultiply. */ * from integer division, so we need to premultiply. */
@ -226,10 +226,9 @@ static double convert(
int32_t shamt = 5 - exponent / 4; int32_t shamt = 5 - exponent / 4;
bignat_lshift_n(mant, shamt); bignat_lshift_n(mant, shamt);
exponent2 -= shamt * BIGNAT_NBIT; exponent2 -= shamt * BIGNAT_NBIT;
while (exponent < 0) { for (;exponent < -3; exponent += 4) bignat_div(mant, base * base * base * base);
bignat_div(mant, base); for (;exponent < -2; exponent += 2) bignat_div(mant, base * base);
exponent++; for (;exponent < 0; exponent += 1) bignat_div(mant, base);
}
} }
return negative return negative