Browse Source

Fix CI & compatibility with older rust

jD91mZM2 5 years ago
parent
commit
1a0f72dad8
2 changed files with 9 additions and 5 deletions
  1. 1 0
      .gitlab-ci.yml
  2. 8 5
      src/header/stdio/printf.rs

+ 1 - 0
.gitlab-ci.yml

@@ -7,6 +7,7 @@ stages:
 before_script:
     - apt-get update -qq
     - apt-get install -qq git
+    - git submodule sync --recursive
     - git submodule update --init --recursive
 
 cache:

+ 8 - 5
src/header/stdio/printf.rs

@@ -315,11 +315,14 @@ fn abs(float: c_double) -> c_double {
 fn float_string(float: c_double, precision: usize, trim: bool) -> String {
     let mut string = format!("{:.p$}", float, p = precision);
     if trim && string.contains('.') {
-        let slice = string.trim_end_matches('0');
-        let mut truncate = slice.len();
-        if slice.ends_with('.') {
-            truncate -= 1;
-        }
+        let truncate = {
+            let slice = string.trim_end_matches('0');
+            let mut truncate = slice.len();
+            if slice.ends_with('.') {
+                truncate -= 1;
+            }
+            truncate
+        };
         string.truncate(truncate);
     }
     string