When attempting to fix the dirent code I also changed
this to use strlcpy instead of the custom string copy
loop that was there before. Looking over strlcpy it
looked like it should work when using a non null terminated
string, I obviously misinterpreted the implementation
as it will read till it finds a null terminator.
Manually null terminate the string to address this.
Gunnar found this after he fixed UserspaceEmulator.
I reproduced it locally using his branch, and also
found the memory leak I had in the unit test for the
scandir that I added, so lets fix that as well.
Reported-by: Gunnar Beutner <gbeutner@serenityos.org>
This patches fixes a crash of the Userland/TextEditor where it would
crash when deleting a range spanning two lines. This was because the
TextEditor would delete the range and modify the cursor position
before clearing the selection. This would trigger a status bar update
with the invalid selection.
math.cpp: In function 'int64_t __moddi3(int64_t, int64_t)':
math.cpp:168:13: error: 'r' may be used uninitialized
[-Werror=maybe-uninitialized]
168 | return ((int64_t)r ^ s) - s; // negate if s == -1
| ^~~~~~~~~~
This commit adds a draw_physical_line method, which is the exact same
as draw_line, except it's parameters are already transformed and
scaled. This is used by both draw_line and draw_rect, as a slight
optimization to save some work. It also fixed draw_rect not checking
whether it should draw the lines before drawing them.
If the user tries to exit HackStudio, or build the project, when there
are unsaved changes in some of the editors, A Yes/No/Cancel dialog will
be shown.
It had the following FIXME:
// FIXME: This doesn't seem compatible with multiple split editors
In practice this member was used to get the filename of the currently
active edtior. So we now get it directly from the currently active
EditorWrapper.
This allows the painter to be scaled separately in both directions, and
not just in integer intervals. This is crucial for proper SVG viewBox
support.
Most bitmap-related things verify the scale to be one as of now.
This commit unifies methods and method/param names between the above
classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where
appropriate. It also renamed the various move_by methods to
translate_by, as that more closely matches the transformation
terminology.
This change establishes a new set of LibTest based tests for validating
the functionality of our pthread implementation. The first tests added
validate the error handling for the pthread spinlock API:
* pthread_spin_init
* pthread_spin_lock
* pthread_spin_try_lock
* pthread_spin_unlock
* pthread_spin_destroy
This change implements the pthread user space spinlock API. The
stress-ng Port requires a functioning version to work correctly.
To facilitate the requirements of the posix specification for the API
we implement the spinlock so that the owning tid is the value stored
in the spinlock. This gives us the proper ownership semantics needed
to implement the proper error handling.
This resolves the crash in #6812 where the browser was trying to open a
file in the Download directory, but the check against allowed paths was
also trying to match the URL fragment.
Resolves#6812
This commit makes the shell:
- highlight executables in the current directory as invalid, unless an
explicit `./' is given (so, `./foo` isn't red, but `foo` is)
- not suggest executables in the current directory unless explicitly
requested (by prepending `./`)
- not attempt to run an executable in the current directory that has
been invoked as a program name and failed execvp().
Note that `./foo` is still executed because it's not invoked as
a name, but rather as a path.
Fixes the other half of #6774.
This bit of code was kept unmodified since it was first implemented,
and I'm not entirely convinced that it ever actually worked :P
This commit updates the code to use "modern" classes and constructs,
and fixes an issue where the shebang would still contain the '#!'
when it was passed to execvp().
Fixes#6774.
Windows that are marked as modified will now have another (themable)
close button. This gives an additional visual clue that some action
will be required by the user before the window gets closed.
The default window-close-modified icon is an "X" with "..." underneath,
building on the established use of "..." in menus to signify that
additional user input will be required before an action is completed.
I ran into a need for this when running stress-ng against the system.
This change implements the full functionality of scandir, where it
accepts a selection callback, as well as a comparison callback.
These can be used to trim and sort the entries from the directory
that we are being asked to enumerate. A test was also included to
validate the new functionality.
While adding new functionality which used the d_reclen member
to copy a dirent, I realized that the value being populated
was incorrect. sys_ent::total_size() function calculates the
size of the sys_ent structure, but dirent is larger than sys_ent.
This causes the malloc to be too small and you end up missing
the end of the copy, which can miss the null terminator
resulting in corrupt dirent names.
Since we don't actually use the variable length member nature
of dirent on other platforms we can just use the full size of
the struct ad the d_reclen value.
Also replace the custom strcpy with the standard version.
This allows the user to specify a specific line and column number to
start at when opening a file in TextEditor through the terminal, by
adding a colon after the file name.
For example, `TextEditor ReadMe.md:10:5` will open ReadMe.md and put
the cursor on line 10 at column 5.
To ensure that the user isn't trying to open a file that actually has
colons in its name, it checks if the file exists before parsing.
Replaces the feature added in b474f49164Closes#5589
Instead of tracking this stuff ourselves at the application level,
we now just act as an intermediary and pass along the information to
the windowing system.