Closed arthurbacci closed 9 months ago
I am having some trouble with my box for now, but I will test it as soon as possible.
@arthurbacci It seems to work fairly well. How does it go with optimizations? I haven't tested -O3 or -funroll-loops yet.
"This is an old sock project";
Proceeds to replace all /* */
s by //
s
@arthurbacci It seems to work fairly well. How does it go with optimizations? I haven't tested -O3 or -funroll-loops yet.
Needs testing
@arthurbacci It seems to work fairly well. How does it go with optimizations? I haven't tested -O3 or -funroll-loops yet.
Needs testing
"Testing Heirloom" for me usually means using it everyday, but I think we could fix some annotations I've made before.
I believe perror()
is from the C standard library. The one that seems to be specific to heirloom is prerror()
The code was previously using prerror()
, but in my additions i used perror()
. prerror()
seems to require an integer argument (errno
), but it doesn't require any string in order to print the specific issue.
FIXME: When ones use "-n 0.1", it actually prints "0.100000000" instead of 0.1 or even 0.10. That could be fixed --- although not being a real problem --- aiming for less visual pollution on the status bar. Maybe this could be fixed by multiplying the interval by a nanosecond ratio on nanosleep()?
nanosleep()
requires seconds and nanoseconds separately. In order to do what you want, you would need to either: print (double/float)seconds + (double/float)nanoseconds / 10e9
, formatted with %f
, or somehow remove the trailing zeroes from the nanoseconds.
But I think the best way would be to just print the argument the user gave the program instead. The only problem with this is checking either the parsing of the argument is working as intended or not. If you're going to implement that way please check if the user argument is valid during the entire program.
I think that a case involving left_len and right_len, which contain the "Every (int).(int) second(s): (string)" and "hostname: date". respectively, is improbable, so this is just a pure formality in case of one's curses implementation having a faulty snprintf(). EXIT_FAILURE could be a more "frightening" code that gives a clue about the seriousness of this error on his/her system curses implementation.
snprintf()
is not part of curses, but of the C Standard Library (since C99). In versions before C99 it may be implemented somewhere else, but definitely not curses. Considering the wide usage of this function, the user should be warned if his implementation has faults, since this could cause catastrophic consequences.
When not consideration a faulty impl., I don't really know if runtime issues can cause snprintf
to err or not. But I couldn't find any resources saying that it can't. In old versions of gnu's libc, for example, it would return a negative value if truncation happens. I don't know what you expect more to be done, but since a negative (or 0, it makes no sense for nothing to be print) can't represent the expected behaviour in any way, I think the best is to panic and exit.
FIXME: When ones use "-n 0.1", it actually prints "0.100000000" instead of 0.1 or even 0.10. That could be fixed --- although not being a real problem --- aiming for less visual pollution on the status bar. Maybe this could be fixed by multiplying the interval by a nanosecond ratio on nanosleep()?
nanosleep()
requires seconds and nanoseconds separately. In order to do what you want, you would need to either: print(double/float)seconds + (double/float)nanoseconds / 10e9
, formatted with%f
, or somehow remove the trailing zeroes from the nanoseconds. But I think the best way would be to just print the argument the user gave the program instead. The only problem with this is checking either the parsing of the argument is working as intended or not. If you're going to implement that way please check if the user argument is valid during the entire program.
After implementing it, pls. request a review from me.
I believe
perror()
is from the C standard library. The one that seems to be specific to heirloom isprerror()
Yes, we've implemented back in 2022 if I'm not erred.
The code was previously using
prerror()
, but in my additions i usedperror()
.perror()
seems to require an integer argument (errno
), but it doesn't require any string in order to print the specific issue.
It's weird the fact that it just prints "ERROR:" anyway, isn't this our fault?
[...] or somehow remove the trailing zeroes from the nanoseconds.
Couldn't this be achieved by using some specific option at printf()
? I don't think that a more complex solution than trimming everything is worth.
But I think the best way would be to just print the argument the user gave the program instead. The only problem with this is checking either the parsing of the argument is working as intended or not. If you're going to implement that way please check if the user argument is valid during the entire program.
Well, I think we already do this sort of check back in getopt()
when parsing the time, so we doesn't need to be preoccupied with re-checking the input.
snprintf()
is not part of curses, but of the C Standard Library (since C99). In versions before C99 it may be implemented somewhere else, but definitely not curses.
I will correct this later at the comment. Thanks.
I don't know what you expect more to be done, but since a negative (or 0, it makes no sense for nothing to be print) can't represent the expected behaviour in any way, I think the best is to panic and exit.
Just change EXIT_FAILURE
to 255, which usually means that a severe error occurred in the UNIX tradition.
Yes, we've implemented back in 2022 if I'm not erred.
Was there any old function from heirloom with that name or you decided to create it?
It's weird the fact that it just prints "ERROR:" anyway, isn't this our fault?
ERRATA: prerror()
needs a number. perror("amongus")
is expected to print amongus: READABLE ERRNO
in stderr. It doesn't?
Couldn't this be achieved by using some specific option at
printf()
? I don't think that a more complex solution than trimming everything is worth.
I was thinking about it but couldn't recall any.
But I think the best way would be to just print the argument the user gave the program instead. The only problem with this is checking either the parsing of the argument is working as intended or not. If you're going to implement that way please check if the user argument is valid during the entire program.
Well, I think we already do this sort of check back in
getopt()
when parsing the time, so we doesn't need to be preoccupied with re-checking the input.
The problem isn't checking the input itself, but making sure getopt()
doesn't free or replace it in any way. I don't think that's the case
Just change
EXIT_FAILURE
to 255, which usually means that a severe error occurred in the UNIX tradition.
Feel free to do so.
How can I request a review? Damn.
o k . Still, the code doesn't comform with C90.
I know this is not so urgent for now, but what is missing in this code to it conform with C90?
o k . Still, the code doesn't comform with C90.
I know this is not so urgent for now, but what is missing in this code to it conform with C90?
Several things
I believe it's ready for merging
I will just look for memory leaks before merging.
Although Valgrind reports memory leaks at newterm()
(line 153) and refresh()
(line 244), it's perfectly normal to it give some false positives about memory leaks on ncurses functions, according to its F.A.Q.: https://invisible-island.net/ncurses/ncurses.faq.html#config_leaks
We can conclude that it's good to merge and working flawlessly well.
DON'T MERGE NOW! Please review the code and test it. More commits will most likely be needed before the merge since I didn't test anything.