Sorting and POTFILES.in

2003-02-11 Thread Jean-Marc Lasgouttes

As Michael S pointed out, po/POTFILES.in gets updated every other
commit just because the sort command has different semantics on
different systems. This is a pain because it affects the po files too.

Why is that? The current command used to sort is sort -f -n, where
-f is to ignore case and -n is for numeric sorting.

First, the -n seems bogus, and on my system it actually prevents case
ignoring. This is why when I commit the file the case is preserved,
while others commit a POTFILES.in with case ignored.

I tried to use sort -f only, but it is not yet portable since I get
the following diff:

-src/insets/insetbib.C
 src/insets/inset.C
+src/insets/insetbib.C

So in one case '.' is before 'b' and in the other case it is after.
Why are different sort implementations do different things, I don't
know.

So what should we do? Maybe remove the options altogether and use a
plain sort? Would that give the same result for everybody?

JMarc



Re: Sorting and POTFILES.in

2003-02-11 Thread Andre Poenitz
On Tue, Feb 11, 2003 at 03:51:42PM +0100, Jean-Marc Lasgouttes wrote:
 So what should we do? Maybe remove the options altogether and use a
 plain sort? Would that give the same result for everybody?

Do they need to be sorted at all?

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Sorting and POTFILES.in

2003-02-11 Thread Jean-Marc Lasgouttes
 Andre == Andre Poenitz [EMAIL PROTECTED] writes:

Andre On Tue, Feb 11, 2003 at 03:51:42PM +0100, Jean-Marc Lasgouttes
Andre wrote:
 So what should we do? Maybe remove the options altogether and use a
 plain sort? Would that give the same result for everybody?

Andre Do they need to be sorted at all?

Yes, probably, so that we can uniquify the list.

JMarc



Re: Sorting and POTFILES.in

2003-02-11 Thread Andre Poenitz
On Tue, Feb 11, 2003 at 04:05:05PM +0100, Jean-Marc Lasgouttes wrote:
 Andre Do they need to be sorted at all?
 
 Yes, probably, so that we can uniquify the list.

This could be solved in twelve lines or so  in any language that has map

#include set
#include string
#include iostream

int main()
{
setstring seen;
string word;
while (cin  word) 
if (seen.find(word) == seen.end()) {
seen.insert(word);
cout  word  ' ';
}
}

It's probably even shorter in perl.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Sorting and POTFILES.in

2003-02-11 Thread Jean-Marc Lasgouttes
 Andre == Andre Poenitz [EMAIL PROTECTED] writes:

Andre On Tue, Feb 11, 2003 at 04:05:05PM +0100, Jean-Marc Lasgouttes
Andre wrote: Do they need to be sorted at all?
  Yes, probably, so that we can uniquify the list.

Andre This could be solved in twelve lines or so in any language that
Andre has map

Which is irrelevant to our problem, probably but...

Andre setstring seen; 

Does the standard offer guarrantees about the order in which these
things will be given by the iterator? 

JMarc



Re: Sorting and POTFILES.in

2003-02-11 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes [EMAIL PROTECTED] writes:

|  Andre == Andre Poenitz [EMAIL PROTECTED] writes:
| 
| Andre On Tue, Feb 11, 2003 at 04:05:05PM +0100, Jean-Marc Lasgouttes
| Andre wrote: Do they need to be sorted at all?
|   Yes, probably, so that we can uniquify the list.
| 
| Andre This could be solved in twelve lines or so in any language that
| Andre has map
| 
| Which is irrelevant to our problem, probably but...
| 
| Andre setstring seen; 
| 
| Does the standard offer guarrantees about the order in which these
| things will be given by the iterator? 

sorted.

sorting function and locale decides sorting order.

-- 
Lgb



Re: Sorting and POTFILES.in

2003-02-11 Thread Andre Poenitz
On Tue, Feb 11, 2003 at 04:42:38PM +0100, Jean-Marc Lasgouttes wrote:
 Andre This could be solved in twelve lines or so in any language that
 Andre has map
 
 Which is irrelevant to our problem, probably but...

Why? Can't this be used as instead of the 'sort | uniq' you need?

 Andre setstring seen; 
 
 Does the standard offer guarrantees about the order in which these
 things will be given by the iterator? 

Sorted by  operator(string,string) unless specified otherwise if I am not
mistaken.

Note that _this_ is irrelevant as it is not used for sorting but just to
determine whether we currently look at a duplicate. If so, it is swallowed,
if not, the current string is echoed to cout.

Andre' 

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Sorting and POTFILES.in

2003-02-11 Thread Jean-Marc Lasgouttes
 Lars == Lars Gullik Bjønnes [EMAIL PROTECTED] writes:

Lars sorted.

Lars sorting function and locale decides sorting order.

I stand corrected, then.

So, lars, would you be OK with replacing sort -f -n with a plain
sort? I do not understand why you used -n actually.

JMarc



Re: Sorting and POTFILES.in

2003-02-11 Thread Jean-Marc Lasgouttes
 Andre == Andre Poenitz [EMAIL PROTECTED] writes:

Andre On Tue, Feb 11, 2003 at 04:42:38PM +0100, Jean-Marc Lasgouttes
Andre wrote: This could be solved in twelve lines or so in any
Andre language that has map
  Which is irrelevant to our problem, probably but...

Andre Why? Can't this be used as instead of the 'sort | uniq' you
Andre need?

This is a command used in a makefile. If we write a C++ program
everytime someone has to think more than 30 seconds about a shell command,
we are soon going to have problems.

JMarc




Re: Sorting and POTFILES.in

2003-02-11 Thread Andre Poenitz
On Tue, Feb 11, 2003 at 04:56:17PM +0100, Jean-Marc Lasgouttes wrote:
 Andre Why? Can't this be used as instead of the 'sort | uniq' you
 Andre need?
 
 This is a command used in a makefile. If we write a C++ program
 everytime someone has to think more than 30 seconds about a shell command,
 we are soon going to have problems.

Maybe. But we spent already more than 30 seconds on that shell command.

Ok. I bite:

Is:

`$^'
 The names of all the prerequisites, with spaces between them.  For
 prerequisites which are archive members, only the member named is
 used (*note Archives::).  A target has only one prerequisite on
 each other file it depends on, no matter how many times each file
 is listed as a prerequisite.  So if you list a prerequisite more
 than once for a target, the value of `$^' contains just one copy
 of the name.

portable?

If so, one could probably use make itself to remove the duplicates.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Sorting and POTFILES.in

2003-02-11 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes [EMAIL PROTECTED] writes:

|  Lars == Lars Gullik Bjønnes [EMAIL PROTECTED] writes:
| 
| Lars sorted.
| 
| Lars sorting function and locale decides sorting order.
| 
| I stand corrected, then.
| 
| So, lars, would you be OK with replacing sort -f -n with a plain
| sort? I do not understand why you used -n actually.

Me neither... I probably thought that it would help.

-- 
Lgb



Sorting and POTFILES.in

2003-02-11 Thread Jean-Marc Lasgouttes

As Michael S pointed out, po/POTFILES.in gets updated every other
commit just because the sort command has different semantics on
different systems. This is a pain because it affects the po files too.

Why is that? The current command used to sort is "sort -f -n", where
-f is to ignore case and -n is for numeric sorting.

First, the -n seems bogus, and on my system it actually prevents case
ignoring. This is why when I commit the file the case is preserved,
while others commit a POTFILES.in with case ignored.

I tried to use "sort -f" only, but it is not yet portable since I get
the following diff:

-src/insets/insetbib.C
 src/insets/inset.C
+src/insets/insetbib.C

So in one case '.' is before 'b' and in the other case it is after.
Why are different sort implementations do different things, I don't
know.

So what should we do? Maybe remove the options altogether and use a
plain "sort"? Would that give the same result for everybody?

JMarc



Re: Sorting and POTFILES.in

2003-02-11 Thread Andre Poenitz
On Tue, Feb 11, 2003 at 03:51:42PM +0100, Jean-Marc Lasgouttes wrote:
> So what should we do? Maybe remove the options altogether and use a
> plain "sort"? Would that give the same result for everybody?

Do they need to be sorted at all?

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Sorting and POTFILES.in

2003-02-11 Thread Jean-Marc Lasgouttes
> "Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes:

Andre> On Tue, Feb 11, 2003 at 03:51:42PM +0100, Jean-Marc Lasgouttes
Andre> wrote:
>> So what should we do? Maybe remove the options altogether and use a
>> plain "sort"? Would that give the same result for everybody?

Andre> Do they need to be sorted at all?

Yes, probably, so that we can uniquify the list.

JMarc



Re: Sorting and POTFILES.in

2003-02-11 Thread Andre Poenitz
On Tue, Feb 11, 2003 at 04:05:05PM +0100, Jean-Marc Lasgouttes wrote:
> Andre> Do they need to be sorted at all?
> 
> Yes, probably, so that we can uniquify the list.

This could be solved in twelve lines or so  in any language that has "map"

#include 
#include 
#include 

int main()
{
set seen;
string word;
while (cin >> word) 
if (seen.find(word) == seen.end()) {
seen.insert(word);
cout << word << ' ';
}
}

It's probably even shorter in perl.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Sorting and POTFILES.in

2003-02-11 Thread Jean-Marc Lasgouttes
> "Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes:

Andre> On Tue, Feb 11, 2003 at 04:05:05PM +0100, Jean-Marc Lasgouttes
Andre> wrote: Do they need to be sorted at all?
>>  Yes, probably, so that we can uniquify the list.

Andre> This could be solved in twelve lines or so in any language that
Andre> has "map"

Which is irrelevant to our problem, probably but...

Andre> set seen; 

Does the standard offer guarrantees about the order in which these
things will be given by the iterator? 

JMarc



Re: Sorting and POTFILES.in

2003-02-11 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:

| > "Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes:
| 
| Andre> On Tue, Feb 11, 2003 at 04:05:05PM +0100, Jean-Marc Lasgouttes
| Andre> wrote: Do they need to be sorted at all?
| >>  Yes, probably, so that we can uniquify the list.
| 
| Andre> This could be solved in twelve lines or so in any language that
| Andre> has "map"
| 
| Which is irrelevant to our problem, probably but...
| 
| Andre> set seen; 
| 
| Does the standard offer guarrantees about the order in which these
| things will be given by the iterator? 

sorted.

sorting function and locale decides sorting order.

-- 
Lgb



Re: Sorting and POTFILES.in

2003-02-11 Thread Andre Poenitz
On Tue, Feb 11, 2003 at 04:42:38PM +0100, Jean-Marc Lasgouttes wrote:
> Andre> This could be solved in twelve lines or so in any language that
> Andre> has "map"
> 
> Which is irrelevant to our problem, probably but...

Why? Can't this be used as instead of the 'sort | uniq' you need?

> Andre> set seen; 
> 
> Does the standard offer guarrantees about the order in which these
> things will be given by the iterator? 

Sorted by  operator<(string,string) unless specified otherwise if I am not
mistaken.

Note that _this_ is irrelevant as it is not used for sorting but just to
determine whether we currently look at a duplicate. If so, it is swallowed,
if not, the current string is echoed to cout.

Andre' 

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Sorting and POTFILES.in

2003-02-11 Thread Jean-Marc Lasgouttes
> "Lars" == Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes:

Lars> sorted.

Lars> sorting function and locale decides sorting order.

I stand corrected, then.

So, lars, would you be OK with replacing "sort -f -n" with a plain
"sort"? I do not understand why you used "-n" actually.

JMarc



Re: Sorting and POTFILES.in

2003-02-11 Thread Jean-Marc Lasgouttes
> "Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes:

Andre> On Tue, Feb 11, 2003 at 04:42:38PM +0100, Jean-Marc Lasgouttes
Andre> wrote: This could be solved in twelve lines or so in any
Andre> language that has "map"
>>  Which is irrelevant to our problem, probably but...

Andre> Why? Can't this be used as instead of the 'sort | uniq' you
Andre> need?

This is a command used in a makefile. If we write a C++ program
everytime someone has to think more than 30 seconds about a shell command,
we are soon going to have problems.

JMarc




Re: Sorting and POTFILES.in

2003-02-11 Thread Andre Poenitz
On Tue, Feb 11, 2003 at 04:56:17PM +0100, Jean-Marc Lasgouttes wrote:
> Andre> Why? Can't this be used as instead of the 'sort | uniq' you
> Andre> need?
> 
> This is a command used in a makefile. If we write a C++ program
> everytime someone has to think more than 30 seconds about a shell command,
> we are soon going to have problems.

Maybe. But we spent already more than 30 seconds on that shell command.

Ok. I bite:

Is:

`$^'
 The names of all the prerequisites, with spaces between them.  For
 prerequisites which are archive members, only the member named is
 used (*note Archives::).  A target has only one prerequisite on
 each other file it depends on, no matter how many times each file
 is listed as a prerequisite.  So if you list a prerequisite more
 than once for a target, the value of `$^' contains just one copy
 of the name.

portable?

If so, one could probably use make itself to remove the duplicates.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)



Re: Sorting and POTFILES.in

2003-02-11 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:

| > "Lars" == Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes:
| 
| Lars> sorted.
| 
| Lars> sorting function and locale decides sorting order.
| 
| I stand corrected, then.
| 
| So, lars, would you be OK with replacing "sort -f -n" with a plain
| "sort"? I do not understand why you used "-n" actually.

Me neither... I probably thought that it would help.

-- 
Lgb