Commit Graph

30125 Commits

Author SHA1 Message Date
Timothy Flynn
04b8b87c17 LibJS+LibUnicode: Support multiple identifiers within format pattern
This wasn't the case for compact patterns, but unit patterns can contain
multiple (up to 2, really) identifiers that must each be recognized by
LibJS.

Each generated NumberFormat object now stores an array of identifiers
parsed. The format pattern itself is encoded with the index into this
array for that identifier, e.g. the compact format string "0K" will
become "{number}{compactIdentifier:0}".
2021-11-16 23:14:09 +00:00
Timothy Flynn
3b68370212 LibJS+LibUnicode: Rename the generated compact_identifier to identifier
This field is currently used to store the StringView into the compact
name/symbol in the format string. Units will need to store a similar
field, so rename the field to be more generic, and extract the parser
for it.
2021-11-16 23:14:09 +00:00
Timothy Flynn
6d34a0b4e8 LibJS+LibUnicode: Rename method to select a NumberFormat plurality
Instead of currency pattern lookups within select_currency_unit_pattern,
rename the method to select_pattern_with_plurality and accept any list
of patterns. This method will be needed for units.
2021-11-16 23:14:09 +00:00
Lady Gegga
fa13ab61e4 Base: Add/adjust glyphs in font Tiny Regular
Maintenance to stabilize the font.

- Added glyph FFFD
- Adjusted multiple glyphs for improved consistency
- Added a few glyphs to current ranges
- Added range Mende Kikakui 1E800-1E8DF (incomplete, I continued my work
  in Katica)
2021-11-16 23:07:43 +00:00
Linus Groh
6b2e004c28 LibJS: Fix incorrect use of "modulo" in {hour,min,sec,ms}_from_time()
These all would return incorrect results for negative time values.
Also adds a missing floor() in sec_from_time().
2021-11-16 19:40:49 +00:00
Benjamin S Osenbach
d82e41440c LibCore: Don't include crypt.h in Account.cpp on FreeBSD
Fixes #10803.
2021-11-16 19:06:13 +00:00
Linus Groh
58c6a156bf LibCrypto: Fix subtracting two negative SignedBigIntegers
Currently, we get the following results

    -1 - -2 = -1
    -2 - -1 =  1

Correct would be:

    -1 - -2 =  1
    -2 - -1 = -1

This was already attempted to be fixed in 7ed8970, but that change was
incorrect. This directly translates to LibJS BigInts having the same
incorrect behavior - it even was tested.
2021-11-16 10:06:53 +00:00
Luke Wilde
014840eeca LibJS: Use else-if's in Temporal.Duration.prototype.until
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/3dd2397
2021-11-16 09:10:41 +00:00
Karol Kosek
c3256a51cb LibGfx: Remove scale factor option from try_load_from_fd_and_close()
... and bring it back to try_load_from_file().

Prior to this change, changing the scaling option to x2 in the Display
Settings resulted in the following crash:

  WindowServer(15:15): ASSERTION FAILED: bitmap->width() % scale_factor
  == 0 ./Userland/Libraries/LibGfx/Bitmap.cpp:126

That was caused by two minor overlooked yaks:

- First, Bitmap::try_load_from_fd_and_close() tried to respect your
  scale factor.

  While requesting a bitmap from file can make a switcheroo to give you
  a higher resolution bitmap, doing the same when you already have an fd
  might violate the unveil agreement.
  ... but, it didn't do that.

  It read bitmaps from requested fds, but also pretended all system
  bitmaps in /res/ are the HiDPI ones when you enabled that mode.

- d85d741c59 used this function to deduplicate try_load_from_file().

  It actually made this bug a lot easier to replicate!


Closes #10920
2021-11-16 01:07:37 +00:00
Karol Kosek
e38b3f526e DisplaySettings: Handle errors when loading wallpaper bitmap
Prior this change, the app crashed if the first file in alphabetical
order in /res/wallpapers couldn't be decoded.
2021-11-16 01:07:37 +00:00
Luke Wilde
ac65fb40d9 LibJS: Implement Temporal.PlainDate.prototype.since 2021-11-16 01:06:07 +00:00
Luke Wilde
ddec3bc888 LibJS: Implement Temporal.PlainDate.prototype.until 2021-11-16 01:06:07 +00:00
Timothy Flynn
99c15741ba LibJS: Conditionally ignore [[UseGrouping]] in compact notation 2021-11-16 00:56:55 +00:00
Timothy Flynn
14aca03161 LibJS: Remove FIXME comment from PartitionNotationSubPattern AO
All possible patterns generated by LibUnicode are now handled. We have a
similar VERIFY_NOT_REACHED in PartitionNumberPattern.
2021-11-16 00:56:55 +00:00
Timothy Flynn
fdae323401 LibJS: Implement compact formatting for Intl.NumberFormat 2021-11-16 00:56:55 +00:00
Timothy Flynn
80b86d20dc LibJS: Cache the number format used for compact notation
Finding the best number format to use for compact notation involves
creating a Vector of all compact formats for the locale and looking for
the one that best matches the number's magnitude. ECMA-402 wants this
number format to be found multiple times, so cache the result for future
use.
2021-11-16 00:56:55 +00:00
Timothy Flynn
1f546476d5 LibJS+LibUnicode: Fix computation of compact pattern exponents
The compact scale of each formatting rule was precomputed in commit:
be69eae651

Using the formula: compact scale = magnitude - pattern scale

This computation was off-by-one.

For example, consider the format key "10000-count-one", which maps to
"00 thousand" in en-US. What we are really after is the exponent that
best represents the string "thousand" for values greater than 10000
and less than 100000 (the next format key). We were previously doing:

    log10(10000) - "00 thousand".count("0") = 2

Which clearly isn't what we want. Instead, if we do:

    log10(10000) + 1 - "00 thousand".count("0") = 3

We get the correct exponent for each format key for each locale.

This commit also renames the generated variable from "compact_scale" to
"exponent" to match the terminology used in ECMA-402.
2021-11-16 00:56:55 +00:00
Timothy Flynn
48d5684780 LibUnicode: Parse compact identifiers and replace them with a format key
For example, in en-US, the decimal, long compact pattern for numbers
between 10,000 and 100,000 is "00 thousand". In that pattern, "thousand"
is the compact identifier, and the generated format pattern is now
"{number} {compactIdentifier}". This also generates that identifier as
its own field in the NumberFormat structure.
2021-11-16 00:56:55 +00:00
Hendiadyoin1
1533123263 Profiler: Stop disassembly on invalid instructions 2021-11-16 00:49:48 +00:00
Hendiadyoin1
134f43ba12 Profiler: Don't try to disassemble empty buffers 2021-11-16 00:49:48 +00:00
Hendiadyoin1
6cb42d8a40 AK: Verify that we are not overreaching in StringView's substring_view() 2021-11-16 00:49:48 +00:00
Nico Weber
a164e6ecbb LibJS: Unbreak to_iso_day_of_week
481f7d6afa tried to use `modulo()` here, but missed that the
code used `<=` instead of `<`.

Keep using `modulo()` and add an explicit conditional, which is
arguably clearer.
2021-11-16 00:41:45 +00:00
kleines Filmröllchen
8f8ae5eb53 Piano: Create controller widgets for processor parameters
These widgets attach to a processor parameter and keep the two sides in
sync. They will become very useful for smart processor interfaces.
2021-11-16 00:09:58 +00:00
Nico Weber
481f7d6afa LibJS: Use modulo() function in to_iso_day_of_week
No behavior change.
2021-11-15 23:54:41 +00:00
Simon Woertz
b87ab989a3 LibPDF: Check if there is data left before consuming
Add a check to `Parser::consume_eol` to ensure that there is more data
to read before actually consuming any data. Not checking if there is
data left leads to failing an assertion in case of e.g., a truncated
pdf file.
2021-11-16 00:16:57 +01:00
Andrew Kaster
f1d8978804 AK+Kernel: Remove implicit conversion from Userspace<T*> to FlatPtr
This feels like it was a refactor transition kind of conversion. The
places that were relying on it can easily be changed to explicitly ask
for the ptr() or a new vaddr() method on Userspace<T*>.

FlatPtr can still implicitly convert to Userspace<T> because the
constructor is not explicit, but there's quite a few more places that
are relying on that conversion.
2021-11-16 00:13:22 +01:00
Andrew Kaster
7243bcb7da Kernel: Use static_ptr_cast to convert between Userspace<T*> types
Some calls of copy_to_user were converting Userspace<T*> to
Userspace<U*> via the implicit conversion to FlatPtr. Change them to use
the static_ptr_cast overload that is designed to express this conversion
2021-11-16 00:13:22 +01:00
Andrew Kaster
194456efdc Kernel: Remove unnecessary StringBuilder from sys$create_thread()
A series of refactors changed Threads to always have a name, and to
store their name as a KString. Before the refactors a StringBuilder was
used to format the default thread name for a non-main thread, but it is
since unused. Remove it and the AK/String related header includes from
the thread syscall implementation file.
2021-11-16 00:13:22 +01:00
kleines Filmröllchen
cca4268ff8 Piano: Always show Processor parameter values
The processor parameter values are displayed with two decimal places by
default. However, when these values become very large and exceed about 7
text symbols, the text is too long to fit the label and it'll simply not
show up. This commit fixes that by disabling the decimal place for such
large values, which allows us to show values up to 9,999,999, be it
only at integer precision.
2021-11-15 23:04:16 +00:00
kleines Filmröllchen
d50b1465c3 LibAudio: Add explanatory comments to the FlacLoader
Some nuances in the FLAC loading code can do well with an explanation,
as these non-obvious insights are often the result of long and painful
debugging and nobody should touch the affected code without careful
deliberation.

