public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
From: Johnny Richard <johnny@johnnyrichard.com>
To: ~johnnyrichard/olang-devel@lists.sr.ht
Cc: Johnny Richard <johnny@johnnyrichard.com>
Subject: [PATCH olang v1 2/3] string_view: add function to create from cstr
Date: Mon,  4 Mar 2024 20:23:11 +0100	[thread overview]
Message-ID: <20240304193313.961286-3-johnny@johnnyrichard.com> (raw)
In-Reply-To: <20240304193313.961286-1-johnny@johnnyrichard.com>

Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
---
 src/string_view.c | 6 ++++++
 src/string_view.h | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/src/string_view.c b/src/string_view.c
index 646dabd..b4d4103 100644
--- a/src/string_view.c
+++ b/src/string_view.c
@@ -21,6 +21,12 @@
 #include <stdlib.h>
 #include <string.h>
 
+string_view_t
+string_view_from_cstr(char *cstr)
+{
+    return (string_view_t){ .chars = cstr, .size = strlen(cstr) };
+}
+
 bool
 string_view_eq_to_cstr(string_view_t str, char *cstr)
 {
diff --git a/src/string_view.h b/src/string_view.h
index d5d2e6c..0a3654f 100644
--- a/src/string_view.h
+++ b/src/string_view.h
@@ -31,6 +31,9 @@ typedef struct string_view
 
 } string_view_t;
 
+string_view_t
+string_view_from_cstr(char *cstr);
+
 bool
 string_view_eq_to_cstr(string_view_t str, char *cstr);
 
-- 
2.44.0


  parent reply	other threads:[~2024-03-04 18:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 19:23 [PATCH olang v1 0/3] implement assembly linux x86_64 compiler Johnny Richard
2024-03-04 19:23 ` [PATCH olang v1 1/3] be: create linux-x86_64 gas asm codegen Johnny Richard
2024-03-04 19:23 ` Johnny Richard [this message]
2024-03-04 19:23 ` [PATCH olang v1 3/3] cli: add compilation -o option with --save-temps Johnny Richard
2024-03-04 18:33   ` [olang/patches/.build.yml] build failed builds.sr.ht
2024-03-04 19:39     ` Johnny Richard
2024-03-05  2:05       ` Carlos Maniero
2024-03-05  2:02   ` [PATCH olang v1 3/3] cli: add compilation -o option with --save-temps Carlos Maniero
2024-03-05  8:27     ` Johnny Richard
2024-03-05  8:53 ` [PATCH olang v1 0/3] implement assembly linux x86_64 compiler Johnny Richard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240304193313.961286-3-johnny@johnnyrichard.com \
    --to=johnny@johnnyrichard.com \
    --cc=~johnnyrichard/olang-devel@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox