From 8c0154ef92f5134ae54c70f326bbc1cc1b16b8a4 Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 26 Jun 2020 11:34:05 +0100 Subject: [PATCH] indent --- README.org | 8 ++++---- src/mnemonic.rs | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.org b/README.org index f008ef0..c3b30be 100644 --- a/README.org +++ b/README.org @@ -86,7 +86,7 @@ #+BEGIN_SRC c char* buffer = alloca(length+1); assert(khash_do(&ctx, input_data, strlen(input_data), buffer, length) == KHASH_SUCCESS, "khash_do() failed."); - buffer[length] = 0; // Ensure we have a NUL terminator. + buffer[length+1] = 0; // Ensure we have a NUL terminator. setlocale(LC_ALL, ""); //Ensure we can print UTF-8. printf("Kana hash: %s\n", buffer); @@ -239,9 +239,9 @@ 3. The first index is calculated as the unsigned first byte modulo the size (exclusive) of /range/. Store this as /index/. 4. Compute the value of the first byte bitwise ~XOR~ the second byte, store this as /index1/. 5. The swap table is checked to see if /index/ + start of /range/ has an entry. Then each following step is checked in order: - + If the swap entry exists and /index1/ bitwise ~AND~ =0x2= is =0=, set the first character of the output to the value found in the swap table. - + If the swap entry exists and /index1/ bitwise ~AND~ =0x8= is =0= and /index/ + start of /range/ has an entry in the 2nd swap table, set the first character of the output to the value found in the 2nd swap table. - + In any other case, set the first character of the output to the value found in the /kana/ slice at /index/. + + If the swap entry exists and /index1/ bitwise ~AND~ =0x2= is =0=, set the first character of the output to the value found in the swap table. + + If the swap entry exists and /index1/ bitwise ~AND~ =0x8= is =0= and /index/ + start of /range/ has an entry in the 2nd swap table, set the first character of the output to the value found in the 2nd swap table. + + In any other case, set the first character of the output to the value found in the /kana/ slice at /index/. - Stage 1: 1. Compute a sub table for /index/ plus the start of /range/ using the ranges defined in ~KANA_SUB_VALID_FOR~ and store it in /sub/. If there is no sub table possible, skip to step 3. 2. If there is an entry in /sub/ for the index of the 2nd byte modulo the size of ~KANA_SUB~, set the second output character to be that character. diff --git a/src/mnemonic.rs b/src/mnemonic.rs index 74bd228..80de6ad 100644 --- a/src/mnemonic.rs +++ b/src/mnemonic.rs @@ -42,8 +42,7 @@ impl Digest { return d; } } - let from = [from[1]]; - d.1 = Self::new(&from[..]).0; + d.1 = Self::new(&from[1..]).0; } d }