Skip to content

bmedicke/power_of_2_decode

Repository files navigation

readme

usage

See decode -h.

notes on compiling

  • Tested with clang and gcc.
  • Tested on macos 10.13 and Arch Linux 4.13.
  • Uses the C99 standard (for _Bool).
  • Edit the Makefile to change settings.

make commands

make all

Compile everything that's out of date. The default compiler is clang.

make clean

Remove all binaries, object files and other output files.

make run

Runs the command with the default settings.

make verbose

Runs the command with default settings plus enable verbose output.

make help

Show the help text.

make format

Format all source files and shows changes via a git diff to make individual decisions. Requires astyle and git.

make link

Create a symlink pointing to the binary. Default target is /usr/local/bin.

make watch

Watches the source files for changes, recompiles and runs the binaries as necessary. Requires hr and entr.

make doc

Watches source and markdown files for changes, regenerates the documentation with Doxygen. Requires doxygen and entr.

make report

Run to detect memory leaks. Removes PID from the report file to allow proper usage of git diff. Requires Valgrind and sponge from the moreutils.

used third party libraries

All code not written by me is in the vendor folder.

  • klib, MIT licensed
    • specifically khash.h for a hash map storing the count of the occurrences for the decoded words.
    • reasoning: fast, single file (header only), independent libraries; used in big projects (e.g. Neovim)

useful links and notes

C

IDE

get header search path for clang:

echo | clang -v -E -x c -

add paths to .ycm_extra_conf.py.

doxygen

klib

error handling

  • input file characters not exclusively ones and zeroes
  • input file characters outside the defined ASCII range (A-Z + space)
  • input file characters not resolvable
  • any file not writeable (chowned by root)

known limitations

  • can't handle words longer than MAXWORDSIZE defined in helpers.c
  • order of words with same count is semi-random (based on hash table)
  • assumes there's enough memory available to store entire decoded file