diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2017-04-30 13:08:39 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2017-05-10 16:14:12 +0200 |
commit | c778311505fe89e3f32ff3027f0a41f0a2b2fd95 (patch) | |
tree | 88068e20af8d2eeb0ef2de8c726ffa718f406f56 /scripts/gencharblob.lua | |
parent | 4eb781ce1d8d5796bb5c2db96c48152021165b50 (diff) | |
download | rneovim-c778311505fe89e3f32ff3027f0a41f0a2b2fd95.tar.gz rneovim-c778311505fe89e3f32ff3027f0a41f0a2b2fd95.tar.bz2 rneovim-c778311505fe89e3f32ff3027f0a41f0a2b2fd95.zip |
generators: separate source generators from scripts
Diffstat (limited to 'scripts/gencharblob.lua')
-rw-r--r-- | scripts/gencharblob.lua | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/scripts/gencharblob.lua b/scripts/gencharblob.lua deleted file mode 100644 index d860375e26..0000000000 --- a/scripts/gencharblob.lua +++ /dev/null @@ -1,48 +0,0 @@ -if arg[1] == '--help' then - print('Usage:') - print(' gencharblob.lua source target varname') - print('') - print('Generates C file with big uint8_t blob.') - print('Blob will be stored in a static const array named varname.') - os.exit() -end - -assert(#arg == 3) - -local source_file = arg[1] -local target_file = arg[2] -local varname = arg[3] - -source = io.open(source_file, 'r') -target = io.open(target_file, 'w') - -target:write('#include <stdint.h>\n\n') -target:write(('static const uint8_t %s[] = {\n'):format(varname)) - -num_bytes = 0 -MAX_NUM_BYTES = 15 -- 78 / 5: maximum number of bytes on one line -target:write(' ') - -increase_num_bytes = function() - num_bytes = num_bytes + 1 - if num_bytes == MAX_NUM_BYTES then - num_bytes = 0 - target:write('\n ') - end -end - -for line in source:lines() do - for i = 1,string.len(line) do - byte = string.byte(line, i) - assert(byte ~= 0) - target:write(string.format(' %3u,', byte)) - increase_num_bytes() - end - target:write(string.format(' %3u,', string.byte('\n', 1))) - increase_num_bytes() -end - -target:write(' 0};\n') - -source:close() -target:close() |