Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

If you're not careful, you're going to catch something.


devel / comp.lang.c / Re: getFirstDayOfMonth()

SubjectAuthor
* getFirstDayOfMonth()Mike Sanders
`* Re: getFirstDayOfMonth()Kenny McCormack
 +* Re: getFirstDayOfMonth()Janis Papanagnou
 |`* Re: getFirstDayOfMonth()Keith Thompson
 | +* Re: getFirstDayOfMonth()Janis Papanagnou
 | |`* Re: getFirstDayOfMonth()Janis Papanagnou
 | | `* Re: getFirstDayOfMonth()Keith Thompson
 | |  `- Re: getFirstDayOfMonth()Janis Papanagnou
 | `- Re: getFirstDayOfMonth()Mike Sanders
 +- Re: getFirstDayOfMonth()Scott Lurndal
 +- Re: getFirstDayOfMonth()Janis Papanagnou
 +- Re: getFirstDayOfMonth()Mike Sanders
 +* Re: getFirstDayOfMonth()Mike Sanders
 |`* Re: getFirstDayOfMonth()Scott Lurndal
 | +* Re: getFirstDayOfMonth()Mike Sanders
 | |`- Re: getFirstDayOfMonth()Tim Rentsch
 | `* Re: getFirstDayOfMonth()Mike Sanders
 |  `* Re: getFirstDayOfMonth()Scott Lurndal
 |   +- Re: getFirstDayOfMonth()Janis Papanagnou
 |   +* Re: getFirstDayOfMonth()Mike Sanders
 |   |+* Re: getFirstDayOfMonth()Janis Papanagnou
 |   ||`* Re: getFirstDayOfMonth()Mike Sanders
 |   || `- Re: getFirstDayOfMonth()Janis Papanagnou
 |   |+* Re: getFirstDayOfMonth()Keith Thompson
 |   ||+* Re: getFirstDayOfMonth()Janis Papanagnou
 |   |||+* Re: getFirstDayOfMonth()David Brown
 |   ||||+* Re: getFirstDayOfMonth()Kaz Kylheku
 |   |||||`- Re: getFirstDayOfMonth()David Brown
 |   ||||+* Re: getFirstDayOfMonth()Malcolm McLean
 |   |||||`- Re: getFirstDayOfMonth()Richard Harnden
 |   ||||`- Re: getFirstDayOfMonth()Janis Papanagnou
 |   |||`* Re: getFirstDayOfMonth()Mike Sanders
 |   ||| +* Re: getFirstDayOfMonth()Scott Lurndal
 |   ||| |`* Re: getFirstDayOfMonth()Mike Sanders
 |   ||| | `* Re: getFirstDayOfMonth()Scott Lurndal
 |   ||| |  +* Re: getFirstDayOfMonth()Kaz Kylheku
 |   ||| |  |`- Re: getFirstDayOfMonth()Scott Lurndal
 |   ||| |  `* Re: getFirstDayOfMonth()Janis Papanagnou
 |   ||| |   `- Re: getFirstDayOfMonth()Scott Lurndal
 |   ||| `* Re: getFirstDayOfMonth()Janis Papanagnou
 |   |||  +- Re: getFirstDayOfMonth()Mike Sanders
 |   |||  `* Re: getFirstDayOfMonth()Mark Bourne
 |   |||   `- Re: getFirstDayOfMonth()Scott Lurndal
 |   ||`* Re: getFirstDayOfMonth()Mike Sanders
 |   || +* Re: getFirstDayOfMonth()Scott Lurndal
 |   || |+- Re: getFirstDayOfMonth()Keith Thompson
 |   || |`* Re: getFirstDayOfMonth()Mike Sanders
 |   || | +- Re: getFirstDayOfMonth()Keith Thompson
 |   || | +* Re: getFirstDayOfMonth()Mike Sanders
 |   || | |`* [OT] Re: getFirstDayOfMonth()Janis Papanagnou
 |   || | | `- Re: [OT] Re: getFirstDayOfMonth()Mike Sanders
 |   || | `* Re: getFirstDayOfMonth()Scott Lurndal
 |   || |  `- Re: getFirstDayOfMonth()Keith Thompson
 |   || `* Re: getFirstDayOfMonth()Lew Pitcher
 |   ||  +* Re: getFirstDayOfMonth()Michael S
 |   ||  |+- Re: getFirstDayOfMonth()Michael S
 |   ||  |`- Re: getFirstDayOfMonth()Tim Rentsch
 |   ||  +- Re: getFirstDayOfMonth()Mike Sanders
 |   ||  `- Re: getFirstDayOfMonth()Janis Papanagnou
 |   |+* Re: getFirstDayOfMonth()James Kuyper
 |   ||`* Re: getFirstDayOfMonth()Mike Sanders
 |   || +- Re: getFirstDayOfMonth()James Kuyper
 |   || +* Re: getFirstDayOfMonth()Keith Thompson
 |   || |`* Re: getFirstDayOfMonth()Mike Sanders
 |   || | +* Re: getFirstDayOfMonth()Kaz Kylheku
 |   || | |+- Re: getFirstDayOfMonth()Mike Sanders
 |   || | |`- Re: getFirstDayOfMonth()Scott Lurndal
 |   || | `* Re: getFirstDayOfMonth()Keith Thompson
 |   || |  `- Re: getFirstDayOfMonth()Mike Sanders
 |   || `* Re: getFirstDayOfMonth()Michael S
 |   ||  `* Re: getFirstDayOfMonth()Mike Sanders
 |   ||   `- Re: getFirstDayOfMonth()Keith Thompson
 |   |`* Re: getFirstDayOfMonth()Scott Lurndal
 |   | `* Re: getFirstDayOfMonth()Michael S
 |   |  `- Re: getFirstDayOfMonth()Scott Lurndal
 |   `- Re: getFirstDayOfMonth()Mark Bourne
 +* Re: getFirstDayOfMonth()jak
 |+* Re: getFirstDayOfMonth()Tim Rentsch
 ||`- Re: getFirstDayOfMonth()jak
 |`* Re: getFirstDayOfMonth()Peter 'Shaggy' Haywood
 | `* Re: getFirstDayOfMonth()bart
 |  `* Re: getFirstDayOfMonth()jak
 |   `* Re: getFirstDayOfMonth()jak
 |    +* Re: getFirstDayOfMonth()Spiros Bousbouras
 |    |`* Re: getFirstDayOfMonth()Keith Thompson
 |    | `- Re: getFirstDayOfMonth()Keith Thompson
 |    `* Re: getFirstDayOfMonth()Keith Thompson
 |     `- Re: getFirstDayOfMonth()Tim Rentsch
 `* Re: getFirstDayOfMonth()Kaz Kylheku
  +- Re: getFirstDayOfMonth()Peter 'Shaggy' Haywood
  `- Re: getFirstDayOfMonth()Kenny McCormack

Pages:1234
Re: getFirstDayOfMonth()

