[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cat.c
From: |
maxime |
Subject: |
cat.c |
Date: |
Thu, 02 Apr 2009 00:40:16 +0200 |
User-agent: |
Thunderbird 2.0.0.21 (X11/20090318) |
Hi,
in the coreutils source of cat
/* cat -- concatenate files and print on the standard output.
Copyright (C) 88, 90, 91, 1995-2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Differences from the Unix cat:
* Always unbuffered, -u is ignored.
* Usually much faster than other versions of cat, the difference
is especially apparent when using the -v option.
By address@hidden, Torbjorn Granlund, advised by rms, Richard Stallman. */
... many understandable lines ...
while (++argind < argc);
... some lines...
coreutil 7.2
file cat.c
line 776
I realy don't understand why U use a while loop in this case...
Ive test that :
#include <stdio.h>
#include <stdlib.h>
int ok(int i, int j){
while(++ i < j);
return i;
}
int ok2(int i, int j){
if (i < j) i = j;
else i++;
return i;
}
void test(int i, int j){
printf("%d %d\n", ok(i, j), ok2(i, j));
}
int main(){
test(1,1);
test(1,3);
test(3,1);
test(2,1);
test(1,2);
return 0;
}
the functions ok and ok2 returns same values, but ok2 is better.
plz say me why U write a loop to do that...