keplerproject/luafilesystem — pull request #44 by stefan991 (2014-08-09 12:51:45+00:00)
Title: Fix attributes `blksize` and `blocks`

While writing unittests for [Neovim](http://neovim.org) I found this bug:
```
% lua
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> require 'lfs'
> print(lfs.attributes('./lfs.so', 'blksize'))
48
> print(lfs.attributes('./lfs.so', 'blocks'))
rwxr-xr-x
```
`48` is the number of blocks and `rwxr-xr-x` is the permission string for the file.

Luckily there is a workaround until this gets merged:
```
> print(lfs.attributes('./lfs.so').blksize)
4096
```

[The current code](
https://github.com/keplerproject/luafilesystem/blob/5be0c7156e0d34e3379cb13e9d487a069ac07557/src/lfs.c#L812) uses [magic constants](http://en.wikipedia.org/wiki/Magic_number_(programming)#Unnamed_numerical_constants) and [this commit](https://github.com/keplerproject/luafilesystem/commit/84f1af5eef6af267109eaa84c18c5a70edaf65ea#diff-f6b7bcefa5f97fba6fa9e82b43357724R778) broke the indexes.

This PR adds a test for this bug and updates the code to simply compare the whole string instead of the first character of the attribute name and removes the spacial cases for `mode`, `blocks` and `blksize`.