<us5e0k$37ho2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34091&group=comp.lang.c#34091

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Mon, 4 Mar 2024 21:21:25 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <us5e0k$37ho2$1@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me>
<urssrf$1vntr$1@news.xmission.com> <urteto$1e55r$1@dont-email.me>
<7VrEN.517245$xHn7.96511@fx14.iad> <urtq7q$1ggh0$1@dont-email.me>
<pZGEN.500996$7sbb.11881@fx16.iad> <us00f7$21v55$1@dont-email.me>
<87ttloqnnk.fsf@nosuchdomain.example.com> <us507s$38rq1$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 4 Mar 2024 21:21:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="da7eb8f844424d609727ab2bbb39fd2e";
logging-data="3393282"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18LLlED2whamnIHLHa3QlM0jqXqhlkWdw4="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:XIS/1kFKuFFBmMuR6FKqsFl42No=
 by: Lew Pitcher - Mon, 4 Mar 2024 21:21 UTC

On Mon, 04 Mar 2024 17:26:21 +0000, Mike Sanders wrote:

> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>
>> I wouldn't use '-?'. The '?' character is a wildcard in most Unix
>> shells. If you happen to have a file in the current directory that
>> matches the pattern, it will expand to the name of that file. If you
>> don't, the behavior depends on the shell and settings.
>
> Embarrassed to say I know that, but had forgotten it...
>
>> And most users of Unix-like systems won't expect '-?' to be an option;
>> '-h' is much more common.
>
> Can of worms there too, '-h' (or whatever) is valid file name. Under win,
> we also use '/h' which certainly wont work under unix.
>
>>> Oh yeah. Have been wrestling with the potential
>>> consequences of this for a good while. I think I'm
>>> going leave it as is because, (only speaking for
>>> myself here) the POSIX 0 good, 1 bad is terrible.
>>> This is perhaps the only area I've ever seen where
>>> other OSs, like Windows, have a superior methodology
>>> on the issue. 0/1 provides next to no nuance. But
>>> I'm no expert, just my experience.
>>
>> The C standard, not just POSIX, defines 0 as a successful status. If
>> your program is intended to work on Unix-like systems (or on Windows if
>> I'm not mistaken), using a status of 0 to indicate an error will cause
>> problems. Conventions exist for a reason.
>
> int ok = strcmp(foo, bar);
>
> if (!ok) then success
>
> ok == -1 less
> ok == 0 same
> ok == 1 greater

Ahhhhh..... no. (CLC has had this conversation before :-) )

The standard only guarantees that strcmp()
"returns an integer greater than, equal to, or less than zero"
but otherwise does not state what value that integer will be.

So, strcmp() could just as easily return -30 for "less than"
or +97 for "greater than".

If you want to /guarantee/ that the return value of strcmp()
is -1, 0, or +1 (for "less than", "equal to", or "greater than")
you will have to process the return value with something like

/*
** Returns -1 if argument < 0, 0 if argument == 0, 1 if argument > 0
*/
int iSignOf(int valu)
{
return ((valu > 0) - (valu < 0));
}

as in
int ok = isignof(strcmp(foo, bar));

> Hmm, so for someone from a differing OS, things need to be considered.

Always.

HTH
--
Lew Pitcher
"In Skills We Trust"

Re: getFirstDayOfMonth()

<20240305003723.000045a3@yahoo.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34095&group=comp.lang.c#34095

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5...@yahoo.com (Michael S)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 00:37:23 +0200
Organization: A noiseless patient Spider
Lines: 93
Message-ID: <20240305003723.000045a3@yahoo.com>
References: <urrj5l$124o9$1@dont-email.me>
<urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me>
<7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me>
<pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me>
<87ttloqnnk.fsf@nosuchdomain.example.com>
<us507s$38rq1$1@dont-email.me>
<us5e0k$37ho2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="ca10b4c024403001a5662ed8e59df858";
logging-data="3548838"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fnE3TUpUNm0bJdLUUr2w0buzqINFpXvI="
Cancel-Lock: sha1:CzOpe/tGZbAkk8LQye1Gfb5dxSk=
X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)
 by: Michael S - Mon, 4 Mar 2024 22:37 UTC

On Mon, 4 Mar 2024 21:21:25 -0000 (UTC)
Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:

> On Mon, 04 Mar 2024 17:26:21 +0000, Mike Sanders wrote:
>
> > Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> >
> >> I wouldn't use '-?'. The '?' character is a wildcard in most Unix
> >> shells. If you happen to have a file in the current directory that
> >> matches the pattern, it will expand to the name of that file. If
> >> you don't, the behavior depends on the shell and settings.
> >
> > Embarrassed to say I know that, but had forgotten it...
> >
> >> And most users of Unix-like systems won't expect '-?' to be an
> >> option; '-h' is much more common.
> >
> > Can of worms there too, '-h' (or whatever) is valid file name.
> > Under win, we also use '/h' which certainly wont work under unix.
> >
> >>> Oh yeah. Have been wrestling with the potential
> >>> consequences of this for a good while. I think I'm
> >>> going leave it as is because, (only speaking for
> >>> myself here) the POSIX 0 good, 1 bad is terrible.
> >>> This is perhaps the only area I've ever seen where
> >>> other OSs, like Windows, have a superior methodology
> >>> on the issue. 0/1 provides next to no nuance. But
> >>> I'm no expert, just my experience.
> >>
> >> The C standard, not just POSIX, defines 0 as a successful status.
> >> If your program is intended to work on Unix-like systems (or on
> >> Windows if I'm not mistaken), using a status of 0 to indicate an
> >> error will cause problems. Conventions exist for a reason.
> >
> > int ok = strcmp(foo, bar);
> >
> > if (!ok) then success
> >
> > ok == -1 less
> > ok == 0 same
> > ok == 1 greater
>
> Ahhhhh..... no. (CLC has had this conversation before :-) )
>
> The standard only guarantees that strcmp()
> "returns an integer greater than, equal to, or less than zero"
> but otherwise does not state what value that integer will be.
>
> So, strcmp() could just as easily return -30 for "less than"
> or +97 for "greater than".
>
> If you want to /guarantee/ that the return value of strcmp()
> is -1, 0, or +1 (for "less than", "equal to", or "greater than")
> you will have to process the return value with something like
>
> /*
> ** Returns -1 if argument < 0, 0 if argument == 0, 1 if argument > 0
> */
> int iSignOf(int valu)
> {
> return ((valu > 0) - (valu < 0));
> }
>

Too tricky to my liking.
I'd rather write straight-forward code and let compiler to figure out
the best sequence.

int iSignOf(int val)
{ if (val < 0)
return -1;
if (val > 0)
return +1;
return 0;
}

https://godbolt.org/z/TzsevxKeE
https://godbolt.org/z/TzsevxKeE

> as in
> int ok = isignof(strcmp(foo, bar));
>
>
> > Hmm, so for someone from a differing OS, things need to be
> > considered.
>
> Always.
>
> HTH

Re: getFirstDayOfMonth()

<87le6xr4r2.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34096&group=comp.lang.c#34096

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Mon, 04 Mar 2024 14:50:25 -0800
Organization: None to speak of
Lines: 55
Message-ID: <87le6xr4r2.fsf@nosuchdomain.example.com>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me> <us1ein$2dfo0$1@dont-email.me>
<us53ei$3993i$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5c683459994fa3e34e479e42ca46e26d";
logging-data="3565619"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5VPJb03oSn3KrPQ6xI8vJ"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:r4pY8YU7QJkIcCruaXBCnt8iJ08=
sha1:IVX/vd88+ujrU6KGluZ2jxVyREw=
 by: Keith Thompson - Mon, 4 Mar 2024 22:50 UTC

porkchop@invalid.foo (Mike Sanders) writes:
> James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>> The lack of nuance is apparently the result of your being unaware of the
>> fact that 1 is not the only permitted error return.
>>
>> Keep in mind that the make utility and shells designed for Unix-like
>> systems (as well as many other programs targeting such systems) expect 0
>> for success, and may produce unexpected results if you violate that
>> convention.
>
> Not at all, what the shell accepts as success under unix, is not the
> same under windows. The convention is OS specific, everyone here tends
> to think only in terms of POSIX & $SHELL & yet, there are other worlds
> out there...
>
> :: comment
>
> @echo off & cls
>
> if %errorlevel% EQU 1000 (
>
> echo successful as defined by my needs not yours
>
> )

Sure, you can write a script that assumes 1000 indicates success -- but
it's just as non-idiomatic on Windows as on POSIX systems. (POSIX only
supports values from 0 to 255.)

some_command
if [ $? = 100 ] ; then
echo SUCCESS
else
echo FAILURE
fi

But Windows, like POSIX, has a convention than an exit code of zero
denotes success, and non-zero denotes an error. The convention probably
isn't as hardwired into the system on Windows as it is on POSIX, but
it's there.

For example, the documentation for the C# Environment.Exit() function
says "Use 0 (zero) to indicate that the process completed
successfully.". Windows cmd (the command that runs batch files) has a
special syntax in its "if" statement that tests the value of
%errorlevel; "if errorlevel 1" is used to test if the errorlevel is 1 or
greater, i.e., denotes failure.

VMS (officially OpenVMS) uses 1 to denote success, which is why exit(0)
in a VMS C program sets the system status to 1, not 0.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: getFirstDayOfMonth()

<20240305010824.00003617@yahoo.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34098&group=comp.lang.c#34098

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5...@yahoo.com (Michael S)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 01:08:24 +0200
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <20240305010824.00003617@yahoo.com>
References: <urrj5l$124o9$1@dont-email.me>
<urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me>
<7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me>
<pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me>
<us1ein$2dfo0$1@dont-email.me>
<us53ei$3993i$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="31f8214f19f29f680f4ca2d83e873e49";
logging-data="3548838"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iy+C/MWvEfZLda61MoAkIdPTA8zLFSGg="
Cancel-Lock: sha1:3LdRNdYJLidzXrdteG2wvo/QWS8=
X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)
 by: Michael S - Mon, 4 Mar 2024 23:08 UTC

On Mon, 4 Mar 2024 18:21:06 -0000 (UTC)
porkchop@invalid.foo (Mike Sanders) wrote:

> James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>
> > The lack of nuance is apparently the result of your being unaware
> > of the fact that 1 is not the only permitted error return.
> >
> > Keep in mind that the make utility and shells designed for Unix-like
> > systems (as well as many other programs targeting such systems)
> > expect 0 for success, and may produce unexpected results if you
> > violate that convention.
>
> Not at all, what the shell accepts as success under unix, is not the
> same under windows. The convention is OS specific, everyone here tends
> to think only in terms of POSIX & $SHELL & yet, there are other worlds
> out there...
>
> :: comment
>
> @echo off & cls
>
> if %errorlevel% EQU 1000 (
>
> echo successful as defined by my needs not yours
>
> )
>

However all Microsoft-supplied utilities as well as most (all ?)
built-in commands of their shells , like 'copy' or 'move', follow Unix
conventions for exit codes.

Re: getFirstDayOfMonth()

<us5lrg$3d69p$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34099&group=comp.lang.c#34099

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Mon, 4 Mar 2024 23:35:12 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 48
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <us5lrg$3d69p$1@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com> <urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad> <urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad> <us00f7$21v55$1@dont-email.me> <87ttloqnnk.fsf@nosuchdomain.example.com> <us507s$38rq1$1@dont-email.me> <us5e0k$37ho2$1@dont-email.me>
Injection-Date: Mon, 4 Mar 2024 23:35:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f39f06c5c85be206a030c1f22cff1159";
logging-data="3578169"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iJnJGhVOA7oXXBQHy3hbg"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:L5QnSIKbTDAMALFOPCYFFEOh7wI=
 by: Mike Sanders - Mon, 4 Mar 2024 23:35 UTC

Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:

>> int ok = strcmp(foo, bar);
>>
>> if (!ok) then success
>>
>> ok == -1 less
>> ok == 0 same
>> ok == 1 greater
>
> Ahhhhh..... no. (CLC has had this conversation before :-) )
>
> The standard only guarantees that strcmp()
> "returns an integer greater than, equal to, or less than zero"
> but otherwise does not state what value that integer will be.
>
> So, strcmp() could just as easily return -30 for "less than"
> or +97 for "greater than".
>
> If you want to /guarantee/ that the return value of strcmp()
> is -1, 0, or +1 (for "less than", "equal to", or "greater than")
> you will have to process the return value with something like
>
> /*
> ** Returns -1 if argument < 0, 0 if argument == 0, 1 if argument > 0
> */
> int iSignOf(int valu)
> {
> return ((valu > 0) - (valu < 0));
> }
>
> as in
> int ok = isignof(strcmp(foo, bar));
>
>
>> Hmm, so for someone from a differing OS, things need to be considered.
>
> Always.
>
> HTH

Yes sir, it does help in fact, copied to my notes. Lots of brainfood
from you all, appreciate it =)

--
:wq
Mike Sanders

Re: getFirstDayOfMonth()

<us5mj5$3dckj$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34100&group=comp.lang.c#34100

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Mon, 4 Mar 2024 23:47:49 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <us5mj5$3dckj$1@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com> <urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad> <urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad> <us00f7$21v55$1@dont-email.me> <87ttloqnnk.fsf@nosuchdomain.example.com> <us507s$38rq1$1@dont-email.me> <tCnFN.138324$t8cc.53416@fx06.iad>
Injection-Date: Mon, 4 Mar 2024 23:47:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f39f06c5c85be206a030c1f22cff1159";
logging-data="3584659"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19S56I1CEfaQZ9WkRFSZQXC"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:Nv6aypCPZRQyXmwrA1w2Wzm4SUY=
 by: Mike Sanders - Mon, 4 Mar 2024 23:47 UTC

Scott Lurndal <scott@slp53.sl.home> wrote:

> POSIX defines 0 as a successful status "for shell commmands", in
> the context of this discussion.

Sure enough & Keith as well. Cobbled together a simple solution
just display more informative error messages as well as sticking
to zero/one. This satisfies scripting in the unix world:

[ dates -op1 -op2 file || echo no banana ]

And specific messaging in the windows world (-d is my new debug
switch):

C:\type junk.txt

fubar/5/2024

C:\dates -op1 -op2 -d junk.txt

DEBUG: Invalid month field line 1 in file junk.txt

> I refer you to Ralph Waldo Emerson's quote about consistency :-).

=)

--
:wq
Mike Sanders

Re: getFirstDayOfMonth()

