Its now been two hours. I tried to watch the video and follow along but I failed because someone knocked like crazy on the door. Hopefully someone will post a helpful summary here
@ 1:23:52 you can get the compiler to warn you about fallthrough cases with ``-Wimplicit-fallthrough``, and @ 1:36:39 you could make use of the ``__attribute__((fallthrough))`` to prevent the compiler from warning you in cases where you are certain about using it. example: ```c int main(void) { switch (69) { case 69: printf("69"); __attribute__((fallthrough)); case 420: { printf("420"); } } } ``` although ``__attribute__(())`` isnt standard and some compilers may or may not have it implemented, it is still better than nothing i guess😛also if you were to use C23, you could instead opt to use the ``[[fallthrough]]`` attribute which is now in the C standard!
First time seeing emacs. I like you compile setup. The "quickfix" window allows you to jump to an error, which seems pretty cool. Configuring something like that myself rn. Anyhow, cool video and nice content, keep it up :)
You can maybe improve the performance of the recursive call in the `*` case to skip the length matched (if glob will return the number of chars matched) instead of skipping a single character.
1:43:45 This is actually a reasonable interface if you are reading and converting a utf8 file into utf32 because you would need both a pointer to the end of the source buffer (to properly read code points lying on the file buffer boundary), and a pointer to the end of the target (for continuing decoding after a new chunk of the file was read and in case you are using sized strings or you don't want to memset your entire buffer to zero and just want to write zero terminator on the end)
You can also improve ranges by expanding it before running glob. For example: pattern "main.[a-d]" expands to "main.abcd". For that you have to find "-" between valid characters inside [] and iteratively add all characters in range.
Zozin: Why compiler let switch case fall through? Zozin in another video: This applies to both cases so we don't need to have a break. Compiler: sure bro
I once „quickly“ converted glob into RE to implement it in java (with the advanced ** ant pattern) and itmhad so many painful edge cases.. so much work for substring matches ,)
There's been a real bool type since C99 (_Bool), just not language-level `true` and `false` literals. The reason you have to include stdbool.h is because it contains `#define bool _Bool` as well as macros true and false for 1 and 0.
@@michalbotordoes bool had been existed before C? It's pretty old language and many things was made after it. Though the shitty part is that many things didn't implemented when new standards introduced.
11:45 The description of outlining the cases first and crashing during development if a new case occurs sounds an awful lot like TDD to me, if you would turn the input that triggers a new case into a testcase. EDIT: Ah. You point it out yourself at 36:00. :D
imo you should split glob into two stages: reductive (and, optionally, corrective) validation and matching. validation checks the validity of the pattern, if its badly formed it reports syntax error and quits reductive validation is a validation that reduces the pattern to a simpler, equivalent form that is going to be easier to match on before validating it, e.g. (1) "**" equiv. "*", "a**b***" equiv. "a*b*", (2) "*?abc" equiv. "*abc", (3) "[a[bc]]de" equiv. "[abc]de", "[[abc][def]]gh" equiv. "[abcdef]gh", "a[[bc]]de" equiv. "a[bc]de", (4) "[]abc" equiv "abc", "a[b]c" equiv "abc", etc., etc. corrective validation is a validation that attempts to fix the malformed pattern before validating it, e.g. "[abc" -> "abc", "[a?bc]de" -> "[abc]de", "[a*bc]de" -> "[abc]de", "a]bc[fg]" -> "abc[fg]", etc., etc. matching does what you did in the video, but it should be much simpler as you can assume that your input is already correct and in simplest possible form. thank you for your videos, they are a delight to watch and learn from!
31:50 sometimes I wonder if I should comment immediately on an error in a coding video to not forget about it later, or keep watching to see if the author has fixed it EDIT: 32:26 well shit
70s UNIX people read manual pages all the way through first, then realized they were parsing a regular language, planned their work strategically and implemented a design. It is a poor craftsman who blames his tools. 😅
youtube hasn't even generated subtitles. Becomes difficult when you see such an interesting video while sitting in a bar toilet
How long are you planning to spend in that toilet?
Are you done shitting ? I need to use the toilet now
@@vytah i guess at least 2 hours like the videos goes
it's not youtube, it's him. he has to turn on auto generated subtitles feature.
Its now been two hours. I tried to watch the video and follow along but I failed because someone knocked like crazy on the door. Hopefully someone will post a helpful summary here
@ 1:23:52 you can get the compiler to warn you about fallthrough cases with ``-Wimplicit-fallthrough``, and @ 1:36:39 you could make use of the ``__attribute__((fallthrough))`` to prevent the compiler from warning you in cases where you are certain about using it. example:
```c
int main(void)
{
switch (69)
{
case 69: printf("69"); __attribute__((fallthrough));
case 420:
{
printf("420");
}
}
}
```
although ``__attribute__(())`` isnt standard and some compilers may or may not have it implemented, it is still better than nothing i guess😛also if you were to use C23, you could instead opt to use the ``[[fallthrough]]`` attribute which is now in the C standard!
Bro tried to use markdown on yt 💀
Also, a single tick is enough instead of double.
First time seeing emacs. I like you compile setup. The "quickfix" window allows you to jump to an error, which seems pretty cool. Configuring something like that myself rn. Anyhow, cool video and nice content, keep it up :)
You are so captivating....I could not stop watching! I appreciate you taking time to explain everything.
You can maybe improve the performance of the recursive call in the `*` case to skip the length matched (if glob will return the number of chars matched) instead of skipping a single character.
1:43:45 This is actually a reasonable interface if you are reading and converting a utf8 file into utf32 because you would need both a pointer to the end of the source buffer (to properly read code points lying on the file buffer boundary), and a pointer to the end of the target (for continuing decoding after a new chunk of the file was read and in case you are using sized strings or you don't want to memset your entire buffer to zero and just want to write zero terminator on the end)
You can also improve ranges by expanding it before running glob. For example: pattern "main.[a-d]" expands to "main.abcd". For that you have to find "-" between valid characters inside [] and iteratively add all characters in range.
"I solve actual problems." - Tsoding
Zozin: Why compiler let switch case fall through?
Zozin in another video: This applies to both cases so we don't need to have a break.
Compiler: sure bro
1:24:39 That's why I think every programming language sucks in their own way
"Kind of a, like a, messy sophisticated parsing-like style code, uh, right?"
19:50 "error porn"
😭💀😭😭
I once „quickly“ converted glob into RE to implement it in java (with the advanced ** ant pattern) and itmhad so many painful edge cases.. so much work for substring matches ,)
06:45 C is getting the real bool in C23
There's been a real bool type since C99 (_Bool), just not language-level `true` and `false` literals. The reason you have to include stdbool.h is because it contains `#define bool _Bool` as well as macros true and false for 1 and 0.
c not having a bool from the start is a joke
@@michalbotordoes bool had been existed before C? It's pretty old language and many things was made after it.
Though the shitty part is that many things didn't implemented when new standards introduced.
@@maxrinehart4177 lol, obviously. george boole lived in xix century!
@@michalbotorholy shit, you destroyed him
11:45 The description of outlining the cases first and crashing during development if a new case occurs sounds an awful lot like TDD to me, if you would turn the input that triggers a new case into a testcase.
EDIT: Ah. You point it out yourself at 36:00. :D
Me voy a fumar este video como no tienes idea **snifff**
en español?
imo you should split glob into two stages: reductive (and, optionally, corrective) validation and matching.
validation checks the validity of the pattern, if its badly formed it reports syntax error and quits
reductive validation is a validation that reduces the pattern to a simpler, equivalent form that is going to be easier to match on before validating it, e.g. (1) "**" equiv. "*", "a**b***" equiv. "a*b*", (2) "*?abc" equiv. "*abc", (3) "[a[bc]]de" equiv. "[abc]de", "[[abc][def]]gh" equiv. "[abcdef]gh", "a[[bc]]de" equiv. "a[bc]de", (4) "[]abc" equiv "abc", "a[b]c" equiv "abc", etc., etc.
corrective validation is a validation that attempts to fix the malformed pattern before validating it, e.g. "[abc" -> "abc", "[a?bc]de" -> "[abc]de", "[a*bc]de" -> "[abc]de", "a]bc[fg]" -> "abc[fg]", etc., etc.
matching does what you did in the video, but it should be much simpler as you can assume that your input is already correct and in simplest possible form.
thank you for your videos, they are a delight to watch and learn from!
Crazy idea: regex for common programming concepts
"I like to write code" - Steve Tsoding
who tf is Steve?
@@TsodingDailySteve "nobuild.c" Nobs
I'm not sure if "syntax error" is a good idea. Just return "not mached", 'cause even with brackets every sequence of characters have sence.
Pragmatic as always, I love that
18:00 I think that's what's called "compartmentalization"
Like it very much, but fnmatch is like a glob that has options, you can turn the special cases for Paths off
The King Tsoding Daily!
Hello! Can you later make a topic onto how to make auto update system for any application?
1:13:56 Can't you just replace the inital copy of the code with a "goto" into the default case inside the switch? :-} Don't at me.
crash oriented programming is the best! I also do that
31:50 sometimes I wonder if I should comment immediately on an error in a coding video to not forget about it later, or keep watching to see if the author has fixed it
EDIT: 32:26 well shit
Maybe VSCode could be something with syntax highlighting ;) Would be fun to see you try it. Anyway, great video as always!
What font is he using in the terminal?
Iosevka
You did not check for inverted ranges like `[z-a]`, and it's broken!
easy fix line 310:
matched |= (prev = *pattern);
how about that
bet u didnt expect that shiz to happen
public static bool IsMatch(ReadOnlySpan input, ReadOnlySpan pattern) {
int ii = 0, ip = 0;
while (ip < pattern.Length) {
char cp = pattern[ip];
if (cp == '*') {
if (ii < input.Length) {
if (IsMatch(input.Slice(ii), pattern.Slice(ip + 1))) {
return true;
}
ii++;
}
else ip++;
}
else if (ii < input.Length && (cp == '?' || cp == input[ii])) {
ii++;
ip++;
}
else return false;
}
return ii == input.Length;
}
70s UNIX people read manual pages all the way through first, then realized they were parsing a regular language, planned their work strategically and implemented a design. It is a poor craftsman who blames his tools. 😅
we zozin
amazing
какой у тебя хороший английский
Спасибо! Все равно славянский акцент слышно, но надеюсь хотя бы все понятно. :D
@@TsodingDaily да, все понятно и это главное
I'm porth?
Importhant question
yup
Am I the first one??
Second
Third lool
That __FILE__ and __LINE__ trick why some amazing that i never know, Now I gonna flex that in my College with that trick😂
But you gotta tell them to keep it secret! shhh shhh
@@jesusjar11secret industry knowledge shhhhhhh 🤫