Re: Obsecure problem 1

2022-07-31 Thread pascal111 via Digitalmars-d-learn
On Sunday, 31 July 2022 at 17:03:59 UTC, Salih Dincer wrote: On Sunday, 31 July 2022 at 15:01:21 UTC, pascal111 wrote: I don't know how "assert" works, if you explained it I'll be able to get the idea of your suggestion to apply the appropriate changes on my code. **// This code runs foreve

Re: Obsecure problem 1

2022-07-31 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 31 July 2022 at 15:01:21 UTC, pascal111 wrote: I don't know how "assert" works, if you explained it I'll be able to get the idea of your suggestion to apply the appropriate changes on my code. **// This code runs forever:** ```d string str; assert(str is null); str = "test"

Re: Obsecure problem 1

2022-07-31 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 31 July 2022 at 14:52:03 UTC, FeepingCreature wrote: Note sure if I'm misunderstanding, but: D does not copy strings on value passing, because they're inherently reference types. You can think of a string (or any array) as a `struct { size_t length; T* ptr; }` combined with a bunch

Re: Obsecure problem 1

2022-07-31 Thread pascal111 via Digitalmars-d-learn
On Sunday, 31 July 2022 at 07:43:06 UTC, Salih Dincer wrote: On Sunday, 31 July 2022 at 00:58:47 UTC, pascal111 wrote: Another version of the program: https://github.com/pascal111-fra/D/blob/main/proj04.d I have a few more suggestions for you; Among them the first is on the following sample:

Re: Obsecure problem 1

2022-07-31 Thread FeepingCreature via Digitalmars-d-learn
On Sunday, 31 July 2022 at 07:43:06 UTC, Salih Dincer wrote: Why are you using const for strings? After all, they are protected by immutable. Moreover, since you do not use refs, copies are taken in every function and also you have created extra copy for results. Note sure if I'm misunderst

Re: Obsecure problem 1

2022-07-31 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 31 July 2022 at 00:58:47 UTC, pascal111 wrote: Another version of the program: https://github.com/pascal111-fra/D/blob/main/proj04.d I have a few more suggestions for you; Among them the first is on the following sample: ```d auto sentence_x = "she has six oxen"; auto noNeedT

Re: Obsecure problem 1

2022-07-30 Thread frame via Digitalmars-d-learn
On Saturday, 30 July 2022 at 23:40:44 UTC, pascal111 wrote: Provide me a free solution better than code::blocks with available gdc compiler I found. SDB@79 I don't know if's "better" but there is Visual Studio Code and IntelliJ IDEA for example. Yeah ctrl+v doesn't work on XTERM, the mid

Re: Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
Another version of the program: https://github.com/pascal111-fra/D/blob/main/proj04.d

Re: Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
On Saturday, 30 July 2022 at 22:45:14 UTC, Salih Dincer wrote: On Saturday, 30 July 2022 at 22:17:10 UTC, pascal111 wrote: The program works fine now: https://i.postimg.cc/3wkgXmVs/Screenshot-from-2022-07-31-00-04-23.png I have a suggestion for you. Use modern possibilities instead of applyi

Re: Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
On Saturday, 30 July 2022 at 22:28:52 UTC, frame wrote: On Saturday, 30 July 2022 at 22:13:55 UTC, pascal111 wrote: Because copying the running window contents is not allowed, I couldn't do it in Code::Blocks. Not allowed? o.O Did you try to select the text and insert it via middle mouse bu

Re: Obsecure problem 1

2022-07-30 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 30 July 2022 at 22:17:10 UTC, pascal111 wrote: The program works fine now: https://i.postimg.cc/3wkgXmVs/Screenshot-from-2022-07-31-00-04-23.png I have a suggestion for you. Use modern possibilities instead of applying functions used in the past to the present. For example, in a

Re: Obsecure problem 1

2022-07-30 Thread frame via Digitalmars-d-learn
On Saturday, 30 July 2022 at 22:13:55 UTC, pascal111 wrote: Because copying the running window contents is not allowed, I couldn't do it in Code::Blocks. Not allowed? o.O Did you try to select the text and insert it via middle mouse button in another window? Those terminals usually copy the

Re: Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
On Saturday, 30 July 2022 at 21:48:35 UTC, rikki cattermole wrote: It is a pretty straight forward. You tried to access memory out of bounds of the slice. https://github.com/pascal111-fra/D/blob/main/dcollect.d#L34 That for loop is problematic in a number of ways. You should not use int, or u

Re: Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
On Saturday, 30 July 2022 at 21:52:42 UTC, frame wrote: On Saturday, 30 July 2022 at 21:24:50 UTC, pascal111 wrote: I've typed a code to enjoy with my library "dcollect", and found non-understandable error: ... Running screen says: https://i.postimg.cc/G3YyCmbF/Screenshot-from-2022-07-30-23-

Re: Obsecure problem 1

2022-07-30 Thread frame via Digitalmars-d-learn
On Saturday, 30 July 2022 at 21:24:50 UTC, pascal111 wrote: I've typed a code to enjoy with my library "dcollect", and found non-understandable error: ... Running screen says: https://i.postimg.cc/G3YyCmbF/Screenshot-from-2022-07-30-23-23-59.png Why you don't copy the output instead? A ran

Re: Obsecure problem 1

2022-07-30 Thread rikki cattermole via Digitalmars-d-learn
It is a pretty straight forward. You tried to access memory out of bounds of the slice. https://github.com/pascal111-fra/D/blob/main/dcollect.d#L34 That for loop is problematic in a number of ways. You should not use int, or uint to index into memory, only size_t should be used. It is an alia

Obsecure problem 1

2022-07-30 Thread pascal111 via Digitalmars-d-learn
I've typed a code to enjoy with my library "dcollect", and found non-understandable error: module main; import std.stdio; import dcollect; import std.string; import std.conv; int main(string[] args) { string sentence_x, sent_result, token2; string[] sentence_tokens;