(Of course, secretly I just want people to maintain my loader code.)
:^)
2021-11-15 23:00:11 +00:00
kleines Filmröllchen
8af97d0ce7 Audio: Fix code smells and issues found by static analysis
This fixes all current code smells, bugs and issues reported by
SonarCloud static analysis. Other issues are almost exclusively false
positives. This makes much code clearer, and some minor benefits in
performance or bug evasion may be gained.
2021-11-15 23:00:11 +00:00
Linus Groh
a757f3f421 LibJS: Fix leap year check in to_iso_week_of_year() for week < 1
When the resulting week is in the previous year, we need to check if the
previous year is a leap year and can potentially have 53 weeks, instead
of the given year.
Also added a comment to briefly explain what's going on, as it took me a
while to figure out.
2021-11-15 21:33:26 +00:00
Pedro Pereira
b7af536f9b Minesweeper: Decrease min for Columns and Rows on Custom Game
Since the Beginner difficulty has a 9x9 playing field, it is expected
that a Custom Game should allow to create a field with that size.
2021-11-15 14:05:03 +00:00
Pedro Pereira
7b4b060b9c Minesweeper: Create field from Difficulty enum
This change makes it easier to generate a new field. Instead of using
hard-coded values everywhere, we now just need to keep track of
the Difficulty enum value.
2021-11-15 14:05:03 +00:00
Pedro Pereira
1c29633110 Minesweeper: Turn difficulty menu into checkable actions
This change makes use of checkable actions to specify the current
selected difficulty for the game.
2021-11-15 14:05:03 +00:00
Pedro Pereira
557075465c Minesweeper: Add "Custom game..." difficulty
This adds a dialog window which allows us to customize the size of the
board and the amount of mines that will be placed.
The current max amount of mines is 50% of the total number of cells
due to the fact that the generator algorithm takes too long to create a
board for higher percentages of mines.
2021-11-14 23:52:55 +00:00
Linus Groh
42071f69cf LibJS: Fix balance_time() for times with negative offset day outcome
...and change the parameter types from i64 to double, as predicted by
a FIXME. The issue here is that integer division with a negative
dividend doesn't yield the same result as floating point division
wrapped in floor().
Additionally, the `days` variable needs to be signed.
2021-11-14 23:10:00 +00:00
Linus Groh
32c52e3511 LibJS: Add missing spaces in balance_iso_date() spec comments 2021-11-14 23:08:49 +00:00
Linus Groh
a3de9dcf95 LibJS: Fix incorrect use of "modulo" in balance_iso_year_month() 2021-11-14 23:08:40 +00:00
Andrew Kaster
b1d5d3cc34 Kernel: Avoid redundant bool comparisons in Kernel::Thread
Two instances of comparing a bool with == true or == false, and one
instance where we can just return an expression instead of checking it
to return true on succeess and false on failure.
2021-11-14 22:52:35 +01:00
Andrew Kaster
c9d1c12efa Kernel: Remove unused forward declaration of Syscall::StringArgument
The real struct is in Kernel::Syscall::StringArgument, so the namespace
was wrong anyway. But regardless, this forward declaration was unused.
2021-11-14 22:52:35 +01:00
Andrew Kaster
39993a8fab Kernel: Avoid else after return in Process and ThreadSafeRefCounted 2021-11-14 22:52:35 +01:00
Andrew Kaster
eb1181b898 Kernel: Convert Process-related const member functions to static
Process::get_syscall_path_argument() and
ProcFSExposedComponent::modified_time() both are independent of this.
2021-11-14 22:52:35 +01:00
Andrew Kaster
bc29c7f04f Kernel: Make OpenFileDescriptions::max_open() static and constexpr
This method was just returning a static constexpr member variable
verbatim, so there's no point requiring a member function to observe
its value.
2021-11-14 22:52:35 +01:00
Andrew Kaster
fff265a9a9 Kernel: Suppress clang-tidy warning on declaration of s_mm_lock
Seems we are declaring this guy as extern RecursiveSpinLock s_mm_lock;
in both Thread.h and MemoryManager.h. Smells funny for sure.
2021-11-14 22:52:35 +01:00
Andrew Kaster
542640e766 Kernel: Mark private members of SharedCommittedCowPages as private
They were marked public, which seems like an obvious typo.
2021-11-14 22:52:35 +01:00
Andrew Kaster
16d8556472 Kernel: Remove redundant return statement from Spinlock::lock()
Also from RecursiveSpinlock::lock()
2021-11-14 22:52:35 +01:00
Andrew Kaster
5920b84696 Kernel: Stop truncating PageTableEntry::raw(), and make set_bit private
set_bit() in both PageDirectory and PageTableEntry are now private, and
remove a useless cast from PageTableEntry::raw().
2021-11-14 22:52:35 +01:00
Andrew Kaster
e824bead54 Kernel: Resolve clang-tidy readability-qualified-auto warning
... In files included by Kernel/Process.cpp or Kernel/Thread.cpp
2021-11-14 22:52:35 +01:00
Andrew Kaster
65edc62c02 Kernel: Resolve clang-tidy readability-make-member-function-const
... In files included from Kernel/Thread.cpp or Kernel/Process.cpp

Some places the warning is suppressed, because we do not want a const
object do have non-const access to the returned sub-object.
2021-11-14 22:52:35 +01:00