summaryrefslogtreecommitdiff
path: root/text.c
AgeCommit message (Collapse)Author
2017-05-03text: remove count argument from text_{earlier,later}Marc André Tanner
2017-05-03text: rename text_sigbus to text_mmapedMarc André Tanner
Add casts to uintptr_t to avoid unrelated pointer comparisons.
2017-05-03text: rename text_byte_get argument nameMarc André Tanner
2017-04-11text: do not redefine _GNU_SOURCEMarc André Tanner
Fix #536
2017-04-09text: use MB_LEN_MAX instead of MB_CUR_MAXMarc André Tanner
2017-04-09vis: remove handling of \r\n line endingsMarc André Tanner
Use something like dos2unix(1) and unix2dos(1), if you need to edit such files.
2017-04-09text: drop special handling of \r\n line endingsMarc André Tanner
2017-04-09text: add mem{r,}chr(3) based byte search functionsMarc André Tanner
These are generally implemented efficiently in libc. While memrchr(3) is non-standard, it is a common extension. If it is not available, we use a simple C implementation from musl.
2017-04-08text: adjust iterator position when switching to adjacent piecesMarc André Tanner
2017-04-08text: introduce text_char_get which converts \r\n to \nMarc André Tanner
2017-04-08text: fix iterator semantics regarding windows style newlinesMarc André Tanner
At some point we might drop this mess and ask users to rely upon dos2unix(1) and unix2dos(1), respectively.
2017-03-31text: Add missing va_end() whenRaúl Peñacoba
vsnprintf fails
2017-03-22text: use proper open(2) flags when saving inplaceMarc André Tanner
This was wrongly changed in commit 74085e92c095d0bf4b98e262cc07ccf9b7dfff3b.
2017-02-27Honor user's umask when saving filesMichael Forney
If the user wants new files to be created as 600, they will have set their umask to 077 in their environment. vis shouldn't restrict this further than the user has configured.
2017-02-27Remove unnecessary umask change in text_save_begin_inplaceMichael Forney
POSIX says that The mkstemp() function shall use the resulting pathname to create the file, and obtain a file descriptor for it, as if by a call to: open(pathname, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR) So this umask change didn't do anything in practice, unless the original umask was more restrictive than 0177.
2017-02-27Fix a couple typosMichael Forney
2017-02-25text: add iterator accessor function which translates \r\n to \nMarc André Tanner
2017-02-23vis: improve handling of \r\n line endingsMarc André Tanner
Change the text_iterator_char_{prev,next} functions to treat them as a single character, meaning cursor motions will skip both bytes at the same time.
2017-02-20text: fix some integer overflow issuesMarc André Tanner
2017-02-09text: fix use of uninitialized variable in error pathMarc André Tanner
2017-02-08text: clean up iterator semanticsMarc André Tanner
We now guarantee the existence of at least one non-sentinel piece at all time and allow iterators to recover from these delimiting pieces.
2017-02-08text: remove special case for marks at start of fileMarc André Tanner
Unlike EOF address 0 needs no special treatment.
2017-01-20text: fix EOF handling for text_iterator_byte_nextMarc André Tanner
Handle zero length pieces gracefully. At some point we should write a comprehensive set of unit tests for the iterator API.
2016-12-23text: make text_vprintf static, it is only used within text.cMarc André Tanner
2016-12-22text: introduce EMARK to denote an invalid markMarc André Tanner
Technically this macro name is in the reserved namespace of errno.h. The same is true for EPOS. Maybe we should rename them at some point, but for now the short names are convenient. Fix #443 Close #444
2016-12-22text: change datatype of Mark to uintptr_tMarc André Tanner
This should avoid undefined pointer comparisons.
2016-12-22text: make default block size overridable via C pre-processorMarc André Tanner
This will be used for unit test purposes to force more allocations.
2016-12-22text: avoid undefined multiple accesses in expressionMarc André Tanner
Work around for a (bogus?) tis-interpreter warning.
2016-12-22text: do not rely on indeterminate value in a comparisonMarc André Tanner
2016-12-14text: expose text save method to calling codeMarc André Tanner
There are cases where it is useful to specify how the file should be saved.
2016-11-10vis-lua: change misnamed attribute values of `file.newlines`Marc André Tanner
Also rename underlying C code.
2016-11-01text: change usage of sizeof idiom for allocation of new objectsMarc André Tanner
The new code is preferable because it works independently of the variable type. Whereas before a change in type, but not within the sizeof expression would cause a wrongly sized allocation.
2016-11-01text: rename Buffer to Block to avoid confusion with buffer.[ch]Marc André Tanner
2016-09-25text: improve variable namingMarc André Tanner
s/Action/Revision/g
2016-05-07text: fix bug in line break caching logicMarc André Tanner
2016-04-18text: when saving also fsync(2) the destination directory after rename(2)Marc André Tanner
2016-04-17text: add infrastructure to save non-contiguous rangesMarc André Tanner
2016-03-23Remove identically replicated copyright comments from source filesMarc André Tanner
2016-03-15text: improve ENOSPC handling when savingMarc André Tanner
The default atomic save method using rename(2) would correctly fail, but the calling code would wrongly assume it was because of dealing with a special (e.g. hard or symlink) file or that some other properties (e.g. POSIX ACL, SELinux labels, permissions etc) could not be restored. It would then go on to ftruncate(2) the file, if the following writes then fail (which is likely if the new file content is bigger or some other process has used up disk space in the mean time) we lose data. This should fix it for the common case i.e. regular file where the rename(2) based method is used. The problem persits when directly overwriting a file. It is unclear whether this could be improved/fixed by: 1) first appending the new file content to the old one 2) fsync the data (old||new) 3) deleteing the original file content by overwritting it with the previously appended new file content. That is essentially moving the new file content from the end of the file to the start. 4) ftruncate to the new file size 5) fsync the data (new) if during 1) or 2) an error would occur we could revert the operation by doing a ftruncate to the original file size. An error in steps 3-5 would still be fatal. Another option would be to first write a backup file somewhere.
2016-02-21Cleanup new line insertion codeMarc André Tanner
2016-01-10text: introduce text_bytes_alloc0 utility functionMarc André Tanner
Heap allocates a zero terminated string of the given range. Freeing is the caller's responsibility. Checks for unsigned integer overflow i.e. passing SIZE_MAX as len will always fail because there is no room for the terminating NUL byte. This is important as EPOS is defined to be SIZE_MAX.
2015-12-31text: let text_pos_by_lineno return EPOS if given a too large line numberMarc André Tanner
2015-12-31text: introduce text_newline_insertMarc André Tanner
2015-12-29Clean up build systemMarc André Tanner
2015-11-23text: introduce functions to iterate over graphemesMarc André Tanner
They currently consider any character for which wcwidth(3) return 0 as a combining character.
2015-11-20text: get modification time after replacing file content in placeMarc André Tanner
At the start of text_save_range we stat(2) the file to check whether we have currently mmap(2)-ed it. Then we proceed to write the new file content which changes modification time. Hence we have to stat(2) again to retrieve it. This should fix spurious warnings about file changes outside the editor when editing e.g. symlinked files.
2015-11-08Update year numbers in Copyright clauseMarc André Tanner
2015-11-02text: return end of changed range in text_redoMarc André Tanner
This affects the cursor placement when redoing changes in single cursor mode. Closes #42
2015-10-22text: introduce text_appendf utility functionMarc André Tanner
2015-10-09text: fix usage of va_arg in text_vprintfDavid B. Lamkins
Closes #76