Просмотр исходного кода

Add unlocked variation of fwide function.

Signed-off-by: Wren Turkal <[email protected]>
Wren Turkal 4 лет назад
Родитель
Сommit
746a86a267
1 измененных файлов с 9 добавлено и 5 удалено
  1. 9 5
      src/header/stdio/mod.rs

+ 9 - 5
src/header/stdio/mod.rs

@@ -174,15 +174,19 @@ impl FILE {
     }
 
     pub fn try_set_orientation(&mut self, mode: c_int) -> c_int {
-        let mut stream = self.lock();
-        if stream.0.orientation == 0 {
-            stream.0.orientation = match mode {
+        let stream = self.lock();
+        stream.0.try_set_orientation_unlocked(mode)
+    }
+
+    pub fn try_set_orientation_unlocked(&mut self, mode: c_int) -> c_int {
+        if self.orientation == 0 {
+            self.orientation = match mode {
                 1..=i32::MAX => 1,
                 i32::MIN..=-1 => -1,
-                0 => stream.0.orientation,
+                0 => self.orientation,
             };
         }
-        stream.0.orientation
+        self.orientation
     }
 }