<87bk7tr115.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34101&group=comp.lang.c#34101

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Mon, 04 Mar 2024 16:10:46 -0800
Organization: None to speak of
Lines: 27
Message-ID: <87bk7tr115.fsf@nosuchdomain.example.com>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me>
<87ttloqnnk.fsf@nosuchdomain.example.com>
<us507s$38rq1$1@dont-email.me> <tCnFN.138324$t8cc.53416@fx06.iad>
<us5mj5$3dckj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="1a8f7ad2f6e687631fe43fc4c823263c";
logging-data="3590193"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18P6HDgkUohU54c4GrJmAG6"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:ej5v5LciKfdxMTTUxXGbFPVX5pg=
sha1:XvcnMoKrubHCkmHp823vo8VMX+M=
 by: Keith Thompson - Tue, 5 Mar 2024 00:10 UTC

porkchop@invalid.foo (Mike Sanders) writes:
> Scott Lurndal <scott@slp53.sl.home> wrote:
>
>> POSIX defines 0 as a successful status "for shell commmands", in
>> the context of this discussion.
>
> Sure enough & Keith as well. Cobbled together a simple solution
> just display more informative error messages as well as sticking
> to zero/one. This satisfies scripting in the unix world:
>
> [ dates -op1 -op2 file || echo no banana ]

This is off-topic (try comp.unix.shell if you have questions), but you
should be aware that '[' on POSIX systems is actually a command, not
shell syntax. (It's typically a built-in command. This applies to most
shells, like sh, bash, ksh, but not to csh, tcsh, fish.)

"[ args... ]" is equivalent to "test ...". You'll see the [ command
used as a condition in shell if statements, which makes it easy to
assume (incorrectly) that it's part of the syntax of an if statement.
In fact a shell "if" statement uses a command as its condition, and
determines control flow based on whether the command succeeds or fails.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: getFirstDayOfMonth()

<us5o28$3dil7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34102&group=comp.lang.c#34102

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 00:12:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <us5o28$3dil7$1@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com> <urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad> <urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad> <us00f7$21v55$1@dont-email.me> <87ttloqnnk.fsf@nosuchdomain.example.com> <us507s$38rq1$1@dont-email.me> <tCnFN.138324$t8cc.53416@fx06.iad> <us5mj5$3dckj$1@dont-email.me>
Injection-Date: Tue, 5 Mar 2024 00:12:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f39f06c5c85be206a030c1f22cff1159";
logging-data="3590823"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/VMrkwtKUf95x0DfLNWvWV"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:DcSGzvHgRenC2K8iQ3RByrNuD48=
 by: Mike Sanders - Tue, 5 Mar 2024 00:12 UTC

Mike Sanders <porkchop@invalid.foo> wrote:

> [ dates -op1 -op2 file || echo no banana ]

Make that instead:

[ cmd ] || failure

--
:wq
Mike Sanders

Re: getFirstDayOfMonth()

<us5oda$3dil7$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34103&group=comp.lang.c#34103

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 00:18:50 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <us5oda$3dil7$2@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com> <urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad> <urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad> <us00f7$21v55$1@dont-email.me> <us1ein$2dfo0$1@dont-email.me> <us53ei$3993i$3@dont-email.me> <20240305010824.00003617@yahoo.com>
Injection-Date: Tue, 5 Mar 2024 00:18:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f39f06c5c85be206a030c1f22cff1159";
logging-data="3590823"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/6OqzGsKNmUlSC6ErOdqaA"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:C3KBlPQ9reqGQRDlw3nmNOCroFg=
 by: Mike Sanders - Tue, 5 Mar 2024 00:18 UTC

Michael S <already5chosen@yahoo.com> wrote:

> However all Microsoft-supplied utilities as well as most (all ?)
> built-in commands of their shells , like 'copy' or 'move', follow Unix
> conventions for exit codes.

Well, maybe not so much in practice as in theory, witness...

cmd /c exit -1073741510

--
:wq
Mike Sanders

Re: getFirstDayOfMonth()

<877cihr001.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34104&group=comp.lang.c#34104

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Mon, 04 Mar 2024 16:33:02 -0800
Organization: None to speak of
Lines: 26
Message-ID: <877cihr001.fsf@nosuchdomain.example.com>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me> <us1ein$2dfo0$1@dont-email.me>
<us53ei$3993i$3@dont-email.me> <20240305010824.00003617@yahoo.com>
<us5oda$3dil7$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="1a8f7ad2f6e687631fe43fc4c823263c";
logging-data="3596413"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18tJqa+R4uePofs5X/cq7zj"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:D1gmBwlEj7vyOBPIj9JcK8HMnVQ=
sha1:3MbFxH0VTqXrrYcKjSBkqpzUBuA=
 by: Keith Thompson - Tue, 5 Mar 2024 00:33 UTC

porkchop@invalid.foo (Mike Sanders) writes:
> Michael S <already5chosen@yahoo.com> wrote:
>> However all Microsoft-supplied utilities as well as most (all ?)
>> built-in commands of their shells , like 'copy' or 'move', follow Unix
>> conventions for exit codes.
>
> Well, maybe not so much in practice as in theory, witness...
>
> cmd /c exit -1073741510

I'm not sure what your point is. Of course if a command lets you
specify a particular error code, it will use that error code regardless
of any conventions. Or is your point that Windows supports a wider
range of error codes than POSIX does?

Windows follows the Unix convention of commands returning an exit status
of zero for success, non-zero for failure. I don't know why you're so
determined to fight against that point. There are differences in the
details (and better places to discuss them). Status values in the range
0..255 are likely to be reasonably portable across POSIX and Windows
systems.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: getFirstDayOfMonth()

<us5pl8$3dsgj$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34105&group=comp.lang.c#34105

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 00:40:08 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 48
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <us5pl8$3dsgj$1@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com> <urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad> <urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad> <us00f7$21v55$1@dont-email.me> <us1ein$2dfo0$1@dont-email.me> <us53ei$3993i$3@dont-email.me> <87le6xr4r2.fsf@nosuchdomain.example.com>
Injection-Date: Tue, 5 Mar 2024 00:40:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f39f06c5c85be206a030c1f22cff1159";
logging-data="3600915"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XkTbH6H2BjrXfDYMKAI8y"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:NfrWmzdQUy2znzFU0Vzb37onBus=
 by: Mike Sanders - Tue, 5 Mar 2024 00:40 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> Sure, you can write a script that assumes 1000 indicates success -- but
> it's just as non-idiomatic on Windows as on POSIX systems. (POSIX only
> supports values from 0 to 255.)
>
> some_command
> if [ $? = 100 ] ; then
> echo SUCCESS
> else
> echo FAILURE
> fi
>
> But Windows, like POSIX, has a convention than an exit code of zero
> denotes success, and non-zero denotes an error. The convention probably
> isn't as hardwired into the system on Windows as it is on POSIX, but
> it's there.
>
> For example, the documentation for the C# Environment.Exit() function
> says "Use 0 (zero) to indicate that the process completed
> successfully.". Windows cmd (the command that runs batch files) has a
> special syntax in its "if" statement that tests the value of
> %errorlevel; "if errorlevel 1" is used to test if the errorlevel is 1 or
> greater, i.e., denotes failure.
>
> VMS (officially OpenVMS) uses 1 to denote success, which is why exit(0)
> in a VMS C program sets the system status to 1, not 0.

Interesting stuff. The main thing with me is to (under Windows at least)
facilitate an easier way to use my tool in an automated way.

The GetExitCodeProcess function documentation specifies that the ExitCode
is a "DWORD 32-bits integer". This means that from cmd.exe point of view
(remember, cmd.exe *is the primary interface* or shell under win):

(emphasis mine)

*****
an .exe program may return as %ERRORLEVEL% a value from -2147483648 to
2147483647
*****

So... yeah. I mean, I would rather leverage that force multiplier than not.

--
:wq
Mike Sanders

Re: getFirstDayOfMonth()

<20240304170756.995@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34106&group=comp.lang.c#34106

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 01:27:50 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <20240304170756.995@kylheku.com>
References: <urrj5l$124o9$1@dont-email.me>
<urssrf$1vntr$1@news.xmission.com> <urteto$1e55r$1@dont-email.me>
<7VrEN.517245$xHn7.96511@fx14.iad> <urtq7q$1ggh0$1@dont-email.me>
<pZGEN.500996$7sbb.11881@fx16.iad> <us00f7$21v55$1@dont-email.me>
<us1ein$2dfo0$1@dont-email.me> <us53ei$3993i$3@dont-email.me>
<87le6xr4r2.fsf@nosuchdomain.example.com> <us5pl8$3dsgj$1@dont-email.me>
Injection-Date: Tue, 5 Mar 2024 01:27:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1d42fd5c0f101e603afff72490e9e6f6";
logging-data="3615914"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bQOosKjJ5klEFkPgTZCaT/TeI/YCkeuQ="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:cFmoWQV1oPiMBJQV/hIuCgJX99Q=
 by: Kaz Kylheku - Tue, 5 Mar 2024 01:27 UTC

On 2024-03-05, Mike Sanders <porkchop@invalid.foo> wrote:
> Interesting stuff. The main thing with me is to (under Windows at least)
> facilitate an easier way to use my tool in an automated way.
>
> The GetExitCodeProcess function documentation specifies that the ExitCode
> is a "DWORD 32-bits integer". This means that from cmd.exe point of view
> (remember, cmd.exe *is the primary interface* or shell under win):
>
> (emphasis mine)
>
> *****
> an .exe program may return as %ERRORLEVEL% a value from -2147483648 to
> 2147483647
> *****

Your reasoning is far from air tight here.

Consider that on Unix, the exit system call takes an "int". Does that
mean that any value from INT_MIN to INT_MAX will be passed through
cleanly as a termination status?

For monitoring the status of a child process, you can use waitpid.
Again, that takes a pointer to an int.

That int is not simply an exit code. It can indicate whether the
process terminated successfully or abnormally (due to a fatal signal),
and if abnormally, which signal. There are portable C macros for
obtaining this information, like WIFEXITED and whatnot.

In the Microsoft exit code case, the docuumentation says:

This function returns immediately. If the process has not terminated
and the function succeeds, the status returned is STILL_ACTIVE (a
macro for STATUS_PENDING (minwinbase.h)). If the process has
terminated and the function succeeds, the status returned is one of
the following values:

- The exit value specified in the ExitProcess or TerminateProcess
function.

- The return value from the main or WinMain function of the process.

- The exception value for an unhandled exception that caused the
process to terminate.

So while you could use any value in the DWORD range, some of the values would
be confused for STILL_ACTIVE, STATUS_PENDING, or might look like the
code of an unhandled exception (I'm guessing 0xCxxxxxxx? Or are therere
others). If you don't want to know what all those are, and don't require
a vast range of exit statuses, your best bet is probably to stick to
small, nonnegative integers.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: getFirstDayOfMonth()

<8734t5qwxs.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34107&group=comp.lang.c#34107

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Mon, 04 Mar 2024 17:39:11 -0800
Organization: None to speak of
Lines: 44
Message-ID: <8734t5qwxs.fsf@nosuchdomain.example.com>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me> <us1ein$2dfo0$1@dont-email.me>
<us53ei$3993i$3@dont-email.me>
<87le6xr4r2.fsf@nosuchdomain.example.com>
<us5pl8$3dsgj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="1a8f7ad2f6e687631fe43fc4c823263c";
logging-data="3616089"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189Y4rDCAHpx1D2QttMcSL5"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:ANMxY8V7BLVRuSMDVzixDyEbvIc=
sha1:BPIhbuLLw7kRUzQOjfFyuy+dzD0=
 by: Keith Thompson - Tue, 5 Mar 2024 01:39 UTC

porkchop@invalid.foo (Mike Sanders) writes:
[...]
> Interesting stuff. The main thing with me is to (under Windows at least)
> facilitate an easier way to use my tool in an automated way.
>
> The GetExitCodeProcess function documentation specifies that the ExitCode
> is a "DWORD 32-bits integer". This means that from cmd.exe point of view
> (remember, cmd.exe *is the primary interface* or shell under win):
>
> (emphasis mine)
>
> *****
> an .exe program may return as %ERRORLEVEL% a value from -2147483648 to
> 2147483647
> *****
>
> So... yeah. I mean, I would rather leverage that force multiplier than not.

Why?

Sure, assuming %ERRORLEVEL% can really take on any integer value from
-2147483648 to +2147483647 (I don't know whether it can), you can write
Windows-specific code that takes full advantage of that range.

Do you really have a requirement to use that full range? Do you have
several billion distinct error conditions that you want to report? Or
are you using %ERRORLEVEL% as some kind of counter? You've only shown
us 4 distinct error conditions for the tool we were discussing.

On POSIX, "$?" is restricted to the range 0 to 255. Do you really need
more than 256 distinct status codes? (The most I've seen in any common
command is less than 100, for curl, and that's a rather extreme
outlier.)

If you don't care about portability to non-Windows systems, that's fine,
but then there are better places to discuss your requirements.

The C standard doesn't guarantee more than 0, EXIT_SUCCESS (which is
usually equal to 0), and EXIT_FAILURE.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: getFirstDayOfMonth()

<us5u51$3ejjp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34110&group=comp.lang.c#34110

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 02:56:48 +0100
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <us5u51$3ejjp$1@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me> <87ttloqnnk.fsf@nosuchdomain.example.com>
<us22ac$2hp4u$1@dont-email.me> <us50mq$38rq1$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 5 Mar 2024 01:56:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c5598e8be5514ee0f1cec2683e74459d";
logging-data="3624569"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pOn16gxLd8Q6Snrox9NlZ"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:IR8H32iWu7g4y+OUQQthiPiE7Ek=
In-Reply-To: <us50mq$38rq1$2@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Tue, 5 Mar 2024 01:56 UTC

On 04.03.2024 18:34, Mike Sanders wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>
>> The "problem" is that you may want to have -h as an option character,
>> especially if your program supports a lot of options and you have no
>> creative naming way of choosing another character. (An example from
>> one of my recent implementations is using -h for 'height'.[*])
>
> This is my rationale as well: All of the switches have a more/or less
> mnemonic feel -X (eXport), -H (Holiday), -C (Calendar), -M (Manual).
>
> I thought it made good sense at least.

Yes, of course it does. Most software developers obviously try
to choose memorable mnemonics. (Imagine we'd have -o1 -o2 -o3
...., or -a -b -c ..., as option interface design rules.)

I wonder, though, my you've chosen letters in caps; I'd avoided
the additional <shift> key press. (First I thought it might be
some Windows/DOS restriction or so.)

Janis

Re: getFirstDayOfMonth()

<us5ugv$3elks$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34111&group=comp.lang.c#34111

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 03:03:10 +0100
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <us5ugv$3elks$1@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me> <us04rd$22som$1@dont-email.me>
<us52nb$3993i$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 5 Mar 2024 02:03:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="08ab02cdafd9838a8a0b3dc05a0f31f6";
logging-data="3626652"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SVOUaDAJZdoTGuz5P1AUB"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:3HeoVpneSIB2yO/PCslir2d66tc=
In-Reply-To: <us52nb$3993i$1@dont-email.me>
 by: Janis Papanagnou - Tue, 5 Mar 2024 02:03 UTC

On 04.03.2024 19:08, Mike Sanders wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>
>> You haven't provided any evidence or facts of experience.
>
> Janis, relax. I have nothing to prove to anyone. [...]

No, you don't have to. Just expect responses if you're posting
just opinions based on misconceptions. - But yes, let's relax
and close that file.

Janis

Re: getFirstDayOfMonth()

<us5ut2$3en3p$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34112&group=comp.lang.c#34112

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 03:09:37 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <us5ut2$3en3p$1@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me> <87ttloqnnk.fsf@nosuchdomain.example.com>
<us22ac$2hp4u$1@dont-email.me> <us50mq$38rq1$2@dont-email.me>
<VHnFN.393318$Ama9.190889@fx12.iad> <us52t1$3993i$2@dont-email.me>
<2noFN.519729$xHn7.255625@fx14.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 5 Mar 2024 02:09:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c5598e8be5514ee0f1cec2683e74459d";
logging-data="3628153"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zDJSk7rhzXkBwsBo1WN13"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Sb7RLvmQbghsZjkF0E0mrfHGxRw=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <2noFN.519729$xHn7.255625@fx14.iad>
 by: Janis Papanagnou - Tue, 5 Mar 2024 02:09 UTC

On 04.03.2024 19:26, Scott Lurndal wrote:
> porkchop@invalid.foo (Mike Sanders) writes:
>> Scott Lurndal <scott@slp53.sl.home> wrote:
>>
>>> As someone who started using unix in an environment where there
>>> was only one case, I find I prefer lower-case option
>>> flags, simply because they're easier to type.
>>>
>>> (In the old days, to type upper-case characters on a teletype
>>> required prefixing each upper-case character with a backslash
>>> character - and the terminal driver would display uppercase
>>> with the prefix).
>>
>> Wow, chuckle, really made you work hard for the results!
>
> It does explain why CamelCase never gained traction in Unix.

You mean in Unix commands, or in the Unix source code, or in
application source code developed for Unix. - I can just say
that for the latter we used camel-case. For the Unix sources
it's probably just a natural evolution to stay with the
convention used as it started. - But how does is come then
that there's CPP identifiers typically in all caps...?
(We're speculating.)

Janis

[OT] Re: getFirstDayOfMonth()

<us5vct$3eq0e$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34113&group=comp.lang.c#34113

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.c
Subject: [OT] Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 03:18:03 +0100
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <us5vct$3eq0e$1@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me> <87ttloqnnk.fsf@nosuchdomain.example.com>
<us507s$38rq1$1@dont-email.me> <tCnFN.138324$t8cc.53416@fx06.iad>
<us5mj5$3dckj$1@dont-email.me> <us5o28$3dil7$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 5 Mar 2024 02:18:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="08ab02cdafd9838a8a0b3dc05a0f31f6";
logging-data="3631118"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/l3yZIyLZ4DVnzONf0N3jn"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:i05RXGxhB0kW3Lsym9V4eXjNBhM=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <us5o28$3dil7$1@dont-email.me>
 by: Janis Papanagnou - Tue, 5 Mar 2024 02:18 UTC

On 05.03.2024 01:12, Mike Sanders wrote:
> Mike Sanders <porkchop@invalid.foo> wrote:
>
>> [ dates -op1 -op2 file || echo no banana ]

ITYM:

dates -op1 -op2 file || echo no banana

>
> Make that instead:
>
> [ cmd ] || failure

This makes little sense. Either write

cmd || failure

(with cmd and failure being commands), or write

[ test-cond ] || failure

with the '[' being another form of the 'test' command

test test-cond || failure

and test-cond being any valid test condition.

There's also other applications possible, like, say,

[ -n "$(cmd)" ] || failure

that somewhat resembles your cmd expression above.

Janis

Re: getFirstDayOfMonth()

<us5vhb$3eq0e$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34114&group=comp.lang.c#34114

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 03:20:27 +0100
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <us5vhb$3eq0e$2@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me> <87ttloqnnk.fsf@nosuchdomain.example.com>
<us507s$38rq1$1@dont-email.me> <us5e0k$37ho2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 5 Mar 2024 02:20:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="08ab02cdafd9838a8a0b3dc05a0f31f6";
logging-data="3631118"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wjt9Mfhnp3wA7M9W3JcdZ"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:QskYtDSymqKe4RHieKcju03ssDA=
In-Reply-To: <us5e0k$37ho2$1@dont-email.me>
 by: Janis Papanagnou - Tue, 5 Mar 2024 02:20 UTC

On 04.03.2024 22:21, Lew Pitcher wrote:
>
> If you want to /guarantee/ that the return value of strcmp()
> is -1, 0, or +1 (for "less than", "equal to", or "greater than")
> you will have to process the return value with something like
>
> /*
> ** Returns -1 if argument < 0, 0 if argument == 0, 1 if argument > 0
> */
> int iSignOf(int valu)
> {
> return ((valu > 0) - (valu < 0));
> }

Neat!

Janis

Re: getFirstDayOfMonth()

<us60nd$3imdn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34116&group=comp.lang.c#34116

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 02:40:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 42
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <us60nd$3imdn$1@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com> <urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad> <urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad> <us00f7$21v55$1@dont-email.me> <us1ein$2dfo0$1@dont-email.me> <us53ei$3993i$3@dont-email.me> <87le6xr4r2.fsf@nosuchdomain.example.com> <us5pl8$3dsgj$1@dont-email.me> <20240304170756.995@kylheku.com>
Injection-Date: Tue, 5 Mar 2024 02:40:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f39f06c5c85be206a030c1f22cff1159";
logging-data="3758519"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8dWFo1+VgAF5AV0j7Dskj"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:K0EC1d0jX6NbGYEQWwZgDL61+/M=
 by: Mike Sanders - Tue, 5 Mar 2024 02:40 UTC

Kaz Kylheku <433-929-6894@kylheku.com> wrote:

> Your reasoning is far from air tight here.

Hey-hey Kaz! But I've got a simple way...

> For monitoring the status of a child process, you can use waitpid.
> Again, that takes a pointer to an int.

For threaded stuff & children I'm actually not sure. Was under the
impression that the parent's return value was defacto, YMMV.

> So while you could use any value in the DWORD range, some of the values would
> be confused for STILL_ACTIVE, STATUS_PENDING, or might look like the
> code of an unhandled exception (I'm guessing 0xCxxxxxxx? Or are therere
> others). If you don't want to know what all those are, and don't require
> a vast range of exit statuses, your best bet is probably to stick to
> small, nonnegative integers.

Here's the way I'm handling it (the error code debate), because the app
I'm working is a subsystem exe (console only in this case as you know),
I don't have WinMain(), & a confounded message pump (so never need to
filter WM_CLOSE, WM_DESTROY, etc) no manifest, no packed icons (multiple
icons are required now - ugh) & all the rest, just plain-jane main() &
am happily (mercifully?) insulated from several layers of abstraction.
That & limiting myself to a range, likely the real secret sauce...

class 3 errors: 300x
class 2 errors: 200x
class 1 errors: 100x

So 3 cheers for subsystem exes' small & quick. but hey, I'm getting close
rankling the other guys so I'll let it be.

Saw your page too at: https://www.kylheku.com/~kaz/

You're a very creative guy, keep on keepin' on =)

--
:wq
Mike Sanders

Re: getFirstDayOfMonth()

<us60rp$3imdn$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34117&group=comp.lang.c#34117

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 02:43:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 31
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <us60rp$3imdn$2@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com> <urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad> <urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad> <us00f7$21v55$1@dont-email.me> <us1ein$2dfo0$1@dont-email.me> <us53ei$3993i$3@dont-email.me> <87le6xr4r2.fsf@nosuchdomain.example.com> <us5pl8$3dsgj$1@dont-email.me> <8734t5qwxs.fsf@nosuchdomain.example.com>
Injection-Date: Tue, 5 Mar 2024 02:43:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f39f06c5c85be206a030c1f22cff1159";
logging-data="3758519"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+cLNRIn9KrWIxXHQVi0Zc"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:hS58kNavuIg/MHNbe6ooprLFKrM=
 by: Mike Sanders - Tue, 5 Mar 2024 02:43 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> Why?
>
> Sure, assuming %ERRORLEVEL% can really take on any integer value from
> -2147483648 to +2147483647 (I don't know whether it can), you can write
> Windows-specific code that takes full advantage of that range.
>
> Do you really have a requirement to use that full range? Do you have
> several billion distinct error conditions that you want to report? Or
> are you using %ERRORLEVEL% as some kind of counter? You've only shown
> us 4 distinct error conditions for the tool we were discussing.
>
> On POSIX, "$?" is restricted to the range 0 to 255. Do you really need
> more than 256 distinct status codes? (The most I've seen in any common
> command is less than 100, for curl, and that's a rather extreme
> outlier.)
>
> If you don't care about portability to non-Windows systems, that's fine,
> but then there are better places to discuss your requirements.
>
> The C standard doesn't guarantee more than 0, EXIT_SUCCESS (which is
> usually equal to 0), and EXIT_FAILURE.

Its no big deal Keith =) I'll let it ride, but earnest thanks for all
your help.

--
:wq
Mike Sanders

Re: getFirstDayOfMonth()

<us618g$3imdn$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34119&group=comp.lang.c#34119

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 02:49:52 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <us618g$3imdn$3@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com> <urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad> <urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad> <us00f7$21v55$1@dont-email.me> <87ttloqnnk.fsf@nosuchdomain.example.com> <us22ac$2hp4u$1@dont-email.me> <us50mq$38rq1$2@dont-email.me> <us5u51$3ejjp$1@dont-email.me>
Injection-Date: Tue, 5 Mar 2024 02:49:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f39f06c5c85be206a030c1f22cff1159";
logging-data="3758519"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1TeTAZMNiVvThbZ1kx9hn"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:7TM/bBiXX0VsAsTX5zNDw1kVKzM=
 by: Mike Sanders - Tue, 5 Mar 2024 02:49 UTC

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

>> I thought it made good sense at least.
>
> Yes, of course it does. Most software developers obviously try
> to choose memorable mnemonics. (Imagine we'd have -o1 -o2 -o3
> ..., or -a -b -c ..., as option interface design rules.)

Considering also --gnu-style, might remove some ambiguities
here & there.

> I wonder, though, my you've chosen letters in caps; I'd avoided
> the additional <shift> key press. (First I thought it might be
> some Windows/DOS restriction or so.)

Honestly just habit... the options are all case-insensitive
in the app across all platforms. Still very much, a work in
progress. I learn, I try new things, I mess up & try again =)

--
:wq
Mike Sanders

Re: [OT] Re: getFirstDayOfMonth()

<us61jp$3imdn$4@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34120&group=comp.lang.c#34120

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: [OT] Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 02:55:53 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 34
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <us61jp$3imdn$4@dont-email.me>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com> <urteto$1e55r$1@dont-email.me> <7VrEN.517245$xHn7.96511@fx14.iad> <urtq7q$1ggh0$1@dont-email.me> <pZGEN.500996$7sbb.11881@fx16.iad> <us00f7$21v55$1@dont-email.me> <87ttloqnnk.fsf@nosuchdomain.example.com> <us507s$38rq1$1@dont-email.me> <tCnFN.138324$t8cc.53416@fx06.iad> <us5mj5$3dckj$1@dont-email.me> <us5o28$3dil7$1@dont-email.me> <us5vct$3eq0e$1@dont-email.me>
Injection-Date: Tue, 5 Mar 2024 02:55:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f39f06c5c85be206a030c1f22cff1159";
logging-data="3758519"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19keTwBfCCAnfebeVujMqS5"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:vTC8m0yOhzbt2s+4xc9CA1BNMnQ=
 by: Mike Sanders - Tue, 5 Mar 2024 02:55 UTC

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

>> [ cmd ] || failure
>
> This makes little sense. Either write
>
> cmd || failure
>
> (with cmd and failure being commands), or write
>
> [ test-cond ] || failure
>
> with the '[' being another form of the 'test' command
>
> test test-cond || failure
>
> and test-cond being any valid test condition.
>
> There's also other applications possible, like, say,
>
> [ -n "$(cmd)" ] || failure
>
> that somewhat resembles your cmd expression above.
>
> Janis

Another post for my notes (about dozen or more of yours now).

Thanks.

--
:wq
Mike Sanders

Re: getFirstDayOfMonth()

<20240305114144.00003c49@yahoo.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34139&group=comp.lang.c#34139

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5...@yahoo.com (Michael S)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 5 Mar 2024 11:41:44 +0200
Organization: A noiseless patient Spider
Lines: 89
Message-ID: <20240305114144.00003c49@yahoo.com>
References: <urrj5l$124o9$1@dont-email.me>
<urssrf$1vntr$1@news.xmission.com>
<urteto$1e55r$1@dont-email.me>
<7VrEN.517245$xHn7.96511@fx14.iad>
<urtq7q$1ggh0$1@dont-email.me>
<pZGEN.500996$7sbb.11881@fx16.iad>
<us00f7$21v55$1@dont-email.me>
<87ttloqnnk.fsf@nosuchdomain.example.com>
<us507s$38rq1$1@dont-email.me>
<us5e0k$37ho2$1@dont-email.me>
<20240305003723.000045a3@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="b67788b2bc2078ab6f2505117462af41";
logging-data="3874508"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lClC589DMi9mpKFO02nDWxIWbNuPLfjg="
Cancel-Lock: sha1:cW3CZhSd+Kj9jdwAmM/7UIVROyE=
X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
 by: Michael S - Tue, 5 Mar 2024 09:41 UTC

On Tue, 5 Mar 2024 00:37:23 +0200
Michael S <already5chosen@yahoo.com> wrote:

> On Mon, 4 Mar 2024 21:21:25 -0000 (UTC)
> Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>
> > On Mon, 04 Mar 2024 17:26:21 +0000, Mike Sanders wrote:
> >
> > > Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> > >
> > >> I wouldn't use '-?'. The '?' character is a wildcard in most
> > >> Unix shells. If you happen to have a file in the current
> > >> directory that matches the pattern, it will expand to the name
> > >> of that file. If you don't, the behavior depends on the shell
> > >> and settings.
> > >
> > > Embarrassed to say I know that, but had forgotten it...
> > >
> > >> And most users of Unix-like systems won't expect '-?' to be an
> > >> option; '-h' is much more common.
> > >
> > > Can of worms there too, '-h' (or whatever) is valid file name.
> > > Under win, we also use '/h' which certainly wont work under unix.
> > >
> > >>> Oh yeah. Have been wrestling with the potential
> > >>> consequences of this for a good while. I think I'm
> > >>> going leave it as is because, (only speaking for
> > >>> myself here) the POSIX 0 good, 1 bad is terrible.
> > >>> This is perhaps the only area I've ever seen where
> > >>> other OSs, like Windows, have a superior methodology
> > >>> on the issue. 0/1 provides next to no nuance. But
> > >>> I'm no expert, just my experience.
> > >>
> > >> The C standard, not just POSIX, defines 0 as a successful status.
> > >> If your program is intended to work on Unix-like systems (or on
> > >> Windows if I'm not mistaken), using a status of 0 to indicate an
> > >> error will cause problems. Conventions exist for a reason.
> > >
> > > int ok = strcmp(foo, bar);
> > >
> > > if (!ok) then success
> > >
> > > ok == -1 less
> > > ok == 0 same
> > > ok == 1 greater
> >
> > Ahhhhh..... no. (CLC has had this conversation before :-) )
> >
> > The standard only guarantees that strcmp()
> > "returns an integer greater than, equal to, or less than zero"
> > but otherwise does not state what value that integer will be.
> >
> > So, strcmp() could just as easily return -30 for "less than"
> > or +97 for "greater than".
> >
> > If you want to /guarantee/ that the return value of strcmp()
> > is -1, 0, or +1 (for "less than", "equal to", or "greater than")
> > you will have to process the return value with something like
> >
> > /*
> > ** Returns -1 if argument < 0, 0 if argument == 0, 1 if argument
> > > 0 */
> > int iSignOf(int valu)
> > {
> > return ((valu > 0) - (valu < 0));
> > }
> >
>
> Too tricky to my liking.
> I'd rather write straight-forward code and let compiler to figure out
> the best sequence.
>
> int iSignOf(int val)
> {
> if (val < 0)
> return -1;
> if (val > 0)
> return +1;
> return 0;
> }
>
> https://godbolt.org/z/TzsevxKeE
> https://godbolt.org/z/TzsevxKeE
>
>

I posted the same link twice by mistake. Meant this
https://godbolt.org/z/4rcfqrje7

Re: getFirstDayOfMonth()

<kseibk-jk1.ln1@hendrix.foo>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34143&group=comp.lang.c#34143

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: phayw...@alphalink.com.au (Peter 'Shaggy' Haywood)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 05 Mar 2024 14:07:32 +1100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <kseibk-jk1.ln1@hendrix.foo>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com> <20240301180259.118@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
Injection-Info: dont-email.me; posting-host="307d17812b7f727f4853cfea2711ae0f";
logging-data="3974172"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185+JIrETa5RvPehTxy82A8dRWrQPMysSI="
User-Agent: KNode/0.10.9
Cancel-Lock: sha1:e+FP/buonoJjlhDbbfWd7dkfT2A=
 by: Peter 'Shaggy&# - Tue, 5 Mar 2024 03:07 UTC

Groovy hepcat Kaz Kylheku was jivin' in comp.lang.c on Sat, 2 Mar 2024
02:44 pm. It's a cool scene! Dig it.

> On 2024-03-01, Kenny McCormack <gazelle@shell.xmission.com> wrote:
>> int day(d,m,y)
>> int d, m, y;
>> {
> [...]
>> BTW, how long do you think it will be until this thread gets hijacked
>> into a long, acrimonious debate about what the definition of the
>> first day of the month is and how various cultures define it
>> differently, and how
>
> Pissing on new code using old-style C in 5... 4... 3....

I'm surprised noone's mentioned this until now.

--

----- Dig the NEW and IMPROVED news sig!! -----

-------------- Shaggy was here! ---------------
Ain't I'm a dawg!!

Re: getFirstDayOfMonth()

<cleibk-jk1.ln1@hendrix.foo>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34144&group=comp.lang.c#34144

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: phayw...@alphalink.com.au (Peter 'Shaggy' Haywood)
Newsgroups: comp.lang.c
Subject: Re: getFirstDayOfMonth()
Date: Tue, 05 Mar 2024 14:03:40 +1100
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <cleibk-jk1.ln1@hendrix.foo>
References: <urrj5l$124o9$1@dont-email.me> <urssrf$1vntr$1@news.xmission.com> <uru0k6$1hpdi$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
Injection-Info: dont-email.me; posting-host="307d17812b7f727f4853cfea2711ae0f";
logging-data="3974172"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8xsz+bszT7uh7rmJhMFfor1WJDTAOPrg="
User-Agent: KNode/0.10.9
Cancel-Lock: sha1:fQDWDYOuYCHkQLOayrTiAm2zCAo=
 by: Peter 'Shaggy&# - Tue, 5 Mar 2024 03:03 UTC

Groovy hepcat jak was jivin' in comp.lang.c on Sat, 2 Mar 2024 12:49 pm.
It's a cool scene! Dig it.

> Kenny McCormack ha scritto:
>> In article <urrj5l$124o9$1@dont-email.me>,
>> Mike Sanders <porkchop@invalid.foo> wrote:
>>> Just sharing what I've learned, hope some of you can adapt
>>> it for your own use.
>>>
>>> Calculates the name of the weekday (Sun, Mon, etc) for the
>>> 1st day of a given month & year...
>>>
>>> https://busybox.neocities.org/notes/get-first-day-of-month.txt
>>
>> Here's the guts of my version of the Zeller algorithm:
>>
>> int day(d,m,y)
>> int d, m, y;
>> {
>> if (m < 3) {
>> m += 12;
>> y--;
>> }
>> return (d + (13*m-27)/5 + y + y/4 - y/100 + y/400) % 7;
>
> Hi,
> I am referring in particular to this part of the equation:
> y + y/4 - y/100 + y/400
> Shouldn't it be calculated in a floating point and then truncated only
> the final result? Because, for example, if the year is 2024, the
> floating point calculation is 2514 (2514.82) while executed between
> integer is 2515.

No. The "+ y/4 - y/100 + y/400" part is adding a day for each leap
year. You see, a leap year is divisible by 4, but is not divisible by
100, but is divisible by 400. So, it's adding the number of years
divisible by 4, subtracting those divisible by 100 and adding those
divisible by 400 to determine the number of leap days up to the given
date.
So often in the last week or two I've heard people (who ought to know
better) on news programs on telly say that a leap year comes every 4
years, and I want to beat them about the head with a humorous object of
some kind until they get this right! A leap year does NOT come EVERY 4
years.

--

----- Dig the NEW and IMPROVED news sig!! -----

-------------- Shaggy was here! ---------------
Ain't I'm a dawg!!


devel / comp.lang.c / Re: getFirstDayOfMonth()

Pages:1234
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor