From ca36b7fb9004981f376db4f3d01c7e1e6544f08e Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 24 Sep 2023 16:11:20 +1300 Subject: [PATCH] OpenBSD code style --- esv.d | 9 ++++++--- esvapi.d | 30 ++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/esv.d b/esv.d index 9026d83..e8dd861 100644 --- a/esv.d +++ b/esv.d @@ -206,7 +206,8 @@ key = %s esv.extraParameters = iniData["api"].getKey("parameters"); - string returnValid(string def, string val) + string + returnValid(string def, string val) { return val == "" ? def : val; } @@ -275,12 +276,14 @@ key = %s return true; } -private string extractOpt(in GetOptException e) @safe +private string +extractOpt(in GetOptException e) @safe { return e.msg.matchFirst("-.")[0]; } -private string parseBook(in string book) @safe +private string +parseBook(in string book) @safe { return book.replaceAll(regex("[-_]"), " "); } diff --git a/esvapi.d b/esvapi.d index f0cac7d..ec14723 100644 --- a/esvapi.d +++ b/esvapi.d @@ -135,7 +135,8 @@ const string[] ESVAPI_PARAMETERS = [ * Returns true if the argument book is a valid book of the Bible. * Otherwise, returns false. */ -bool bookValid(in char[] book) nothrow @safe +bool +bookValid(in char[] book) nothrow @safe { foreach (string b; BIBLE_BOOKS) { if (book.capitalize() == b.capitalize()) @@ -147,9 +148,11 @@ bool bookValid(in char[] book) nothrow @safe * Returns true if the argument book is a valid verse format. * Otherwise, returns false. */ -bool verseValid(in char[] verse) @safe +bool +verseValid(in char[] verse) @safe { - bool vMatch(in string re) @safe + bool + vMatch(in string re) @safe { return !verse.matchAll(regex(re)).empty; } @@ -188,28 +191,32 @@ class ESVApi * Returns the API authentication key that was given when the object * was constructed. This authentication key cannot be changed. */ - @property string key() const nothrow pure @safe + @property string + key() const nothrow pure @safe { return _key; } /* * Returns the subdirectory used to store temporary audio passages. */ - @property string tmpDir() const nothrow pure @safe + @property string + tmpDir() const nothrow pure @safe { return _tmp; } /* * Returns the API URL currently in use. */ - @property string url() const nothrow pure @safe + @property string + url() const nothrow pure @safe { return _url; } /* * Sets the API URL currently in use to the given url argument. */ - @property void url(immutable(string) url) @safe + @property void + url(immutable(string) url) @safe in (!url.matchAll(`^https?://.+\\..+(/.+)?`).empty, "Invalid URL format") { _url = url; @@ -222,7 +229,8 @@ class ESVApi * * Example: getVerses("John", "3:16-21") */ - string getVerses(in char[] book, in char[] verse) const + string + getVerses(in char[] book, in char[] verse) const in (bookValid(book), "Invalid book") in (verseValid(verse), "Invalid verse format") { @@ -299,7 +307,8 @@ class ESVApi * * Example: getAudioVerses("John", "3:16-21") */ - string getAudioVerses(in char[] book, in char[] verse) const + string + getAudioVerses(in char[] book, in char[] verse) const in (bookValid(book), "Invalid book") in (verseValid(verse), "Invalid verse format") { @@ -333,7 +342,8 @@ class ESVApi * * Example: search("It is finished") */ - char[] search(in string query, in bool raw = true) + char[] + search(in string query, in bool raw = true) { ulong i; char[] response;