Skip to content

Make readblob() possible to read from character device#11407

Closed
k-takata wants to merge 5 commits intovim:masterfrom
k-takata:readblob-char-dev
Closed

Make readblob() possible to read from character device#11407
k-takata wants to merge 5 commits intovim:masterfrom
k-takata:readblob-char-dev

Conversation

@k-takata
Copy link
Member

With this patch, readblob() can read from a character device if "offset" is zero and "size" is specified (on Unix):

let b = readblob('/dev/random', 0, 10)

(Not sure if this is useful, though.)

With this patch, readblob() can read from a character device if "offset"
is zero and "size" is specified (on Unix):

```
let b = readblob('/dev/random', 0, 10)
```

(Not sure if this is useful, though.)
@codecov
Copy link

codecov bot commented Oct 20, 2022

Codecov Report

Merging #11407 (b558df5) into master (7609c88) will decrease coverage by 0.02%.
The diff coverage is 75.00%.

@@            Coverage Diff             @@
##           master   #11407      +/-   ##
==========================================
- Coverage   81.82%   81.79%   -0.03%     
==========================================
  Files         162      162              
  Lines      189685   189687       +2     
  Branches    43124    43124              
==========================================
- Hits       155206   155162      -44     
- Misses      21919    21951      +32     
- Partials    12560    12574      +14     
Flag Coverage Δ
huge-clang-none 82.72% <75.00%> (-0.01%) ⬇️
huge-gcc-none 54.66% <75.00%> (-0.01%) ⬇️
huge-gcc-testgui ?
huge-gcc-unittests 0.29% <0.00%> (ø)
linux 82.41% <75.00%> (-0.09%) ⬇️
mingw-x64-HUGE 76.42% <50.00%> (+<0.01%) ⬆️
mingw-x86-HUGE 77.28% <75.00%> (+0.01%) ⬆️
windows 78.07% <75.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/blob.c 91.90% <75.00%> (+0.04%) ⬆️
src/gui_gtk_x11.c 51.11% <0.00%> (-0.52%) ⬇️
src/buffer.c 86.74% <0.00%> (-0.38%) ⬇️
src/optionstr.c 91.22% <0.00%> (-0.27%) ⬇️
src/regexp_nfa.c 89.57% <0.00%> (-0.24%) ⬇️
src/hardcopy.c 76.83% <0.00%> (-0.22%) ⬇️
src/insexpand.c 88.09% <0.00%> (-0.18%) ⬇️
src/netbeans.c 72.30% <0.00%> (-0.15%) ⬇️
src/spellfile.c 80.42% <0.00%> (-0.14%) ⬇️
src/misc2.c 89.26% <0.00%> (-0.10%) ⬇️
... and 11 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@brammool
Copy link
Contributor

brammool commented Oct 20, 2022 via email

@k-takata
Copy link
Member Author

Updated.

@chrisbra
Copy link
Member

let b = readblob('/dev/random', 0, 10)

Hm, why would we read from /dev/random, we have the rand() function already.
Perhaps a better example would be to read using /dev/ttyS0 to read something from a serial console?

@k-takata
Copy link
Member Author

Okay, updated.

@k-takata
Copy link
Member Author

Updated about {offset} for character devices.

@brammool brammool closed this in 4362576 Oct 20, 2022
@k-takata k-takata deleted the readblob-char-dev branch October 20, 2022 12:29
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Feb 28, 2023
Problem:    readblob() cannot read from character device.
Solution:   Use S_ISCHR() to not check the size. (Ken Takata, closes vim/vim#11407)

vim/vim@4362576

S_ISCHR is always defined in Nvim.

Co-authored-by: K.Takata <kentkt@csc.jp>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Feb 28, 2023
Problem:    readblob() cannot read from character device.
Solution:   Use S_ISCHR() to not check the size. (Ken Takata, closes vim/vim#11407)

vim/vim@4362576

S_ISCHR is always defined in Nvim.

Co-authored-by: K.Takata <kentkt@csc.jp>
yesean pushed a commit to yesean/neovim that referenced this pull request Mar 25, 2023
Problem:    readblob() cannot read from character device.
Solution:   Use S_ISCHR() to not check the size. (Ken Takata, closes vim/vim#11407)

vim/vim@4362576

S_ISCHR is always defined in Nvim.

Co-authored-by: K.Takata <kentkt@csc.jp>
folke pushed a commit to folke/neovim that referenced this pull request May 22, 2023
Problem:    readblob() cannot read from character device.
Solution:   Use S_ISCHR() to not check the size. (Ken Takata, closes vim/vim#11407)

vim/vim@4362576

S_ISCHR is always defined in Nvim.

Co-authored-by: K.Takata <kentkt@csc.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants