summaryrefslogtreecommitdiff
path: root/Userland/Utilities
AgeCommit message (Collapse)Author
2021-07-04LibJS: Rewrite most of Object for spec compliance :^)Linus Groh
This is a huge patch, I know. In hindsight this perhaps could've been done slightly more incremental, but I started and then fixed everything until it worked, and here we are. I tried splitting of some completely unrelated changes into separate commits, however. Anyway. This is a rewrite of most of Object, and by extension large parts of Array, Proxy, Reflect, String, TypedArray, and some other things. What we already had worked fine for about 90% of things, but getting the last 10% right proved to be increasingly difficult with the current code that sort of grew organically and is only very loosely based on the spec - this became especially obvious when we started fixing a large number of test262 failures. Key changes include: - 1:1 matching function names and parameters of all object-related functions, to avoid ambiguity. Previously we had things like put(), which the spec doesn't have - as a result it wasn't always clear which need to be used. - Better separation between object abstract operations and internal methods - the former are always the same, the latter can be overridden (and are therefore virtual). The internal methods (i.e. [[Foo]] in the spec) are now prefixed with 'internal_' for clarity - again, it was previously not always clear which AO a certain method represents, get() could've been both Get and [[Get]] (I don't know which one it was closer to right now). Note that some of the old names have been kept until all code relying on them is updated, but they are now simple wrappers around the closest matching standard abstract operation. - Simplifications of the storage layer: functions that write values to storage are now prefixed with 'storage_' to make their purpose clear, and as they are not part of the spec they should not contain any steps specified by it. Much functionality is now covered by the layers above it and was removed (e.g. handling of accessors, attribute checks). - PropertyAttributes has been greatly simplified, and is being replaced by PropertyDescriptor - a concept similar to the current implementation, but more aligned with the actual spec. See the commit message of the previous commit where it was introduced for details. - As a bonus, and since I had to look at the spec a whole lot anyway, I introduced more inline comments with the exact steps from the spec - this makes it super easy to verify correctness. - East-const all the things. As a result of all of this, things are much more correct but a bit slower now. Retaining speed wasn't a consideration at all, I have done no profiling of the new code - there might be low hanging fruits, which we can then harvest separately. Special thanks to Idan for helping me with this by tracking down bugs, updating everything outside of LibJS to work with these changes (LibWeb, Spreadsheet, HackStudio), as well as providing countless patches to fix regressions I introduced - there still are very few (we got it down to 5), but we also get many new passing test262 tests in return. :^) Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04js: Handle detached ArrayBuffer in print_typed_array()Linus Groh
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04Userland: Add pgrepAziz Berkay Yesilyurt
2021-07-04Everywhere: Prefer using "..."sv over StringView { "..." }Gunnar Beutner
2021-07-02AK+Everywhere: Remove StringView::find_{first,last}_of(char) methodsMax Wipfli
This removes StringView::find_first_of(char) and find_last_of(char) and replaces all its usages with find and find_last respectively. This is because those two methods are functionally equivalent. find_{first,last}_of should only be used if searching for multiple different characters, which is never the case with the char argument. This also adds the [[nodiscard]] to the remaining find_{first,last}_of methods.
2021-07-02LibWasm: Give traps a reason and display it when neededAli Mohammad Pur
This makes debugging wasm code a bit easier, as we now know what fails instead of just "too bad, something went wrong".
2021-06-30Utilities: Fix Build on x86_64Hendiadyoin1
2021-06-30run-tests: Update for LexicalPath API changesAndreas Kling
2021-06-30AK+Everywhere: Use mostly StringView in LexicalPathMax Wipfli
This changes the m_parts, m_dirname, m_basename, m_title and m_extension member variables to StringViews onto the m_string String. It also removes the m_is_absolute member in favour of computing if a path is absolute in the is_absolute() getter. Due to this, the canonicalize() method has been completely rewritten. The parts() getter still returns a Vector<String>, although it is no longer a const reference as m_parts is no longer a Vector<String>. Rather, it is constructed from the StringViews in m_parts upon request. The parts_view() getter has been added, which returns Vector<StringView> const&. Most previous users of parts() have been changed to use parts_view(), except where Strings are required. Due to this change, it's is now no longer allow to create temporary LexicalPath objects to call the dirname, basename, title, or extension getters on them because the returned StringViews will point to possible freed memory.
2021-06-30AK+Everywhere: Add and use static APIs for LexicalPathMax Wipfli
The LexicalPath instance methods dirname(), basename(), title() and extension() will be changed to return StringView const& in a further commit. Due to this, users creating temporary LexicalPath objects just to call one of those getters will recieve a StringView const& pointing to a possible freed buffer. To avoid this, static methods for those APIs have been added, which will return a String by value to avoid those problems. All cases where temporary LexicalPath objects have been used as described above haven been changed to use the static APIs.
2021-06-30AK: Remove the LexicalPath::is_valid() APIMax Wipfli
Since this is always set to true on the non-default constructor and subsequently never modified, it is somewhat pointless. Furthermore, there are arguably no invalid relative paths.
2021-06-30LibVideo: Migrate to east-const style & apply other minor fixesFalseHonesty
This patch brings all of LibVideo up to the east-const style in the project. Additionally, it applies a few fixes from the reviews in #8170 that referred to older LibVideo code.
2021-06-30Userland: Unlink file after waiting for child in run-testsAndrew Kaster
TestProcFs expects to be able to stat its stdout and stderr. The new ProcFS implemetnation properly forwards the symlinks for /proc/pid/fd/[1,2] to the temporary file that we had unlinked prior to spawning the process. However, this makes it so that a normal stat on the symlink to that file fails (as expected). Move the unlink to after we've waited on the child, so that we know it won't be trying any funny business with its stdout/stderr anymore.
2021-06-30Base+Utilities: Add run-tests program to run system tests with LibTestAndrew Kaster
This test program heavily pulls from the JavaScriptTestRunner/test-js, but with a twist. Instead of loading JavaScript files into the current process, constructing a JS environment for them, and executing test suites/tests directly, run-tests posix_spawns each test file. Test file stdout is written to a temp file, and only dumped to console if the test fails or the verbose option is passed to the program. Unlike test-js, times are always printed for every test executed for better visibility in CI.
2021-06-29LibCrypto: Replace from_base{2,8,10,16}() & to_base10 with from_base(N)Idan Horowitz
This allows us to support parsing and serializing BigIntegers to and from any base N (such that 2 <= N <= 36).
2021-06-29AK+Everywhere: Change int to size_t in JsonObject and JsonArrayMax Wipfli
2021-06-28Kernel+LibELF: Add support for validating and loading ELF64 executablesGunnar Beutner
2021-06-28Utilities/top: Remove unused header includesMarcus Nilsson
2021-06-28Utilities/top: Add sort-by and delay-time optionsMarcus Nilsson
Add optional arguments to top so that the user can choose which field to sort by and change the update frequency.
2021-06-27LibJS: Rename ScriptFunction => OrdinaryFunctionObjectAndreas Kling
These are basically what the spec calls "ordinary function objects", so let's have the name reflect that. :^)
2021-06-27LibJS: Rename Function => FunctionObjectAndreas Kling
2021-06-27Kernel: Rename Thread::tss to Thread::regs and add x86_64 supportGunnar Beutner
We're using software context switches so calling this struct tss is somewhat misleading.
2021-06-27Kernel+Userland: Add x86_64 registers to RegisterState/PtraceRegistersGunnar Beutner
2021-06-24Utilities: Validate user with Core::Account in userdelbrapru
Previously the remove home directory option never actually removed the user's home directory because it was not properly unveiled. By validating the user with Core::Account, we can identify the user's home directory earlier in the program and unveil as necessary. Additionally, by identifying if the user does not exist much earlier in the program, this elimates depending on getpwent to validate the user and creating unneccessary temp files.
2021-06-24LibSQL: Make lexer and parser more standard SQL compliantJan de Visser
SQL was standardized before there was consensus on sane language syntax constructs had evolved. The language is mostly case-insensitive, with unquoted text converted to upper case. Identifiers can include lower case characters and other 'special' characters by enclosing the identifier with double quotes. A double quote is escaped by doubling it. Likewise, a single quote in a literal string is escaped by doubling it. All this means that the strategy used in the lexer, where a token's value is a StringView 'window' on the source string, does not work, because the value needs to be massaged before being handed to the parser. Therefore a token now has a String containing its value. Given the limited lifetime of a token, this is acceptable overhead. Not doing this means that for example quote removal and double quote escaping would need to be done in the parser or in AST node construction, which would spread lexing basically all over the place. Which would be suboptimal. There was some impact on the sql utility and SyntaxHighlighter component which was addressed by storing the token's end position together with the start position in order to properly highlight it. Finally, reviewing the tests for parsing numeric literals revealed an inconsistency in which tokens we accept or reject: `1a` is accepted but `1e` is rejected. Related to this is the fate of `0x`. Added a FIXME reminding us to address this.
2021-06-24LibSQL: Move Lexer and Parser machinery to AST directoryJan de Visser
The SQL engine is expected to be a fairly sizeable piece of software. Therefore we're starting to restructure the codebase for growth.
2021-06-21cp: Copy sources into destination if it is already a directorySam Atkins
Previously, copying a file to a directory, like this: ```cp README.md Desktop``` correctly copied it to Desktop/README.md, but would fail if the source was also a directory, for example: ```cp -R Documents Desktop``` Now, that correctly copies it to Desktop/Documents, as you would expect. :^)
2021-06-20js: Insert newline after each line in REPL modeyeeter-the-dog
This makes ASI work in the REPL.
2021-06-20WindowServer: Enable screen capture to span multiple screensTom
This enables the shot utility to capture all screens or just one, and enables the Magnifier application to track the mouse cursor across multiple screens.
2021-06-20WindowServer: Add API to set/get screen layoutsTom
This sets the stage so that DisplaySettings can configure the screen layout and set various screen resolutions in one go. It also allows for an easy "atomic" revert of the previous settings.
2021-06-20WindowServer: Add initial support for rendering on multiple screensTom
This allows WindowServer to use multiple framebuffer devices and compose the desktop with any arbitrary layout. Currently, it is assumed that it is configured contiguous and non-overlapping, but this should eventually be enforced. To make rendering efficient, each window now also tracks on which screens it needs to be rendered. This way we don't have to iterate all the windows for each screen but instead use the same rendering loop and then only render to the screen (or screens) that the window actually uses.
2021-06-19LibSymbolication+Utilities: Show inlined functions for btGunnar Beutner
2021-06-18LibJS: Implement the 'Hashbang Grammar for JS' proposalLinus Groh
Stage 3 since August 2019 - we already have shebang stripping implemented in js(1), so this removes it from there in favor of adding support to the lexer directly. Most straightforward proposal and implementation I've ever seen :^) https://github.com/tc39/proposal-hashbang
2021-06-18Userland/Libraries: Add LibUSBDB libraryJesse Buhagiar
Simple clone of LibPCIDB to support USB IDs instead of PCI ones. The format is basically identical, besides a few changes of the double tab fields.
2021-06-18Userland: Add `lsusb` :^)Jesse Buhagiar
2021-06-17passwd: Do not allow empty passwordsbrapru
The user should use the delete flag when wanting to issue an empty password. passwd should return an error after receiving empty input.
2021-06-17passwd: Provide more verbose output regarding status of changed passwdbrapru
passwd should explicitly indicate the status of the password change.
2021-06-17passwd: Retype password to confirmbrapru
Previously passwd would accept the first password input by the user. It should ask the user to re-type the password to check for mismatches and prevent typos in the password.
2021-06-17passwd: Prompt for the current password before setting new passwordbrapru
This changes passwd to authenticate non-root users before prompting for new password.
2021-06-17Everywhere: Replace the multiple impls of print_buffer() with :hex-dumpAli Mohammad Pur
2021-06-17Everywhere: Add component declarationsGunnar Beutner
This adds component declarations so that users can select to not build certain parts of the OS.
2021-06-17js: Add print_number method and use it to print out TypedArray valuesLuke
We can't construct Values with u64 and i64. I tried adding these constructors, but then it refuses to build in lagom.
2021-06-17Userland: Allow multiple files to be run by jssin-ack
js only accepted a single script file to run before this. With this patch, multiple scripts can be run in the same execution environment, allowing the user to specify a "preamble script" to be executed before the main script.
2021-06-15Userland: Teach the file utility that empty files also existValtteri Koskivuori
Previously, empty files with no identifiable file type extension would show up as `text/plain`. This fixes it up to show empty files as what they really are - full of nothing.
2021-06-15LibJS: Add a basic pass manager and add some basic passesAli Mohammad Pur
This commit adds a bunch of passes, the most interesting of which is a pass that merges blocks together, and a pass that places blocks that flow into each other next to each other, and a very simply pass that removes duplicate basic blocks. Note that this does not remove the jump at the end of each block in that pass to avoid scope creep in the passes.
2021-06-14Userland: Fix double line spacing in grepSahan Fernando
2021-06-14LibJS: Add the DataView built-in objectIdan Horowitz
2021-06-13LibJS: Make StringOrSymbol always be FlyString in the string caseAndreas Kling
This makes equality checking O(1) instead of O(n).
2021-06-13Utilites: Implement `unzip -q`Jelle Raaijmakers
2021-06-13Utilities: Change `unzip -o` option to `-d`Jelle Raaijmakers
Other `unzip` implementations universally use `-d` to indicate the output directory, so let's follow this convention.