mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
expr, sync, whoami: update Oniguruma and winapi
This commit is contained in:
parent
5d241da7ca
commit
2d798bd601
6 changed files with 23 additions and 16 deletions
|
@ -10,7 +10,7 @@ path = "expr.rs"
|
|||
|
||||
[dependencies]
|
||||
libc = "0.2.26"
|
||||
onig = "1.3.0"
|
||||
onig = "3.1.1"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
[[bin]]
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//!
|
||||
|
||||
use tokens::{Token};
|
||||
use onig::{Regex, Syntax, REGEX_OPTION_NONE};
|
||||
use onig::{Regex, RegexOptions, Syntax};
|
||||
|
||||
type TokenStack = Vec<(usize, Token)>;
|
||||
pub type OperandsList = Vec< Box<ASTNode> >;
|
||||
|
@ -354,7 +354,7 @@ fn infix_operator_and( values: &Vec<String> ) -> Result<String, String> {
|
|||
|
||||
fn operator_match(values: &Vec<String>) -> Result<String, String> {
|
||||
assert!(values.len() == 2);
|
||||
let re = match Regex::with_options(&values[1], REGEX_OPTION_NONE, Syntax::grep()) {
|
||||
let re = match Regex::with_options(&values[1], RegexOptions::REGEX_OPTION_NONE, Syntax::grep()) {
|
||||
Ok(m) => m,
|
||||
Err(err) => return Err(err.description().to_string())
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@ path = "sync.rs"
|
|||
[dependencies]
|
||||
getopts = "0.2.14"
|
||||
libc = "0.2.26"
|
||||
winapi = "0.2.8"
|
||||
winapi = { version = "0.3", features = ["handleapi", "winerror"] }
|
||||
kernel32-sys = "0.2.2"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
|
|
|
@ -44,13 +44,17 @@ mod platform {
|
|||
extern crate kernel32;
|
||||
use std::{mem};
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::{Write};
|
||||
use std::os::windows::prelude::*;
|
||||
use uucore::wide::{FromWide, ToWide};
|
||||
use self::winapi::um::winbase;
|
||||
use self::winapi::um::winnt;
|
||||
use self::winapi::shared::minwindef;
|
||||
use self::winapi::um::handleapi;
|
||||
use self::winapi::shared::winerror;
|
||||
|
||||
unsafe fn flush_volume(name: &str) {
|
||||
let name_wide = name.to_wide_null();
|
||||
if kernel32::GetDriveTypeW(name_wide.as_ptr()) == winapi::DRIVE_FIXED {
|
||||
if kernel32::GetDriveTypeW(name_wide.as_ptr()) == winbase::DRIVE_FIXED {
|
||||
let sliced_name = &name[..name.len() - 1]; // eliminate trailing backslash
|
||||
match OpenOptions::new().write(true).open(sliced_name) {
|
||||
Ok(file) => if kernel32::FlushFileBuffers(file.as_raw_handle()) == 0 {
|
||||
|
@ -61,10 +65,10 @@ mod platform {
|
|||
}
|
||||
}
|
||||
|
||||
unsafe fn find_first_volume() -> (String, winapi::HANDLE) {
|
||||
let mut name: [winapi::WCHAR; winapi::MAX_PATH] = mem::uninitialized();
|
||||
let handle = kernel32::FindFirstVolumeW(name.as_mut_ptr(), name.len() as winapi::DWORD);
|
||||
if handle == winapi::INVALID_HANDLE_VALUE {
|
||||
unsafe fn find_first_volume() -> (String, winnt::HANDLE) {
|
||||
let mut name: [winnt::WCHAR; minwindef::MAX_PATH] = mem::uninitialized();
|
||||
let handle = kernel32::FindFirstVolumeW(name.as_mut_ptr(), name.len() as minwindef::DWORD);
|
||||
if handle == handleapi::INVALID_HANDLE_VALUE {
|
||||
crash!(kernel32::GetLastError() as i32, "failed to find first volume");
|
||||
}
|
||||
(String::from_wide_null(&name), handle)
|
||||
|
@ -74,12 +78,12 @@ mod platform {
|
|||
let (first_volume, next_volume_handle) = find_first_volume();
|
||||
let mut volumes = vec![first_volume];
|
||||
loop {
|
||||
let mut name: [winapi::WCHAR; winapi::MAX_PATH] = mem::uninitialized();
|
||||
let mut name: [winnt::WCHAR; minwindef::MAX_PATH] = mem::uninitialized();
|
||||
if kernel32::FindNextVolumeW(
|
||||
next_volume_handle, name.as_mut_ptr(), name.len() as winapi::DWORD
|
||||
next_volume_handle, name.as_mut_ptr(), name.len() as minwindef::DWORD
|
||||
) == 0 {
|
||||
match kernel32::GetLastError() {
|
||||
winapi::ERROR_NO_MORE_FILES => {
|
||||
winerror::ERROR_NO_MORE_FILES => {
|
||||
kernel32::FindVolumeClose(next_volume_handle);
|
||||
return volumes
|
||||
},
|
||||
|
|
|
@ -10,7 +10,7 @@ path = "whoami.rs"
|
|||
|
||||
[dependencies]
|
||||
getopts = "0.2.14"
|
||||
winapi = "0.2.8"
|
||||
winapi = { version = "0.3", features = ["lmcons"] }
|
||||
advapi32-sys = "0.2.0"
|
||||
|
||||
[dependencies.uucore]
|
||||
|
|
|
@ -14,10 +14,13 @@ extern crate uucore;
|
|||
use std::io::{Error, Result};
|
||||
use std::mem;
|
||||
use uucore::wide::FromWide;
|
||||
use self::winapi::um::winnt;
|
||||
use self::winapi::shared::lmcons;
|
||||
use self::winapi::shared::minwindef;
|
||||
|
||||
pub unsafe fn getusername() -> Result<String> {
|
||||
let mut buffer: [winapi::WCHAR; winapi::UNLEN as usize + 1] = mem::uninitialized();
|
||||
let mut len = buffer.len() as winapi::DWORD;
|
||||
let mut buffer: [winnt::WCHAR; lmcons::UNLEN as usize + 1] = mem::uninitialized();
|
||||
let mut len = buffer.len() as minwindef::DWORD;
|
||||
if advapi32::GetUserNameW(buffer.as_mut_ptr(), &mut len) == 0 {
|
||||
return Err(Error::last_os_error())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue