Commit Graph

372 Commits

Author SHA1 Message Date
Thomas Jensen
241459e5b4
Add ncurses library to check terminal's color support 2023-05-08 21:12:00 +02:00
Thomas Jensen
89111c55b6
Add new command line options --color and --no-color 2023-05-07 15:25:23 +02:00
Thomas Jensen
08feb7eb2c
Add long options capability to command line 2023-05-06 22:43:11 +02:00
Thomas Jensen
1845d1ebb1
Disable some code in the "tools" module which is only for debugging purposes 2023-05-04 21:49:52 +02:00
Thomas Jensen
d36380268d
Add first test case for a UTF-8 config file 2023-05-04 21:32:49 +02:00
Thomas Jensen
4cce7ae461
Add bxs_is_visible_char() to 'bxstring' module 2023-05-04 21:30:47 +02:00
Thomas Jensen
d80ed48102
Fix declared header dependencies in Makefiles 2023-05-01 21:41:02 +02:00
Thomas Jensen
c41997870e
Add test case and fix for string with broken escape sequences 2023-05-01 14:18:33 +02:00
Thomas Jensen
34759334f7
Print useful error message on invalid design name 2023-04-30 17:44:32 +02:00
Thomas Jensen
b7e3549d15
Implement some of the things marked as to-do 2023-04-30 17:15:22 +02:00
Thomas Jensen
771f78874e
Move code on shape lines from parser.y to parsecode.c 2023-04-30 14:14:21 +02:00
Thomas Jensen
24018c3f86
Update help text for -m option 2023-04-20 21:54:00 +02:00
Thomas Jensen
21a691fbd1
Use UTF-8 data read from config file #72
- shapes get additional MBCS values
- metadata is already converted for real to use bxstr_t*
2023-04-19 21:06:00 +02:00
Thomas Jensen
8a7bb8039f
Enable lexer and parser to handle UTF-8 config file #72 2023-04-07 21:10:00 +02:00
Thomas Jensen
4ff37eb5ba
Extend bxstring functionality 2023-03-31 21:00:00 +02:00
Thomas Jensen
5026357fc2
Add more tests for bxstring creating functions 2023-03-28 21:27:06 +02:00
Thomas Jensen
b0d3384bd4
Add new "bxstring" module which is meant to evolve into boxes' string abstraction
It handles embedded escape sequences, mbcs encodings, and characters wider than 1 column.
2023-03-26 21:34:44 +02:00
Thomas Jensen
77d02890a7
Update copyright statements for 2023 2023-03-26 21:32:08 +02:00
Pascal Jaeger
bfb5545215 Fix K&R C declaration to work with Clang16
By default Clang16 will not allow implicit function declarations, which
would let this build fail with it.

Fix #106

Signed-off-by: Pascal Jaeger <pascal.jaeger@leimstift.de>
2022-10-18 14:17:43 +02:00
Đoàn Trần Công Danh
61562b0158 remove: fix out-of-bound access
The `u32_move` will try to read `input.lines[j].num_chars - c + 1` `u32`
octets from `input.lines[j].mbtext + input.lines[j].posmap[c]`. That
means, it needs access memory at address
`input.lines[j].mbtext + input.lines[j].posmap[c] + input.lines[j].num_chars - c`
while the max range is `input.lines[j].mbtext + input.lines[j].num_chars`,
which is out-of-bound because `input.lines[j].posmap[c] > c` obviously.

Fix #103
2022-10-04 21:33:18 +02:00
Thomas Jensen
6b6c1ad528
Enable build process to create a static binary for Unix #100
One can now run "make static" to get a binary that is statically linked
to libunistring and pcre2. Both libraries are downloaded first,
so they don't need to be available on the machine.
2022-09-23 22:06:47 +02:00
Thomas Jensen
a3a37b50fc
Upgrade project license to GPL-3 #101 2022-09-18 15:00:15 +02:00
Thomas Jensen
11da751439
Add more unit tests for command line option parsing 2021-11-05 22:02:55 +01:00
Thomas Jensen
7b828461ed
Add unit tests for different input and output file situations 2021-11-05 21:48:50 +01:00
Thomas Jensen
413b174d6c
Add unit tests for alignment option parsing (-a) 2021-11-05 21:10:11 +01:00
Thomas Jensen
fbc4678faa
Add some unit tests for tab option parsing (-t) 2021-11-05 14:28:13 +01:00
Thomas Jensen
eab1e13df2
Fix a small bug when parsing the padding command line argument (-p)
When an empty string was passed as padding spec, this was
not properly flagged as an error.
2021-11-05 14:03:49 +01:00
Thomas Jensen
84d051f1e5
Add unit tests for '-k' option parsing 2021-11-04 21:53:35 +01:00
Thomas Jensen
0e2b57c97d
Add unit tests for indentation mode cmdline parsing 2021-11-04 14:12:40 +01:00
Thomas Jensen
b07af10931
Add three more unit tests for regex_replace() 2021-11-01 21:46:43 +01:00
Thomas Jensen
ab28ad8c3a
Add workaround for mockable fprintf on MinGW 2021-11-01 14:23:19 +01:00
Thomas Jensen
4ae947ff99
Extend unit testing capabilities
- Structure unit tests into multiple modules
- Add setup/teardown of fixtures
- Add ability to capture and check stdout and stderr
- Add mock handling to Makefile
2021-10-28 09:01:14 +02:00
Thomas Jensen
a5dae11c4c
Add the first cmocka-based unit tests 2021-10-21 20:23:52 +02:00
Thomas Jensen
e40fe370e2
Add test coverage measurement to black-box tests 2021-09-09 21:44:49 +02:00
David Yang
3c56934ddc
Remove whitespace check on -c (#92)
Resolves #88
2021-08-31 17:31:43 +02:00
Thomas Jensen
ab9f123981
Count tab as whitespace in "empty shape" check #92 2021-08-28 15:08:44 +02:00
Thomas Jensen
4ced2b4715
Fix bug with :global: parent resolution 2021-06-16 20:52:36 +02:00
Thomas Jensen
252d080403
Tag 'none' is not allowed 2021-06-13 22:35:39 +02:00
Thomas Jensen
2d3a842728
Refactor lexer and parser for maintainability
- Speedmode is now purely a parser thing
- Lexer start condition SPEEDMODE is no longer needed
- Added lexer start condition BOX to distinguish box def content
- DELIMs are now purely a lexer thing
- No shared state between lexer and parser for DELIMs anymore
- Fix bug where speedmode could terminate in a SAMPLE block
- All lexer start conditions now exclusive
- Improved debug output
- Renamed parser token YDELWORD to YDELIMSPEC
2021-06-13 22:34:53 +02:00
Thomas Jensen
00153f8068
Fix a bug where alias names could be defined twice
This could happen when configs are inherited, but aliases redefined
(a rare case so far).
2021-06-08 22:06:25 +02:00
Thomas Jensen
4daa0f4f46
Fix repo encoding of ISO-8859-15 encoded files #83 2021-04-27 10:51:00 +02:00
Thomas Jensen
b90475eb2c
Remove preproc troubleshooting file parser.p #82
It was useful for checking what the pre-processor
did to the parser.c file, but as this invocation
caused problems on macos, we can leave it out.
2021-04-27 10:39:13 +02:00
Thomas Jensen
d1a1cf1580
Declare our src/Makefile as serial #79
because for some reason, make exhibits very strange behavior
when executing it in parallel jobs
2021-04-20 21:28:30 +02:00
Thomas Jensen
434d5971bf
Extract smaller functions from the main() function #78 2021-04-17 15:31:08 +02:00
Thomas Jensen
82bc084bad
Extract tag query functionality into its own, new 'query' module #78 2021-04-17 15:31:04 +02:00
Thomas Jensen
4d0dbcd59b
Rename global variable anz_designs to num_designs #78 2021-04-17 15:31:00 +02:00
Thomas Jensen
9d17203f50
Rename anz_lines field in input_t to num_lines #78 2021-04-17 15:30:56 +02:00
Thomas Jensen
a7227c8aa8
Extract reading of input lines into its own, new 'input' module #78 2021-04-17 15:30:51 +02:00
Thomas Jensen
fb010bc7d6
Remove lexer.l special around input_t in boxes.h #78 2021-04-17 15:30:47 +02:00
Thomas Jensen
aa36998f77
Rename ANZ_* constants in shape.h to NUM_* #78
This is more in keeping with English standards, and hopefully
improves maintainability a small bit.
2021-04-17 15:30:42 +02:00
Thomas Jensen
2cc2bc1021
Extract list_designs functionality into its own, new 'list' module #78 2021-04-17 15:30:37 +02:00
Thomas Jensen
af6f123c99
Extract command line parsing functionality into its own, new 'cmdline' module #78
Also encapsulate this feature better, eliminate side effects,
and refactor into smaller functions.
2021-04-17 15:30:26 +02:00
Thomas Jensen
139994f97f
Add option to override line terminators #60 2021-04-11 20:34:51 +02:00
Thomas Jensen
8a6d0d3315
Add and use bx_strndup() in 'tools' module for cross-platform compatibility 2021-04-11 20:34:51 +02:00
Thomas Jensen
f620c1b19b
Extract full_parse_required() in parsecode.c for maintainability 2021-04-11 20:34:51 +02:00
Thomas Jensen
04283eb697
Remove undocumented contentpos feature
It is no longer needed, as we have MBCS support for input now.
2021-04-11 20:34:50 +02:00
Thomas Jensen
09d5ebcbb4
Untangle -l and -q options #23
Both are now used stand-alone for their respective purposes.
2021-04-11 20:34:41 +02:00
Thomas Jensen
76880f1c3c
Extract parser.y's C code into new parsecode module
We took the larger pieces only, with the aim of making parser.y more
readable and making it easier to understand the syntax rules.
Also, some IDEs (such as CLion and vscode) don't support yacc/bison
syntax to the full extent, so we have better IDE support in a C file.
2021-04-11 20:27:17 +02:00
Thomas Jensen
f147c8f6fc
Enable querying of the design list by tag #23 2021-04-11 20:27:15 +02:00
Thomas Jensen
27adf5b6ba
Add argument to -q option for tag queries #23
-q is no longer undocumented,
but can officially be used in combination with -l
2021-04-06 22:13:41 +02:00
Thomas Jensen
aab643acbc
Add array_contains0() and array_count0() function to tools module 2021-04-06 22:13:41 +02:00
Thomas Jensen
b51724f3b1
Handle tags as a real list in memory and config file #23
The previous keyword-based syntax remains supported for
forwards compatibility reasons.
2021-04-06 22:13:40 +02:00
Thomas Jensen
e360bfde4e
Use pre-built flex and bison on Windows for MinGW 2021-04-06 22:13:40 +02:00
Thomas Jensen
0d2cb14b95
Add some defines for compilation on Windows 2021-04-06 22:13:38 +02:00
Thomas Jensen
08cf6a5396
Flush stderr after parsing
This helps test cases find consistent output on all platforms
2021-04-06 22:13:37 +02:00
Thomas Jensen
157f4a136b
Normalize leading line break in sample text 2021-04-06 22:13:37 +02:00
Thomas Jensen
f6913d6684
Change order of includes in discovery module
This helps avoid a conflict between windows.h and unistd.h
2021-04-06 22:13:37 +02:00
Thomas Jensen
44f4c8adaa
Add support of alias names for designs #30 2021-03-30 20:34:20 +02:00
Thomas Jensen
97b62dd09a
Support multiple configuration files #5
Main implementation
2021-03-22 21:31:27 +01:00
Thomas Jensen
46aab3faa6
Add config file location to each design #5 2021-03-22 20:45:46 +01:00
Thomas Jensen
9315e62528
Add 'parent' keyword to parser/lexer #5
Also major parser/lexer rework to support being called multiple
times.  Switch to reentrant and parameterizable parser.
2021-03-22 20:45:45 +01:00
Thomas Jensen
425d354bc0
Move generated boxes.h to 'out/'
Also rename boxes.h.in to boxes.in.h to make file type detection easier
2021-03-22 20:45:45 +01:00
Thomas Jensen
614ea31237
Add function array_contains() to 'tools' module 2021-03-22 20:45:45 +01:00
Thomas Jensen
5c7680fbdb
Increase LINE_MAX_BYTES from 4096 to 16382 2021-03-22 20:45:44 +01:00
Thomas Jensen
f27bac6465
Add and update some project settings 2021-03-22 20:45:38 +01:00
Thomas Jensen
97a2e2d76d
Add global_only argument to discover_config_file() 2021-03-19 16:41:36 +01:00
Thomas Jensen
278246bde7
Move most generated files and binaries to 'out' dir
Better separation of sources and binaries
Fewer files in 'src' dir
2021-03-19 16:40:54 +01:00
Thomas Jensen
5cb5435119
Extract config file discovery code into new module 'discovery' 2021-03-19 16:40:54 +01:00
Thomas Jensen
d952bd6eea
Unify config file search order Linux/Unix and Windows #69
This means we have some XDG support on Windows, too,
although some global locations like /etc/xdg are unlikely to exist.
2021-03-19 16:40:53 +01:00
Thomas Jensen
033c879ae6
Add helper function concat_strings_alloc() to tools module 2021-03-19 16:40:53 +01:00
Thomas Jensen
877336a114
Add support for XDG base directories #69
for config file discovery. Also, the config file is searched in
more places, and can have more names. Details in issue comments.
2021-03-19 16:40:53 +01:00
Thomas Jensen
58148de27f
Fix initialization of tabpos data in boxes.c 2021-03-19 16:40:00 +01:00
Thomas Jensen
e106e1412a
Fix bug where tabpos data was not properly initialized in tools/expand_tabs_into() 2021-03-14 12:25:29 +01:00
Thomas Jensen
e68de92a6f
Fix number of blank lines after title in box design list 2021-02-16 11:36:59 +01:00
Thomas Jensen
1fae201e47
Clean misc/getopt.o along with other object files 2021-02-16 10:51:46 +01:00
Thomas Jensen
2f8f463a46
Fix length argument to pcre2_substitute() 2021-02-15 21:10:57 +01:00
Thomas Jensen
b0d2dd835d
Add \E( as a possible start of an escape sequence 2021-02-15 21:10:57 +01:00
Thomas Jensen
352a7b6d5d
Add test cases for removal of colored boxes 2021-02-15 21:10:57 +01:00
Thomas Jensen
f60b9c5140
Update declared dependencies between files in src/Makefile #1 2021-02-15 21:10:55 +01:00
Thomas Jensen
fc7f881767
Explicitly set UTF-8 charset in unicode test cases
so that they don't fail on systems where UTF-8 is not properly set on the terminal #1
2021-02-15 21:10:54 +01:00
Thomas Jensen
7532faf755
Enable Windows build with new unicode-enabled version under MinGW #1 2021-02-15 21:10:54 +01:00
Thomas Jensen
f4f14cdc61
Update copyright statements in source files with current year 2021-02-15 21:10:54 +01:00
Thomas Jensen
363e0266e0
Add test cases for unicode and invalid manual encoding #1 2021-02-15 20:35:29 +01:00
Thomas Jensen
44c2c526af
Add command line option -n to set character encoding of input text #1 2021-02-15 20:35:20 +01:00
Thomas Jensen
4c656727ec
Add advance_next32() function to 'unicode' module to encapsulate the escape handling logic #1 2021-02-13 11:01:55 +01:00
Thomas Jensen
5dad2d1137
Add unicode-awareness in box removal functionality #1 2021-02-13 11:01:55 +01:00
Thomas Jensen
c41a4e881e
Extract some duplicate code in boxes.c into new function analyze_line_ascii() #1 2021-02-13 11:01:54 +01:00
Thomas Jensen
a579da13a5
Unicode-enable regex processing by introducing PCRE2 #1 #67 2021-02-13 11:01:54 +01:00
Thomas Jensen
6a3d0e715c
Apply new code format from CLion 2021-02-13 11:01:54 +01:00
Thomas Jensen
53e7782b5f
Remove unused function nspaces32() from tools module #1 2021-02-13 11:01:54 +01:00