mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
AK: Make string-to-number conversion helpers return Optional
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
This commit is contained in:
parent
15f4043a7a
commit
fdfda6dec2
Notes:
sideshowbarker
2024-07-19 05:41:49 +09:00
Author: https://github.com/awesomekling
Commit: fdfda6dec2
55 changed files with 354 additions and 455 deletions
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
|
@ -52,10 +53,11 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
new_gid = gid_arg.to_uint(ok);
|
||||
auto number = gid_arg.to_uint();
|
||||
|
||||
if (!ok) {
|
||||
if (number.has_value()) {
|
||||
new_gid = number.value();
|
||||
} else {
|
||||
auto* group = getgrnam(gid_arg.characters());
|
||||
if (!group) {
|
||||
fprintf(stderr, "Unknown group '%s'\n", gid_arg.characters());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue