Subject: CVS domivogt: * Applied another restart fix by Mikhael.

From: CVS <[email-masked]>
Date: Thu, 17 Jun 1999 06:58:21 -0500 (CDT)

CVSROOT:	/home/cvs/fvwm
Module name:	fvwm
Changes by:	domivogt	99/06/17 06:58:21

Modified files:
	.              : ChangeLog 
	fvwm           : fvwm.c 

Log message:
* Applied another restart fix by Mikhael.

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Brad Giaccio <[email-masked]>
Date: Thu, 17 Jun 1999 08:46:04 -0400

one problem with this
fvwm.c:1751
if (command == NULL) command = "";
    if (
      command[0] == '\0' || strcmp(command, g_argv[0]) == 0 ||
      (getBasename(command) == command || getBasename(g_argv[0]) == g_argv[0]) 
      && strcmp(getBasename(command), getBasename(g_argv[0])) == 0
    ) native = 1;

should use strcmp's for the middle line not ==

-- 
--- There are two kinds of knowledge, you either know the answer or
			you know where to find it
		      -Kane, Johnson, and anonymous
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Steve Robbins <[email-masked]>
Date: Thu, 17 Jun 1999 09:08:31 -0400 (EDT)

> should use strcmp's for the middle line not ==

Notwithstanding the fact that '==' actually does work in the above, using
strcmp() is *way* too error prone. 

Better to look at libs/Strings.h for some help.  I see "StrEquals", for
example.

And for the above, what is up with "getBasename"?  What is wrong with
using strrchr? 

--
Steve Robbins                              <[email-masked]>

A man came up to me and said, "I'd like to change your mind,
by hitting it with a rock," he said, "though I am not unkind."

---

From: Brad Giaccio <[email-masked]>
Date: Thu, 17 Jun 1999 09:18:59 -0400

> strcmp() is *way* too error prone. 

since when does == work with char * in C? And strcmp is only errorprone if you pass it nulls but we check that case in the code beforehand, besides only said strcmp because that is what is used throughout the if.

---

From: Mikhael Goikhman <[email-masked]>
Date: Thu, 17 Jun 1999 19:04:08 +0300 (IDT)

On Thu, 17 Jun 1999, Brad Giaccio wrote:

> since when does == work with char * in C?

== in C works just fine with any pointers (including char*).
It does not work with strings (in java context).

Regards,
Mikhael.

---

From: Mikhael Goikhman <[email-masked]>
Date: Thu, 17 Jun 1999 19:04:47 +0300 (IDT)

> And for the above, what is up with "getBasename"? What is wrong with

Maybe it is good to have it just in case other OSes use different
directory separators. I agree, getBasename (if any) must use strrchr.

Regards,
Mikhael.

---

From: Matthias Clasen <[email-masked]>
Date: Thu, 17 Jun 1999 21:19:21 +0200

> It does not work with strings (in java context).

But it doesn't tell you what you want to know. 

-- 
Matthias Clasen, 
Tel. 0761/203-5606
Email: [email-masked]
Mathematisches Institut, Albert-Ludwigs-Universitaet Freiburg
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 18 Jun 1999 01:10:39 +0300 (IDT)

> But it doesn't tell you what you want to know.

I don't understand this dispute. I suppose everyone knows C here. :)
There are functions, which return a pointer inside the given string,
like strchr or getBasename, so these lines, for example, are equvivalent:
  (str == strchr(str, '.'))
  (str[0] == '.')
where str is a valid string.

Regards,
Mikhael.

---

From: Matthias Clasen <[email-masked]>
Date: Fri, 18 Jun 1999 01:23:47 +0200

:q

---

From: Matthias Clasen <[email-masked]>
Date: Fri, 18 Jun 1999 01:27:21 +0200

> where str is a valid string.

Yes, of course. You can use == to compare pointers if you know they
point into the same string. What I wanted to express is that you can't
use == to compare arbitrary strings.

---

From: Steve Robbins <[email-masked]>
Date: Fri, 18 Jun 1999 02:52:12 -0400 (EDT)

On Thu, 17 Jun 1999, Mikhael Goikhman wrote:

> directory separators. 

Mmm.  That's a good point.  It really ought to be in libfvwm, though,
'cause most of the modules do a similar check (for module aliases).

> I agree, getBasename (if any) must use strrchr.

Yeah, that's what I was getting at.  It's rather ludicrous to write
pointer-manipulating code like that.  There's too much potential for
off-by-one errors, whereas the C library has a well-debugged strrchr() 
that does the job perfectly. 

I'd rather have one of your minutes
than a year with all the hours in it.

---

From: Steve Robbins <[email-masked]>
Date: Fri, 18 Jun 1999 03:07:26 -0400 (EDT)

> since when does == work with char * in C? 

I think this one got beaten to death already.  :)

> And strcmp is only errorprone if you pass it nulls but we check that
> case in the code beforehand, 

The str[n][case]cmp() routines are error prone in that it is way too easy
to forget the "== 0" bit when you want to test strings for equality.
Didn't I just see a message this morning that Dominik applied a patch to
put "== 0" into some code that needed it?

I don't know about the rest of you, but I frequently make the mistake of
forgetting "== 0".  Conversely, when someone is perverse enough to use
"strcmp(a,b)" to mean "strings a and b differ", I usually misread it as a
bug at first.

I know the C hotshots will never make these mistakes, but for the rest of
us, it is much easier to read "StrEquals(a,b)" and "!StrEquals(a,b)".
This should not unduly confuse the hotshots, either.  :-)

The revolution will not be televised.

---

From: Brad Giaccio <[email-masked]>
Date: Fri, 18 Jun 1999 08:26:26 -0400

> where str is a valid string.

Sorry, my intent got lost somewhere here, yes of course you can compare
pointers.  What I didn't understand was the purpose of the == in the
first place.  It seems to just check if process is foo that I didn't
pass in arg as <pathto>/foo but just said foo again.  The whole reason
I brought it up was that this if doesn't do what I want and I was going
to have to add a couple of lines anyway to get the job done right, and I
was just trying to understand it all before I added my own fix.

In case your wondering for myself and about fifteen others that use my
binaries we run a script called fvwm2, that will make a copy of the
most current binary into fvwm2.$USER and almost all of us run M4.  The
problem is when they say restart I want the script fvwm2 to get run
not fvwm2.$USER, so my users won't have to exit to pick up the latest
binary.  And I can't just remove there binaries and replace them when I
recompile because fvwm2 crashes when the inode gets removed.

Brad

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 18 Jun 1999 17:25:01 +0300 (IDT)

On Fri, 18 Jun 1999, Brad Giaccio wrote:

> first place.It seems to just check if process is foo that I didn't
> pass in arg as <pathto>/foo but just said foo again.The whole reason

Don't try to understand this. This was not final. I will remove the
entire "if" in the question. No need for special cases for "Restart wm".
I thought to leave this special case for backward compatibility, but there
are more problems with it than benefits. Also, if you noticed, the "if" in
the question affected only ones with session manager and not others.

> not fvwm2. $USER, so my users won't have to exit to pick up the latest

Oh, your users run fvwm for so long that you are able to install a new
fvwm version between their restarts, right? :)
I will implement "Restart --pass-args fvwm2" soon.

Regards,
Mikhael.

---

From: Brad Giaccio <[email-masked]>
Date: Fri, 18 Jun 1999 11:18:56 -0400

> fvwm version between their restarts, right? :)

I could probabbly install several times between their restarts and
unless they are the ones complaining about some bug then it doesn't
matter to me when they restart.  For example one user has been logged
in 87 days, the X server has been running for 87 days and their fvwm2
has been running for 3 days (because that is when I upgraded the 2.2
instillation they all use).